* The auto-config looper now correctly sets the IFF_CONFIGURING flag - it
cannot be set in the AF_LINK level. * It now also checks for this flag, so that the fallback configuration won't overwrite a manually configured interface anymore. * When an interface is configured, the IFF_CONFIGURING flag is now cleared as it should. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29230 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4712bc807c
commit
1a905a762a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -63,17 +63,15 @@ AutoconfigLooper::_Configure()
|
||||
|
||||
// set IFF_CONFIGURING flag on interface
|
||||
|
||||
int socket = ::socket(AF_LINK, SOCK_DGRAM, 0);
|
||||
int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket < 0)
|
||||
return;
|
||||
|
||||
if (ioctl(socket, SIOCGIFFLAGS, &request, sizeof(struct ifreq)) == 0) {
|
||||
request.ifr_flags |= IFF_CONFIGURING;
|
||||
ioctl(socket, SIOCSIFFLAGS, &request, sizeof(struct ifreq));
|
||||
ioctl(socket, SIOCSIFFLAGS, &request, sizeof(struct ifreq)));
|
||||
}
|
||||
|
||||
close(socket);
|
||||
|
||||
// remove current handler
|
||||
|
||||
_RemoveClient();
|
||||
@ -83,8 +81,10 @@ AutoconfigLooper::_Configure()
|
||||
fCurrentClient = new DHCPClient(fTarget, fDevice.String());
|
||||
AddHandler(fCurrentClient);
|
||||
|
||||
if (fCurrentClient->Initialize() == B_OK)
|
||||
if (fCurrentClient->Initialize() == B_OK) {
|
||||
close(socket);
|
||||
return;
|
||||
}
|
||||
|
||||
_RemoveClient();
|
||||
|
||||
@ -94,6 +94,15 @@ AutoconfigLooper::_Configure()
|
||||
// TODO: have a look at zeroconf
|
||||
// TODO: this could also be done add-on based
|
||||
|
||||
if (ioctl(socket, SIOCGIFFLAGS, &request, sizeof(struct ifreq)) == 0
|
||||
&& (request.ifr_flags & IFF_CONFIGURING) == 0) {
|
||||
// Someone else configured the interface in the mean time
|
||||
close(socket);
|
||||
return;
|
||||
}
|
||||
|
||||
close(socket);
|
||||
|
||||
BMessage interface(kMsgConfigureInterface);
|
||||
interface.AddString("device", fDevice.String());
|
||||
interface.AddBool("auto", true);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -788,7 +788,8 @@ DHCPClient::_ToString(in_addr_t address) const
|
||||
|
||||
|
||||
status_t
|
||||
DHCPClient::_SendMessage(int socket, dhcp_message& message, sockaddr_in& address) const
|
||||
DHCPClient::_SendMessage(int socket, dhcp_message& message,
|
||||
sockaddr_in& address) const
|
||||
{
|
||||
ssize_t bytesSent = sendto(socket, &message, message.Size(),
|
||||
address.sin_addr.s_addr == INADDR_BROADCAST ? MSG_BCAST : 0,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -660,7 +660,7 @@ NetServer::_ConfigureInterface(int socket, BMessage& interface,
|
||||
// set flags
|
||||
|
||||
if (flags != 0) {
|
||||
request.ifr_flags = currentFlags | flags;
|
||||
request.ifr_flags = (currentFlags & ~IFF_CONFIGURING) | flags;
|
||||
if (ioctl(familySocket, SIOCSIFFLAGS, &request, sizeof(struct ifreq)) < 0)
|
||||
fprintf(stderr, "%s: Setting flags failed: %s\n", Name(), strerror(errno));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user