Reputation: 2253
I'd need to sniff on an interface BPDU (bridge protocol data unit) packets which are encapsulated in eth frames of type 802.3 with LLC header. I tried to open a socket raw:
skd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_802_3))
but trying to sniff packets i can't catch them. Looking at include/linux/if_ether.h seems that ETH_P_802_3 was a dummy type...is there a solution or i should use ETH_P_ALL
and analize the EtherType field of the ethernet header?
Thank you all!
Upvotes: 1
Views: 1273
Reputation: 78673
Sorry, I'm not sure if your question is regarding the ETH_P_ALL
flag or if your sniffer simply doesn't work.
I would recommend using ETH_P_ALL
and decoding the headers yourself.
If your sniffers not working, make sure that you have promiscuous mode on? From the command line, you can use ifconfig eth0 promisc
, assuming your ethernet device is eth0
. Or you can set the IFF_PROMISC
flag on your device using ioctl
.
All that said, unless you have a good reason not to, it's probably strongly worth your while to not reinvent the wheel and simply use libpcap.
Upvotes: 1