Re: newbie: ethernet, ip header proble

From: Ruslan Ermilov (ru_at_freebsd.org)
Date: 06/25/04

  • Next message: Murat Balaban: "Re: newbie: ethernet, ip header proble"
    Date: Fri, 25 Jun 2004 15:01:53 +0300
    To: kamal kc <rosey_kc@yahoo.com>
    
    
    

    On Fri, Jun 25, 2004 at 03:49:11AM -0700, kamal kc wrote:
    > Hi i am new to this mailing list.
    >
    > I have written a program to capture packets using pcap library routines. I have a FreeBSD 5.1. The problem I faced was I successfully captured packets and parsed to ethernet header and ip header.
    >
    > i present a section of code how i did it.
    >
    > --
    > char *ptr;
    > ptr=pcap_next(.....);
    >
    > struct ether_header *eth;
    > struct ip *ip;
    >
    > eth=(struct ether_header *)ptr; // datalink type DLT_EN10MB
    > ptr+=14; // the size of the ether_header being 14 bytes;
    >
    > ip=(struct ip *)ptr;
    >
    > printf("\n %s %s", ether_ntoa(eth->ether_dhost), ether_ntoa(eth->ether_shost));
    > printf("\n %s %s", inet_ntoa(ip->ip_src), inet_ntoa(ip->ip_dst));
    >
    > ----------------
    >
    > Now the problem is that the ethernet destination and sender host is printed the same.
    > it is equal to that of the sender MAC address(linux) when ICMP packets (by ping utility)
    > is sent to the host(FreeBSD) running the program.
    >
    > Also that the ip adresses printed is the same as the sender ip address(ie linux).
    >
    > The program is run on host with FreeBSD.
    >
    > The ip address of the computers are:
    > 192.168.1.10 has Linux
    > 192.168.1.11 has FreeBSD
    >
    > I couldn't think of a solution as i guess the coding was alright.
    >
    > Anybody could help
    >
    Sure, carefully read the BUGS sections of both ether_ntoa(3) and inet_ntoa(3)
    manpages.

    Cheers,

    -- 
    Ruslan Ermilov
    ru@FreeBSD.org
    FreeBSD committer
    
    



  • Next message: Murat Balaban: "Re: newbie: ethernet, ip header proble"

    Relevant Pages

    • Re: mathematica/mathlink/python/linux
      ... >>I have installed Mathematica on FreeBSD 5-stable. ... > Is this a Linux binary, ... you have received this message in error, please notify the sender immediately ...
      (freebsd-hackers)
    • newbie: ethernet, ip header proble
      ... I have written a program to capture packets using pcap library routines. ... Now the problem is that the ethernet destination and sender host is printed the same. ... The program is run on host with FreeBSD. ... New and Improved Yahoo! ...
      (freebsd-net)
    • Re: newbie: ethernet, ip header proble
      ... > I have written a program to capture packets using pcap library routines. ... I have a FreeBSD 5.1. ... > Now the problem is that the ethernet destination and sender host is printed the same. ... > Also that the ip adresses printed is the same as the sender ip address(ie linux). ...
      (freebsd-net)
    • Re: FreeBSD 4.x Opteron Question
      ... the FreeBSD developers told everyone that 5.3 was da ... initially over linux not because there's a bunch of good guys on the ... My tests measure kernel performance; ... > a networking device is a key performance indicator. ...
      (freebsd-questions)
    • Re: Newbie Experience
      ... I've only been around since FreeBSD 5.4 ... FreeBSD kernel too. ... always sunshine and linux is farts. ... in the hey day of AT&T Unix I'm ...
      (freebsd-questions)