1 /*
2  * Copyright (c) 2016 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief IEEE 802.15.4 Net Management Private API
10  */
11 
12 #ifndef __IEEE802154_MGMT_PRIV_H__
13 #define __IEEE802154_MGMT_PRIV_H__
14 
15 #include "ieee802154_frame.h"
16 
17 #ifdef CONFIG_NET_MGMT
18 
ieee802154_is_scanning(struct net_if * iface)19 static inline bool ieee802154_is_scanning(struct net_if *iface)
20 {
21 	struct ieee802154_context *ctx = net_if_l2_data(iface);
22 
23 	return !(!ctx->scan_ctx);
24 }
25 
ieee802154_mgmt_init(struct net_if * iface)26 static inline void ieee802154_mgmt_init(struct net_if *iface)
27 {
28 	struct ieee802154_context *ctx = net_if_l2_data(iface);
29 
30 	k_sem_init(&ctx->scan_ctx_lock, 1, 1);
31 }
32 
33 /**
34  * Handles the given Beacon frame.
35  *
36  * Returns NET_OK if successful. It's the caller's responsibility
37  * to release the corresponding package in that case.
38  */
39 enum net_verdict ieee802154_handle_beacon(struct net_if *iface,
40 					  struct ieee802154_mpdu *mpdu,
41 					  uint8_t lqi);
42 
43 /**
44  * Executes the given MAC command.
45  *
46  * Returns NET_OK if successful. It's the caller's responsibility
47  * to release the corresponding package in that case.
48  */
49 enum net_verdict ieee802154_handle_mac_command(struct net_if *iface,
50 					       struct ieee802154_mpdu *mpdu);
51 
52 #else /* CONFIG_NET_MGMT */
53 
54 #define ieee802154_is_scanning(...) false
55 #define ieee802154_mgmt_init(...)
56 #define ieee802154_handle_beacon(...) NET_DROP
57 #define ieee802154_handle_mac_command(...) NET_DROP
58 
59 #endif /* CONFIG_NET_MGMT */
60 
61 #endif /* __IEEE802154_MGMT_PRIV_H__ */
62