in.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* Copyright (C) 1997-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /* Generic version. */
  15. #ifndef _NETINET_IN_H
  16. # error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
  17. #endif
  18. /* This is the generic version, do not assume a linux-based kernel. */
  19. #define __USE_KERNEL_IPV6_DEFS 0
  20. /* To select the IP level. */
  21. #define SOL_IP 0
  22. /* Options for use with `getsockopt' and `setsockopt' at the IP level.
  23. The first word in the comment at the right is the data type used;
  24. "bool" means a boolean value stored in an `int'. */
  25. #define IP_OPTIONS 1 /* ip_opts; IP per-packet options. */
  26. #define IP_HDRINCL 2 /* int; Header is included with data. */
  27. #define IP_TOS 3 /* int; IP type of service and precedence. */
  28. #define IP_TTL 4 /* int; IP time to live. */
  29. #define IP_RECVOPTS 5 /* bool; Receive all IP options w/datagram. */
  30. #define IP_RECVRETOPTS 6 /* bool; Receive IP options for response. */
  31. #define IP_RECVDSTADDR 7 /* bool; Receive IP dst addr w/datagram. */
  32. #define IP_RETOPTS 8 /* ip_opts; Set/get IP per-packet options. */
  33. #define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */
  34. #define IP_MULTICAST_TTL 10 /* unsigned char; set/get IP multicast ttl */
  35. #define IP_MULTICAST_LOOP 11 /* bool; set/get IP multicast loopback */
  36. #define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
  37. #define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */
  38. /* IP_MTU_DISCOVER arguments. */
  39. #define IP_PMTUDISC_DONT 0 /* Never send DF frames. */
  40. #define IP_PMTUDISC_WANT 1 /* Use per route hints. */
  41. #define IP_PMTUDISC_DO 2 /* Always DF. */
  42. #define IP_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */
  43. /* Always use interface mtu (ignores dst pmtu) but don't set DF flag.
  44. Also incoming ICMP frag_needed notifications will be ignored on
  45. this socket to prevent accepting spoofed ones. */
  46. #define IP_PMTUDISC_INTERFACE 4
  47. /* Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented. */
  48. #define IP_PMTUDISC_OMIT 5
  49. #ifdef __USE_MISC
  50. /* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
  51. The `ip_dst' field is used for the first-hop gateway when using a
  52. source route (this gets put into the header proper). */
  53. struct ip_opts
  54. {
  55. struct in_addr ip_dst; /* First hop; zero without source route. */
  56. char ip_opts[40]; /* Actually variable in size. */
  57. };
  58. #endif
  59. /* Socket-level values for IPv6. */
  60. #define SOL_IPV6 41
  61. #define SOL_ICMPV6 58
  62. /* IPV6 socket options. */
  63. #define IPV6_ADDRFORM 1
  64. #define IPV6_2292PKTINFO 2
  65. #define IPV6_2292HOPOPTS 3
  66. #define IPV6_2292DSTOPTS 4
  67. #define IPV6_2292RTHDR 5
  68. #define IPV6_2292PKTOPTIONS 6
  69. #define IPV6_CHECKSUM 7
  70. #define IPV6_2292HOPLIMIT 8
  71. #define IPV6_RXINFO IPV6_2292PKTINFO
  72. #define IPV6_TXINFO IPV6_RXINFO
  73. #define SCM_SRCINFO IPV6_TXINFO
  74. #define SCM_SRCRT IPV6_RXSRCRT
  75. #define IPV6_UNICAST_HOPS 16
  76. #define IPV6_MULTICAST_IF 17
  77. #define IPV6_MULTICAST_HOPS 18
  78. #define IPV6_MULTICAST_LOOP 19
  79. #define IPV6_JOIN_GROUP 20
  80. #define IPV6_LEAVE_GROUP 21
  81. #define IPV6_ROUTER_ALERT 22
  82. #define IPV6_MTU_DISCOVER 23
  83. #define IPV6_MTU 24
  84. #define IPV6_RECVERR 25
  85. #define IPV6_V6ONLY 26
  86. #define IPV6_JOIN_ANYCAST 27
  87. #define IPV6_LEAVE_ANYCAST 28
  88. /* IPV6_MTU_DISCOVER values. */
  89. #define IPV6_PMTUDISC_DONT 0 /* Never send DF frames. */
  90. #define IPV6_PMTUDISC_WANT 1 /* Use per route hints. */
  91. #define IPV6_PMTUDISC_DO 2 /* Always DF. */
  92. #define IPV6_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */
  93. #define IPV6_PMTUDISC_INTERFACE 4 /* See IP_PMTUDISC_INTERFACE. */
  94. #define IPV6_PMTUDISC_OMIT 5 /* See IP_PMTUDISC_OMIT. */
  95. /* Advanced API (RFC3542) (1). */
  96. #define IPV6_RECVPKTINFO 49
  97. #define IPV6_PKTINFO 50
  98. #define IPV6_RECVHOPLIMIT 51
  99. #define IPV6_HOPLIMIT 52
  100. #define IPV6_RECVHOPOPTS 53
  101. #define IPV6_HOPOPTS 54
  102. #define IPV6_RTHDRDSTOPTS 55
  103. #define IPV6_RECVRTHDR 56
  104. #define IPV6_RTHDR 57
  105. #define IPV6_RECVDSTOPTS 58
  106. #define IPV6_DSTOPTS 59
  107. #define IPV6_RECVPATHMTU 60
  108. #define IPV6_PATHMTU 61
  109. #define IPV6_DONTFRAG 62
  110. /* Advanced API (RFC3542) (2). */
  111. #define IPV6_RECVTCLASS 66
  112. #define IPV6_TCLASS 67
  113. /* RFC5014. */
  114. #define IPV6_ADDR_PREFERENCES 72
  115. /* RFC5082. */
  116. #define IPV6_MINHOPCOUNT 73
  117. /* Obsolete synonyms for the above. */
  118. #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
  119. #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
  120. #define IPV6_RXHOPOPTS IPV6_2292HOPOPTS
  121. #define IPV6_RXDSTOPTS IPV6_2292DSTOPTS
  122. /* Routing header options for IPv6. */
  123. #define IPV6_RTHDR_LOOSE 0 /* Hop doesn't need to be neighbour. */
  124. #define IPV6_RTHDR_STRICT 1 /* Hop must be a neighbour. */
  125. #define IPV6_RTHDR_TYPE_0 0 /* IPv6 Routing header type 0. */