LCOV - code coverage report
Current view: top level - zephyr/net - wifi_nm.h Coverage Total Hit
Test: new.info Lines: 100.0 % 17 17
Test Date: 2025-09-05 22:20:39

            Line data    Source code
       1            1 : /** @file
       2              :  * @brief Wi-Fi Network manager API
       3              :  *
       4              :  * This file contains the Wi-Fi network manager API. These APIs are used by the
       5              :  * any network management application to register as a Wi-Fi network manager.
       6              :  */
       7              : 
       8              : /*
       9              :  * Copyright (c) 2023 Nordic Semiconductor ASA.
      10              :  *
      11              :  * SPDX-License-Identifier: Apache-2.0
      12              :  */
      13              : 
      14              : #ifndef ZEPHYR_INCLUDE_ZEPHYR_NET_WIFI_NM_H_
      15              : #define ZEPHYR_INCLUDE_ZEPHYR_NET_WIFI_NM_H_
      16              : 
      17              : #include <zephyr/kernel.h>
      18              : #include <zephyr/types.h>
      19              : #include <zephyr/sys/iterable_sections.h>
      20              : #include <zephyr/net/net_if.h>
      21              : #include <zephyr/net/wifi_mgmt.h>
      22              : /**
      23              :  * @brief Wi-Fi Network manager API
      24              :  * @defgroup wifi_nm Wi-Fi Network Manager API
      25              :  * @since 3.5
      26              :  * @version 0.8.0
      27              :  * @ingroup networking
      28              :  * @{
      29              :  */
      30              : 
      31              : #ifdef __cplusplus
      32              : extern "C" {
      33              : #endif
      34              : 
      35              : /** Types of Wi-Fi interface */
      36            1 : enum wifi_nm_iface_type {
      37              :         /** IEEE 802.11 Wi-Fi Station */
      38              :         WIFI_TYPE_STA = 0,
      39              :         /** IEEE 802.11 Wi-Fi Soft AP */
      40              :         WIFI_TYPE_SAP,
      41              : };
      42              : 
      43              : /**
      44              :  * @brief WiFi Network Managed interfaces
      45              :  */
      46            1 : struct wifi_nm_mgd_iface {
      47              :         /** Wi-Fi interface type */
      48            1 :         unsigned char type;
      49              :         /** Managed net interfaces */
      50            1 :         struct net_if *iface;
      51              : };
      52              : 
      53              : /**
      54              :  * @brief WiFi Network manager instance
      55              :  */
      56            1 : struct wifi_nm_instance {
      57              :         /** Name of the Network manager instance */
      58            1 :         const char *name;
      59              :         /** Wi-Fi Management operations */
      60            1 :         const struct wifi_mgmt_ops *ops;
      61              :         /** List of Managed interfaces */
      62            1 :         struct wifi_nm_mgd_iface mgd_ifaces[CONFIG_WIFI_NM_MAX_MANAGED_INTERFACES];
      63              : };
      64              : 
      65              : /** @cond INTERNAL_HIDDEN */
      66              : 
      67              : #define WIFI_NM_NAME(name) wifi_nm_##name
      68              : 
      69              : #define DEFINE_WIFI_NM_INSTANCE(_name, _ops)            \
      70              :         static STRUCT_SECTION_ITERABLE(wifi_nm_instance, WIFI_NM_NAME(_name)) = { \
      71              :                 .name = STRINGIFY(_name),               \
      72              :                 .ops = _ops,                            \
      73              :                 .mgd_ifaces = {},               \
      74              :         }
      75              : 
      76              : /** @endcond */
      77              : 
      78              : /**
      79              :  * @brief Get a Network manager instance for a given name
      80              :  *
      81              :  * @param name Name of the Network manager instance
      82              :  *
      83              :  */
      84            1 : struct wifi_nm_instance *wifi_nm_get_instance(const char *name);
      85              : 
      86              : /**
      87              :  * @brief Get a Network manager instance for a given interface
      88              :  *
      89              :  * @param iface Interface
      90              :  *
      91              :  */
      92            1 : struct wifi_nm_instance *wifi_nm_get_instance_iface(struct net_if *iface);
      93              : 
      94              : /**
      95              :  * @brief Get a Wi-Fi type for a given interface
      96              :  *
      97              :  * @param iface Interface
      98              :  *
      99              :  */
     100            1 : unsigned char wifi_nm_get_type_iface(struct net_if *iface);
     101              : 
     102              : /**
     103              :  * @brief Check if the interface is a Wi-Fi station interface
     104              :  *
     105              :  * @param iface Interface
     106              :  *
     107              :  * @retval true If the interface is a Wi-Fi station interface.
     108              :  *
     109              :  */
     110            1 : bool wifi_nm_iface_is_sta(struct net_if *iface);
     111              : 
     112              : /**
     113              :  * @brief Check if the interface is a Wi-Fi Soft AP interface
     114              :  *
     115              :  * @param iface Interface
     116              :  *
     117              :  * @retval true If the interface is a Wi-Fi Soft AP interface.
     118              :  *
     119              :  */
     120            1 : bool wifi_nm_iface_is_sap(struct net_if *iface);
     121              : 
     122              : /**
     123              :  * @brief Register a managed interface
     124              :  *
     125              :  * @param nm Pointer to Network manager instance
     126              :  * @param iface Managed interface
     127              :  *
     128              :  * @retval 0 If successful.
     129              :  * @retval -EINVAL If invalid parameters were passed.
     130              :  * @retval -ENOTSUP If the interface is not a Wi-Fi interface.
     131              :  * @retval -ENOMEM If the maximum number of managed interfaces has been reached.
     132              :  */
     133            1 : int wifi_nm_register_mgd_iface(struct wifi_nm_instance *nm, struct net_if *iface);
     134              : 
     135              : /**
     136              :  * @brief Register a managed interface
     137              :  *
     138              :  * @param nm Pointer to Network manager instance
     139              :  * @param type Wi-Fi type
     140              :  * @param iface Managed interface
     141              :  *
     142              :  * @retval 0 If successful.
     143              :  * @retval -EINVAL If invalid parameters were passed.
     144              :  * @retval -ENOTSUP If the interface is not a Wi-Fi interface.
     145              :  * @retval -ENOMEM If the maximum number of managed interfaces has been reached.
     146              :  */
     147            1 : int wifi_nm_register_mgd_type_iface(struct wifi_nm_instance *nm,
     148              :                 enum wifi_nm_iface_type type, struct net_if *iface);
     149              : 
     150              : /**
     151              :  * @brief Unregister managed interface
     152              :  *
     153              :  * @param nm Pointer to Network manager instance
     154              :  * @param iface Interface
     155              :  * @return int 0 for OK; -EINVAL for invalid parameters; -ENOENT if interface is not registered
     156              :  *         with the Network manager.
     157              :  */
     158            1 : int wifi_nm_unregister_mgd_iface(struct wifi_nm_instance *nm, struct net_if *iface);
     159              : 
     160              : /**
     161              :  * @}
     162              :  */
     163              : 
     164              : #ifdef __cplusplus
     165              : }
     166              : #endif
     167              : #endif /* ZEPHYR_INCLUDE_ZEPHYR_NET_WIFI_NM_H_ */
        

Generated by: LCOV version 2.0-1