コード例 #1
0
        public override bool Process()
        {
            byte[] chAddr = _requestMsg.GetChAddr();

            V4AddrBindingManager bindingMgr = _dhcpServerConfig.GetV4AddrBindingMgr();

            if (bindingMgr != null)
            {
                log.Info("Processing Decline" + " from chAddr=" + Util.ToHexString(chAddr) + " requestedIp=" + requestedIpAddrOption.GetIpAddress());
                Binding binding = bindingMgr.FindCurrentBinding(_clientLink, chAddr, _requestMsg);
                if (binding != null)
                {
                    HashSet <BindingObject> bindingObjs = binding.GetBindingObjects();
                    if ((bindingObjs != null) && bindingObjs.Count != 0)
                    {
                        V4BindingAddress bindingAddr = (V4BindingAddress)bindingObjs.First();
                        bindingMgr.DeclineIaAddress(binding, bindingAddr);
                    }
                    else
                    {
                        log.Error("No binding addresses in binding for client: " + Util.ToHexString(chAddr));
                    }
                }
                else
                {
                    log.Error("No Binding available for client: " + Util.ToHexString(chAddr));
                }
            }
            else
            {
                log.Error("Unable to process V4 Decline:" + " No V4AddrBindingManager available");
            }

            return(false); // no reply for v4 decline
        }
コード例 #2
0
        /* (non-Javadoc)
         * @see com.jagornet.dhcpv6.server.request.BaseDhcpProcessor#process()
         */
        public override bool Process()
        {
            bool sendReply = true;

            byte[] chAddr = _requestMsg.GetChAddr();
            lock (_lock)
            {
                V4AddrBindingManager bindingMgr = _dhcpServerConfig.GetV4AddrBindingMgr();
                if (bindingMgr != null)
                {
                    log.Info("Processing " + type +
                             " from chAddr=" + Util.ToHexString(chAddr) +
                             " ciAddr=" + _requestMsg.GetCiAddr().ToString() +
                             " requestedIpAddrOption=" + requestedIpAddrOption);

                    if (!AddrOnLink(requestedIpAddrOption, _clientLink))
                    {
                        log.Info("Client requested IP is off-link, returning NAK");
                        _replyMsg.SetMessageType((short)DhcpConstants.V4MESSAGE_TYPE_NAK);
                        return(sendReply);
                    }
                    else
                    {
                        Binding binding = bindingMgr.FindCurrentBinding(_clientLink,
                                                                        chAddr, _requestMsg);
                        if (binding != null)
                        {
                            binding = bindingMgr.UpdateBinding(binding, _clientLink,
                                                               chAddr, _requestMsg, IdentityAssoc.COMMITTED);
                            if (binding != null)
                            {
                                AddBindingToReply(_clientLink, binding);
                                _bindings.Add(binding);
                            }
                            else
                            {
                                log.Error("Failed to update binding for client: " +
                                          Util.ToHexString(chAddr));
                                sendReply = false;
                            }
                        }
                        else
                        {
                            log.Error("No Binding available for client: " +
                                      Util.ToHexString(chAddr));
                            sendReply = false;
                        }
                    }
                }
                else
                {
                    log.Error("Unable to process V4 Request:" +
                              " No V4AddrBindingManager available");
                }

                if (sendReply)
                {
                    _replyMsg.SetMessageType((short)DhcpConstants.V4MESSAGE_TYPE_ACK);
                    if (_bindings.Count > 0)
                    {
                        ProcessDdnsUpdates(true);
                    }
                }
            }
            return(sendReply);
        }
コード例 #3
0
        public override bool Process()
        {
            bool sendReply = true;

            lock (_lock)
            {
                bool   rapidCommit = IsRapidCommit(_requestMsg, _clientLink.GetLink());
                byte   state       = rapidCommit ? IaAddress.COMMITTED : IaAddress.ADVERTISED;
                byte[] chAddr      = _requestMsg.GetChAddr();

                V4AddrBindingManager bindingMgr = _dhcpServerConfig.GetV4AddrBindingMgr();
                if (bindingMgr != null)
                {
                    log.Info("Processing Discover from: chAddr=" + Util.ToHexString(chAddr));
                    Binding binding = bindingMgr.FindCurrentBinding(_clientLink, chAddr, _requestMsg);
                    if (binding == null)
                    {
                        // no current binding for this MAC, create a new one
                        binding = bindingMgr.CreateDiscoverBinding(_clientLink, chAddr, _requestMsg, state);
                    }
                    else
                    {
                        binding = bindingMgr.UpdateBinding(binding, _clientLink, chAddr, _requestMsg, state);
                    }
                    if (binding != null)
                    {
                        // have a good binding, put it in the reply with options
                        AddBindingToReply(_clientLink, binding);
                        _bindings.Add(binding);
                    }
                    else
                    {
                        log.Error("Failed to create binding for Discover from: " + Util.ToHexString(chAddr));
                        sendReply = false;
                    }
                }
                else
                {
                    log.Error("Unable to process V4 Discover:" + " No V4AddrBindingManager available");
                    sendReply = false;
                }

                if (sendReply)
                {
                    if (rapidCommit)
                    {
                        _replyMsg.SetMessageType((short)DhcpConstants.V4MESSAGE_TYPE_ACK);
                    }
                    else
                    {
                        _replyMsg.SetMessageType((short)DhcpConstants.V4MESSAGE_TYPE_OFFER);
                    }
                    if (_bindings.Count != 0)
                    {
                        if (rapidCommit)
                        {
                            ProcessDdnsUpdates(true);
                        }
                        else
                        {
                            ProcessDdnsUpdates(false);
                        }
                    }
                }
            }
            return(sendReply);
        }