icmp.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * INET An implementation of the TCP/IP protocol suite for the LINUX
  4. * operating system. INET is implemented using the BSD Socket
  5. * interface as the means of communication with the user level.
  6. *
  7. * Definitions for the ICMP protocol.
  8. *
  9. * Version: @(#)icmp.h 1.0.3 04/28/93
  10. *
  11. * Author: Fred N. van Kempen, <[email protected]>
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version
  16. * 2 of the License, or (at your option) any later version.
  17. */
  18. #ifndef _UAPI_LINUX_ICMP_H
  19. #define _UAPI_LINUX_ICMP_H
  20. #include <linux/types.h>
  21. #include <asm/byteorder.h>
  22. #include <linux/if.h>
  23. #include <linux/in6.h>
  24. #define ICMP_ECHOREPLY 0 /* Echo Reply */
  25. #define ICMP_DEST_UNREACH 3 /* Destination Unreachable */
  26. #define ICMP_SOURCE_QUENCH 4 /* Source Quench */
  27. #define ICMP_REDIRECT 5 /* Redirect (change route) */
  28. #define ICMP_ECHO 8 /* Echo Request */
  29. #define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */
  30. #define ICMP_PARAMETERPROB 12 /* Parameter Problem */
  31. #define ICMP_TIMESTAMP 13 /* Timestamp Request */
  32. #define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */
  33. #define ICMP_INFO_REQUEST 15 /* Information Request */
  34. #define ICMP_INFO_REPLY 16 /* Information Reply */
  35. #define ICMP_ADDRESS 17 /* Address Mask Request */
  36. #define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */
  37. #define NR_ICMP_TYPES 18
  38. /* Codes for UNREACH. */
  39. #define ICMP_NET_UNREACH 0 /* Network Unreachable */
  40. #define ICMP_HOST_UNREACH 1 /* Host Unreachable */
  41. #define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */
  42. #define ICMP_PORT_UNREACH 3 /* Port Unreachable */
  43. #define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */
  44. #define ICMP_SR_FAILED 5 /* Source Route failed */
  45. #define ICMP_NET_UNKNOWN 6
  46. #define ICMP_HOST_UNKNOWN 7
  47. #define ICMP_HOST_ISOLATED 8
  48. #define ICMP_NET_ANO 9
  49. #define ICMP_HOST_ANO 10
  50. #define ICMP_NET_UNR_TOS 11
  51. #define ICMP_HOST_UNR_TOS 12
  52. #define ICMP_PKT_FILTERED 13 /* Packet filtered */
  53. #define ICMP_PREC_VIOLATION 14 /* Precedence violation */
  54. #define ICMP_PREC_CUTOFF 15 /* Precedence cut off */
  55. #define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */
  56. /* Codes for REDIRECT. */
  57. #define ICMP_REDIR_NET 0 /* Redirect Net */
  58. #define ICMP_REDIR_HOST 1 /* Redirect Host */
  59. #define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */
  60. #define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */
  61. /* Codes for TIME_EXCEEDED. */
  62. #define ICMP_EXC_TTL 0 /* TTL count exceeded */
  63. #define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */
  64. /* Codes for EXT_ECHO (PROBE) */
  65. #define ICMP_EXT_ECHO 42
  66. #define ICMP_EXT_ECHOREPLY 43
  67. #define ICMP_EXT_CODE_MAL_QUERY 1 /* Malformed Query */
  68. #define ICMP_EXT_CODE_NO_IF 2 /* No such Interface */
  69. #define ICMP_EXT_CODE_NO_TABLE_ENT 3 /* No such Table Entry */
  70. #define ICMP_EXT_CODE_MULT_IFS 4 /* Multiple Interfaces Satisfy Query */
  71. /* Constants for EXT_ECHO (PROBE) */
  72. #define ICMP_EXT_ECHOREPLY_ACTIVE (1 << 2)/* active bit in reply message */
  73. #define ICMP_EXT_ECHOREPLY_IPV4 (1 << 1)/* ipv4 bit in reply message */
  74. #define ICMP_EXT_ECHOREPLY_IPV6 1 /* ipv6 bit in reply message */
  75. #define ICMP_EXT_ECHO_CTYPE_NAME 1
  76. #define ICMP_EXT_ECHO_CTYPE_INDEX 2
  77. #define ICMP_EXT_ECHO_CTYPE_ADDR 3
  78. #define ICMP_AFI_IP 1 /* Address Family Identifier for ipv4 */
  79. #define ICMP_AFI_IP6 2 /* Address Family Identifier for ipv6 */
  80. struct icmphdr {
  81. __u8 type;
  82. __u8 code;
  83. __sum16 checksum;
  84. union {
  85. struct {
  86. __be16 id;
  87. __be16 sequence;
  88. } echo;
  89. __be32 gateway;
  90. struct {
  91. #ifdef __BIONIC__
  92. __be16 __linux_unused;
  93. #else
  94. __be16 __unused;
  95. #endif
  96. __be16 mtu;
  97. } frag;
  98. __u8 reserved[4];
  99. } un;
  100. };
  101. /*
  102. * constants for (set|get)sockopt
  103. */
  104. #define ICMP_FILTER 1
  105. struct icmp_filter {
  106. __u32 data;
  107. };
  108. /* RFC 4884 extension struct: one per message */
  109. struct icmp_ext_hdr {
  110. #if defined(__LITTLE_ENDIAN_BITFIELD)
  111. __u8 reserved1:4,
  112. version:4;
  113. #elif defined(__BIG_ENDIAN_BITFIELD)
  114. __u8 version:4,
  115. reserved1:4;
  116. #else
  117. #error "Please fix <asm/byteorder.h>"
  118. #endif
  119. __u8 reserved2;
  120. __sum16 checksum;
  121. };
  122. /* RFC 4884 extension object header: one for each object */
  123. struct icmp_extobj_hdr {
  124. __be16 length;
  125. __u8 class_num;
  126. __u8 class_type;
  127. };
  128. /* RFC 8335: 2.1 Header for c-type 3 payload */
  129. struct icmp_ext_echo_ctype3_hdr {
  130. __be16 afi;
  131. __u8 addrlen;
  132. __u8 reserved;
  133. };
  134. /* RFC 8335: 2.1 Interface Identification Object */
  135. struct icmp_ext_echo_iio {
  136. struct icmp_extobj_hdr extobj_hdr;
  137. union {
  138. char name[IFNAMSIZ];
  139. __be32 ifindex;
  140. struct {
  141. struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
  142. union {
  143. __be32 ipv4_addr;
  144. struct in6_addr ipv6_addr;
  145. } ip_addr;
  146. } addr;
  147. } ident;
  148. };
  149. #endif /* _UAPI_LINUX_ICMP_H */