github.com/afumu/libc@v0.0.6/musl/include/netinet/ip_icmp.h (about)

     1  #ifndef _NETINET_IP_ICMP_H
     2  #define _NETINET_IP_ICMP_H
     3  
     4  #include <stdint.h>
     5  #include <netinet/in.h>
     6  #include <netinet/ip.h>
     7  
     8  #ifdef __cplusplus
     9  extern "C" {
    10  #endif
    11  
    12  struct icmphdr {
    13  	uint8_t type;
    14  	uint8_t code;
    15  	uint16_t checksum;
    16  	union {
    17  		struct {
    18  			uint16_t id;
    19  			uint16_t sequence;
    20  		} echo;
    21  		uint32_t gateway;
    22  		struct {
    23  			uint16_t __unused;
    24  			uint16_t mtu;
    25  		} frag;
    26  		uint8_t reserved[4];
    27  	} un;
    28  };
    29  
    30  #define ICMP_ECHOREPLY		0
    31  #define ICMP_DEST_UNREACH	3
    32  #define ICMP_SOURCE_QUENCH	4
    33  #define ICMP_REDIRECT		5
    34  #define ICMP_ECHO		8
    35  #define ICMP_TIME_EXCEEDED	11
    36  #define ICMP_PARAMETERPROB	12
    37  #define ICMP_TIMESTAMP		13
    38  #define ICMP_TIMESTAMPREPLY	14
    39  #define ICMP_INFO_REQUEST	15
    40  #define ICMP_INFO_REPLY		16
    41  #define ICMP_ADDRESS		17
    42  #define ICMP_ADDRESSREPLY	18
    43  #define NR_ICMP_TYPES		18
    44  
    45  
    46  #define ICMP_NET_UNREACH	0
    47  #define ICMP_HOST_UNREACH	1
    48  #define ICMP_PROT_UNREACH	2
    49  #define ICMP_PORT_UNREACH	3
    50  #define ICMP_FRAG_NEEDED	4
    51  #define ICMP_SR_FAILED		5
    52  #define ICMP_NET_UNKNOWN	6
    53  #define ICMP_HOST_UNKNOWN	7
    54  #define ICMP_HOST_ISOLATED	8
    55  #define ICMP_NET_ANO		9
    56  #define ICMP_HOST_ANO		10
    57  #define ICMP_NET_UNR_TOS	11
    58  #define ICMP_HOST_UNR_TOS	12
    59  #define ICMP_PKT_FILTERED	13
    60  #define ICMP_PREC_VIOLATION	14
    61  #define ICMP_PREC_CUTOFF	15
    62  #define NR_ICMP_UNREACH		15
    63  
    64  #define ICMP_REDIR_NET		0
    65  #define ICMP_REDIR_HOST		1
    66  #define ICMP_REDIR_NETTOS	2
    67  #define ICMP_REDIR_HOSTTOS	3
    68  
    69  #define ICMP_EXC_TTL		0
    70  #define ICMP_EXC_FRAGTIME	1
    71  
    72  
    73  struct icmp_ra_addr {
    74  	uint32_t ira_addr;
    75  	uint32_t ira_preference;
    76  };
    77  
    78  struct icmp {
    79  	uint8_t  icmp_type;
    80  	uint8_t  icmp_code;
    81  	uint16_t icmp_cksum;
    82  	union {
    83  		uint8_t ih_pptr;
    84  		struct in_addr ih_gwaddr;
    85  		struct ih_idseq {
    86  			uint16_t icd_id;
    87  			uint16_t icd_seq;
    88  		} ih_idseq;
    89  		uint32_t ih_void;
    90  
    91  		struct ih_pmtu {
    92  			uint16_t ipm_void;
    93  			uint16_t ipm_nextmtu;
    94  		} ih_pmtu;
    95  
    96  		struct ih_rtradv {
    97  			uint8_t irt_num_addrs;
    98  			uint8_t irt_wpa;
    99  			uint16_t irt_lifetime;
   100  		} ih_rtradv;
   101  	} icmp_hun;
   102  	union {
   103  		struct {
   104  			uint32_t its_otime;
   105  			uint32_t its_rtime;
   106  			uint32_t its_ttime;
   107  		} id_ts;
   108  		struct {
   109  			struct ip idi_ip;
   110  		} id_ip;
   111  		struct icmp_ra_addr id_radv;
   112  		uint32_t   id_mask;
   113  		uint8_t    id_data[1];
   114  	} icmp_dun;
   115  };
   116  
   117  #define	icmp_pptr	icmp_hun.ih_pptr
   118  #define	icmp_gwaddr	icmp_hun.ih_gwaddr
   119  #define	icmp_id		icmp_hun.ih_idseq.icd_id
   120  #define	icmp_seq	icmp_hun.ih_idseq.icd_seq
   121  #define	icmp_void	icmp_hun.ih_void
   122  #define	icmp_pmvoid	icmp_hun.ih_pmtu.ipm_void
   123  #define	icmp_nextmtu	icmp_hun.ih_pmtu.ipm_nextmtu
   124  #define	icmp_num_addrs	icmp_hun.ih_rtradv.irt_num_addrs
   125  #define	icmp_wpa	icmp_hun.ih_rtradv.irt_wpa
   126  #define	icmp_lifetime	icmp_hun.ih_rtradv.irt_lifetime
   127  #define	icmp_otime	icmp_dun.id_ts.its_otime
   128  #define	icmp_rtime	icmp_dun.id_ts.its_rtime
   129  #define	icmp_ttime	icmp_dun.id_ts.its_ttime
   130  #define	icmp_ip		icmp_dun.id_ip.idi_ip
   131  #define	icmp_radv	icmp_dun.id_radv
   132  #define	icmp_mask	icmp_dun.id_mask
   133  #define	icmp_data	icmp_dun.id_data
   134  
   135  #define	ICMP_MINLEN	8
   136  #define	ICMP_TSLEN	(8 + 3 * sizeof (n_time))
   137  #define	ICMP_MASKLEN	12
   138  #define	ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)
   139  #define	ICMP_ADVLEN(p)	(8 + ((p)->icmp_ip.ip_hl << 2) + 8)
   140  
   141  #define	ICMP_UNREACH		3
   142  #define	ICMP_SOURCEQUENCH	4
   143  #define	ICMP_ROUTERADVERT	9
   144  #define	ICMP_ROUTERSOLICIT	10
   145  #define	ICMP_TIMXCEED		11
   146  #define	ICMP_PARAMPROB		12
   147  #define	ICMP_TSTAMP		13
   148  #define	ICMP_TSTAMPREPLY	14
   149  #define	ICMP_IREQ		15
   150  #define	ICMP_IREQREPLY		16
   151  #define	ICMP_MASKREQ		17
   152  #define	ICMP_MASKREPLY		18
   153  #define	ICMP_MAXTYPE		18
   154  
   155  #define	ICMP_UNREACH_NET	        0
   156  #define	ICMP_UNREACH_HOST	        1
   157  #define	ICMP_UNREACH_PROTOCOL	        2
   158  #define	ICMP_UNREACH_PORT	        3
   159  #define	ICMP_UNREACH_NEEDFRAG	        4
   160  #define	ICMP_UNREACH_SRCFAIL	        5
   161  #define	ICMP_UNREACH_NET_UNKNOWN        6
   162  #define	ICMP_UNREACH_HOST_UNKNOWN       7
   163  #define	ICMP_UNREACH_ISOLATED	        8
   164  #define	ICMP_UNREACH_NET_PROHIB	        9
   165  #define	ICMP_UNREACH_HOST_PROHIB        10
   166  #define	ICMP_UNREACH_TOSNET	        11
   167  #define	ICMP_UNREACH_TOSHOST	        12
   168  #define	ICMP_UNREACH_FILTER_PROHIB      13
   169  #define	ICMP_UNREACH_HOST_PRECEDENCE    14
   170  #define	ICMP_UNREACH_PRECEDENCE_CUTOFF  15
   171  
   172  #define	ICMP_REDIRECT_NET	0
   173  #define	ICMP_REDIRECT_HOST	1
   174  #define	ICMP_REDIRECT_TOSNET	2
   175  #define	ICMP_REDIRECT_TOSHOST	3
   176  
   177  #define	ICMP_TIMXCEED_INTRANS	0
   178  #define	ICMP_TIMXCEED_REASS	1
   179  
   180  #define	ICMP_PARAMPROB_OPTABSENT 1
   181  
   182  #define	ICMP_INFOTYPE(type) \
   183  	((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
   184  	(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
   185  	(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
   186  	(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
   187  	(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
   188  
   189  #ifdef __cplusplus
   190  }
   191  #endif
   192  
   193  #endif