28.5 ping Program


27.7 IPv6 Sticky Options

We have described the use of ancillary data with sendmsg and recvmsg to send and receive seven different ancillary data objects:

  1. IPv6 packet information: the in6_pktinfo structure containing either the destination address and outgoing interface index, or the source address and the arriving interface index (Figure 22.21)

  2. The outgoing hop limit or received hop limit (Figure 22.21)

  3. The next -hop address (Figure 22.21)

  4. The outgoing or received traffic class (Figure 22.21)

  5. Hop-by-hop options (Figure 27.10)

  6. Destination options (Figure 27.10)

  7. Routing header (Figure 27.12)

We summarized the cmsg_level and cmsg_type values for these objects, along with the values for the other ancillary data object in Figure 14.11.

When the same value will be used for all packets sent on a socket, instead of sending these options in every call to sendmsg , we can set the corresponding socket options instead. The socket options use the same constants as the ancillary data, that is, the option level is always IPPROTO_IPV6 and the option name is IPV6_DSTOPTS , IPV6_HOPLIMIT , IPV6_HOPOPTS , IPV6_NEXTHOP , IPV6_PKTINFO , IPV6_RTHDR , or IPV6_TCLASS . But, these sticky options can be overridden on a per-packet basis for a UDP socket or for a raw IPv6 socket by specifying ancillary data in a call to sendmsg . If any ancillary data is specified in a call to sendmsg , the corresponding sticky options are not sent with that datagram.

The concept of sticky options can also be used with TCP because ancillary data is never sent or received by sendmsg or recvmsg on a TCP socket. Instead, a TCP application can set the corresponding socket option and specify any of the seven option types mentioned at the beginning of this section. These objects then affect all packets sent on this socket. However, retransmission of packets that were originally sent when other (or no) sticky options were set may use either the original or the new sticky options.

There is no way to retrieve options received via TCP since there is no relationship between received packets and user receive operations.



UNIX Network Programming Volume 1, Third Edition
Unix Network Programming, Volume 1: The Sockets Networking API (3rd Edition)
ISBN: 0131411551
EAN: 2147483647
Year: 2003
Pages: 441

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net