* Made the stack send out interface change notifications where needed (at least

hopefully :-)).
* Improved interface change notification to include the flags that changed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37594 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2010-07-19 13:48:16 +00:00
parent be6c5ba6a7
commit d869a06172
5 changed files with 24 additions and 5 deletions

View File

@ -326,6 +326,7 @@ ethernet_receive_data(net_device *_device, net_buffer **_buffer)
status = bytesRead; status = bytesRead;
goto err; goto err;
} }
//dump_block((const char *)data, bytesRead, "rcv: ");
status = gBufferModule->trim(buffer, bytesRead); status = gBufferModule->trim(buffer, bytesRead);
if (status < B_OK) { if (status < B_OK) {

View File

@ -717,6 +717,7 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option,
} }
add_default_routes(interface, option); add_default_routes(interface, option);
notify_interface_changed(interface);
} }
return address != NULL ? B_OK : B_NO_MEMORY; return address != NULL ? B_OK : B_NO_MEMORY;
@ -811,6 +812,7 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option,
return B_BAD_VALUE; return B_BAD_VALUE;
interface->mtu = request.ifr_mtu; interface->mtu = request.ifr_mtu;
notify_interface_changed(interface);
return B_OK; return B_OK;
} }
@ -851,6 +853,7 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option,
return B_BAD_ADDRESS; return B_BAD_ADDRESS;
interface->metric = request.ifr_metric; interface->metric = request.ifr_metric;
notify_interface_changed(interface);
return B_OK; return B_OK;
} }

View File

@ -271,11 +271,12 @@ domain_interface_control(net_domain_private* domain, int32 option,
case SIOCSIFFLAGS: case SIOCSIFFLAGS:
{ {
uint32 oldFlags = interface->flags;
uint32 requestFlags = request->ifr_flags; uint32 requestFlags = request->ifr_flags;
request->ifr_flags &= ~(IFF_UP | IFF_LINK | IFF_BROADCAST); request->ifr_flags &= ~(IFF_UP | IFF_LINK | IFF_BROADCAST);
if ((requestFlags & IFF_UP) != (interface->flags & IFF_UP)) { if ((requestFlags & IFF_UP) != (interface->flags & IFF_UP)) {
if (requestFlags & IFF_UP) { if ((requestFlags & IFF_UP) != 0) {
status = interface->first_info->interface_up( status = interface->first_info->interface_up(
interface->first_protocol); interface->first_protocol);
if (status == B_OK) if (status == B_OK)
@ -290,6 +291,11 @@ domain_interface_control(net_domain_private* domain, int32 option,
interface->flags &= IFF_UP | IFF_LINK | IFF_BROADCAST; interface->flags &= IFF_UP | IFF_LINK | IFF_BROADCAST;
interface->flags |= request->ifr_flags; interface->flags |= request->ifr_flags;
} }
if (oldFlags != interface->flags) {
notify_interface_changed(interface, oldFlags,
interface->flags);
}
break; break;
} }
} }

View File

@ -1,14 +1,16 @@
/* /*
* Copyright 2008, Axel Dörfler, axeld@pinc-software.de. * Copyright 2008-2010, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
/*! Provides the stack internal notification API. /*! Provides the stack internal notification API.
The actual message sending happens in another module to make the The actual message sending happens in another module to make the
notification listeners independent from the stack status. notification listeners independent from the stack status.
*/ */
#include <net_device.h> #include <net_device.h>
#include <net_notifications.h> #include <net_notifications.h>
@ -53,7 +55,8 @@ notify_interface_removed(net_interface* interface)
status_t status_t
notify_interface_changed(net_interface* interface) notify_interface_changed(net_interface* interface, uint32 oldFlags,
uint32 newFlags)
{ {
if (sNotificationModule == NULL) if (sNotificationModule == NULL)
return B_NOT_SUPPORTED; return B_NOT_SUPPORTED;
@ -63,6 +66,10 @@ notify_interface_changed(net_interface* interface)
message.SetTo(messageBuffer, sizeof(messageBuffer), B_NETWORK_MONITOR); message.SetTo(messageBuffer, sizeof(messageBuffer), B_NETWORK_MONITOR);
message.AddInt32("opcode", B_NETWORK_INTERFACE_CHANGED); message.AddInt32("opcode", B_NETWORK_INTERFACE_CHANGED);
message.AddString("interface", interface->name); message.AddString("interface", interface->name);
if (oldFlags != newFlags) {
message.AddInt32("old flags", oldFlags);
message.AddInt32("new flags", newFlags);
}
return sNotificationModule->send_notification(&message); return sNotificationModule->send_notification(&message);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -36,7 +36,8 @@ status_t put_domain_datalink_protocols(net_interface *interface);
// notifications.cpp // notifications.cpp
status_t notify_interface_added(net_interface* interface); status_t notify_interface_added(net_interface* interface);
status_t notify_interface_removed(net_interface* interface); status_t notify_interface_removed(net_interface* interface);
status_t notify_interface_changed(net_interface* interface); status_t notify_interface_changed(net_interface* interface, uint32 oldFlags = 0,
uint32 newFlags = 0);
status_t notify_link_changed(net_device* device); status_t notify_link_changed(net_device* device);
status_t init_notifications(); status_t init_notifications();
void uninit_notifications(); void uninit_notifications();
@ -44,4 +45,5 @@ void uninit_notifications();
status_t init_stack(); status_t init_stack();
status_t uninit_stack(); status_t uninit_stack();
#endif // STACK_PRIVATE_H #endif // STACK_PRIVATE_H