Commit 5a9a39ca authored by Jukka Rissanen's avatar Jukka Rissanen Committed by Benjamin Cabé
Browse files

net: mgmt: Convert the mgmt API to use 64-bit masks



Instead of using 32 bit enum values for event numbers, convert
the code to use 64 bit long bit fields. This means that the
user API is changed to use 64 bit event values instead of 32
bit event values.

Signed-off-by: default avatarJukka Rissanen <jukka.rissanen@nordicsemi.no>
parent f51a8926
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ following example simply prints when an event occurs.
    #define COAP_EVENTS_SET (NET_EVENT_COAP_OBSERVER_ADDED | NET_EVENT_COAP_OBSERVER_REMOVED | \
                             NET_EVENT_COAP_SERVICE_STARTED | NET_EVENT_COAP_SERVICE_STOPPED)

    void coap_event_handler(uint32_t mgmt_event, struct net_if *iface,
    void coap_event_handler(uint64_t mgmt_event, struct net_if *iface,
                            void *info, size_t info_length, void *user_data)
    {
        switch (mgmt_event) {
+3 −3
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ An example follows.
	struct net_mgmt_event_callback ipv4_callback;

	void callback_handler(struct net_mgmt_event_callback *cb,
			      uint32_t mgmt_event,
			      uint64_t mgmt_event,
			      struct net_if *iface)
	{
		if (mgmt_event == NET_EVENT_IF_xxx) {
@@ -139,7 +139,7 @@ Or similarly using :c:macro:`NET_MGMT_REGISTER_EVENT_HANDLER`.
	#define EVENT_IFACE_SET (NET_EVENT_IF_xxx | NET_EVENT_IF_yyy)
	#define EVENT_IPV4_SET (NET_EVENT_IPV4_xxx | NET_EVENT_IPV4_yyy)

	static void event_handler(uint32_t mgmt_event, struct net_if *iface,
	static void event_handler(uint64_t mgmt_event, struct net_if *iface,
				  void *info, size_t info_length,
				  void *user_data)
	{
@@ -183,7 +183,7 @@ You define your handler modeled with this signature:

.. code-block:: c

   static int your_handler(uint32_t mgmt_event, struct net_if *iface,
   static int your_handler(uint64_t mgmt_event, struct net_if *iface,
                           void *data, size_t len);

and then register it with an associated mgmt_request code:
+1 −1
Original line number Diff line number Diff line
@@ -1774,7 +1774,7 @@ static int modem_cellular_pm_action(const struct device *dev, enum pm_device_act
}
#endif /* CONFIG_PM_DEVICE */

static void net_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event,
static void net_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event,
				   struct net_if *iface)
{
	struct modem_cellular_data *data =
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ struct esp32_wifi_runtime {

static struct net_mgmt_event_callback esp32_dhcp_cb;

static void wifi_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event,
static void wifi_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event,
			       struct net_if *iface)
{
	switch (mgmt_event) {
+16 −4
Original line number Diff line number Diff line
@@ -40,13 +40,25 @@ struct coap_service;
struct coap_resource;
struct coap_observer;

enum {
	NET_EVENT_COAP_CMD_SERVICE_STARTED_VAL,
	NET_EVENT_COAP_CMD_SERVICE_STOPPED_VAL,
	NET_EVENT_COAP_CMD_OBSERVER_ADDED_VAL,
	NET_EVENT_COAP_CMD_OBSERVER_REMOVED_VAL,

	NET_EVENT_COAP_CMD_MAX
};

BUILD_ASSERT(NET_EVENT_COAP_CMD_MAX <= NET_MGMT_MAX_COMMANDS,
	     "Number of events in net_event_coap_cmd exceeds the limit");

enum net_event_coap_cmd {
	/* Service events */
	NET_EVENT_COAP_CMD_SERVICE_STARTED = 1,
	NET_EVENT_COAP_CMD_SERVICE_STOPPED,
	NET_MGMT_CMD(NET_EVENT_COAP_CMD_SERVICE_STARTED),
	NET_MGMT_CMD(NET_EVENT_COAP_CMD_SERVICE_STOPPED),
	/* Observer events */
	NET_EVENT_COAP_CMD_OBSERVER_ADDED,
	NET_EVENT_COAP_CMD_OBSERVER_REMOVED,
	NET_MGMT_CMD(NET_EVENT_COAP_CMD_OBSERVER_ADDED),
	NET_MGMT_CMD(NET_EVENT_COAP_CMD_OBSERVER_REMOVED),
};

/** @endcond */
Loading