12#ifndef ZEPHYR_INCLUDE_NET_NET_MGMT_H_
13#define ZEPHYR_INCLUDE_NET_NET_MGMT_H_
38#define NET_MGMT_EVENT_MASK GENMASK64(63, 63)
39#define NET_MGMT_ON_IFACE_MASK GENMASK64(62, 62)
40#define NET_MGMT_LAYER_MASK GENMASK64(61, 60)
41#define NET_MGMT_SYNC_EVENT_MASK GENMASK64(59, 59)
42#define NET_MGMT_LAYER_CODE_MASK GENMASK64(58, 52)
43#define NET_MGMT_COMMAND_MASK GENMASK64(51, 0)
45#define NET_MGMT_MAX_COMMANDS 52
47#define NET_MGMT_EVENT_BIT BIT64(63)
48#define NET_MGMT_IFACE_BIT BIT64(62)
49#define NET_MGMT_SYNC_EVENT_BIT BIT64(59)
51#define NET_MGMT_LAYER(_layer) FIELD_PREP(NET_MGMT_LAYER_MASK, (_layer))
52#define NET_MGMT_LAYER_CODE(_code) FIELD_PREP(NET_MGMT_LAYER_CODE_MASK, (_code))
54#define NET_MGMT_EVENT(mgmt_request) FIELD_GET(NET_MGMT_EVENT_MASK, mgmt_request)
55#define NET_MGMT_ON_IFACE(mgmt_request) FIELD_GET(NET_MGMT_ON_IFACE_MASK, mgmt_request)
56#define NET_MGMT_EVENT_SYNCHRONOUS(mgmt_request) FIELD_GET(NET_MGMT_SYNC_EVENT_MASK, mgmt_request)
57#define NET_MGMT_GET_LAYER(mgmt_request) FIELD_GET(NET_MGMT_LAYER_MASK, mgmt_request)
58#define NET_MGMT_GET_LAYER_CODE(mgmt_request) FIELD_GET(NET_MGMT_LAYER_CODE_MASK, mgmt_request)
59#define NET_MGMT_GET_COMMAND(mgmt_request) FIELD_GET(NET_MGMT_COMMAND_MASK, mgmt_request)
61#define NET_MGMT_CMD(cmd) cmd = BIT64(cmd ##_VAL)
64#define NET_MGMT_LAYER_L2 1
65#define NET_MGMT_LAYER_L3 2
66#define NET_MGMT_LAYER_L4 3
111 void *data,
size_t len);
121#define net_mgmt(_mgmt_request, _iface, _data, _len) \
122 net_mgmt_##_mgmt_request(_mgmt_request, _iface, _data, _len)
129#define NET_MGMT_DEFINE_REQUEST_HANDLER(_mgmt_request) \
130 extern int net_mgmt_##_mgmt_request(uint64_t mgmt_request, \
131 struct net_if *iface, \
132 void *data, size_t len)
140#define NET_MGMT_REGISTER_REQUEST_HANDLER(_mgmt_request, _func) \
141 FUNC_ALIAS(_func, net_mgmt_##_mgmt_request, int)
179#ifdef CONFIG_NET_MGMT_EVENT_INFO
219 void *info,
size_t info_length,
225struct net_mgmt_event_static_handler {
246#define NET_MGMT_REGISTER_EVENT_HANDLER(_name, _event_mask, _func, _user_data) \
247 const STRUCT_SECTION_ITERABLE(net_mgmt_event_static_handler, _name) = { \
248 .event_mask = _event_mask, \
250 .user_data = (void *)_user_data, \
259#ifdef CONFIG_NET_MGMT_EVENT
265 __ASSERT(cb,
"Callback pointer should not be NULL");
266 __ASSERT(handler,
"Handler pointer should not be NULL");
272#define net_mgmt_init_event_callback(...)
279#ifdef CONFIG_NET_MGMT_EVENT
282#define net_mgmt_add_event_callback(...)
289#ifdef CONFIG_NET_MGMT_EVENT
292#define net_mgmt_del_event_callback(...)
308#if defined(CONFIG_NET_MGMT_EVENT)
310 const void *info,
size_t length);
312#define net_mgmt_event_notify_with_info(...)
321#if defined(CONFIG_NET_MGMT_EVENT)
328#define net_mgmt_event_notify(...)
351#ifdef CONFIG_NET_MGMT_EVENT
366 ARG_UNUSED(mgmt_event_mask);
367 ARG_UNUSED(raised_event);
370 ARG_UNUSED(info_length);
395#ifdef CONFIG_NET_MGMT_EVENT
411 ARG_UNUSED(mgmt_event_mask);
412 ARG_UNUSED(raised_event);
414 ARG_UNUSED(info_length);
424#ifdef CONFIG_NET_MGMT_EVENT
427#define net_mgmt_event_init(...)
void(* net_mgmt_event_static_handler_t)(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data)
Define the user's callback handler function signature.
Definition net_mgmt.h:217
int net_mgmt_event_wait_on_iface(struct net_if *iface, uint64_t mgmt_event_mask, uint64_t *raised_event, const void **info, size_t *info_length, k_timeout_t timeout)
Used to wait synchronously on an event mask for a specific iface.
void net_mgmt_del_event_callback(struct net_mgmt_event_callback *cb)
Delete a user callback.
static void net_mgmt_init_event_callback(struct net_mgmt_event_callback *cb, net_mgmt_event_handler_t handler, uint64_t mgmt_event_mask)
Helper to initialize a struct net_mgmt_event_callback properly.
Definition net_mgmt.h:261
int(* net_mgmt_request_handler_t)(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len)
Signature which all Net MGMT request handler need to follow.
Definition net_mgmt.h:109
net_mgmt_layer_code
Central place the definition of the layer codes (7 bit value)
Definition net_mgmt.h:71
void net_mgmt_event_notify_with_info(uint64_t mgmt_event, struct net_if *iface, const void *info, size_t length)
Used by the system to notify an event.
int net_mgmt_event_wait(uint64_t mgmt_event_mask, uint64_t *raised_event, struct net_if **iface, const void **info, size_t *info_length, k_timeout_t timeout)
Used to wait synchronously on an event mask.
void net_mgmt_event_init(void)
Used by the core of the network stack to initialize the network event processing.
static void net_mgmt_event_notify(uint64_t mgmt_event, struct net_if *iface)
Used by the system to notify an event without any additional information.
Definition net_mgmt.h:322
void net_mgmt_add_event_callback(struct net_mgmt_event_callback *cb)
Add a user callback.
void(* net_mgmt_event_handler_t)(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface)
Define the user's callback handler function signature.
Definition net_mgmt.h:153
@ NET_MGMT_LAYER_CODE_HOSTAP
Hostap (wpa_supplicant) layer code.
Definition net_mgmt.h:80
@ NET_MGMT_LAYER_CODE_USER1
User layer code 1.
Definition net_mgmt.h:90
@ NET_MGMT_LAYER_CODE_IPV4
IPv4 layer code.
Definition net_mgmt.h:75
@ NET_MGMT_LAYER_CODE_IFACE
Network interface layer code.
Definition net_mgmt.h:73
@ NET_MGMT_LAYER_CODE_UNKNOWN
Unknown layer code, do not use.
Definition net_mgmt.h:72
@ NET_MGMT_LAYER_CODE_STATS
Statistics layer code.
Definition net_mgmt.h:79
@ NET_MGMT_LAYER_CODE_IEEE802514
IEEE 802.15.4 layer code.
Definition net_mgmt.h:82
@ NET_MGMT_LAYER_CODE_USER3
User layer code 3.
Definition net_mgmt.h:88
@ NET_MGMT_LAYER_CODE_PPP
PPP layer code.
Definition net_mgmt.h:83
@ NET_MGMT_LAYER_CODE_COAP
CoAP layer code.
Definition net_mgmt.h:78
@ NET_MGMT_LAYER_CODE_WIFI
Wi-Fi layer code.
Definition net_mgmt.h:85
@ NET_MGMT_LAYER_CODE_IPV6
IPv6 layer code.
Definition net_mgmt.h:76
@ NET_MGMT_LAYER_CODE_USER2
User layer code 2.
Definition net_mgmt.h:89
@ NET_MGMT_LAYER_CODE_L4
L4 layer code.
Definition net_mgmt.h:77
@ NET_MGMT_LAYER_CODE_CONN
Connectivity layer code.
Definition net_mgmt.h:74
@ NET_MGMT_LAYER_CODE_VIRTUAL
Virtual network interface layer code.
Definition net_mgmt.h:84
@ NET_MGMT_LAYER_CODE_RESERVED
Reserved layer code for future use.
Definition net_mgmt.h:93
@ NET_MGMT_LAYER_CODE_ETHERNET
Ethernet layer code.
Definition net_mgmt.h:81
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
#define NULL
Definition iar_missing_defs.h:20
Network core definitions.
Network Events code public header.
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Semaphore structure.
Definition kernel.h:3275
Kernel timeout type.
Definition sys_clock.h:65
Network Interface structure.
Definition net_if.h:726
Network Management event callback structure Used to register a callback into the network management e...
Definition net_mgmt.h:163
sys_snode_t node
Meant to be used internally, to insert the callback into a list.
Definition net_mgmt.h:167
uint64_t raised_event
Internal place holder when a synchronous event wait is successfully unlocked on a event.
Definition net_mgmt.h:202
struct k_sem * sync_call
Semaphore meant to be used internally for the synchronous net_mgmt_event_wait() function.
Definition net_mgmt.h:176
uint64_t event_mask
A mask of network events on which the above handler should be called in case those events come.
Definition net_mgmt.h:198
net_mgmt_event_handler_t handler
Actual callback function being used to notify the owner.
Definition net_mgmt.h:172