Unix Programming - Re: Parsing Packets

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2004 > Re: Parsing Packets





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Parsing Packets
chris

2004-06-30, 6: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;
}
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com