Return time value for Discover packet

This commit is contained in:
valentinbreiz 2021-01-22 14:31:15 +01:00
parent f98690cb74
commit 0ee21466cd

View file

@ -71,7 +71,7 @@ namespace Cosmos.System.Network.IPv4.UDP.DHCP
{ {
if (packet.RawData[284] == 0x02) //Offer packet received if (packet.RawData[284] == 0x02) //Offer packet received
{ {
SendRequestPacket(packet.Client, packet.Server); return SendRequestPacket(packet.Client, packet.Server);
} }
else if (packet.RawData[284] == 0x05 || packet.RawData[284] == 0x06) //ACK or NAK DHCP packet received else if (packet.RawData[284] == 0x05 || packet.RawData[284] == 0x06) //ACK or NAK DHCP packet received
{ {
@ -113,7 +113,8 @@ namespace Cosmos.System.Network.IPv4.UDP.DHCP
/// <summary> /// <summary>
/// Send a packet to find the DHCP server and tell that we want a new IP address /// Send a packet to find the DHCP server and tell that we want a new IP address
/// </summary> /// </summary>
public void SendDiscoverPacket() /// <returns>time value (-1 = timeout)</returns>
public int SendDiscoverPacket()
{ {
NetworkStack.RemoveAllConfigIP(); NetworkStack.RemoveAllConfigIP();
@ -128,13 +129,14 @@ namespace Cosmos.System.Network.IPv4.UDP.DHCP
asked = true; asked = true;
} }
Receive(); return Receive();
} }
/// <summary> /// <summary>
/// Send a request to apply the new IP configuration /// Send a request to apply the new IP configuration
/// </summary> /// </summary>
private void SendRequestPacket(Address RequestedAddress, Address DHCPServerAddress) /// <returns>time value (-1 = timeout)</returns>
private int SendRequestPacket(Address RequestedAddress, Address DHCPServerAddress)
{ {
foreach (NetworkDevice networkDevice in NetworkDevice.Devices) foreach (NetworkDevice networkDevice in NetworkDevice.Devices)
{ {
@ -142,7 +144,7 @@ namespace Cosmos.System.Network.IPv4.UDP.DHCP
OutgoingBuffer.AddPacket(dhcp_request); OutgoingBuffer.AddPacket(dhcp_request);
NetworkStack.Update(); NetworkStack.Update();
} }
Receive(); return Receive();
} }
/* /*