icmpv6.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI_LINUX_ICMPV6_H
  3. #define _UAPI_LINUX_ICMPV6_H
  4. #include <linux/types.h>
  5. #include <asm/byteorder.h>
  6. struct icmp6hdr {
  7. __u8 icmp6_type;
  8. __u8 icmp6_code;
  9. __sum16 icmp6_cksum;
  10. union {
  11. __be32 un_data32[1];
  12. __be16 un_data16[2];
  13. __u8 un_data8[4];
  14. struct icmpv6_echo {
  15. __be16 identifier;
  16. __be16 sequence;
  17. } u_echo;
  18. struct icmpv6_nd_advt {
  19. #if defined(__LITTLE_ENDIAN_BITFIELD)
  20. __u32 reserved:5,
  21. override:1,
  22. solicited:1,
  23. router:1,
  24. reserved2:24;
  25. #elif defined(__BIG_ENDIAN_BITFIELD)
  26. __u32 router:1,
  27. solicited:1,
  28. override:1,
  29. reserved:29;
  30. #else
  31. #error "Please fix <asm/byteorder.h>"
  32. #endif
  33. } u_nd_advt;
  34. struct icmpv6_nd_ra {
  35. __u8 hop_limit;
  36. #if defined(__LITTLE_ENDIAN_BITFIELD)
  37. __u8 reserved:3,
  38. router_pref:2,
  39. home_agent:1,
  40. other:1,
  41. managed:1;
  42. #elif defined(__BIG_ENDIAN_BITFIELD)
  43. __u8 managed:1,
  44. other:1,
  45. home_agent:1,
  46. router_pref:2,
  47. reserved:3;
  48. #else
  49. #error "Please fix <asm/byteorder.h>"
  50. #endif
  51. __be16 rt_lifetime;
  52. } u_nd_ra;
  53. } icmp6_dataun;
  54. #define icmp6_identifier icmp6_dataun.u_echo.identifier
  55. #define icmp6_sequence icmp6_dataun.u_echo.sequence
  56. #define icmp6_pointer icmp6_dataun.un_data32[0]
  57. #define icmp6_mtu icmp6_dataun.un_data32[0]
  58. #define icmp6_unused icmp6_dataun.un_data32[0]
  59. #define icmp6_maxdelay icmp6_dataun.un_data16[0]
  60. #define icmp6_datagram_len icmp6_dataun.un_data8[0]
  61. #define icmp6_router icmp6_dataun.u_nd_advt.router
  62. #define icmp6_solicited icmp6_dataun.u_nd_advt.solicited
  63. #define icmp6_override icmp6_dataun.u_nd_advt.override
  64. #define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved
  65. #define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit
  66. #define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed
  67. #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
  68. #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
  69. #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref
  70. };
  71. #define ICMPV6_ROUTER_PREF_LOW 0x3
  72. #define ICMPV6_ROUTER_PREF_MEDIUM 0x0
  73. #define ICMPV6_ROUTER_PREF_HIGH 0x1
  74. #define ICMPV6_ROUTER_PREF_INVALID 0x2
  75. #define ICMPV6_DEST_UNREACH 1
  76. #define ICMPV6_PKT_TOOBIG 2
  77. #define ICMPV6_TIME_EXCEED 3
  78. #define ICMPV6_PARAMPROB 4
  79. #define ICMPV6_ERRMSG_MAX 127
  80. #define ICMPV6_INFOMSG_MASK 0x80
  81. #define ICMPV6_ECHO_REQUEST 128
  82. #define ICMPV6_ECHO_REPLY 129
  83. #define ICMPV6_MGM_QUERY 130
  84. #define ICMPV6_MGM_REPORT 131
  85. #define ICMPV6_MGM_REDUCTION 132
  86. #define ICMPV6_NI_QUERY 139
  87. #define ICMPV6_NI_REPLY 140
  88. #define ICMPV6_MLD2_REPORT 143
  89. #define ICMPV6_DHAAD_REQUEST 144
  90. #define ICMPV6_DHAAD_REPLY 145
  91. #define ICMPV6_MOBILE_PREFIX_SOL 146
  92. #define ICMPV6_MOBILE_PREFIX_ADV 147
  93. #define ICMPV6_MRDISC_ADV 151
  94. #define ICMPV6_MSG_MAX 255
  95. /*
  96. * Codes for Destination Unreachable
  97. */
  98. #define ICMPV6_NOROUTE 0
  99. #define ICMPV6_ADM_PROHIBITED 1
  100. #define ICMPV6_NOT_NEIGHBOUR 2
  101. #define ICMPV6_ADDR_UNREACH 3
  102. #define ICMPV6_PORT_UNREACH 4
  103. #define ICMPV6_POLICY_FAIL 5
  104. #define ICMPV6_REJECT_ROUTE 6
  105. /*
  106. * Codes for Time Exceeded
  107. */
  108. #define ICMPV6_EXC_HOPLIMIT 0
  109. #define ICMPV6_EXC_FRAGTIME 1
  110. /*
  111. * Codes for Parameter Problem
  112. */
  113. #define ICMPV6_HDR_FIELD 0
  114. #define ICMPV6_UNK_NEXTHDR 1
  115. #define ICMPV6_UNK_OPTION 2
  116. #define ICMPV6_HDR_INCOMP 3
  117. /* Codes for EXT_ECHO (PROBE) */
  118. #define ICMPV6_EXT_ECHO_REQUEST 160
  119. #define ICMPV6_EXT_ECHO_REPLY 161
  120. /*
  121. * constants for (set|get)sockopt
  122. */
  123. #define ICMPV6_FILTER 1
  124. /*
  125. * ICMPV6 filter
  126. */
  127. #define ICMPV6_FILTER_BLOCK 1
  128. #define ICMPV6_FILTER_PASS 2
  129. #define ICMPV6_FILTER_BLOCKOTHERS 3
  130. #define ICMPV6_FILTER_PASSONLY 4
  131. struct icmp6_filter {
  132. __u32 data[8];
  133. };
  134. /*
  135. * Definitions for MLDv2
  136. */
  137. #define MLD2_MODE_IS_INCLUDE 1
  138. #define MLD2_MODE_IS_EXCLUDE 2
  139. #define MLD2_CHANGE_TO_INCLUDE 3
  140. #define MLD2_CHANGE_TO_EXCLUDE 4
  141. #define MLD2_ALLOW_NEW_SOURCES 5
  142. #define MLD2_BLOCK_OLD_SOURCES 6
  143. #define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } }
  144. #endif /* _UAPI_LINUX_ICMPV6_H */