if ( (sock=socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)))<0) { perror("socket"); exit(1); } /* Get Interface index */ strncpy((char *)ifr.ifr_name, device, IFNAMSIZ); if((ioctl(sock, SIOCGIFFLAGS, &ifr)) == -1) { perror("ioctl"); printf("Error getting Interface index...
Looking at the code in TCPDUMP was no help since it uses socket(PF_INET, SOCK_PACKET, ...) and I (think) I want to use socket(PF_PACKET, SOCK_RAW, ...) which is the newer idiom. The problem is that if I do the bind, I never see any packets at all, even though the bind...