1inet6_opt(3SOCKET)         Sockets Library Functions        inet6_opt(3SOCKET)
2
3
4

NAME

6       inet6_opt,    inet6_opt_init,    inet6_opt_append,    inet6_opt_finish,
7       inet6_opt_set_val, inet6_opt_next, inet6_opt_find, inet6_opt_get_val  -
8       Option manipulation mechanism
9

SYNOPSIS

11       cc [ flag ... ] file ... -lsocket [library...]
12       #include <netinet/in.h>
13
14       int inet6_opt_init(void *extbuf, socklen_t extlen);
15
16
17       int inet6_opt_append(void *extbuf, socklen_t extlen,
18            int offset, uint8_t type, socklen_t len, uint_t align,
19            void **databufp);
20
21
22       int inet6_opt_finish(void *extbuf, socklen_t extlen,
23            int offset);
24
25
26       int inet6_opt_set_val(void *databuf, int offset,
27            void *val, socklen_t vallen);
28
29
30       int inet6_opt_next(void *extbuf, socklen_t extlen,
31            int offset, uint8_t *typep, socklen_t *lenp,
32            void **databufp);
33
34
35       int inet6_opt_find(void *extbuf, socklen_t extlen, int offset,
36            uint8_t type, socklen_t *lenp, void **databufp);
37
38
39       intinet6_opt_get_val(void *databuf, int offset,
40            void *val, socklen_t *vallen);
41
42

DESCRIPTION

44       The inet6_opt functions enable users to manipulate options without hav‐
45       ing to know the structure of the option header.
46
47
48       The inet6_opt_init() function returns the number of  bytes  needed  for
49       the  empty extension header, that is, without any options. If extbuf is
50       not NULL, it also initializes  the  extension  header  to  the  correct
51       length  field.  If the extlen value is not a positive non-zero multiple
52       of 8, the function fails and returns -1.
53
54
55       The inet6_opt_append() function returns the updated total length  while
56       adding  an option with length len and alignment align. If extbuf is not
57       NULL, then, in addition to returning the length, the  function  inserts
58       any  needed  Pad  option,  initializes  the option setting the type and
59       length fields, and returns a pointer to the  location  for  the  option
60       content in databufp. If the option does not fit in the extension header
61       buffer, the function returns -1. The type is the 8-bit option type. The
62       len  is  the  length  of the option data, excluding the option type and
63       option length fields. Once inet6_opt_append() is called,  the  applica‐
64       tion  can  use the databuf directly, or inet6_opt_set_val() can be used
65       to specify the content of the option. The option type must have a value
66       from  2 to 255, inclusive. The values 0 and 1 are reserved for the Pad1
67       and PadN options, respectively. The option  data  length  must  have  a
68       value  between 0 and 255, inclusive, and it is the length of the option
69       data that follows. The align parameter must have a value of 1, 2, 4, or
70       8. The align value cannot exceed the value of len.
71
72
73       The  inet6_opt_finish()  function  returns the updated total length the
74       takes into account the final padding of the extension header to make it
75       a  multiple  of  8 bytes. If extbuf is not NULL, the function also ini‐
76       tializes the option by inserting a Pad1 or PadN option  of  the  proper
77       length.  If the necessary pad does not fit in the extension header buf‐
78       fer, the function returns -1.
79
80
81       The inet6_opt_set_val() function inserts data items of various sizes in
82       the  data  portion of the option. The val parameter should point to the
83       data to be inserted. The offset  specifies  the  data  portion  of  the
84       option  in which the value should be inserted. The first byte after the
85       option type and length is accessed by specifying an offset of zero.
86
87
88       The inet6_opt_next() function  parses  the  received  option  extension
89       headers  which return the next option. The extbuf and extlen parameters
90       specify the extension header. The offset should be zero for  the  first
91       option   or   the   length  returned  by  a  previous  call  to  either
92       inet6_opt_next() or inet6_opt_find(). The  offset  specifies  where  to
93       continue  scanning  the  extension  buffer.  The  subsequent  option is
94       returned by updating typep, lenp,  and  databufp.  The  typep  argument
95       stores  the  option  type.  The  lenp argument stores the length of the
96       option data, excluding the option type and option  length  fields.  The
97       databufp argument points to the data field of the option.
98
99
100       The  inet6_opt_find() function is similar to the inet6_opt_next() func‐
101       tion. Unlike inet6_opt_next(), the  inet6_opt_find()  function  enables
102       the  caller  to specify the option type to be searched for, rather than
103       returning the next option in the extension header.
104
105
106       The inet6_opt_get_val() function extracts data items of  various  sizes
107       in the portion of the option. The val argument should point to the des‐
108       tination for the extracted data. The offset specifies at which point in
109       the option's data portion the value should be extracted. The first byte
110       following the option type and length is accessed by specifying an  off‐
111       set of zero.
112

RETURN VALUES

114       The  inet6_opt_init()  function  returns the number of bytes needed for
115       the empty extension header. If the extlen value is not a positive  non-
116       zero multiple of 8, the function fails and returns -1.
117
118
119       The inet6_opt_append() function returns the updated total length.
120
121
122       The inet6_opt_finish() function returns the updated total length.
123
124
125       The  inet6_opt_set_val() function returns the offset for the subsequent
126       field.
127
128
129       The inet6_opt_next() function returns  the  updated  "previous"  length
130       computed by advancing past the option that was returned. When there are
131       no additional options or if the option extension header  is  malformed,
132       the return value is -1.
133
134
135       The  inet6_opt_find()  function  returns  the  updated "previous" total
136       length. If an option of the specified type is not located,  the  return
137       value  is  -1.  If the option extension header is malformed, the return
138       value is -1.
139
140
141       The inet6_opt_get_val() function returns the offset for the next  field
142       (that  is,  offset  +  vallen) which can be used when extracting option
143       content with multiple fields.
144

ATTRIBUTES

146       See attributes(5) for descriptions of the following attributes:
147
148
149
150
151       ┌─────────────────────────────┬─────────────────────────────┐
152       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
153       ├─────────────────────────────┼─────────────────────────────┤
154       │Interface Stability          │Standard                     │
155       ├─────────────────────────────┼─────────────────────────────┤
156       │MT-Level                     │Safe                         │
157       └─────────────────────────────┴─────────────────────────────┘
158

SEE ALSO

160       RFC 3542 - Advanced Sockets Application Programming Interface (API) for
161       IPv6, The Internet Society. May 2003
162
163
164
165SunOS 5.11                        15 Feb 2007               inet6_opt(3SOCKET)
Impressum