I'm trying to read ethernet packets with a PF_LINK socket, but so far I can't even successfully open a PF_LINK socket. I haven't been able to turn up any information on how to use a PF_LINK socket, and the few references I've found to questions about how to use such a socket are invariably answered by pointing the poster in some other direction, such as using ioctl, pcap, bfp and such. Are PF_LINK sockets actually supported on FreeBSD, and if so, where might I find some information on how to use them? Thanks for any help.
My attemps fail at step one.
This code always fails with
Trying other types, such as SOCK_DGRAM, don't change the result.
My attemps fail at step one.
Code:
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
int main(void) {
int sock;
if ( (sock = socket(PF_LINK, SOCK_RAW, 0)) < 0) {
perror("socket call failed");
exit(1);
}
close (sock);
return 0;
}
This code always fails with
Code:
socket call failed: Protocol not supported