Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  * INET     An implementation of the TCP/IP protocol suite for the LINUX
0004  *      operating system.  INET is implemented using the  BSD Socket
0005  *      interface as the means of communication with the user level.
0006  *
0007  *      Definitions for the ICMP protocol.
0008  *
0009  * Version: @(#)icmp.h  1.0.3   04/28/93
0010  *
0011  * Author:  Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
0012  *
0013  *      This program is free software; you can redistribute it and/or
0014  *      modify it under the terms of the GNU General Public License
0015  *      as published by the Free Software Foundation; either version
0016  *      2 of the License, or (at your option) any later version.
0017  */
0018 #ifndef _UAPI_LINUX_ICMP_H
0019 #define _UAPI_LINUX_ICMP_H
0020 
0021 #include <linux/types.h>
0022 #include <asm/byteorder.h>
0023 #include <linux/if.h>
0024 #include <linux/in6.h>
0025 
0026 #define ICMP_ECHOREPLY      0   /* Echo Reply           */
0027 #define ICMP_DEST_UNREACH   3   /* Destination Unreachable  */
0028 #define ICMP_SOURCE_QUENCH  4   /* Source Quench        */
0029 #define ICMP_REDIRECT       5   /* Redirect (change route)  */
0030 #define ICMP_ECHO       8   /* Echo Request         */
0031 #define ICMP_TIME_EXCEEDED  11  /* Time Exceeded        */
0032 #define ICMP_PARAMETERPROB  12  /* Parameter Problem        */
0033 #define ICMP_TIMESTAMP      13  /* Timestamp Request        */
0034 #define ICMP_TIMESTAMPREPLY 14  /* Timestamp Reply      */
0035 #define ICMP_INFO_REQUEST   15  /* Information Request      */
0036 #define ICMP_INFO_REPLY     16  /* Information Reply        */
0037 #define ICMP_ADDRESS        17  /* Address Mask Request     */
0038 #define ICMP_ADDRESSREPLY   18  /* Address Mask Reply       */
0039 #define NR_ICMP_TYPES       18
0040 
0041 
0042 /* Codes for UNREACH. */
0043 #define ICMP_NET_UNREACH    0   /* Network Unreachable      */
0044 #define ICMP_HOST_UNREACH   1   /* Host Unreachable     */
0045 #define ICMP_PROT_UNREACH   2   /* Protocol Unreachable     */
0046 #define ICMP_PORT_UNREACH   3   /* Port Unreachable     */
0047 #define ICMP_FRAG_NEEDED    4   /* Fragmentation Needed/DF set  */
0048 #define ICMP_SR_FAILED      5   /* Source Route failed      */
0049 #define ICMP_NET_UNKNOWN    6
0050 #define ICMP_HOST_UNKNOWN   7
0051 #define ICMP_HOST_ISOLATED  8
0052 #define ICMP_NET_ANO        9
0053 #define ICMP_HOST_ANO       10
0054 #define ICMP_NET_UNR_TOS    11
0055 #define ICMP_HOST_UNR_TOS   12
0056 #define ICMP_PKT_FILTERED   13  /* Packet filtered */
0057 #define ICMP_PREC_VIOLATION 14  /* Precedence violation */
0058 #define ICMP_PREC_CUTOFF    15  /* Precedence cut off */
0059 #define NR_ICMP_UNREACH     15  /* instead of hardcoding immediate value */
0060 
0061 /* Codes for REDIRECT. */
0062 #define ICMP_REDIR_NET      0   /* Redirect Net         */
0063 #define ICMP_REDIR_HOST     1   /* Redirect Host        */
0064 #define ICMP_REDIR_NETTOS   2   /* Redirect Net for TOS     */
0065 #define ICMP_REDIR_HOSTTOS  3   /* Redirect Host for TOS    */
0066 
0067 /* Codes for TIME_EXCEEDED. */
0068 #define ICMP_EXC_TTL        0   /* TTL count exceeded       */
0069 #define ICMP_EXC_FRAGTIME   1   /* Fragment Reass time exceeded */
0070 
0071 /* Codes for EXT_ECHO (PROBE) */
0072 #define ICMP_EXT_ECHO           42
0073 #define ICMP_EXT_ECHOREPLY      43
0074 #define ICMP_EXT_CODE_MAL_QUERY     1   /* Malformed Query */
0075 #define ICMP_EXT_CODE_NO_IF     2   /* No such Interface */
0076 #define ICMP_EXT_CODE_NO_TABLE_ENT  3   /* No such Table Entry */
0077 #define ICMP_EXT_CODE_MULT_IFS      4   /* Multiple Interfaces Satisfy Query */
0078 
0079 /* Constants for EXT_ECHO (PROBE) */
0080 #define ICMP_EXT_ECHOREPLY_ACTIVE   (1 << 2)/* active bit in reply message */
0081 #define ICMP_EXT_ECHOREPLY_IPV4     (1 << 1)/* ipv4 bit in reply message */
0082 #define ICMP_EXT_ECHOREPLY_IPV6     1   /* ipv6 bit in reply message */
0083 #define ICMP_EXT_ECHO_CTYPE_NAME    1
0084 #define ICMP_EXT_ECHO_CTYPE_INDEX   2
0085 #define ICMP_EXT_ECHO_CTYPE_ADDR    3
0086 #define ICMP_AFI_IP         1   /* Address Family Identifier for ipv4 */
0087 #define ICMP_AFI_IP6            2   /* Address Family Identifier for ipv6 */
0088 
0089 struct icmphdr {
0090   __u8      type;
0091   __u8      code;
0092   __sum16   checksum;
0093   union {
0094     struct {
0095         __be16  id;
0096         __be16  sequence;
0097     } echo;
0098     __be32  gateway;
0099     struct {
0100         __be16  __unused;
0101         __be16  mtu;
0102     } frag;
0103     __u8    reserved[4];
0104   } un;
0105 };
0106 
0107 
0108 /*
0109  *  constants for (set|get)sockopt
0110  */
0111 
0112 #define ICMP_FILTER         1
0113 
0114 struct icmp_filter {
0115     __u32       data;
0116 };
0117 
0118 /* RFC 4884 extension struct: one per message */
0119 struct icmp_ext_hdr {
0120 #if defined(__LITTLE_ENDIAN_BITFIELD)
0121     __u8        reserved1:4,
0122             version:4;
0123 #elif defined(__BIG_ENDIAN_BITFIELD)
0124     __u8        version:4,
0125             reserved1:4;
0126 #else
0127 #error  "Please fix <asm/byteorder.h>"
0128 #endif
0129     __u8        reserved2;
0130     __sum16     checksum;
0131 };
0132 
0133 /* RFC 4884 extension object header: one for each object */
0134 struct icmp_extobj_hdr {
0135     __be16      length;
0136     __u8        class_num;
0137     __u8        class_type;
0138 };
0139 
0140 /* RFC 8335: 2.1 Header for c-type 3 payload */
0141 struct icmp_ext_echo_ctype3_hdr {
0142     __be16      afi;
0143     __u8        addrlen;
0144     __u8        reserved;
0145 };
0146 
0147 /* RFC 8335: 2.1 Interface Identification Object */
0148 struct icmp_ext_echo_iio {
0149     struct icmp_extobj_hdr extobj_hdr;
0150     union {
0151         char name[IFNAMSIZ];
0152         __be32 ifindex;
0153         struct {
0154             struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
0155             union {
0156                 __be32      ipv4_addr;
0157                 struct in6_addr ipv6_addr;
0158             } ip_addr;
0159         } addr;
0160     } ident;
0161 };
0162 #endif /* _UAPI_LINUX_ICMP_H */