Re: Parsing Packets
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Re: Parsing Packets




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: Parsing Packets  
chris


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:16 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register