diff --git a/examples/netpkt/netpkt_ethercat.c b/examples/netpkt/netpkt_ethercat.c index 8b8ab298abb..6ed6ae8d9cb 100644 --- a/examples/netpkt/netpkt_ethercat.c +++ b/examples/netpkt/netpkt_ethercat.c @@ -30,6 +30,8 @@ #include #include +#include +#include #include #include #include @@ -66,7 +68,7 @@ int main(int argc, FAR const char *argv[]) int num_packets = 0; int len; int ifindex; - int sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW); + int sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sockfd == -1) { @@ -96,6 +98,7 @@ int main(int argc, FAR const char *argv[]) addr.sll_family = AF_PACKET; addr.sll_ifindex = ifindex; + addr.sll_protocol = htons(ETH_P_ALL); if (bind(sockfd, (FAR const struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("ERROR: binding socket failed"); diff --git a/system/tcpdump/tcpdump.c b/system/tcpdump/tcpdump.c index 0220ae8bd02..5f80ef510a3 100644 --- a/system/tcpdump/tcpdump.c +++ b/system/tcpdump/tcpdump.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include #include @@ -201,6 +203,7 @@ static int socket_open(int ifindex) addr.sll_family = AF_PACKET; addr.sll_ifindex = ifindex; + addr.sll_protocol = htons(ETH_P_ALL); if (bind(sd, (FAR const struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("ERROR: binding socket failed");