Update contrib.
1 /** @file ../include/netinet/in.h
6 /** @struct sockaddr_in
8 Socket address, internet style.
14 /** @var sockaddr_in::sin_family
18 /** @var sockaddr_in::sin_port
22 /** @var sockaddr_in::sin_addr
26 /** @var sockaddr_in::sin_zero
27 There's also this sin_zero field which some people claim must be set to zero. Other people don't claim anything about it (the Linux documentation doesn't even mention it at all), and setting it to zero doesn't seem to be actually necessary.
28 So, if you feel like it, set it to zero using memset().
33 Internet address (a structure for historical reasons).
39 /** @var in_addr::s_addr
40 s_addr is a 4-byte number that represents one digit in an IP address per byte
43 /** @typedef typedef uint32_t in_addr_t
45 Internet address manipulation
52 /** @typedef typedef uint16_t in_port_t
54 Internet port manipulation
72 Control message protocol.
88 user datagram protocol KProtocolInetUdp
97 IPv4 local host address.
100 @externallyDefinedApi
104 /** @def INADDR_BROADCAST
106 IPv4 broadcast address.
109 @externallyDefinedApi
113 /** @fn bindresvport(int sd, struct sockaddr_in *sin)
117 The bindresvport function is used to bind a socket descriptor to a privileged IP port, i.e. a port with a number in the range 0-1023.
119 If sin is a pointer to a struct sockaddr_in the appropriate fields in the structure should be
120 defined. Note that sin-\>sin_family must be initialized to the address
121 family of the socket, passed by sd. If sin-\>sin_port is '0' an anonymous port (in the range 600-1023) will be chosen and, if bind is successful, the sin-\>sin_port will be updated to contain the allocated
124 If sin is the NULL pointer an anonymous port will be allocated (as above). However,
125 there is no way for bindresvport to return the allocated port in this case.
127 The function prototype of bindresvport is biased to AF_INET socket.
131 #include <sys/socket.h>
132 #include <netinet/in.h>
137 sockaddr_in selfAddr;
138 sockfd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
140 selfAddr.sin_family = AF_INET;
141 selfAddr.sin_addr.s_addr = INADDR_ANY;
142 selfAddr.sin_port = htons(100);
143 bindresvport(sockfd, &selfAddr;);
148 @return The bindresvport() function returns the value 0 if successful. Otherwise
149 it returns the value -1 and sets the global variable errno to indicate the error.
159 @externallyDefinedApi
163 /** @def IN_BADCLASS(i)
165 Definitions of bits in internet address integers.
172 /** @def IN_CLASSA(i)
174 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
180 /** @def IN_CLASSA_NET
182 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
188 /** @def IN_CLASSA_NSHIFT
190 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
197 /** @def IN_CLASSA_HOST
199 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
206 /** @def IN_CLASSA_MAX
208 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
215 /** @def IN_CLASSB(i)
217 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
224 /** @def IN_CLASSB_NET
226 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
233 /** @def IN_CLASSB_NSHIFT
235 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
242 /** @def IN_CLASSB_HOST
244 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
250 /** @def IN_CLASSB_MAX
252 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
258 /** @def IN_CLASSC(i)
260 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
266 /** @def IN_CLASSC_NET
268 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
275 /** @def IN_CLASSC_NSHIFT
277 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
283 /** @def IN_CLASSC_HOST
285 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
291 /** @def IN_CLASSD(i)
293 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
299 /** @def IN_CLASSD_NET
301 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
307 /** @def IN_CLASSD_NSHIFT
309 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
315 /** @def IN_CLASSD_HOST
317 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
324 /** @def IN_EXPERIMENTAL(i)
326 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
333 /** @def IN_LOOPBACKNET
335 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
341 /** @def IN_MULTICAST(i)
343 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
349 /** @def INADDR_LOOPBACK
351 Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
358 /** @def INADDR_MAX_LOCAL_GROUP
360 Definitions of bits in internet address integers.
369 Definitions of bits in internet address integers.
376 /** @def INADDR_UNSPEC_GROUP
378 Definitions of bits in internet address integers.
385 /** @def INADDR_ALLHOSTS_GROUP
387 Definitions of bits in internet address integers.
394 /** @def IP_DEFAULT_MULTICAST_LOOP
396 Defaults and limits for options. normally hear sends if a member
402 /** @def IP_DEFAULT_MULTICAST_TTL
404 Defaults and limits for options. normally limit m'casts to 1 hop
411 /** @def IP_ADD_MEMBERSHIP
413 ip_mreq; add an IP group membership
420 /** @def IP_DROP_MEMBERSHIP
422 ip_mreq; drop an IP group membership
431 int; header is included with data
440 Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
446 /** @var ip_mreq::imr_multiaddr
447 IP multicast address of group
450 /** @var ip_mreq::imr_interface
451 local IP address of interface
455 /** @def IP_MULTICAST_IF
457 set or get IP multicast interface
464 /** @def IP_MULTICAST_LOOP
466 u_char; set or get IP multicast loopback
472 /** @def IP_MULTICAST_TTL
474 set or get IP multicast timetolive
482 Options for use with [gs]etsockopt at the IP level. First word of comment is data type; bool is stored in int.
483 buf or ip_opts; set or get IP options
490 /** @def IP_RECVDSTADDR
492 Options for use with [gs]etsockopt at the IP level. First word of comment is data type; bool is stored in int.
493 bool; receive IP dst addr wdgram
502 Options for use with [gs]etsockopt at the IP level. First word of comment is data type; bool is stored in int.
503 bool; receive all IP opts w dgram
510 /** @def IP_RECVRETOPTS
512 Options for use with [gs]etsockopt at the IP level. First word of comment is data type; bool is stored in int.
513 bool; receive IP opts for response
522 Options for use with [gs]etsockopt at the IP level. First word of comment is data type; bool is stored in int.
523 ip_opts; set or get IP options
533 Options for use with [gs]etsockopt at the IP level. First word of comment is data type; bool is stored in int.
534 int; IP type of service and preced.
542 Options for use with [gs]etsockopt at the IP level. First word of comment is data type; bool is stored in int.
543 int; IP type of service and preced.
551 exterior gateway protocol
558 /** @def IPPROTO_HOPOPTS
560 IP6 hop-by-hop options
566 /** @def IPPROTO_IGMP
576 gateway2 (deprecated)
583 /** @def IPPROTO_IPV4
591 /** @def IPPROTO_IPIP
610 exterior gateway protocol
617 /** @def IPPROTO_PIGP
619 private interior gateway
625 /** @def IPPROTO_RCCMON
633 /** @def IPPROTO_NVPII
635 network voice protocol
650 /** @def IPPROTO_ARGUS
658 /** @def IPPROTO_EMCON
666 /** @def IPPROTO_XNET
675 /** @def IPPROTO_CHAOS
692 /** @def IPPROTO_MEAS
694 DCN Measurement Subsystems
711 Packet Radio Measurement
725 /** @def IPPROTO_TRUNK1
733 /** @def IPPROTO_TRUNK2
742 /** @def IPPROTO_LEAF1
751 /** @def IPPROTO_LEAF2
767 /** @def IPPROTO_IRTP
778 tp-4 w class negotiation
828 InterDomain Policy Routing
851 /** @def IPPROTO_SDRP
853 Source Demand Routing
860 /** @def IPPROTO_CMTP
862 Control Message Transport
868 /** @def IPPROTO_TPXX
878 IL transport protocol
885 /** @def IPPROTO_IPV6
893 /** @def IPPROTO_ROUTING
902 /** @def IPPROTO_FRAGMENT
904 IP6 fragmentation header
911 /** @def IPPROTO_IDRP
919 /** @def IPPROTO_RSVP
930 General Routing Encap.
949 IP6 Encap Sec. Payload
963 /** @def IPPROTO_INLSP
965 Integ. Net Layer Security
972 /** @def IPPROTO_SWIPE
980 /** @def IPPROTO_NHRP
989 /** @def IPPROTO_MOBILE
999 Transport Layer Security
1005 /** @def IPPROTO_SKIP
1014 /** @def IPPROTO_ICMPV6
1022 /** @def IPPROTO_NONE
1031 /** @def IPPROTO_DSTOPTS
1033 IP6 destination option
1041 /** @def IPPROTO_AHIP
1043 any host internal protocol
1051 /** @def IPPROTO_CFTP
1060 /** @def IPPROTO_HELLO
1062 "hello" routing protocol
1069 /** @def IPPROTO_SATEXPAK
1071 SATNET or Backroom EXPAK
1078 /** @def IPPROTO_KRYPTOLAN
1087 /** @def IPPROTO_RVD
1096 /** @def IPPROTO_IPPC
1098 Pluribus Packet Core
1105 /** @def IPPROTO_ADFS
1115 /** @def IPPROTO_SATMON
1124 /** @def IPPROTO_VISA
1133 /** @def IPPROTO_IPCV
1141 /** @def IPPROTO_CPNX
1143 Comp. Prot. Net. Executive
1150 /** @def IPPROTO_CPHB
1152 Comp. Prot. HeartBeat
1159 /** @def IPPROTO_WSN
1168 /** @def IPPROTO_PVP
1170 Packet Video Protocol
1176 /** @def IPPROTO_BRSATMON
1178 BackRoom SATNET Monitoring
1186 Sun net disk proto (temp.)
1193 /** @def IPPROTO_WBMON
1202 /** @def IPPROTO_WBEXPAK
1211 /** @def IPPROTO_EON
1219 /** @def IPPROTO_VMTP
1227 /** @def IPPROTO_SVMTP
1236 /** @def IPPROTO_VINES
1245 /** @def IPPROTO_TTP
1253 /** @def IPPROTO_IGP
1261 /** @def IPPROTO_DGP
1263 dissimilar gateway prot.
1270 /** @def IPPROTO_TCF
1279 /** @def IPPROTO_IGRP
1287 /** @def IPPROTO_OSPFIGP
1295 /** @def IPPROTO_SRPC
1304 /** @def IPPROTO_LARP
1306 Locus Address Resoloution
1313 /** @def IPPROTO_MTP
1321 /** @def IPPROTO_AX25
1329 /** @def IPPROTO_IPEIP
1331 IP encapsulated in IP
1338 /** @def IPPROTO_MICP
1340 Mobile Int.ing control
1347 /** @def IPPROTO_SCCSP
1349 Semaphore Comm. security
1355 /** @def IPPROTO_ETHERIP
1357 Ethernet IP encapsulation
1363 /** @def IPPROTO_ENCAP
1365 encapsulation header
1372 /** @def IPPROTO_APES
1374 any private encr. scheme
1381 /** @def IPPROTO_GMTP
1392 Protocol Independent Mcast
1398 /** @def IPPROTO_CARP
1406 /** @def IPPROTO_PGM
1415 /** @def IPPROTO_PFSYNC
1426 options for IP level KSolInetIp
1435 options for TCP level KSolInetTcp
1442 /** @def TCP_NODELAY
1444 User-settable options (used with setsockopt). don't delay send to coalesce packets KSoTcpNoDelay
1453 User-settable options (used with setsockopt). set maximum segment size KSoTcpMaxSegSize
1460 /** @def IPPORT_RESERVED
1462 Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root). (IP_PORTRANGE_LOW)
1469 /** @def IPPORT_HIFIRSTAUTO
1471 Default local port range, used by both IP_PORTRANGE_DEFAULT and IP_PORTRANGE_HIGH.
1478 /** @def IPPORT_HILASTAUTO
1480 Default local port range, used by both IP_PORTRANGE_DEFAULT and IP_PORTRANGE_HIGH.
1487 /** @def IPPORT_RESERVEDSTART
1489 Scanning for a free reserved port return a value below IPPORT_RESERVED, but higher than IPPORT_RESERVEDSTART. Traditionally the start value was 512, but that conflicts with some well-known-services that firewalls may have a fit if we use.
1496 /** @def IPPROTO_MAX
1498 Maximum value for IPPROTO options
1514 /** @def IPPROTO_DONE
1516 last return value of _input(), meaning all job for this pkt is done.
1523 /** @def IPPROTO_SPACER
1525 Defined to avoid confusion. The master value is defined by PROTO_SPACER in sys//protosw.h.
1534 enable RSVP in kernel
1541 /** @def IP_RSVP_OFF
1543 disable RSVP in kernel
1550 /** @def IP_RSVP_VIF_ON
1552 set RSVP per-vif socket
1559 /** @def IP_RSVP_VIF_OFF
1561 unset RSVP per-vif socket
1568 /** @def IP_PORTRANGE
1570 int; range to choose for unspec port
1579 bool; receive reception if w dgram
1586 /** @def IP_IPSEC_POLICY
1588 int; set or get security policy
1597 bool; accept FAITH'ed connections
1604 /** @def IP_ONESBCAST
1606 bool: send all-ones broadcast
1613 /** @def IP_FW_TABLE_ADD
1622 /** @def IP_FW_TABLE_DEL
1631 /** @def IP_FW_TABLE_FLUSH
1640 /** @def IP_FW_TABLE_GETSIZE
1649 /** @def IP_FW_TABLE_LIST
1660 add a firewall rule to chain
1669 delete a firewall rule from chain
1676 /** @def IP_FW_FLUSH
1678 flush firewall rule chain
1687 clear single or all firewall counter(s)
1696 get entire firewall rule chain
1703 /** @def IP_FW_RESETLOG
1705 reset logging counters
1712 /** @def IP_DUMMYNET_CONFIGURE
1714 add or configure a dummynet pipe
1721 /** @def IP_DUMMYNET_DEL
1723 delete a dummynet pipe from chain
1730 /** @def IP_DUMMYNET_FLUSH
1739 /** @def IP_DUMMYNET_GET
1741 get entire dummynet pipes
1749 bool; receive IP TTL w dgram
1758 minimum TTL for packet or drop
1764 /** @def IP_DONTFRAG
1766 don't fragment packet