So I am trying to create a packet sniffer in C. After following the man7 page I inferred that the socket function should look like this
.....
int socketfd = socket(AF_PACKET , SOCK_RAW , htons(ETH_P_ALL));
if(socketfd < 0)
{
perror("Socket Error");
return 0;
}
.....
And the error is Socket Error: Address family not supported by protocol
I looked it up but didn't find a solution to my problem. There is a question that looks similar but it's not even with the socket syscall. I didn't really try anything else because I didn't find any alternative parameters to put in the function.