On Thu, 2009-05-14 at 15:20 -0400, Dan McDonald wrote:
> > That's exactly what this feature was designed to *avoid*.
> >
> > You can have a single socket bound to address INADDR_ANY and port 500,
> > and use that one socket to send replies to clients, and use the proper
> > source address (and port 500) on each.
>
> Thanks for your patience. I think I got it...
>
> If I have UDP socket 's' bound to INADDR_ANY/500, can I do something like
> (pardon my abstraction):
>
> init_cmsg(&msg);
> add_data(&msg, data, len);
> add_name(&msg, peers_sockaddr_ptr); /* Assume len from sa_family */
> add_ancillary(&msg, IP{,V6}_PKTINFO, my_specific_local_addr)
>
> rc = sendmsg(s, &msg, 0);
>
> and it'll send a UDP datagram that looks like:
>
> IP (my_specific_local_addr -> peer_addr) + UDP (500, peer_port) + data
>
> correct?
Yes. Your function will look alot like sendtoif() in in.routed except
that you're specifying a source address instead of an output interface
(the other utility for IP_PKTINFO):
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/cmd-inet/usr.sbin/in.routed/output.c#197
-Seb
_______________________________________________
networking-discuss mailing list
[email protected]