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);
52 bool (*is_enabled)(
const struct device *dev);
55 int (*
send)(
const struct device *dev,
struct net_if *iface,
struct net_pkt *pkt);
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);
219#if defined(CONFIG_NET_CAPTURE)
240#if defined(CONFIG_NET_CAPTURE)
241int net_capture_pkt_with_status(
struct net_if *iface,
struct net_pkt *pkt);
243static inline int net_capture_pkt_with_status(
struct net_if *iface,
struct net_pkt *pkt)
263#define NET_CAPTURE_LL_ADDRLEN 8
285#if defined(CONFIG_NET_CAPTURE_COOKED_MODE)
319#if defined(CONFIG_NET_CAPTURE_COOKED_MODE)
321 const uint8_t *data,
size_t len,
326 const uint8_t *data,
size_t len,
372#if defined(CONFIG_NET_CAPTURE)
378 ARG_UNUSED(user_data);
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 void net_capture_pkt(struct net_if *iface, struct net_pkt *pkt)
Check if the network packet needs to be captured or not.
Definition capture.h:222
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
net_capture_packet_type
The type and direction of the captured data.
Definition capture.h:255
static int net_capture_cooked_setup(struct net_capture_cooked *ctx, uint16_t hatype, uint16_t halen, uint8_t *addr)
Initialize cooked mode capture context.
Definition capture.h:291
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 void net_capture_data(struct net_capture_cooked *ctx, const uint8_t *data, size_t len, enum net_capture_packet_type type, uint16_t ptype)
Capture arbitrary data from source that does not have an interface.
Definition capture.h:325
static void net_capture_foreach(net_capture_cb_t cb, void *user_data)
Go through all the capture devices in order to get information about them.
Definition capture.h:375
#define NET_CAPTURE_LL_ADDRLEN
Maximum length of a link-layer address.
Definition capture.h:263
void(* net_capture_cb_t)(struct net_capture_info *info, void *user_data)
Callback used while iterating over capture devices.
Definition capture.h:361
static int net_capture_enable(const struct device *dev, struct net_if *iface)
Enable network packet capturing support.
Definition capture.h:115
@ NET_CAPTURE_MULTICAST
Packet was multicast, but not broadcast, by somebody else.
Definition capture.h:258
@ NET_CAPTURE_BROADCAST
Packet was broadcast by somebody else.
Definition capture.h:257
@ NET_CAPTURE_HOST
Packet was sent to us by somebody else.
Definition capture.h:256
@ NET_CAPTURE_OTHERHOST
Packet was sent by somebody else to somebody else.
Definition capture.h:259
@ NET_CAPTURE_OUTGOING
Packet was sent by us.
Definition capture.h:260
#define ENOTSUP
Unsupported value.
Definition errno.h:115
#define NULL
Definition iar_missing_defs.h:20
ssize_t send(int sock, const void *buf, size_t len, int flags)
#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:513
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
The context information for cooked mode capture.
Definition capture.h:266
uint16_t hatype
Link-layer address type.
Definition capture.h:268
uint8_t addr[8]
Link-layer address.
Definition capture.h:272
uint16_t halen
Link-layer address length.
Definition capture.h:270
Network packet capture device information.
Definition capture.h:339
struct net_sockaddr * peer
Peer (inner) tunnel IP address.
Definition capture.h:347
bool is_enabled
Is the capture currently enabled.
Definition capture.h:351
struct net_if * tunnel_iface
IPIP tunnel network interface where the captured packets are sent.
Definition capture.h:345
struct net_sockaddr * local
Local (inner) tunnel IP address.
Definition capture.h:349
struct net_if * capture_iface
Network interface where the network packets are captured.
Definition capture.h:343
const struct device * capture_dev
The capture device.
Definition capture.h:341
Network Interface structure.
Definition net_if.h:744
Network packet.
Definition net_pkt.h:119
Generic sockaddr struct.
Definition net_ip.h:455