internal override void EnterEvent() { client.StartNewTransaction(); DhcpFormat dhcp = new DhcpFormat(DhcpFormat.MessageType.Discover); dhcp.TransactionID = client.TransactionID; dhcp.SetHardwareAddress(client.MacAddress); #if ADVERTISE_CLIENT_ID // Add Client Identifier for self // // This is disabled because the Windows // DHCP server allocates us a different address with the // client id present if we networked booted. Thus having the // identifier breaks static DHCP entries which we use // for test machines. EthernetAddress macAddress = client.MacAddress; dhcp.AddOption(DhcpClientID.Create(macAddress.GetAddressBytes())); #endif // Add parameters we'd like to know about dhcp.AddOption(DhcpParameterRequest.Create( DhcpClient.StandardRequestParameters ) ); // dhcp.AddOption(DhcpAutoConfigure.Create(0)); client.Send(EthernetAddress.Broadcast, dhcp); client.ChangeState(new DhcpClientStateSelecting(client)); }
private void Respond(DhcpFormat request, DhcpFormat.MessageType m) { DhcpFormat response = new DhcpFormat(m); response.TransactionID = request.TransactionID; EthernetAddress hwAddress = request.GetHardwareAddress(); response.SetHardwareAddress(hwAddress); switch (m) { case DhcpFormat.MessageType.Offer: response.NextServerIPAddress = ServerAddress; response.AddOption( DhcpIPAddressLeaseTime.Create(RebindingTime) ); goto case DhcpFormat.MessageType.Ack; case DhcpFormat.MessageType.Ack: response.YourIPAddress = HostAddress; assignedAddress = HostAddress; FillOptions(request, response); break; case DhcpFormat.MessageType.Nak: // Nothing to do break; default: return; } SendResponsePacket(response); }
internal override void EnterEvent() { client.SetStateTimeout(DateTime.Now + StateTimeout); DhcpFormat dhcp = new DhcpFormat(DhcpFormat.MessageType.Request); dhcp.TransactionID = client.TransactionID; dhcp.TransactionSeconds = client.TransactionSeconds; dhcp.SetHardwareAddress(client.MacAddress); #if ADVERTISE_CLIENT_ID dhcp.AddOption( DhcpClientID.Create(client.MacAddress.GetAddressBytes()) ); #endif dhcp.AddOption( DhcpRequestedIPAddress.Create(offeredAddress) ); // Add parameters we'd like to know about dhcp.AddOption(DhcpParameterRequest.Create( DhcpClient.StandardRequestParameters ) ); client.Send(EthernetAddress.Broadcast, dhcp); }