Print this page
13175 Add support for IP_RECVTOS
13182 CMSG_ macros should have man pages
Change-ID: I784aa36cfd3c17e3cccbf1fd329fa7e69b663ef9


  91                              Enable or obtain IPsec security settings for this
  92                              socket. For more details on the protection
  93                              services of IPsec, see ipsec(7P).
  94 
  95 
  96        IP_ADD_MEMBERSHIP
  97                              Join a multicast group.
  98 
  99 
 100        IP_DROP_MEMBERSHIP
 101                              Leave a multicast group.
 102 
 103 
 104        IP_BOUND_IF
 105                              Limit  reception and transmission of packets to
 106                              this interface. Takes an integer as an argument.
 107                              The integer is the selected interface index.
 108 
 109 
 110 
 111        The following options take in_pktinfo_t as the parameter:
 112 
 113        IP_PKTINFO
 114 
 115            Set the source address and/or transmit interface of  the packet(s).
 116            Note that the IP_BOUND_IF socket option takes precedence over the
 117            interface index passed in IP_PKTINFO.
 118 
 119              struct in_pktinfo {
 120                 unsigned int ipi_ifindex;/* send/recv interface index */
 121                 struct in_addr ipi_spec_dst;/* matched source addr. */
 122                 struct in_addr ipi_addr;/* src/dst addr. in IP hdr */
 123              } in_pktinfo_t;
 124 
 125            When passed in (on transmit) via ancillary data with IP_PKTINFO,
 126            ipi_spec_dst is used as the source address and ipi_ifindex is used
 127            as the interface index to send the packet out.
 128 
 129 
























 130        IP_RECVPKTINFO






 131 
 132            Enable/disable receipt of the index of the interface the packet
 133            arrived on, the local address that was matched for reception, and
 134            the inbound packet's actual destination address. Takes boolean as
 135            the parameter.  Returns struct in_pktinfo_t as ancillary data.
 136 





 137 
 138 


















 139        The following options take a struct ip_mreq as the parameter. The
 140        structure contains a multicast address which must be set to the CLASS-D
 141        IP multicast address and an interface address. Normally the interface
 142        address is set to INADDR_ANY which causes the kernel to choose the
 143        interface on which to join.
 144 
 145        IP_BLOCK_SOURCE
 146                                     Block multicast packets whose source
 147                                     address matches the given source address.
 148                                     The specified group must be joined
 149                                     previously using IP_ADD_MEMBERSHIP or
 150                                     MCAST_JOIN_GROUP.
 151 
 152 
 153        IP_UNBLOCK_SOURCE
 154                                     Unblock (begin receiving) multicast
 155                                     packets which were previously blocked
 156                                     using IP_BLOCK_SOURCE.
 157 
 158 


 228                             default behavior).
 229 
 230 
 231        IP_MULTICAST_TTL
 232                             Time to live for multicast datagrams. This option
 233                             takes an unsigned character as an argument. Its
 234                             value is the TTL that IP uses on outgoing
 235                             multicast datagrams. The default is 1.
 236 
 237 
 238        IP_MULTICAST_LOOP
 239                             Loopback for multicast  datagrams. Normally
 240                             multicast  datagrams are delivered to members on
 241                             the sending host (or sending zone). Setting the
 242                             unsigned character argument to 0 causes the
 243                             opposite behavior, meaning that when multiple
 244                             zones are present, the datagrams are delivered to
 245                             all zones except the sending zone.
 246 
 247 
 248        IP_RECVIF
 249                             Receive the inbound interface index.
 250 
 251 
 252        IP_TOS
 253                             This option takes an integer argument as its input
 254                             value. The least significant 8 bits of the value
 255                             are used to set the Type Of Service field in the
 256                             IP header of the outgoing packets.
 257 
 258 
 259        IP_NEXTHOP
 260                             This option specifies the address of the onlink
 261                             nexthop for traffic originating from that socket.
 262                             It causes the routing table to be bypassed and
 263                             outgoing traffic is sent directly to the specified
 264                             nexthop. This option takes an ipaddr_t argument
 265                             representing the IPv4 address of the nexthop as
 266                             the input value. The IP_NEXTHOP option takes
 267                             precedence over IPOPT_LSRR. IP_BOUND_IF and
 268                             SO_DONTROUTE take precedence over IP_NEXTHOP. This
 269                             option has no meaning for broadcast and multicast
 270                             packets. The application must ensure that the
 271                             specified nexthop is alive. An application may


 465        unplumb
 466                          A network interface is no longer associated with this
 467                          protocol.
 468 
 469 
 470        up
 471                          At least one logical interface is now ready to
 472                          receive packets.
 473 
 474 
 475        down
 476                          There are no logical interfaces expecting to receive
 477                          packets.
 478 
 479 
 480        address change
 481                          An address has changed on a logical  interface.
 482 
 483 
 484 SEE ALSO
 485        ifconfig(1M), routeadm(1M), ndd(1M), read(2), write(2), bind(3SOCKET),
 486        connect(3SOCKET), getsockopt(3SOCKET), recv(3SOCKET), send(3SOCKET),
 487        defaultrouter(4), icmp(7P), if_tcp(7P), inet(7P), ip6(7P), ipsec(7P),
 488        routing(7P), tcp(7P), udp(7P), net_hook_register(9F),
 489        hook_pkt_event(9S)
 490 
 491 
 492        Braden, R., RFC 1122, Requirements for Internet Hosts - Communication
 493        Layers, Information Sciences Institute, University of Southern
 494        California, October 1989.
 495 
 496 
 497        Postel, J., RFC 791, Internet Protocol - DARPA Internet Program
 498        Protocol Specification, Information Sciences Institute, University of
 499        Southern California, September 1981.
 500 
 501 DIAGNOSTICS
 502        A socket operation may fail with one of the following errors returned:
 503 
 504        EACCES
 505                         A bind() operation was attempted with a "reserved"
 506                         port number and the effective user ID of the process
 507                         was not the privileged user.
 508 
 509                         Setting the IP_NEXTHOP was attempted by a process


 613 
 614 
 615        ENOPROTOOPT
 616                         Invalid socket type.
 617 
 618 
 619        EPERM
 620                         No permissions.
 621 
 622 
 623 NOTES
 624        Raw sockets should receive ICMP error packets relating to the protocol;
 625        currently such packets are simply discarded.
 626 
 627 
 628        Users of higher-level protocols such as TCP and UDP should be able to
 629        see received IP options.
 630 
 631 
 632 
 633                                December 3, 2008                         IP(7P)


  91                              Enable or obtain IPsec security settings for this
  92                              socket. For more details on the protection
  93                              services of IPsec, see ipsec(7P).
  94 
  95 
  96        IP_ADD_MEMBERSHIP
  97                              Join a multicast group.
  98 
  99 
 100        IP_DROP_MEMBERSHIP
 101                              Leave a multicast group.
 102 
 103 
 104        IP_BOUND_IF
 105                              Limit  reception and transmission of packets to
 106                              this interface. Takes an integer as an argument.
 107                              The integer is the selected interface index.
 108 
 109 
 110 
 111        The following option takes in_pktinfo_t as the parameter:
 112 
 113        IP_PKTINFO
 114 
 115            Set the source address and/or transmit interface of  the packet(s).
 116            Note that the IP_BOUND_IF socket option takes precedence over the
 117            interface index passed in IP_PKTINFO.
 118 
 119              struct in_pktinfo {
 120                 unsigned int ipi_ifindex;/* send/recv interface index */
 121                 struct in_addr ipi_spec_dst;/* matched source addr. */
 122                 struct in_addr ipi_addr;/* src/dst addr. in IP hdr */
 123              } in_pktinfo_t;
 124 
 125            When passed in (on transmit) via ancillary data with IP_PKTINFO,
 126            ipi_spec_dst is used as the source address and ipi_ifindex is used
 127            as the interface index to send the packet out.
 128 
 129 
 130 
 131        The following options are boolean switches controlling the reception of
 132        ancillary data:
 133 
 134 
 135        IP_RECVDSTADDR
 136                              When enabled on a SOCK_DGRAM socket, enables
 137                              receipt of the destination IP address of the
 138                              incoming packet. Returns inaddr_t as ancillary
 139                              data.
 140 
 141 
 142        IP_RECVIF
 143                              Enable/disable receipt of the inbound interface
 144                              index. Returns uint_t as ancillary data.
 145 
 146 
 147        IP_RECVOPTS
 148                              When enabled on a SOCK_DGRAM socket, enables
 149                              receipt of the IP options from the incoming
 150                              packet. Returns variable-length IP options, up to
 151                              40 bytes, as ancillary data.
 152 
 153 
 154        IP_RECVPKTINFO
 155                              Enable/disable receipt of the index of the
 156                              interface the packet arrived on, the local
 157                              address that was matched for reception, and the
 158                              inbound packet's actual destination address.
 159                              Takes boolean as the parameter.  Returns
 160                              in_pktinfo_t as ancillary data.
 161 




 162 
 163        IP_RECVSLLA
 164                              When enabled on a SOCK_DGRAM socket, enables
 165                              receipt of the source link-layer address for the
 166                              incoming packet. Returns struct sockaddr_dl as
 167                              ancillary data.
 168 
 169 
 170        IP_RECVTTL
 171                              When enabled on a SOCK_DGRAM socket, the IP TTL
 172                              (time to live) field for an incoming datagram is
 173                              returned as uint8_t in ancillary data.
 174 
 175 
 176        IP_RECVTOS
 177                              When enabled, the IP TOS (type of service) field
 178                              is returned as uint8_t in ancillary data. For
 179                              SOCK_DGRAM sockets, the ancillary data item is
 180                              included for every call to recvmsg(). For
 181                              SOCK_STREAM sockets, where there is no direct
 182                              mapping between received TCP segments and receive
 183                              operations, the ancillary data item will only be
 184                              present when the value has changed.
 185 
 186 
 187 
 188        The following options take a struct ip_mreq as the parameter. The
 189        structure contains a multicast address which must be set to the CLASS-D
 190        IP multicast address and an interface address. Normally the interface
 191        address is set to INADDR_ANY which causes the kernel to choose the
 192        interface on which to join.
 193 
 194        IP_BLOCK_SOURCE
 195                                     Block multicast packets whose source
 196                                     address matches the given source address.
 197                                     The specified group must be joined
 198                                     previously using IP_ADD_MEMBERSHIP or
 199                                     MCAST_JOIN_GROUP.
 200 
 201 
 202        IP_UNBLOCK_SOURCE
 203                                     Unblock (begin receiving) multicast
 204                                     packets which were previously blocked
 205                                     using IP_BLOCK_SOURCE.
 206 
 207 


 277                             default behavior).
 278 
 279 
 280        IP_MULTICAST_TTL
 281                             Time to live for multicast datagrams. This option
 282                             takes an unsigned character as an argument. Its
 283                             value is the TTL that IP uses on outgoing
 284                             multicast datagrams. The default is 1.
 285 
 286 
 287        IP_MULTICAST_LOOP
 288                             Loopback for multicast  datagrams. Normally
 289                             multicast  datagrams are delivered to members on
 290                             the sending host (or sending zone). Setting the
 291                             unsigned character argument to 0 causes the
 292                             opposite behavior, meaning that when multiple
 293                             zones are present, the datagrams are delivered to
 294                             all zones except the sending zone.
 295 
 296 




 297        IP_TOS
 298                             This option takes an integer argument as its input
 299                             value. The least significant 8 bits of the value
 300                             are used to set the Type Of Service field in the
 301                             IP header of the outgoing packets.
 302 
 303 
 304        IP_NEXTHOP
 305                             This option specifies the address of the onlink
 306                             nexthop for traffic originating from that socket.
 307                             It causes the routing table to be bypassed and
 308                             outgoing traffic is sent directly to the specified
 309                             nexthop. This option takes an ipaddr_t argument
 310                             representing the IPv4 address of the nexthop as
 311                             the input value. The IP_NEXTHOP option takes
 312                             precedence over IPOPT_LSRR. IP_BOUND_IF and
 313                             SO_DONTROUTE take precedence over IP_NEXTHOP. This
 314                             option has no meaning for broadcast and multicast
 315                             packets. The application must ensure that the
 316                             specified nexthop is alive. An application may


 510        unplumb
 511                          A network interface is no longer associated with this
 512                          protocol.
 513 
 514 
 515        up
 516                          At least one logical interface is now ready to
 517                          receive packets.
 518 
 519 
 520        down
 521                          There are no logical interfaces expecting to receive
 522                          packets.
 523 
 524 
 525        address change
 526                          An address has changed on a logical  interface.
 527 
 528 
 529 SEE ALSO
 530        ifconfig(1M), routeadm(1M), ndd(1M), read(2), write(2),
 531        socket.h(3HEAD), bind(3SOCKET), connect(3SOCKET), getsockopt(3SOCKET),
 532        recv(3SOCKET), send(3SOCKET), defaultrouter(4), icmp(7P), if_tcp(7P),
 533        inet(7P), ip(7P), ip6(7P), ipsec(7P), routing(7P), tcp(7P), udp(7P),
 534        net_hook_register(9F), hook_pkt_event(9S)
 535 
 536 
 537        Braden, R., RFC 1122, Requirements for Internet Hosts - Communication
 538        Layers, Information Sciences Institute, University of Southern
 539        California, October 1989.
 540 
 541 
 542        Postel, J., RFC 791, Internet Protocol - DARPA Internet Program
 543        Protocol Specification, Information Sciences Institute, University of
 544        Southern California, September 1981.
 545 
 546 DIAGNOSTICS
 547        A socket operation may fail with one of the following errors returned:
 548 
 549        EACCES
 550                         A bind() operation was attempted with a "reserved"
 551                         port number and the effective user ID of the process
 552                         was not the privileged user.
 553 
 554                         Setting the IP_NEXTHOP was attempted by a process


 658 
 659 
 660        ENOPROTOOPT
 661                         Invalid socket type.
 662 
 663 
 664        EPERM
 665                         No permissions.
 666 
 667 
 668 NOTES
 669        Raw sockets should receive ICMP error packets relating to the protocol;
 670        currently such packets are simply discarded.
 671 
 672 
 673        Users of higher-level protocols such as TCP and UDP should be able to
 674        see received IP options.
 675 
 676 
 677 
 678                               September 18, 2020                        IP(7P)