net: capture: Catch sent and received packets

Create net_l2_send() function which will be called by each L2
sending function so that we can catch all the network packets
that are being sent. Some L2 layers send things a bit differently,
so in those cases call the net_capture_send() directly by the L2
layer.
Add network packet capture call in receive side after the pkt has
been received by the RX queue handler. This avoids calling the
net_capture_send() from ISR context.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2021-03-28 16:19:42 +03:00 committed by Anas Nashif
commit ce2abc26b5
10 changed files with 32 additions and 4 deletions

View file

@ -670,7 +670,7 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
net_pkt_cursor_init(pkt);
send:
ret = api->send(net_if_get_device(iface), pkt);
ret = net_l2_send(api->send, net_if_get_device(iface), iface, pkt);
if (ret != 0) {
eth_stats_update_errors_tx(iface);
ethernet_remove_l2_header(pkt);