logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

netinet_in.h.0p (11530B)


  1. '\" et
  2. .TH netinet_in.h "0P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. netinet/in.h
  12. \(em Internet address family
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <netinet/in.h>
  17. .fi
  18. .SH DESCRIPTION
  19. The
  20. .IR <netinet/in.h>
  21. header shall define the following types:
  22. .IP "\fBin_port_t\fP" 10
  23. Equivalent to the type
  24. .BR uint16_t
  25. as described in
  26. .IR <inttypes.h> .
  27. .IP "\fBin_addr_t\fP" 10
  28. Equivalent to the type
  29. .BR uint32_t
  30. as described in
  31. .IR <inttypes.h> .
  32. .P
  33. The
  34. .IR <netinet_in.h>
  35. header shall define the
  36. .BR sa_family_t
  37. type as described in
  38. .IR <sys/socket.h> .
  39. .P
  40. The
  41. .IR <netinet_in.h>
  42. header shall define the
  43. .BR uint8_t
  44. and
  45. .BR uint32_t
  46. types as described in
  47. .IR <inttypes.h> .
  48. Inclusion of the
  49. .IR <netinet/in.h>
  50. header may also make visible all symbols from
  51. .IR <inttypes.h>
  52. and
  53. .IR <sys/socket.h> .
  54. .P
  55. The
  56. .IR <netinet/in.h>
  57. header shall define the
  58. .BR in_addr
  59. structure, which shall include at least the following member:
  60. .sp
  61. .RS 4
  62. .nf
  63. in_addr_t s_addr
  64. .fi
  65. .P
  66. .RE
  67. .P
  68. The
  69. .IR <netinet/in.h>
  70. header shall define the
  71. .BR sockaddr_in
  72. structure, which shall include at least the following members:
  73. .sp
  74. .RS 4
  75. .nf
  76. sa_family_t sin_family \fRAF_INET.\fR
  77. in_port_t sin_port \fRPort number.\fR
  78. struct in_addr sin_addr \fRIP address.\fR
  79. .fi
  80. .P
  81. .RE
  82. .P
  83. The
  84. .IR sin_port
  85. and
  86. .IR sin_addr
  87. members shall be in network byte order.
  88. .P
  89. The
  90. .BR sockaddr_in
  91. structure is used to store addresses for the Internet address family.
  92. Pointers to this type shall be cast by applications to
  93. .BR "struct sockaddr *"
  94. for use with socket functions.
  95. .P
  96. The
  97. .IR <netinet/in.h>
  98. header shall define the
  99. .BR in6_addr
  100. structure, which shall include at least the following member:
  101. .sp
  102. .RS 4
  103. .nf
  104. uint8_t s6_addr[16]
  105. .fi
  106. .P
  107. .RE
  108. .P
  109. This array is used to contain a 128-bit IPv6 address, stored in network
  110. byte order.
  111. .P
  112. The
  113. .IR <netinet/in.h>
  114. header shall define the
  115. .BR sockaddr_in6
  116. structure, which shall include at least the following members:
  117. .sp
  118. .RS 4
  119. .nf
  120. sa_family_t sin6_family \fRAF_INET6.\fR
  121. in_port_t sin6_port \fRPort number.\fR
  122. uint32_t sin6_flowinfo \fRIPv6 traffic class and flow information.\fR
  123. struct in6_addr sin6_addr \fRIPv6 address.\fR
  124. uint32_t sin6_scope_id \fRSet of interfaces for a scope.\fR
  125. .fi
  126. .P
  127. .RE
  128. .P
  129. The
  130. .IR sin6_port
  131. and
  132. .IR sin6_addr
  133. members shall be in network byte order.
  134. .P
  135. Prior to calling a function in this standard which reads values from a
  136. .BR sockaddr_in6
  137. structure (for example,
  138. \fIbind\fR()
  139. or
  140. \fIconnect\fR()),
  141. the application shall ensure that all members of the structure,
  142. including any additional non-standard members, if any, are initialized.
  143. If the
  144. .BR sockaddr_in6
  145. structure has a non-standard member, and that member has a value
  146. other than the value that would result from default initialization,
  147. the behavior of any function in this standard that reads values
  148. from the
  149. .BR sockaddr_in6
  150. structure is implementation-defined. All functions in this standard
  151. that return data in a
  152. .BR sockaddr_in6
  153. structure (for example,
  154. \fIgetaddrinfo\fR()
  155. or
  156. \fIaccept\fR())
  157. shall initialize the structure in a way that meets the above
  158. requirements, and shall ensure that each non-standard member,
  159. if any, has a value that produces the same behavior as default
  160. initialization would in all functions in this standard which
  161. read values from a
  162. .BR sockaddr_in6
  163. structure.
  164. .P
  165. The
  166. .IR sin6_scope_id
  167. field is a 32-bit integer that identifies a set of interfaces as
  168. appropriate for the scope of the address carried in the
  169. .IR sin6_addr
  170. field. For a link scope
  171. .IR sin6_addr ,
  172. the application shall ensure that
  173. .IR sin6_scope_id
  174. is a link index. For a site scope
  175. .IR sin6_addr ,
  176. the application shall ensure that
  177. .IR sin6_scope_id
  178. is a site index. The mapping of
  179. .IR sin6_scope_id
  180. to an interface or set of interfaces is implementation-defined.
  181. .P
  182. The
  183. .IR <netinet/in.h>
  184. header shall declare the following external variable:
  185. .sp
  186. .RS 4
  187. .nf
  188. const struct in6_addr in6addr_any
  189. .fi
  190. .P
  191. .RE
  192. .P
  193. This variable is initialized by the system to contain the wildcard IPv6
  194. address. The
  195. .IR <netinet/in.h>
  196. header also defines the IN6ADDR_ANY_INIT macro. This macro must be
  197. constant at compile time and can be used to initialize a variable of
  198. type
  199. .BR "struct in6_addr"
  200. to the IPv6 wildcard address.
  201. .P
  202. The
  203. .IR <netinet/in.h>
  204. header shall declare the following external variable:
  205. .sp
  206. .RS 4
  207. .nf
  208. const struct in6_addr in6addr_loopback
  209. .fi
  210. .P
  211. .RE
  212. .P
  213. This variable is initialized by the system to contain the loopback IPv6
  214. address. The
  215. .IR <netinet/in.h>
  216. header also defines the IN6ADDR_LOOPBACK_INIT macro. This macro must be
  217. constant at compile time and can be used to initialize a variable of
  218. type
  219. .BR "struct in6_addr"
  220. to the IPv6 loopback address.
  221. .P
  222. The
  223. .IR <netinet/in.h>
  224. header shall define the
  225. .BR ipv6_mreq
  226. structure, which shall include at least the following members:
  227. .sp
  228. .RS 4
  229. .nf
  230. struct in6_addr ipv6mr_multiaddr \fRIPv6 multicast address.\fR
  231. unsigned ipv6mr_interface \fRInterface index.\fR
  232. .fi
  233. .P
  234. .RE
  235. .P
  236. The
  237. .IR <netinet/in.h>
  238. header shall define the following symbolic constants for use as
  239. values of the
  240. .IR level
  241. argument of
  242. \fIgetsockopt\fR()
  243. and
  244. \fIsetsockopt\fR():
  245. .IP IPPROTO_IP 16
  246. Internet protocol.
  247. .IP IPPROTO_IPV6 16
  248. Internet Protocol Version 6.
  249. .IP IPPROTO_ICMP 16
  250. Control message protocol.
  251. .IP IPPROTO_RAW 16
  252. Raw IP Packets Protocol.
  253. .IP IPPROTO_TCP 16
  254. Transmission control protocol.
  255. .IP IPPROTO_UDP 16
  256. User datagram protocol.
  257. .P
  258. The
  259. .IR <netinet/in.h>
  260. header shall define the following symbolic constant for use as a
  261. local address in the structure passed to
  262. \fIbind\fR():
  263. .IP INADDR_ANY 16
  264. IPv4 wildcard address.
  265. .P
  266. The
  267. .IR <netinet/in.h>
  268. header shall define the following symbolic constant for use as a
  269. destination address in the structures passed to
  270. \fIconnect\fR(),
  271. \fIsendmsg\fR(),
  272. and
  273. \fIsendto\fR():
  274. .IP INADDR_BROADCAST 16
  275. IPv4 broadcast address.
  276. .P
  277. The
  278. .IR <netinet/in.h>
  279. header shall define the following symbolic constant, with the value
  280. specified, to help applications declare buffers of the proper size
  281. to store IPv4 addresses in string form:
  282. .IP INET_ADDRSTRLEN 16
  283. 16. Length of the string form for IP.
  284. .P
  285. The
  286. \fIhtonl\fR(),
  287. \fIhtons\fR(),
  288. \fIntohl\fR(),
  289. and
  290. \fIntohs\fR()
  291. functions shall be available as described in
  292. .IR <arpa/inet.h> .
  293. Inclusion of the
  294. .IR <netinet/in.h>
  295. header may also make visible all symbols from
  296. .IR <arpa/inet.h> .
  297. .P
  298. The
  299. .IR <netinet/in.h>
  300. header shall define the following symbolic constant, with the value
  301. specified, to help applications declare buffers of the proper size
  302. to store IPv6 addresses in string form:
  303. .IP INET6_ADDRSTRLEN 16
  304. 46. Length of the string form for IPv6.
  305. .br
  306. .P
  307. The
  308. .IR <netinet/in.h>
  309. header shall define the following symbolic constants, with distinct
  310. integer values, for use in the
  311. .IR option_name
  312. argument in the
  313. \fIgetsockopt\fR()
  314. or
  315. \fIsetsockopt\fR()
  316. functions at protocol level IPPROTO_IPV6:
  317. .IP IPV6_JOIN_GROUP 16
  318. Join a multicast group.
  319. .IP IPV6_LEAVE_GROUP 16
  320. Quit a multicast group.
  321. .IP IPV6_MULTICAST_HOPS 16
  322. .br
  323. Multicast hop limit.
  324. .IP IPV6_MULTICAST_IF 16
  325. Interface to use for outgoing multicast packets.
  326. .IP IPV6_MULTICAST_LOOP 16
  327. .br
  328. Multicast packets are delivered back to the local application.
  329. .IP IPV6_UNICAST_HOPS 16
  330. Unicast hop limit.
  331. .IP IPV6_V6ONLY 16
  332. Restrict AF_INET6 socket to IPv6 communications only.
  333. .P
  334. The
  335. .IR <netinet/in.h>
  336. header shall define the following macros that test for special IPv6
  337. addresses. Each macro is of type
  338. .BR int
  339. and takes a single argument of type
  340. .BR "const struct in6_addr *" :
  341. .IP IN6_IS_ADDR_UNSPECIFIED 6
  342. .br
  343. Unspecified address.
  344. .IP IN6_IS_ADDR_LOOPBACK 6
  345. .br
  346. Loopback address.
  347. .IP IN6_IS_ADDR_MULTICAST 6
  348. .br
  349. Multicast address.
  350. .IP IN6_IS_ADDR_LINKLOCAL 6
  351. .br
  352. Unicast link-local address.
  353. .IP IN6_IS_ADDR_SITELOCAL 6
  354. .br
  355. Unicast site-local address.
  356. .IP IN6_IS_ADDR_V4MAPPED 6
  357. .br
  358. IPv4 mapped address.
  359. .IP IN6_IS_ADDR_V4COMPAT 6
  360. .br
  361. IPv4-compatible address.
  362. .IP IN6_IS_ADDR_MC_NODELOCAL 6
  363. .br
  364. Multicast node-local address.
  365. .IP IN6_IS_ADDR_MC_LINKLOCAL 6
  366. .br
  367. Multicast link-local address.
  368. .IP IN6_IS_ADDR_MC_SITELOCAL 6
  369. .br
  370. Multicast site-local address.
  371. .IP IN6_IS_ADDR_MC_ORGLOCAL 6
  372. .br
  373. Multicast organization-local address.
  374. .IP IN6_IS_ADDR_MC_GLOBAL 6
  375. .br
  376. Multicast global address.
  377. .LP
  378. .IR "The following sections are informative."
  379. .SH "APPLICATION USAGE"
  380. Although applications are required to initialize all members
  381. (including any non-standard ones) of a
  382. .BR sockaddr_in6
  383. structure, the same is not required for the
  384. .BR sockaddr_in
  385. structure, since historically many applications only initialized
  386. the standard members. Despite this, applications are encouraged
  387. to initialize
  388. .BR sockaddr_in
  389. structures in a manner similar to the required initialization of
  390. .BR sockaddr_in6
  391. structures.
  392. .P
  393. Although it is common practice to initialize a
  394. .BR sockaddr_in6
  395. structure using:
  396. .sp
  397. .RS 4
  398. .nf
  399. struct sockaddr_in6 sa;
  400. memset(&sa, 0, sizeof sa);
  401. .fi
  402. .P
  403. .RE
  404. .P
  405. this method is not portable according to this standard, because the
  406. structure can contain pointer or floating-point members that are
  407. not required to have an all-bits-zero representation after default
  408. initialization. Portable methods make use of default initialization;
  409. for example:
  410. .sp
  411. .RS 4
  412. .nf
  413. struct sockaddr_in6 sa = { 0 };
  414. .fi
  415. .P
  416. .RE
  417. .P
  418. or:
  419. .sp
  420. .RS 4
  421. .nf
  422. static struct sockaddr_in6 sa_init;
  423. struct sockaddr_in6 sa = sa_init;
  424. .fi
  425. .P
  426. .RE
  427. .P
  428. A future version of this standard may require that a pointer object
  429. with an all-bits-zero representation is a null pointer, and that
  430. .BR sockaddr_in6
  431. does not have any floating-point members if a floating-point object
  432. with an all-bits-zero representation does not have the value 0.0.
  433. .SH "RATIONALE"
  434. The INADDR_ANY and INADDR_BROADCAST values are byte-order-neutral
  435. and thus their byte order is not specified. Many implementations
  436. have additional constants as extensions, such as INADDR_LOOPBACK,
  437. that are not byte-order-neutral. Traditionally, these constants
  438. are in host byte order, requiring the use of
  439. \fIhtonl\fR()
  440. when using them in a
  441. .BR sockaddr_in
  442. structure.
  443. .SH "FUTURE DIRECTIONS"
  444. None.
  445. .SH "SEE ALSO"
  446. .IR "Section 4.10" ", " "Host and Network Byte Orders",
  447. .IR "\fB<arpa_inet.h>\fP",
  448. .IR "\fB<inttypes.h>\fP",
  449. .IR "\fB<sys_socket.h>\fP"
  450. .P
  451. The System Interfaces volume of POSIX.1\(hy2017,
  452. .IR "\fIconnect\fR\^(\|)",
  453. .IR "\fIgetsockopt\fR\^(\|)",
  454. .IR "\fIhtonl\fR\^(\|)",
  455. .IR "\fIsendmsg\fR\^(\|)",
  456. .IR "\fIsendto\fR\^(\|)",
  457. .IR "\fIsetsockopt\fR\^(\|)"
  458. .\"
  459. .SH COPYRIGHT
  460. Portions of this text are reprinted and reproduced in electronic form
  461. from IEEE Std 1003.1-2017, Standard for Information Technology
  462. -- Portable Operating System Interface (POSIX), The Open Group Base
  463. Specifications Issue 7, 2018 Edition,
  464. Copyright (C) 2018 by the Institute of
  465. Electrical and Electronics Engineers, Inc and The Open Group.
  466. In the event of any discrepancy between this version and the original IEEE and
  467. The Open Group Standard, the original IEEE and The Open Group Standard
  468. is the referee document. The original Standard can be obtained online at
  469. http://www.opengroup.org/unix/online.html .
  470. .PP
  471. Any typographical or formatting errors that appear
  472. in this page are most likely
  473. to have been introduced during the conversion of the source files to
  474. man page format. To report such errors, see
  475. https://www.kernel.org/doc/man-pages/reporting_bugs.html .