Exemple #1
0
 public DhcpReleaseMessage(DhcpMessage accept)
 {
     // Create DHCP RELEASE message
     mac = accept.mac;
     AddOption(EOption.eMessageType, new byte[] { (byte)EMessageType.eRelease });
     AddOption(EOption.eServerIdentifier, accept.serverId.GetAddressBytes());
     iFlags[0] = 0x00;         // clear BROADCAST bit
 }
Exemple #2
0
 public DhcpRenewMessage(DhcpMessage lease)
 {
     // RENEW message is a REQUEST message without server ID or requested address
     // and completed ciaddr
     mac    = lease.mac;
     secs   = 0;
     ciaddr = lease.yiaddr;
     xid    = lease.xid;
     AddOption(EOption.eMessageType, new byte[] { (byte)EMessageType.eRequest });
     iFlags[0] = 0x00;         // clear BROADCAST bit
 }
Exemple #3
0
        private int SendMessage(DhcpMessage aMessage, string aDestination)
        {
            int bytesSent = 0;

            iLog.Info("Tx " + aMessage.messageType.ToString() + " from " + aMessage.mac + " with XID " + aMessage.xidStr);
            try
            {
                IPEndPoint server = new IPEndPoint(IPAddress.Parse(aDestination), 67);
                bytesSent = iUdpClient.Send(aMessage.message, aMessage.message.Length, server);
            }
            catch (Exception e)
            {
                iLog.Fail(e.ToString());
            }
            return(bytesSent);
        }
Exemple #4
0
 public DhcpRequestMessage(DhcpMessage offer)
 {
     // Create DHCP REQUEST message (caller can modify defaults before sending if required)
     // defaults are set to mimic the message from a DS
     mac  = offer.mac;
     secs = offer.secs;
     xid  = offer.xid;
     AddOption(EOption.eMessageType, new byte[] { (byte)EMessageType.eRequest });
     AddOption(EOption.eServerIdentifier, offer.serverId.GetAddressBytes());
     AddOption(EOption.eRequestedAddress, offer.yiaddr.GetAddressBytes());
     AddOption(EOption.eLeaseTime, offer.leaseTimeBytes);
     AddOption(EOption.eParameterList, new byte[] { (byte)EOption.eSubnetMask,
                                                    (byte)EOption.eRouter,
                                                    (byte)EOption.eDomainNameServer,
                                                    (byte)EOption.eHostName,
                                                    (byte)EOption.eDomainName });
 }