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 * @ingroup networking 21 * @{ 22 */ 23 24 #include <zephyr/net/net_pkt.h> 25 #include <zephyr/net/net_if.h> 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /** 32 * @brief Start to wait received network packets. 33 * 34 * @param timeout How long to wait before returning. 35 * 36 * @return Received net_pkt, NULL if not received any packet. 37 */ 38 #if defined(CONFIG_NET_PROMISCUOUS_MODE) 39 struct net_pkt *net_promisc_mode_wait_data(k_timeout_t timeout); 40 #else 41 static inline struct net_pkt *net_promisc_mode_wait_data(k_timeout_t timeout) 42 { 43 ARG_UNUSED(timeout); 44 45 return NULL; 46 } 47 #endif /* CONFIG_NET_PROMISCUOUS_MODE */ 48 49 /** 50 * @brief Enable promiscuous mode for a given network interface. 51 * 52 * @param iface Network interface 53 * 54 * @return 0 if ok, <0 if error 55 */ 56 #if defined(CONFIG_NET_PROMISCUOUS_MODE) 57 int net_promisc_mode_on(struct net_if *iface); 58 #else net_promisc_mode_on(struct net_if * iface)59static inline int net_promisc_mode_on(struct net_if *iface) 60 { 61 ARG_UNUSED(iface); 62 63 return -ENOTSUP; 64 } 65 #endif /* CONFIG_NET_PROMISCUOUS_MODE */ 66 67 /** 68 * @brief Disable promiscuous mode for a given network interface. 69 * 70 * @param iface Network interface 71 * 72 * @return 0 if ok, <0 if error 73 */ 74 #if defined(CONFIG_NET_PROMISCUOUS_MODE) 75 int net_promisc_mode_off(struct net_if *iface); 76 #else net_promisc_mode_off(struct net_if * iface)77static inline int net_promisc_mode_off(struct net_if *iface) 78 { 79 ARG_UNUSED(iface); 80 81 return -ENOTSUP; 82 } 83 #endif /* CONFIG_NET_PROMISCUOUS_MODE */ 84 85 #ifdef __cplusplus 86 } 87 #endif 88 89 /** 90 * @} 91 */ 92 93 #endif /* ZEPHYR_INCLUDE_NET_PROMISCUOUS_H_ */ 94