* 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:
parent
be6c5ba6a7
commit
d869a06172
@ -326,6 +326,7 @@ ethernet_receive_data(net_device *_device, net_buffer **_buffer)
|
||||
status = bytesRead;
|
||||
goto err;
|
||||
}
|
||||
//dump_block((const char *)data, bytesRead, "rcv: ");
|
||||
|
||||
status = gBufferModule->trim(buffer, bytesRead);
|
||||
if (status < B_OK) {
|
||||
|
@ -717,6 +717,7 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option,
|
||||
}
|
||||
|
||||
add_default_routes(interface, option);
|
||||
notify_interface_changed(interface);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
interface->mtu = request.ifr_mtu;
|
||||
notify_interface_changed(interface);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -851,6 +853,7 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option,
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
interface->metric = request.ifr_metric;
|
||||
notify_interface_changed(interface);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -271,11 +271,12 @@ domain_interface_control(net_domain_private* domain, int32 option,
|
||||
|
||||
case SIOCSIFFLAGS:
|
||||
{
|
||||
uint32 oldFlags = interface->flags;
|
||||
uint32 requestFlags = request->ifr_flags;
|
||||
request->ifr_flags &= ~(IFF_UP | IFF_LINK | IFF_BROADCAST);
|
||||
|
||||
if ((requestFlags & IFF_UP) != (interface->flags & IFF_UP)) {
|
||||
if (requestFlags & IFF_UP) {
|
||||
if ((requestFlags & IFF_UP) != 0) {
|
||||
status = interface->first_info->interface_up(
|
||||
interface->first_protocol);
|
||||
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 |= request->ifr_flags;
|
||||
}
|
||||
|
||||
if (oldFlags != interface->flags) {
|
||||
notify_interface_changed(interface, oldFlags,
|
||||
interface->flags);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
|
||||
/*! Provides the stack internal notification API.
|
||||
|
||||
The actual message sending happens in another module to make the
|
||||
notification listeners independent from the stack status.
|
||||
*/
|
||||
|
||||
|
||||
#include <net_device.h>
|
||||
#include <net_notifications.h>
|
||||
|
||||
@ -53,7 +55,8 @@ notify_interface_removed(net_interface* interface)
|
||||
|
||||
|
||||
status_t
|
||||
notify_interface_changed(net_interface* interface)
|
||||
notify_interface_changed(net_interface* interface, uint32 oldFlags,
|
||||
uint32 newFlags)
|
||||
{
|
||||
if (sNotificationModule == NULL)
|
||||
return B_NOT_SUPPORTED;
|
||||
@ -63,6 +66,10 @@ notify_interface_changed(net_interface* interface)
|
||||
message.SetTo(messageBuffer, sizeof(messageBuffer), B_NETWORK_MONITOR);
|
||||
message.AddInt32("opcode", B_NETWORK_INTERFACE_CHANGED);
|
||||
message.AddString("interface", interface->name);
|
||||
if (oldFlags != newFlags) {
|
||||
message.AddInt32("old flags", oldFlags);
|
||||
message.AddInt32("new flags", newFlags);
|
||||
}
|
||||
|
||||
return sNotificationModule->send_notification(&message);
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
* Authors:
|
||||
@ -36,7 +36,8 @@ status_t put_domain_datalink_protocols(net_interface *interface);
|
||||
// notifications.cpp
|
||||
status_t notify_interface_added(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 init_notifications();
|
||||
void uninit_notifications();
|
||||
@ -44,4 +45,5 @@ void uninit_notifications();
|
||||
status_t init_stack();
|
||||
status_t uninit_stack();
|
||||
|
||||
|
||||
#endif // STACK_PRIVATE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user