tcpdump mailing list archives

Re: Segmentatio Fault while retrieving source and


From: Aaron Turner <synfinatic () gmail com>
Date: Wed, 1 Apr 2009 09:43:14 -0700

Use a debugger like gdb.

On Wed, Apr 1, 2009 at 9:32 AM, Shameem Ahamed
<shameem.ahamed () hotmail com> wrote:

Hi All,


I am getting segmentation fault error, while retrieving the source and destn ip from ip headers.


Code snippet is given below.

packet is the last argument to the Callback function used in pcap_loop


===========================================
struct ip *ipHeader;    //IP Header

ethHeader=(struct ether_header*)packet;
ipHeader=(struct ip*)(packet+ETHER_SIZE);

printf("IP Version is: %d \n",ipHeader->ip_v);

printf("Source IP: %s \n",inet_ntoa(ipHeader->ip_src));
============================================



-- 
Aaron Turner
http://synfin.net/
http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & Windows
Those who would give up essential Liberty, to purchase a little
temporary Safety,
deserve neither Liberty nor Safety.
    -- Benjamin Franklin
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: