net: introduce packet capture support
[oweals/u-boot.git] / net / eth_legacy.c
index 850f362d873e2930da2d0e42bf77f5412c5b64cc..41f52635266280360a6e848f752556c7aed011f6 100644 (file)
@@ -11,6 +11,7 @@
 #include <net.h>
 #include <phy.h>
 #include <linux/errno.h>
+#include <net/pcap.h>
 #include "eth_internal.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -352,10 +353,17 @@ int eth_is_active(struct eth_device *dev)
 
 int eth_send(void *packet, int length)
 {
+       int ret;
+
        if (!eth_current)
                return -ENODEV;
 
-       return eth_current->send(eth_current, packet, length);
+       ret = eth_current->send(eth_current, packet, length);
+#if defined(CONFIG_CMD_PCAP)
+       if (ret >= 0)
+               pcap_post(packet, lengeth, true);
+#endif
+       return ret;
 }
 
 int eth_rx(void)