public void SetDhcpV4ServerIdOption(DhcpV4ServerIdOption option)
 {
     if (option != null)
     {
         _dhcpServerIdOption = option;
     }
 }
 public DhcpV4ServerIdOption GetDhcpV4ServerIdOption()
 {
     if (_dhcpServerIdOption == null)
     {
         if (_dhcpOptions != null)
         {
             _dhcpServerIdOption = (DhcpV4ServerIdOption)_dhcpOptions.Get(DhcpConstants.V4OPTION_SERVERID);
         }
     }
     return(_dhcpServerIdOption);
 }
        /* (non-Javadoc)
         * @see com.jagornet.dhcpv6.server.request.BaseDhcpProcessor#preProcess()
         */
        public override bool PreProcess()
        {
            if (!base.PreProcess())
            {
                return(false);
            }

            DhcpV4ServerIdOption requestedServerIdOption = _requestMsg.GetDhcpV4ServerIdOption();

            requestedIpAddrOption = (DhcpV4RequestedIpAddressOption)
                                    _requestMsg.GetDhcpOption(DhcpConstants.V4OPTION_REQUESTED_IP);

            // first determine what KIND of request we are dealing with
            if (_requestMsg.GetCiAddr().Equals(DhcpConstants.ZEROADDR_V4))
            {
                // the ciAddr MUST be 0.0.0.0 for Init-Reboot and Selecting
                if (requestedServerIdOption == null)
                {
                    // init-reboot MUST NOT have server-id option
                    type = RequestType.Request_InitReboot;
                }
                else
                {
                    // selecting MUST have server-id option
                    type = RequestType.Request_Selecting;
                }
            }
            else
            {
                // the ciAddr MUST NOT be 0.0.0.0 for Renew and Rebind
                if (_requestMsg.IsUnicast())
                {
                    // renew is unicast
                    // NOTE: this will not happen if the v4 broadcast interface used at startup,
                    //		 but handling of DHCPv4 renew/rebind is the same anyway
                    type = RequestType.Request_Renewing;
                }
                else
                {
                    // rebind is broadcast
                    type = RequestType.Request_Rebinding;
                }
            }

            if ((type == RequestType.Request_InitReboot) || (type == RequestType.Request_Selecting))
            {
                if (requestedIpAddrOption == null)
                {
                    log.Warn("Ignoring " + type + " message: " +
                             "Requested IP option is null");
                    return(false);
                }
                if (type == RequestType.Request_Selecting)
                {
                    String requestedServerId = requestedServerIdOption.GetIpAddress();
                    string myServerId        = _dhcpV4ServerIdOption.GetIpAddress();
                    if (!myServerId.Equals(requestedServerId))
                    {
                        log.Warn("Ignoring " + type + " message: " +
                                 "Requested ServerId: " + requestedServerIdOption +
                                 " My ServerId: " + _dhcpV4ServerIdOption);
                        return(false);
                    }
                }
            }
            else
            {   // type == Renewing or Rebinding
                if (requestedIpAddrOption != null)
                {
                    log.Warn("Ignoring " + type + " message: " +
                             "Requested IP option is not null");
                    return(false);
                }
            }

            return(true);
        }