Rao Shoaib wrote:

...
Currently Solaris does not provide a mechanism to set the IP source address for UDP packets on AF_INET (IPv4) sockets.


You need to make this problem statement more detailed as it is
possible to use bind() to select a source address for UDP packets
but not in the scenario you're referring to here.

...

This project implements such a feature in Solaris
...
   The following IPPROTO_IP boolean option may be set or cleared with
   setsockopt() or retrieved with getsockopt():

     IP_RECVPKTINFO      Enable/disable receipt of the index of the
interface the packet arrived on, the local address that was matched for reception, and of the inbound packet's actual destination address. Takes boolean as the parameter.

   The following IPPROTO_IP option may be set or retrieved as sticky
   options with setsockopt/getsockopt or as ancillary data to a
   sendmsg(3XNET) system call:

     IP_PKTINFO          Set the source address and/or interface out
which the packet(s) will be sent. Takes a
                                   struct in4_pktinfo as the parameter.


So in use, what I might find myself doing is:

recvfrom(....)
getsockopt(..., IPPROTO_IP, IP_PKTINFO, .&info, &len)
build up a reply packet
setsockopt(..., IPPROTO_IP, IP_PKTINFO, &info, sizeof(info))
sendto(...)

- correct ?

Although UDP is given as being the source of the problem here, an IP
socket option is being presented.  Will this work with stream protocols
such as TCP or only packet-orientated ones such as UDP/ICMP?

How do these options interact with the policy routing socket option?

Darren

_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to