13#ifndef ZEPHYR_INCLUDE_NET_CAPTURE_H_
14#define ZEPHYR_INCLUDE_NET_CAPTURE_H_
38struct net_capture_interface_api {
42 int (*cleanup)(
const struct device *dev);
45 int (*enable)(
const struct device *dev,
struct net_if *iface);
48 int (*disable)(
const struct device *dev);
75int net_capture_setup(
const char *remote_addr,
const char *my_local_addr,
const char *peer_addr,
76 const struct device **dev);
91#if defined(CONFIG_NET_CAPTURE)
92 const struct net_capture_interface_api *api =
93 (
const struct net_capture_interface_api *)dev->
api;
95 return api->cleanup(dev);
117#if defined(CONFIG_NET_CAPTURE)
118 const struct net_capture_interface_api *api =
119 (
const struct net_capture_interface_api *)dev->
api;
121 return api->enable(dev, iface);
140#if defined(CONFIG_NET_CAPTURE)
141 const struct net_capture_interface_api *api;
151 api = (
const struct net_capture_interface_api *)dev->
api;
153 return api->is_enabled(dev);
170#if defined(CONFIG_NET_CAPTURE)
171 const struct net_capture_interface_api *api =
172 (
const struct net_capture_interface_api *)dev->
api;
174 return api->disable(dev);
193static inline int net_capture_send(
const struct device *dev,
struct net_if *iface,
196#if defined(CONFIG_NET_CAPTURE)
197 const struct net_capture_interface_api *api =
198 (
const struct net_capture_interface_api *)dev->
api;
200 return api->send(dev, iface, pkt);
217#if defined(CONFIG_NET_CAPTURE)
218void net_capture_pkt(
struct net_if *iface,
struct net_pkt *pkt);
220static inline void net_capture_pkt(
struct net_if *iface,
struct net_pkt *pkt)
238#if defined(CONFIG_NET_CAPTURE)
239int net_capture_pkt_with_status(
struct net_if *iface,
struct net_pkt *pkt);
241static inline int net_capture_pkt_with_status(
struct net_if *iface,
struct net_pkt *pkt)
253enum net_capture_packet_type {
255 NET_CAPTURE_BROADCAST,
256 NET_CAPTURE_MULTICAST,
257 NET_CAPTURE_OTHERHOST,
258 NET_CAPTURE_OUTGOING,
261#define NET_CAPTURE_LL_ADDRLEN 8
264struct net_capture_cooked {
270 uint8_t addr[NET_CAPTURE_LL_ADDRLEN];
283#if defined(CONFIG_NET_CAPTURE_COOKED_MODE)
284int net_capture_cooked_setup(
struct net_capture_cooked *ctx,
289static inline int net_capture_cooked_setup(
struct net_capture_cooked *ctx,
317#if defined(CONFIG_NET_CAPTURE_COOKED_MODE)
318void net_capture_data(
struct net_capture_cooked *ctx,
319 const uint8_t *data,
size_t len,
320 enum net_capture_packet_type type,
323static inline void net_capture_data(
struct net_capture_cooked *ctx,
324 const uint8_t *data,
size_t len,
325 enum net_capture_packet_type type,
336struct net_capture_info {
337 const struct device *capture_dev;
338 struct net_if *capture_iface;
339 struct net_if *tunnel_iface;
352typedef void (*net_capture_cb_t)(
struct net_capture_info *info,
void *user_data);
363#if defined(CONFIG_NET_CAPTURE)
364void net_capture_foreach(net_capture_cb_t cb,
void *user_data);
366static inline void net_capture_foreach(net_capture_cb_t cb,
void *user_data)
369 ARG_UNUSED(user_data);
static ssize_t send(int sock, const void *buf, size_t len, int flags)
POSIX wrapper for zsock_send.
Definition socket.h:867
const struct device * device_get_binding(const char *name)
Get a device reference from its device::name field.
static int net_capture_disable(const struct device *dev)
Disable network packet capturing support.
Definition capture.h:168
static bool net_capture_is_enabled(const struct device *dev)
Is network packet capture enabled or disabled.
Definition capture.h:138
static int net_capture_cleanup(const struct device *dev)
Cleanup network packet capturing support.
Definition capture.h:89
int net_capture_setup(const char *remote_addr, const char *my_local_addr, const char *peer_addr, const struct device **dev)
Setup network packet capturing support.
static int net_capture_enable(const struct device *dev, struct net_if *iface)
Enable network packet capturing support.
Definition capture.h:115
#define ENOTSUP
Unsupported value.
Definition errno.h:114
#define bool
Definition stdbool.h:13
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418
Network Interface structure.
Definition net_if.h:690
Network packet.
Definition net_pkt.h:91
Generic sockaddr struct.
Definition net_ip.h:388