Now delays configuring the interface until we got the DHCP acknowledge message - this
might fix the missing message from my router. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19468 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -292,7 +292,8 @@ dhcp_message::PutOption(uint8* options, message_option option, uint8* data, uint
|
|||||||
|
|
||||||
DHCPClient::DHCPClient(BMessenger target, const char* device)
|
DHCPClient::DHCPClient(BMessenger target, const char* device)
|
||||||
: BHandler("dhcp"),
|
: BHandler("dhcp"),
|
||||||
fDevice(device)
|
fDevice(device),
|
||||||
|
fConfiguration(kMsgConfigureInterface)
|
||||||
{
|
{
|
||||||
fTransactionID = system_time();
|
fTransactionID = system_time();
|
||||||
|
|
||||||
@@ -409,42 +410,43 @@ DHCPClient::DHCPClient(BMessenger target, const char* device)
|
|||||||
|
|
||||||
fAssignedAddress = message->your_address;
|
fAssignedAddress = message->your_address;
|
||||||
|
|
||||||
BMessage configure(kMsgConfigureInterface);
|
fConfiguration.MakeEmpty();
|
||||||
configure.AddString("device", fDevice.String());
|
fConfiguration.AddString("device", fDevice.String());
|
||||||
|
|
||||||
BMessage address;
|
BMessage address;
|
||||||
address.AddString("family", "inet");
|
address.AddString("family", "inet");
|
||||||
address.AddString("address", _ToString(fAssignedAddress));
|
address.AddString("address", _ToString(fAssignedAddress));
|
||||||
_ParseOptions(*message, address);
|
_ParseOptions(*message, address);
|
||||||
|
|
||||||
configure.AddMessage("address", &address);
|
fConfiguration.AddMessage("address", &address);
|
||||||
|
|
||||||
// configure interface
|
// request configuration from the server
|
||||||
BMessage reply;
|
|
||||||
target.SendMessage(&configure, &reply);
|
|
||||||
|
|
||||||
status_t status;
|
_ResetTimeout(socket);
|
||||||
if (reply.FindInt32("status", &status) == B_OK
|
state = REQUESTING;
|
||||||
&& status == B_OK) {
|
_PrepareMessage(request);
|
||||||
// configuration succeeded, request it from the server
|
|
||||||
_ResetTimeout(socket);
|
|
||||||
|
|
||||||
state = REQUESTING;
|
fStatus = _SendMessage(socket, request, broadcast);
|
||||||
_PrepareMessage(request);
|
// we're sending a broadcast so that all potential offers get an answer
|
||||||
|
break;
|
||||||
fStatus = _SendMessage(socket, request, broadcast);
|
|
||||||
// we're sending a broadcast so that all offers get an answer
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case DHCP_ACK:
|
case DHCP_ACK:
|
||||||
|
{
|
||||||
if (state != REQUESTING)
|
if (state != REQUESTING)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// our address request has been acknowledged
|
// our address request has been acknowledged
|
||||||
state = ACKNOWLEDGED;
|
state = ACKNOWLEDGED;
|
||||||
fStatus = B_OK;
|
|
||||||
|
// configure interface
|
||||||
|
BMessage reply;
|
||||||
|
target.SendMessage(&fConfiguration, &reply);
|
||||||
|
|
||||||
|
if (reply.FindInt32("status", &fStatus) != B_OK)
|
||||||
|
fStatus = B_OK;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case DHCP_NACK:
|
case DHCP_NACK:
|
||||||
if (state != REQUESTING)
|
if (state != REQUESTING)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class DHCPClient : public BHandler {
|
|||||||
BString _ToString(in_addr_t address) const;
|
BString _ToString(in_addr_t address) const;
|
||||||
|
|
||||||
BString fDevice;
|
BString fDevice;
|
||||||
|
BMessage fConfiguration;
|
||||||
BMessageRunner* fRunner;
|
BMessageRunner* fRunner;
|
||||||
uint8 fMAC[6];
|
uint8 fMAC[6];
|
||||||
uint32 fTransactionID;
|
uint32 fTransactionID;
|
||||||
|
|||||||
Reference in New Issue
Block a user