From 2b829b045f211523957c3adb93e894d1e02dac15 Mon Sep 17 00:00:00 2001 From: "Bruno G. Albuquerque" Date: Thu, 7 May 2009 13:00:08 +0000 Subject: [PATCH] - Fix DHCP client when multiple interfaces are present in the system. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30656 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/net/DHCPClient.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/servers/net/DHCPClient.cpp b/src/servers/net/DHCPClient.cpp index ea62d91cc0..e52f18b50f 100644 --- a/src/servers/net/DHCPClient.cpp +++ b/src/servers/net/DHCPClient.cpp @@ -397,6 +397,13 @@ DHCPClient::_Negotiate(dhcp_state state) local.sin_port = htons(DHCP_CLIENT_PORT); local.sin_addr.s_addr = INADDR_ANY; + // Enable reusing the port . This is needed in case there is more + // than 1 interface that needs to be configured. Note that the only reason + // this works is because there is code below to bind to a specific + // interface. + int option = 1; + setsockopt(socket, SOL_SOCKET, SO_REUSEPORT, &option, sizeof(option)); + if (bind(socket, (struct sockaddr *)&local, sizeof(local)) < 0) { close(socket); return errno; @@ -409,7 +416,7 @@ DHCPClient::_Negotiate(dhcp_state state) broadcast.sin_port = htons(DHCP_SERVER_PORT); broadcast.sin_addr.s_addr = INADDR_BROADCAST; - int option = 1; + option = 1; setsockopt(socket, SOL_SOCKET, SO_BROADCAST, &option, sizeof(option)); if (state == INIT) { @@ -857,4 +864,3 @@ DHCPClient::MessageReceived(BMessage* message) break; } } -