|
Zephyr Project API 4.4.99
A Scalable Open Source RTOS
|
Network packet capture support functions. More...
Data Structures | |
| struct | net_capture_cooked |
| The context information for cooked mode capture. More... | |
| struct | net_capture_info |
| Network packet capture device information. More... | |
Macros | |
| #define | NET_CAPTURE_LL_ADDRLEN 8 |
| Maximum length of a link-layer address. | |
Typedefs | |
| typedef void(* | net_capture_cb_t) (struct net_capture_info *info, void *user_data) |
| Callback used while iterating over capture devices. | |
Enumerations | |
| enum | net_capture_packet_type { NET_CAPTURE_HOST , NET_CAPTURE_BROADCAST , NET_CAPTURE_MULTICAST , NET_CAPTURE_OTHERHOST , NET_CAPTURE_OUTGOING } |
| The type and direction of the captured data. More... | |
Functions | |
| 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_cleanup (const struct device *dev) |
| Cleanup network packet capturing support. | |
| static int | net_capture_enable (const struct device *dev, struct net_if *iface) |
| Enable network packet capturing support. | |
| static bool | net_capture_is_enabled (const struct device *dev) |
| Is network packet capture enabled or disabled. | |
| static int | net_capture_disable (const struct device *dev) |
| Disable network packet capturing support. | |
| static void | net_capture_pkt (struct net_if *iface, struct net_pkt *pkt) |
| Check if the network packet needs to be captured or not. | |
| 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. | |
| 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. | |
| 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. | |
Network packet capture support functions.
| #define NET_CAPTURE_LL_ADDRLEN 8 |
#include <capture.h>
Maximum length of a link-layer address.
| typedef void(* net_capture_cb_t) (struct net_capture_info *info, void *user_data) |
#include <capture.h>
Callback used while iterating over capture devices.
| info | Information about capture device |
| user_data | A valid pointer to user data or NULL |
#include <capture.h>
The type and direction of the captured data.
|
inlinestatic |
#include <capture.h>
Cleanup network packet capturing support.
This should be called after the capturing is done and resources can be released.
| dev | Network capture device. User must allocate using the net_capture_setup() function. |
|
inlinestatic |
#include <capture.h>
Initialize cooked mode capture context.
| ctx | Cooked context struct allocated by user. |
| hatype | Link-layer address type |
| halen | Link-layer address length (maximum is 8 bytes) |
| addr | Link-layer address |
|
inlinestatic |
#include <capture.h>
Capture arbitrary data from source that does not have an interface.
This can be used if you do not have a network interface that you want to capture from. For example low level modem device below PPP containing HDLC frames, CANBUS data or Bluetooth packets etc. The data given to this function should only contain full link layer packets so that packet boundary is not lost.
| ctx | Cooked mode capture context. |
| data | Data to capture. |
| len | Length of the data. |
| type | The direction and type of the packet (did we sent it etc). |
| ptype | Protocol type id. These are the ETH_P_* types set in ethernet.h |
|
inlinestatic |
#include <capture.h>
Disable network packet capturing support.
| dev | Network capture device |
#include <capture.h>
Enable network packet capturing support.
This creates tunnel network interface where all the captured packets are pushed. The captured network packets are placed in UDP packets that are sent to tunnel peer.
| dev | Network capture device |
| iface | Network interface we are starting to capture packets. |
|
inlinestatic |
#include <capture.h>
Go through all the capture devices in order to get information about them.
This is mainly useful in net-shell to print data about currently active captures.
| cb | Callback to call for each capture device |
| user_data | User supplied data |
#include <capture.h>
Is network packet capture enabled or disabled.
| dev | Network capture device. If set to NULL, then the default capture device is used. |
#include <capture.h>
Check if the network packet needs to be captured or not.
This is called for every network packet being sent.
| iface | Network interface the packet is being sent |
| pkt | The network packet that is sent |
| int net_capture_setup | ( | const char * | remote_addr, |
| const char * | my_local_addr, | ||
| const char * | peer_addr, | ||
| const struct device ** | dev ) |
#include <capture.h>
Setup network packet capturing support.
| remote_addr | The value tells the tunnel remote/outer endpoint IP address. The IP address can be either IPv4 or IPv6 address. This address is used to select the network interface where the tunnel is created. |
| my_local_addr | The local/inner IP address of the tunnel. Can contain also port number which is used as UDP source port. |
| peer_addr | The peer/inner IP address of the tunnel. Can contain also port number which is used as UDP destination port. |
| dev | Network capture device. This is returned to the caller. |