From b1b51eddee85e41473198aac796b40a44275bfae Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Thu, 6 Nov 2014 15:00:00 +0100 Subject: [PATCH] Network preferences: Set the "auto configuration" flag. Fixes #11416. --- .../InterfacesAddOn/InterfacesListView.cpp | 5 ++++- .../network/InterfacesAddOn/NetworkSettings.cpp | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/preferences/network/InterfacesAddOn/InterfacesListView.cpp b/src/preferences/network/InterfacesAddOn/InterfacesListView.cpp index 362485e2a4..0675963045 100644 --- a/src/preferences/network/InterfacesAddOn/InterfacesListView.cpp +++ b/src/preferences/network/InterfacesAddOn/InterfacesListView.cpp @@ -564,8 +564,11 @@ InterfacesListView::_HandleNetworkMessage(BMessage* message) switch (opcode) { case B_NETWORK_INTERFACE_CHANGED: case B_NETWORK_DEVICE_LINK_CHANGED: - if (item != NULL) + if (item != NULL) { + // Make sure the item reflects the current state + item->GetSettings()->ReadConfiguration(); InvalidateItem(IndexOf(item)); + } break; case B_NETWORK_INTERFACE_ADDED: diff --git a/src/preferences/network/InterfacesAddOn/NetworkSettings.cpp b/src/preferences/network/InterfacesAddOn/NetworkSettings.cpp index 9fb9956d9b..4aa969d0de 100644 --- a/src/preferences/network/InterfacesAddOn/NetworkSettings.cpp +++ b/src/preferences/network/InterfacesAddOn/NetworkSettings.cpp @@ -300,7 +300,6 @@ NetworkSettings::SetConfiguration() interfaceConfig.SetAddress(fAddress[inet_id]); interfaceConfig.SetMask(fNetmask[inet_id]); fNetworkInterface->SetAddress(interfaceConfig); - fNetworkInterface->SetTo(zeroAddr); } else { // TODO : test this case (no address set for this protocol) printf("no zeroAddr found for %s(%d), found %" B_PRIu32 "\n", @@ -311,6 +310,20 @@ NetworkSettings::SetConfiguration() fNetworkInterface->AddAddress(interfaceConfig); } + // FIXME these flags shouldn't be interface-global, but specific to + // each protocol. Only set them for AF_INET otherwise there is + // confusion and freezes. + if (fProtocols[index].inet_id == AF_INET) { + int32 flags = fNetworkInterface->Flags(); + if (AutoConfigure(fProtocols[index].inet_id)) { + flags |= IFF_AUTO_CONFIGURED; + fNetworkInterface->SetFlags(flags); + fNetworkInterface->AutoConfigure(fProtocols[index].inet_id); + } else { + flags &= ~(IFF_AUTO_CONFIGURED | IFF_CONFIGURING); + fNetworkInterface->SetFlags(flags); + } + } } } }