* 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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
@ -63,17 +63,15 @@ AutoconfigLooper::_Configure()
|
||||||
|
|
||||||
// set IFF_CONFIGURING flag on interface
|
// 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)
|
if (socket < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ioctl(socket, SIOCGIFFLAGS, &request, sizeof(struct ifreq)) == 0) {
|
if (ioctl(socket, SIOCGIFFLAGS, &request, sizeof(struct ifreq)) == 0) {
|
||||||
request.ifr_flags |= IFF_CONFIGURING;
|
request.ifr_flags |= IFF_CONFIGURING;
|
||||||
ioctl(socket, SIOCSIFFLAGS, &request, sizeof(struct ifreq));
|
ioctl(socket, SIOCSIFFLAGS, &request, sizeof(struct ifreq)));
|
||||||
}
|
}
|
||||||
|
|
||||||
close(socket);
|
|
||||||
|
|
||||||
// remove current handler
|
// remove current handler
|
||||||
|
|
||||||
_RemoveClient();
|
_RemoveClient();
|
||||||
|
@ -83,8 +81,10 @@ AutoconfigLooper::_Configure()
|
||||||
fCurrentClient = new DHCPClient(fTarget, fDevice.String());
|
fCurrentClient = new DHCPClient(fTarget, fDevice.String());
|
||||||
AddHandler(fCurrentClient);
|
AddHandler(fCurrentClient);
|
||||||
|
|
||||||
if (fCurrentClient->Initialize() == B_OK)
|
if (fCurrentClient->Initialize() == B_OK) {
|
||||||
|
close(socket);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_RemoveClient();
|
_RemoveClient();
|
||||||
|
|
||||||
|
@ -94,6 +94,15 @@ AutoconfigLooper::_Configure()
|
||||||
// TODO: have a look at zeroconf
|
// TODO: have a look at zeroconf
|
||||||
// TODO: this could also be done add-on based
|
// 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);
|
BMessage interface(kMsgConfigureInterface);
|
||||||
interface.AddString("device", fDevice.String());
|
interface.AddString("device", fDevice.String());
|
||||||
interface.AddBool("auto", true);
|
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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
@ -788,7 +788,8 @@ DHCPClient::_ToString(in_addr_t address) const
|
||||||
|
|
||||||
|
|
||||||
status_t
|
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(),
|
ssize_t bytesSent = sendto(socket, &message, message.Size(),
|
||||||
address.sin_addr.s_addr == INADDR_BROADCAST ? MSG_BCAST : 0,
|
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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
@ -660,7 +660,7 @@ NetServer::_ConfigureInterface(int socket, BMessage& interface,
|
||||||
// set flags
|
// set flags
|
||||||
|
|
||||||
if (flags != 0) {
|
if (flags != 0) {
|
||||||
request.ifr_flags = currentFlags | flags;
|
request.ifr_flags = (currentFlags & ~IFF_CONFIGURING) | flags;
|
||||||
if (ioctl(familySocket, SIOCSIFFLAGS, &request, sizeof(struct ifreq)) < 0)
|
if (ioctl(familySocket, SIOCSIFFLAGS, &request, sizeof(struct ifreq)) < 0)
|
||||||
fprintf(stderr, "%s: Setting flags failed: %s\n", Name(), strerror(errno));
|
fprintf(stderr, "%s: Setting flags failed: %s\n", Name(), strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue