Subject: Re: pcap and ICMP messages
To: Greg Troxel <gdt@ir.bbn.com>
From: =?iso-8859-1?q?J=F6rn_Seger?= <joern.seger@udo.edu>
List: tech-net
Date: 09/15/2004 14:50:25
;-) I would like to have every ip-packet, I don't want to open a lot of=20
sockets, one for every protocol ...=20

I read some stevens stuff, so I came to the conclusion to use pcap.=20

J=F6rn

PS: You are right I haven't read this manpage carefully, because i started=
=20
this project on linux and the ip-manpage is quite different ...

Am Mittwoch, 15. September 2004 13:40 schrieben Sie:
> man ip, and search for IP_HDRINCL:
>
>    RAW IP SOCKETS
>      Raw IP sockets are connectionless, and are normally used with the
>      sendto(2) and recvfrom(2) calls, though the connect(2) call may also
> be used to fix the destination for future packets (in which case the
> read(2) or recv(2) and write(2) or send(2) system calls may be used).
>
>      If proto is 0, the default protocol IPPROTO_RAW is used for outgoing
>      packets, and only incoming packets destined for that protocol are
>      received.  If proto is non-zero, that protocol number will be used on
>      outgoing packets and to filter incoming packets.
>
>      Outgoing packets automatically have an IP header prepended to them
> (based on the destination address and the protocol number the socket is
> created with), unless the IP_HDRINCL option has been set.  Incoming packe=
ts
> are received with IP header and options intact.
>
>      IP_HDRINCL indicates the complete IP header is included with the data
> and may be used only with the SOCK_RAW type.
>
>      #include <netinet/ip.h>
>
>      int hincl =3D 1;                  /* 1 =3D on, 0 =3D off */
>      setsockopt(s, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl));
>
>      Unlike previous BSD releases, the program must set all the fields of
> the IP header, including the following:
>
>      ip->ip_v =3D IPVERSION;
>      ip->ip_hl =3D hlen >> 2;
>      ip->ip_id =3D 0;  /* 0 means kernel set appropriate value */
>      ip->ip_off =3D offset;
>
>      If the header source address is set to INADDR_ANY, the kernel will
> choose an appropriate address.