[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <41bd6ed1194a332231874b2975efe97a@chewa.net>
Date: Tue, 17 Aug 2010 15:08:51 +0200
From: Rémi Denis-Courmont <remi@...lab.net>
To: Paul Rolland <rol@...917.net>
Cc: netdev@...r.kernel.org
Subject: Re: IPv6 raw socket and recvfrom
On Tue, 17 Aug 2010 14:31:20 +0200, Paul Rolland <rol@...917.net> wrote:
> I'd like someone to clarify the behavior I can expect from a RAW IPv6
> socket _in Linux_ :
> - Raw IPv4 sockets : recvfrom() payload contain all the IP header,
> including src ip, dst ip, etc...
>
> - Raw IPv6 sockets : so far, recvfrom returns me only the payload. I've
> added the HDRINCL options, but it seems that this is a no-op in
> IPv6-land.
Yes and no. You get the packet size from the return value of recvfrom().
You can also get the source address from the recvfrom() address parameter.
And you can additionally get the hop limit, destination address and type of
service as ancillary data with recvmsg(). Finally, you can have the kernel
verify the checksum field for you (and discard broken packets), and of
course the IP version. In the end, the only unknown field is the flow
information, for which there is no standardized API that I know.
> I've reviewed RFC 3542, which states that I'm not to expect ip6 header,
> but often "there is more than one way to do it", and I'd like to be sure
> I'm not missing something obvious
On Linux, you should use AF_PACKET sockets if you want to receive (or send)
raw packets including the network header. Alternatively, you can use
libpcap (which really is a wrapper around AF_PACKET anyway).
--
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists