* DHCP will now actually acknowledge a successful negotiation.

* The lease time wasn't printed correctly.
* if the DHCP acknowledge message never comes, we won't try
  forever, but will just stop early and assume the IP address
  we have is okay (looks like my router doesn't send DHCP_ACK).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19463 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-12-12 00:32:05 +00:00
parent f9af65667d
commit df3624c10e
1 changed files with 10 additions and 3 deletions

View File

@ -372,8 +372,15 @@ DHCPClient::DHCPClient(BMessenger target, const char* device)
if (state == INIT)
fStatus = _SendMessage(socket, discover, broadcast);
else if (state == REQUESTING)
else if (state == REQUESTING) {
if (fTries > 0) {
// The server not only didn't acknowledge the address, it did nothing.
// So we just ignore this little annoyance and continue with life.
fStatus = B_OK;
break;
}
fStatus = _SendMessage(socket, request, broadcast);
}
if (fStatus < B_OK)
break;
@ -435,7 +442,7 @@ DHCPClient::DHCPClient(BMessenger target, const char* device)
fServer.sin_addr.s_addr = *(in_addr_t*)data;
break;
case OPTION_ADDRESS_LEASE_TIME:
printf("lease time of %lu seconds\n", *(uint32*)data);
printf("lease time of %lu seconds\n", htonl(*(uint32*)data));
break;
case OPTION_HOST_NAME:
@ -495,6 +502,7 @@ DHCPClient::DHCPClient(BMessenger target, const char* device)
// our address request has been acknowledged
state = ACKNOWLEDGED;
fStatus = B_OK;
break;
case DHCP_NACK:
@ -510,7 +518,6 @@ DHCPClient::DHCPClient(BMessenger target, const char* device)
}
close(socket);
fStatus = B_ERROR;
}