06-30-04 11:02 PM
Lev Walkin wrote:
> chris wrote:
>
>
>
>
>
>
>
> u_char ip_p; /* protocol */
>
> You're trying to perform byte swap on a single character.
>
> Do not use ntohs() function, and you'll probably be fine.
>
>
I removed the call to ntohs() but it didn't make a difference. I learned
that the BPF returns link layer headers (in this case ethernet) so I
tried to accomodate for them but it doesn't seem to make a difference
int
processPacket(char *packet, int size)
{
struct ip *iphdr;
iphdr = (struct ip *) packet + sizeof(struct ether_header);
printf("%x packet captured; %d bytes\n", iphdr->ip_p, size);
return 0;
}
[ Post a follow-up to this message ]
|