Problem with capturing the icmp and udp packets

Problem with capturing the icmp and udp packets

Post by vbhanu.i.. » Thu, 01 Sep 2005 07:42:41



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

 
 
 

1. How to receive UDP and ICMP packet using one UDP socket, (Path MTUD)

Dear All,

Can we configure one socket to receive two different protocols packet.
Like how can we made a UDP socket to receive udp as well as icmp
messages.

Actually I am implementing Path MTUD, so for that I sent some udp
probs to destination host, now I want that the same socket at client
side must be able to receive both udp response and icmp error
messages(like host unreachable, port unreachable etc).

Another approach is that, we will use two sockets for both source and
destination, form source we will send udp probs(through udp socket)
while at destination host, after receiving that prob(through udp
socket), application will make an icmp packet and sent it back to the
source host (using ICMP socket). And here at source host, that message
and other icmp error messages will be received by icmp socket.

But this approch dosen't look efficient to me, what u people say? If
Any one has another approch plz let me know.

Eagerly waiting for some +ve pings.

2. Help with sendmail on Solaris 2.4 Please

3. Kernel does not detect UDP/ICMP packets

4. Need help with "The Gimp"

5. missing icmp errors for udp packets

6. SCO Unix UUCP/MMDF Alias Question

7. no ICMP port unreachable for UDP packets

8. ANSI-compliant C++ iostreams support ?

9. What kind of tools can capture ip packets(such as UDP)fast enough on Linux Platform

10. ICMP and UDP Problems

11. TCP/UDP/ICMP problems on x86 after install of elx (E-Link 100)

12. Q: Problem forwading ICMP packets thru eth0 to ppp0

13. Problem of blocking ICMP packet while calculating Path MTU