1 SOCKET.H(3HEAD) Headers SOCKET.H(3HEAD)
2
3
4
5 NAME
6 socket.h, socket - Internet Protocol family
7
8 SYNOPSIS
9 #include <sys/socket.h>
10
11
12 DESCRIPTION
13 The <sys/socket.h> header defines the unsigned integral type
14 sa_family_t through typedef.
15
16
17 The <sys/socket.h> header defines the sockaddr structure that includes
18 the following members:
19
20 sa_family_t sa_family /* address family */
21 char sa_data[] /* socket address (variable-length
22 data) */
23
24
25 libxnet Interfaces
26 The <sys/socket.h> header defines the msghdr structure for libxnet
45
46
47
48 Ancillary data consists of a sequence of pairs, each consisting of a
49 cmsghdr structure followed by a data array. The data array contains the
50 ancillary data message, and the cmsghdr structure contains descriptive
51 information that allows an application to correctly parse the data.
52
53
54 The values for cmsg_level will be legal values for the level argument
55 to the getsockopt() and setsockopt() functions. The SCM_RIGHTS type is
56 supported for level SOL_SOCKET.
57
58
59 Ancillary data is also possible at the socket level. The <sys/socket.h>
60 header defines the following macros for use as the cmsg_type values
61 when cmsg_level is SOL_SOCKET.
62
63 SCM_RIGHTS
64 Indicates that the data array contains the access rights
65 to be sent or received.
66
67
68 SCM_UCRED
69 Indicates that the data array contains a ucred_t to be
70 received. The ucred_t is the credential of the sending
71 process at the time the message was sent. This is a Sun-
72 specific, Evolving interface. See ucred_get(3C).
73
74
75
76 The IPv4 data formats generally use the same values for data passed
77 back in cmsghdr as for setsockopt() to enable the feature. The IPv4
78 data formats are listed below with the associated payload for each.
79
80 IPPROTO_IP
81 IP_RECVDSTADDR
82
83 ipaddr_t, IP address
84
85
86 IPPROTO_IP
87 IP_RECVOPTS
88
89 variable-length IP options, up to 40 bytes
90
91
92 IPPROTO_IP
93 IP_RECVIF
94
95 uint_t, ifIndex number
96
97
98 IPPROTO_IP
99 IP_RECVSLLA
100
101 struct sockaddr_dl, link layer address
102
103
104 IPPROTO_IP
105 IP_RECVTTL
106
107 uint8_t
108
109
110 SOL_SOCKET
111 SO_RECVUCRED
112
113 ucred_t -- cmsghdr.cmsg_type is SCM_UCRED, not SO_RECVUCRED
114
115
116
117 The IPv6 data formats use different values for enabling the option and
118 for passing the value back to the application. The IPv6 data formats
119 are listed below with the associated payload for each.
120
121 IPPROTO_IPV6
122 IPV6_RECVPKTINFO
123
124 in_pktinfo, cmsg_type IPV6_PKTINFO
125
126
127 IPPROTO_IPV6
128 IPV6_RECVTCLASS
129
130 uint_t, cmsg_type IPV6_TCLASS
131
132
133 IPPROTO_IPV6
134 IPV6_RECVPATHMTU
135
136 ip6_mtuinfo, cmsg_type IPV6_PATHMTU
137
138
139 IPPROTO_IPV6
140 IPV6_RECVHOPLIMIT
141
142 uint_t, cmsg_type IPV6_HOPLIMIT
143
144
145 IPPROTO_IPV6
146 IPV6_RECVHOPOPTS
147
148 variable-length IPv6 options, cmsg_type IPV6_HOPOPTS
149
150
151 IPPROTO_IPV6
152 IPV6_RECVDSTOPTS
153
154 variable-length IPv6 options, cmsg_type IPV6_DSTOPTS
155
156
157 IPPROTO_IPV6
158 IPV6_RECVRTHDR
159
160 variable-length IPv6 options, cmsg_type IPV6_RTHDR
161
162
163 IPPROTO_IPV6
164 IPV6_RECVRTHDRDSTOPTS
165
166 variable-length IPv6 options, cmsg_type IPV6_DSTOPTS
167
168
169
170 The <sys/socket.h> header defines the following macros to gain access
171 to the data arrays in the ancillary data associated with a message
172 header:
173
174 CMSG_DATA(cmsg)
175
176 If the argument is a pointer to a cmsghdr structure, this macro
177 returns an unsigned character pointer to the data array associated
178 with the cmsghdr structure.
179
180
181 CMSG_NXTHDR(mhdr, cmsg)
182
183 If the first argument is a pointer to a msghdr structure and the
184 second argument is a pointer to a cmsghdr structure in the
185 ancillary data, pointed to by the msg_control field of that msghdr
186 structure, this macro returns a pointer to the next cmsghdr
187 structure, or a null pointer if this structure is the last cmsghdr
188 in the ancillary data.
189
405 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
406 +--------------------+-----------------+
407 |Interface Stability | Standard |
408 +--------------------+-----------------+
409
410 SEE ALSO
411 accept(3SOCKET), accept(3XNET), bind(3SOCKET), bind(3XNET),
412 connect(3SOCKET), connect(3XNET), getpeername(3SOCKET),
413 getpeername(3XNET), getpeerucred(3C), getsockname(3SOCKET),
414 getsockname(3XNET), getsockopt(3SOCKET), getsockopt(3XNET),
415 libsocket(3LIB), listen(3SOCKET), listen(3XNET), recv(3SOCKET),
416 recv(3XNET), recvfrom(3SOCKET), recvfrom(3XNET), recvmsg(3SOCKET),
417 recvmsg(3XNET), send(3SOCKET), send(3XNET), sendmsg(3SOCKET),
418 sendmsg(3XNET), sendto(3SOCKET), sendto(3XNET), setsockopt(3SOCKET),
419 setsockopt(3XNET), shutdown(3SOCKET), shutdown(3XNET),
420 sockaddr(3SOCKET), socket(3SOCKET), socket(3XNET), socketpair(3SOCKET),
421 socketpair(3XNET), ucred_get(3C), attributes(5), standards(5)
422
423
424
425 June 18, 2017 SOCKET.H(3HEAD)
|
1 SOCKET.H(3HEAD) Headers SOCKET.H(3HEAD)
2
3
4
5 NAME
6 socket.h, socket, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR,
7 CMSG_SPACE - Internet Protocol family
8
9 SYNOPSIS
10 #include <sys/socket.h>
11
12
13 DESCRIPTION
14 The <sys/socket.h> header defines the unsigned integral type
15 sa_family_t through typedef.
16
17
18 The <sys/socket.h> header defines the sockaddr structure that includes
19 the following members:
20
21 sa_family_t sa_family /* address family */
22 char sa_data[] /* socket address (variable-length
23 data) */
24
25
26 libxnet Interfaces
27 The <sys/socket.h> header defines the msghdr structure for libxnet
46
47
48
49 Ancillary data consists of a sequence of pairs, each consisting of a
50 cmsghdr structure followed by a data array. The data array contains the
51 ancillary data message, and the cmsghdr structure contains descriptive
52 information that allows an application to correctly parse the data.
53
54
55 The values for cmsg_level will be legal values for the level argument
56 to the getsockopt() and setsockopt() functions. The SCM_RIGHTS type is
57 supported for level SOL_SOCKET.
58
59
60 Ancillary data is also possible at the socket level. The <sys/socket.h>
61 header defines the following macros for use as the cmsg_type values
62 when cmsg_level is SOL_SOCKET.
63
64 SCM_RIGHTS
65 Indicates that the data array contains the access rights
66 (set of open file descriptors) to be sent or received.
67
68
69 SCM_UCRED
70 Indicates that the data array contains a ucred_t to be
71 received. The ucred_t is the credential of the sending
72 process at the time the message was sent. This is a Sun-
73 specific, Evolving interface. See ucred_get(3C).
74
75
76
77 The IPv4 ancillary data formats are listed below by cmsg_level and
78 cmsg_type, along with the associated payload for each.
79
80 IPPROTO_IP, IP_RECVDSTADDR -- SOCK_DGRAM only
81
82 ipaddr_t, IP address
83
84
85 IPPROTO_IP, IP_RECVIF
86
87 uint_t, ifIndex number
88
89
90 IPPROTO_IP, IP_RECVOPTS -- SOCK_DGRAM only
91
92 variable-length IP options, up to 40 bytes
93
94
95 IPPROTO_IP, IP_RECVPKTINFO -- SOCK_DGRAM only
96
97 in_pktinfo_t
98
99
100 IPPROTO_IP, IP_RECVSLLA -- SOCK_DGRAM only
101
102 struct sockaddr_dl, link layer address
103
104
105 IPPROTO_IP, IP_RECVTTL -- SOCK_DGRAM only
106
107 uint8_t, the IP TTL (time to live)
108
109
110 IPPROTO_IP, IP_RECVTOS
111
112 uint8_t, the IP TOS (type of service)
113
114
115 SOL_SOCKET, SO_UCRED
116
117 ucred_t
118
119
120
121 The IPv6 ancillary data formats are listed below by cmsg_level and
122 cmsg_type, along with the associated payload for each.
123
124 IPPROTO_IPV6, IPV6_PKTINFO
125
126 in_pktinfo_t
127
128
129 IPPROTO_IPV6, IPV6_TCLASS
130
131 uint_t
132
133
134 IPPROTO_IPV6, IPV6_PATHMTU
135
136 ip6_mtuinfo
137
138
139 IPPROTO_IPV6, IPV6_HOPLIMIT
140
141 uint_t
142
143
144 IPPROTO_IPV6, IPV6_HOPOPTS
145
146 variable-length IPv6 options
147
148
149 IPPROTO_IPV6, IPV6_DSTOPTS
150
151 variable-length IPv6 options
152
153
154 IPPROTO_IPV6, IPV6_RTHDR
155
156 variable-length IPv6 options
157
158
159 IPPROTO_IPV6, IPV6_DSTOPTS
160
161 variable-length IPv6 options
162
163
164
165 The <sys/socket.h> header defines the following macros to gain access
166 to the data arrays in the ancillary data associated with a message
167 header:
168
169 CMSG_DATA(cmsg)
170
171 If the argument is a pointer to a cmsghdr structure, this macro
172 returns an unsigned character pointer to the data array associated
173 with the cmsghdr structure.
174
175
176 CMSG_NXTHDR(mhdr, cmsg)
177
178 If the first argument is a pointer to a msghdr structure and the
179 second argument is a pointer to a cmsghdr structure in the
180 ancillary data, pointed to by the msg_control field of that msghdr
181 structure, this macro returns a pointer to the next cmsghdr
182 structure, or a null pointer if this structure is the last cmsghdr
183 in the ancillary data.
184
400 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
401 +--------------------+-----------------+
402 |Interface Stability | Standard |
403 +--------------------+-----------------+
404
405 SEE ALSO
406 accept(3SOCKET), accept(3XNET), bind(3SOCKET), bind(3XNET),
407 connect(3SOCKET), connect(3XNET), getpeername(3SOCKET),
408 getpeername(3XNET), getpeerucred(3C), getsockname(3SOCKET),
409 getsockname(3XNET), getsockopt(3SOCKET), getsockopt(3XNET),
410 libsocket(3LIB), listen(3SOCKET), listen(3XNET), recv(3SOCKET),
411 recv(3XNET), recvfrom(3SOCKET), recvfrom(3XNET), recvmsg(3SOCKET),
412 recvmsg(3XNET), send(3SOCKET), send(3XNET), sendmsg(3SOCKET),
413 sendmsg(3XNET), sendto(3SOCKET), sendto(3XNET), setsockopt(3SOCKET),
414 setsockopt(3XNET), shutdown(3SOCKET), shutdown(3XNET),
415 sockaddr(3SOCKET), socket(3SOCKET), socket(3XNET), socketpair(3SOCKET),
416 socketpair(3XNET), ucred_get(3C), attributes(5), standards(5)
417
418
419
420 September 18, 2020 SOCKET.H(3HEAD)
|