[Olsr-users] Proposal: Use just one socket to send and receive messages on all interfaces

Joerg Pommnitz (spam-protected)
Wed Sep 10 11:38:37 CEST 2008

Hello all,
while researching on how to set the TTL for IPv6 multicast messages
I found out some things that would be useful for olsrd.
Currently olsrd opens and binds sockets to each interface it feels
responsible for.
Under Linux (and probably other unixish systems) there is an alternativ
to this.

Sending packets on a specific interface:

use sendmsg(2) and add a control message of type IP_PKTINFO to the
outbound message. The data part of the control message is of type
struct in_pktinfo where you can specify the desired interface index in
the ipi_ifindex memeber. Additionally one would probably need to set the
For IPv6 it might even be simpler: the sockaddr_in6 has a sin6_scope_id
which is just the interface index.

Receiving packets:
Use recvmsg(2) to receive the incoming packets. If you enable the
socket option IP_PKTINFO or IPV6_RECVPKTINFO than recvmsg will add
a correcponding control message with information about the interface
the packet was received on, the original destination address and the
local interface address that caused the packet to be received.

I think this would be enough to have a single socket for all interfaces.
I'm just airing the idea, I won't be able to do this myself anytime


Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 

More information about the Olsr-users mailing list