Problem with capturing the icmp and udp packets

vbhanu.iitk_at_gmail.com
Date: 08/31/05


Date: 30 Aug 2005 15:42:41 -0700

Hi all,

I am writing a small code that would capture and read some information
that is contaiend in the packets. What i am doing is described to some
extent here:

char buf[MAX_BUFFER];
bread = recvfrom(sockfd, buf, MAX_BUFFER, 0, (struct sockaddr *)&llh,
&lenllh);
eth_hdr = (struct ethhdr *) buf;
ip_hdr = (struct iphdr *) ((char *) eth_hdr + 14);
char *tl_pkt;
tl_pkt = buf + (4*ip_hdr->ihl);

Till here it is working fine and also if the ip_hdr->protocol is
IPPROTO_TCP then it is working fine but if this is of the type
IPPROTO_ICMP and from here i call a function void capture_udp(char
*tl_pktu); it is giving a SEGMENTATION FAULT here. I have a printf line
as the first statement in this function but even taht is not working.

Some one please please explain as to what is wrong here.

Thanking you

Bhanu