* 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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user