netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* IPv6 raw socket and recvfrom
@ 2010-08-17 12:31 Paul Rolland
  2010-08-17 13:08 ` Rémi Denis-Courmont
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Rolland @ 2010-08-17 12:31 UTC (permalink / raw)
  To: netdev

Hello,

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.

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

Paul

PS : I'm not subscribed to netdev, so please answer directly...


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: IPv6 raw socket and recvfrom
  2010-08-17 12:31 IPv6 raw socket and recvfrom Paul Rolland
@ 2010-08-17 13:08 ` Rémi Denis-Courmont
  0 siblings, 0 replies; 2+ messages in thread
From: Rémi Denis-Courmont @ 2010-08-17 13:08 UTC (permalink / raw)
  To: Paul Rolland; +Cc: netdev


On Tue, 17 Aug 2010 14:31:20 +0200, Paul Rolland <rol@as2917.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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-17 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-17 12:31 IPv6 raw socket and recvfrom Paul Rolland
2010-08-17 13:08 ` Rémi Denis-Courmont

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).