1 /** @file 2 * @brief Network interface promiscuous mode support 3 * 4 * An API for applications to start listening network traffic. 5 * This requires support from network device driver and from application. 6 */ 7 8 /* 9 * Copyright (c) 2018 Intel Corporation 10 * 11 * SPDX-License-Identifier: Apache-2.0 12 */ 13 14 #ifndef ZEPHYR_INCLUDE_NET_PROMISCUOUS_H_ 15 #define ZEPHYR_INCLUDE_NET_PROMISCUOUS_H_ 16 17 /** 18 * @brief Promiscuous mode support. 19 * @defgroup promiscuous Promiscuous mode 20 * @since 1.13 21 * @version 0.8.0 22 * @ingroup networking 23 * @{ 24 */ 25 26 #include <zephyr/net/net_pkt.h> 27 #include <zephyr/net/net_if.h> 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /** 34 * @brief Start to wait received network packets. 35 * 36 * @param timeout How long to wait before returning. 37 * 38 * @return Received net_pkt, NULL if not received any packet. 39 */ 40 #if defined(CONFIG_NET_PROMISCUOUS_MODE) 41 struct net_pkt *net_promisc_mode_wait_data(k_timeout_t timeout); 42 #else 43 static inline struct net_pkt *net_promisc_mode_wait_data(k_timeout_t timeout) 44 { 45 ARG_UNUSED(timeout); 46 47 return NULL; 48 } 49 #endif /* CONFIG_NET_PROMISCUOUS_MODE */ 50 51 /** 52 * @brief Enable promiscuous mode for a given network interface. 53 * 54 * @param iface Network interface 55 * 56 * @return 0 if ok, <0 if error 57 */ 58 #if defined(CONFIG_NET_PROMISCUOUS_MODE) 59 int net_promisc_mode_on(struct net_if *iface); 60 #else net_promisc_mode_on(struct net_if * iface)61static inline int net_promisc_mode_on(struct net_if *iface) 62 { 63 ARG_UNUSED(iface); 64 65 return -ENOTSUP; 66 } 67 #endif /* CONFIG_NET_PROMISCUOUS_MODE */ 68 69 /** 70 * @brief Disable promiscuous mode for a given network interface. 71 * 72 * @param iface Network interface 73 * 74 * @return 0 if ok, <0 if error 75 */ 76 #if defined(CONFIG_NET_PROMISCUOUS_MODE) 77 int net_promisc_mode_off(struct net_if *iface); 78 #else net_promisc_mode_off(struct net_if * iface)79static inline int net_promisc_mode_off(struct net_if *iface) 80 { 81 ARG_UNUSED(iface); 82 83 return -ENOTSUP; 84 } 85 #endif /* CONFIG_NET_PROMISCUOUS_MODE */ 86 87 #ifdef __cplusplus 88 } 89 #endif 90 91 /** 92 * @} 93 */ 94 95 #endif /* ZEPHYR_INCLUDE_NET_PROMISCUOUS_H_ */ 96