I am trying to write a small snifer, but there is a small problem.
I have created a socket with such way:
struct sockaddr sa;
sock = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL);
// bind to specified interface
memset(&sa, 0, sizeof(sa));
sa.sa_family = AF_INET;
strncpy(sa.sa_data, dev, sizeof(sa.sa_data)); // dev is something
like eth0, lo, etc.
bind(sock, &sa, sizeof(sa));
How can I resolve if the packet is incoming to my host or
outgoing from my host without looking at ethernet and ip headers.
Any ideas, please.