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
  28        interfaces that includes the following members:
  29 
  30          void            *msg_name         /* optional address */
  31          socklen_t       msg_namelen       /* size of address */
  32          struct iovec    *msg_iov          /* scatter/gather array */
  33          int             msg_iovlen        /* members in msg_iov */
  34          void            *msg_control      /* ancillary data, see below */
  35          socklen_t       msg_controllen    /* ancillary data buffer len */
  36          int             msg_flags         /* flags on received message */
  37 
  38 
  39 
  40        The <sys/socket.h> header defines the cmsghdr structure for libxnet
  41        that includes the following members:
  42 
  43          socklen_t  cmsg_len      /* data byte count, including hdr */
  44          int        cmsg_level    /* originating protocol */
  45          int        cmsg_type     /* protocol-specific type */
  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 
 185 
 186        CMSG_FIRSTHDR(mhdr)
 187 
 188            If the argument is a pointer to a msghdr structure, this macro
 189            returns a pointer to the first cmsghdr structure in the ancillary
 190            data associated with this msghdr structure, or a null pointer if
 191            there is no ancillary data associated with the msghdr structure.
 192 
 193 
 194        CMSG_SPACE(len)
 195 
 196            Given the length of an ancillary data object, CMSG_SPACE() returns
 197            the space required by the object and its cmsghdr structure,
 198            including any padding needed to satisfy alignment requirements.
 199            This macro can be used, for example, to allocate space dynamically
 200            for the ancillary data. This macro should not be used to initialize
 201            the cmsg_len member of a cmsghdr structure. Use the CMSG_LEN()
 202            macro instead.
 203 
 204 
 205        CMSG_LEN(len)
 206 
 207            Given the length of an ancillary data object, CMSG_LEN() returns
 208            the value to store in the cmsg_len member of the cmsghdr structure,
 209            taking into account any padding needed to satisfy alignment
 210            requirements.
 211 
 212 
 213 
 214        The <sys/socket.h> header defines the linger structure that includes
 215        the following members:
 216 
 217          int   l_onoff   /* indicates  whether  linger option is enabled */
 218          int   l_linger  /* linger time, in seconds */
 219 
 220 
 221 
 222        The <sys/socket.h> header defines the following macros:
 223 
 224        SOCK_DGRAM
 225                          Datagram socket
 226 
 227 
 228        SOCK_STREAM
 229                          Byte-stream socket
 230 
 231 
 232        SOCK_SEQPACKET
 233                          Sequenced-packet socket
 234 
 235 
 236 
 237        The <sys/socket.h> header defines the following macros for use as the
 238        level argument of setsockopt() and getsockopt().
 239 
 240        SOL_SOCKET
 241                      Options to be accessed at the socket level, not the
 242                      protocol level.
 243 
 244 
 245        SOL_ROUTE
 246                      Options to be accessed at the routing socket level, not
 247                      the protocol level.
 248 
 249 
 250 
 251        The <sys/socket.h> header defines the following macros for use as the
 252        option_name argument of getsockopt() or setsockopt() calls:
 253 
 254        SO_DEBUG
 255                         Debugging information is being recorded.
 256 
 257 
 258        SO_ACCEPTCONN
 259                         Socket is accepting connections.
 260 
 261 
 262        SO_BROADCAST
 263                         Transmission of broadcast messages is supported.
 264 
 265 
 266        SO_REUSEADDR
 267                         Reuse of local addresses is supported.
 268 
 269 
 270        SO_KEEPALIVE
 271                         Connections are kept alive with periodic messages.
 272 
 273 
 274        SO_LINGER
 275                         Socket lingers on close.
 276 
 277 
 278        SO_OOBINLINE
 279                         Out-of-band data is transmitted in line.
 280 
 281 
 282        SO_SNDBUF
 283                         Send buffer size.
 284 
 285 
 286        SO_RCVBUF
 287                         Receive buffer size.
 288 
 289 
 290        SO_ERROR
 291                         Socket error status.
 292 
 293 
 294        SO_TYPE
 295                         Socket type.
 296 
 297 
 298        SO_RECVUCRED
 299                         Request the reception of user credential ancillary
 300                         data. This is a Sun-specific, Evolving interface. See
 301                         ucred_get(3C).
 302 
 303 
 304        SO_MAC_EXEMPT
 305                         Mandatory Access Control (MAC) exemption for unlabeled
 306                         peers. This option is available only if the system is
 307                         configured with Trusted Extensions.
 308 
 309 
 310        SO_ALLZONES
 311                         Bypass zone boundaries (privileged).
 312 
 313 
 314 
 315        The <sys/socket.h> header defines the following macros for use as the
 316        valid values for the msg_flags field in the msghdr structure, or the
 317        flags parameter in recvfrom(), recvmsg(), sendto(), or sendmsg() calls:
 318 
 319        MSG_CTRUNC
 320                       Control data truncated.
 321 
 322 
 323        MSG_EOR
 324                       Terminates a record (if supported by the protocol).
 325 
 326 
 327        MSG_OOB
 328                       Out-of-band data.
 329 
 330 
 331        MSG_PEEK
 332                       Leave received data in queue.
 333 
 334 
 335        MSG_TRUNC
 336                       Normal data truncated.
 337 
 338 
 339        MSG_WAITALL
 340                       Wait for complete message.
 341 
 342 
 343        MSG_NOSIGNAL
 344                       Do not generate SIGPIPE signal.
 345 
 346 
 347 
 348        The <sys/socket.h> header defines the following macros:
 349 
 350        AF_UNIX
 351                   UNIX domain sockets
 352 
 353 
 354        AF_INET
 355                   Internet domain sockets
 356 
 357 
 358 
 359        The <sys/socket.h> header defines the following macros:
 360 
 361        SHUT_RD
 362                     Disables further receive operations.
 363 
 364 
 365        SHUT_WR
 366                     Disables further send operations.
 367 
 368 
 369        SHUT_RDWR
 370                     Disables further send and receive operations.
 371 
 372 
 373    libsocket Interfaces
 374        The <sys/socket.h> header defines the msghdr structure for libsocket
 375        interfaces that includes the following members:
 376 
 377          void           *msg_name        /* optional address */
 378          socklen_t      msg_namelen      /* size of address */
 379          struct iovec   *msg_iov         /* scatter/gather array */
 380          int            msg_iovlen       /* # elements in msg_iov */
 381          caddr_t        msg_accrights    /* access rights sent/received */
 382 
 383 
 384 
 385        The msg_name and msg_namelen parameters specify the destination address
 386        when the socket is unconnected The msg_name can be specified as a NULL
 387        pointer if no names are desired or required. The msg_iov and msg_iovlen
 388        parameters describe the scatter-gather locations, as described in
 389        read(2). The msg_accrights parameter specifies the buffer in which
 390        access rights sent along with the message are received. The
 391        msg_accrightslen specifies the length of the buffer.
 392 
 393 ATTRIBUTES
 394        See attributes(5) for descriptions of the following attributes:
 395 
 396 
 397 
 398 
 399        +--------------------+-----------------+
 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)