net: event: Notify on interface being put down or up

It can be thus used to track the status of network interfaces in order
to act accordingly (no need to try sending things on network if the
interface is down for instance).

Change-Id: Ie160ef0dfdad6679d531d05a7abada96ad1de7db
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2017-01-04 15:54:20 +01:00
commit ef041c10b6
2 changed files with 23 additions and 0 deletions

View file

@ -22,6 +22,25 @@
#ifndef __NET_EVENT_H__
#define __NET_EVENT_H__
/* Network Interface events */
#define _NET_IF_LAYER NET_MGMT_LAYER_L1
#define _NET_IF_CORE_CODE 0x001
#define _NET_EVENT_IF_BASE (NET_MGMT_EVENT_BIT | \
NET_MGMT_IFACE_BIT | \
NET_MGMT_LAYER(_NET_IF_LAYER) | \
NET_MGMT_LAYER_CODE(_NET_IF_CORE_CODE))
enum net_event_if_cmd {
NET_EVENT_IF_CMD_DOWN = 0,
NET_EVENT_IF_CMD_UP,
};
#define NET_EVENT_IF_DOWN \
(_NET_EVENT_IF_BASE | NET_EVENT_IF_CMD_DOWN)
#define NET_EVENT_IF_UP \
(_NET_EVENT_IF_BASE | NET_EVENT_IF_CMD_UP)
/* IPv6 Events */
#define _NET_IPV6_LAYER NET_MGMT_LAYER_L3
#define _NET_IPV6_CORE_CODE 0x600

View file

@ -1375,6 +1375,8 @@ done:
net_if_start_rs(iface);
#endif
net_mgmt_event_notify(NET_EVENT_IF_UP, iface);
return 0;
}
@ -1398,6 +1400,8 @@ int net_if_down(struct net_if *iface)
done:
atomic_clear_bit(iface->flags, NET_IF_UP);
net_mgmt_event_notify(NET_EVENT_IF_DOWN, iface);
return 0;
}