1inet6_rth(3SOCKET) Sockets Library Functions inet6_rth(3SOCKET)
2
3
4
6 inet6_rth, inet6_rth_space, inet6_rth_init, inet6_rth_add,
7 inet6_rth_reverse, inet6_rth_segments, inet6_rth_getaddr - Routing
8 header manipulation
9
11 cc [ flag ... ] file ... -lsocket [library]
12 #include <netinet/in.h>
13
14 socklen_t inet6_rth_space(int type, int segments);
15
16
17 void *inet6_rth_init(void *bp, socklen_t bp_len, int type, int segments);
18
19
20 int inet6_rth_add(void *bp, const struct, in6_addr *addr);
21
22
23 int inet6_rth_reverse(const void *in, void *out);
24
25
26 int inet6_rth_segments(const void *bp);
27
28
29 struct in6_addr *inet6_rth_getaddr(const void *bp, int index);
30
31
33 The inet6_rth functions enable users to manipulate routing headers
34 without having knowledge of their structure.
35
36
37 The iet6_rth_init() function initializes the buffer pointed to by bp to
38 contain a routing header of the specified type and sets ip6r_len based
39 on the segments parameter. The bp_len argument is used only to verify
40 that the buffer is large enough. The ip6r_segleft field is set to zero
41 and inet6_rth_add() increments it. The caller allocates the buffer and
42 its size can be determined by calling inet6_rth_space().
43
44
45 The inet6_rth_add() function adds the IPv6 address pointed to by addr
46 to the end of the routing header that is being constructed.
47
48
49 The inet6_rth_reverse() function takes a routing header extension
50 header pointed to by the first argument and writes a new routing header
51 that sends datagrams along the reverse of the route. The function
52 reverses the order of the addresses and sets the segleft member in the
53 new routing header to the number of segments. Both arguments can point
54 to the same buffer (that is, the reversal can occur in place).
55
56
57 The inet6_rth_segments() function returns the number of segments
58 (addresses) contained in the routing header described by bp.
59
60
61 The inet6_rth_getaddr() function returns a pointer to the IPv6 address
62 specified by index, which must have a value between 0 and one less than
63 the value returned by inet6_rth_segments() in the routing header
64 described by bp. Applications should first call inet6_rth_segments() to
65 obtain the number of segments in the routing header.
66
67
68 The inet6_rth_space() function returns the size, but the function does
69 not allocate the space required for the ancillary data routing header.
70
72 To receive a routing header, the application must enable the
73 IPV6_RECVRTHDR socket option:
74
75 int on = 1;
76 setsockopt (fd, IPPROTO_IPV6, IPV6_RECVRTHDR, &on, sizeof(on));
77
78
79
80 Each received routing header is returned as one ancillary data object
81 described by a cmsghdr structure with cmsg_type set to IPV6_RTHDR.
82
83
84 To send a routing header, the application specifies it either as ancil‐
85 lary data in a call to sendmsg() or by using setsockopt(). For the
86 sending side, this API assumes the number of occurrences of the routing
87 header as described in RFC-2460. Applications can specify no more than
88 one outgoing routing header.
89
90
91 The application can remove any sticky routing header by calling set‐
92 sockopt() for IPV6_RTHDR with a zero option length.
93
94
95 When using ancillary data, a routing header is passed between the
96 application and the kernel as follows: The cmsg_level member has a
97 value of IPPROTO_IPV6 and the cmsg_type member has a value of
98 IPV6_RTHDR. The contents of the cmsg_data member is implementation-
99 dependent and should not be accessed directly by the application, but
100 should be accessed using the inet6_rth functions.
101
102
103 The following constant is defined as a result of including the
104 <netinet/in.h>:
105
106 #define IPV6_RTHDR_TYPE_0 0 /* IPv6 Routing header type 0 */
107
108
109 ROUTING HEADER OPTION
110 Source routing in IPv6 is accomplished by specifying a routing header
111 as an extension header. There are a number of different routing head‐
112 ers, but IPv6 currently defines only the Type 0 header. See RFC-2460.
113 The Type 0 header supports up to 127 intermediate nodes, limited by the
114 length field in the extension header. With this maximum number of
115 intermediate nodes, a source, and a destination, there are 128 hops.
116
118 The inet6_rth_init() function returns a pointer to the buffer (bp) upon
119 success.
120
121
122 For the inet6_rth_add() function, the segleft member of the routing
123 header is updated to account for the new address in the routing header.
124 The function returns 0 upon success and -1 upon failure.
125
126
127 The inet6_rth_reverse() function returns 0 upon success or -1 upon an
128 error.
129
130
131 The inet6_rth_segments() function returns 0 or greater upon success and
132 -1 upon an error.
133
134
135 The inet6_rth_getaddr() function returns NULL upon an error.
136
137
138 The inet6_rth_space() function returns the size of the buffer needed
139 for the routing header.
140
142 See attributes(5) for descriptions of the following attributes:
143
144
145
146
147 ┌─────────────────────────────┬─────────────────────────────┐
148 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
149 ├─────────────────────────────┼─────────────────────────────┤
150 │Interface Stability │Standard │
151 ├─────────────────────────────┼─────────────────────────────┤
152 │MT-Level │Safe │
153 └─────────────────────────────┴─────────────────────────────┘
154
156 RFC 3542- Advanced Sockets Application Programming Interface (API) for
157 IPv6, The Internet Society. May 2003
158
159
160
161SunOS 5.11 15 Feb 2007 inet6_rth(3SOCKET)