Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4973 right-hear 1
#ifndef NETINET_IP_ICMP_H
2
#define NETINET_IP_ICMP_H
3
 
4
#include 
5
#include 
6
#include 
7
 
8
__BEGIN_DECLS
9
 
10
struct icmphdr {
11
  uint8_t type;		/* message type */
12
  uint8_t code;		/* type sub-code */
13
  uint16_t checksum;
14
  union {
15
    struct {
16
      uint16_t	id;
17
      uint16_t	sequence;
18
    } echo;			/* echo datagram */
19
    uint32_t	gateway;	/* gateway address */
20
    struct {
21
      uint16_t	__unused;
22
      uint16_t	mtu;
23
    } frag;			/* path mtu discovery */
24
  } un;
25
};
26
 
27
#define ICMP_ECHOREPLY		0	/* Echo Reply			*/
28
#define ICMP_DEST_UNREACH	3	/* Destination Unreachable	*/
29
#define ICMP_SOURCE_QUENCH	4	/* Source Quench		*/
30
#define ICMP_REDIRECT		5	/* Redirect (change route)	*/
31
#define ICMP_ECHO		8	/* Echo Request			*/
32
#define ICMP_TIME_EXCEEDED	11	/* Time Exceeded		*/
33
#define ICMP_PARAMETERPROB	12	/* Parameter Problem		*/
34
#define ICMP_TIMESTAMP		13	/* Timestamp Request		*/
35
#define ICMP_TIMESTAMPREPLY	14	/* Timestamp Reply		*/
36
#define ICMP_INFO_REQUEST	15	/* Information Request		*/
37
#define ICMP_INFO_REPLY		16	/* Information Reply		*/
38
#define ICMP_ADDRESS		17	/* Address Mask Request		*/
39
#define ICMP_ADDRESSREPLY	18	/* Address Mask Reply		*/
40
#define NR_ICMP_TYPES		18
41
 
42
 
43
/* Codes for UNREACH. */
44
#define ICMP_NET_UNREACH	0	/* Network Unreachable		*/
45
#define ICMP_HOST_UNREACH	1	/* Host Unreachable		*/
46
#define ICMP_PROT_UNREACH	2	/* Protocol Unreachable		*/
47
#define ICMP_PORT_UNREACH	3	/* Port Unreachable		*/
48
#define ICMP_FRAG_NEEDED	4	/* Fragmentation Needed/DF set	*/
49
#define ICMP_SR_FAILED		5	/* Source Route failed		*/
50
#define ICMP_NET_UNKNOWN	6
51
#define ICMP_HOST_UNKNOWN	7
52
#define ICMP_HOST_ISOLATED	8
53
#define ICMP_NET_ANO		9
54
#define ICMP_HOST_ANO		10
55
#define ICMP_NET_UNR_TOS	11
56
#define ICMP_HOST_UNR_TOS	12
57
#define ICMP_PKT_FILTERED	13	/* Packet filtered */
58
#define ICMP_PREC_VIOLATION	14	/* Precedence violation */
59
#define ICMP_PREC_CUTOFF	15	/* Precedence cut off */
60
#define NR_ICMP_UNREACH		15	/* instead of hardcoding immediate value */
61
 
62
/* Codes for REDIRECT. */
63
#define ICMP_REDIR_NET		0	/* Redirect Net			*/
64
#define ICMP_REDIR_HOST		1	/* Redirect Host		*/
65
#define ICMP_REDIR_NETTOS	2	/* Redirect Net for TOS		*/
66
#define ICMP_REDIR_HOSTTOS	3	/* Redirect Host for TOS	*/
67
 
68
/* Codes for TIME_EXCEEDED. */
69
#define ICMP_EXC_TTL		0	/* TTL count exceeded		*/
70
#define ICMP_EXC_FRAGTIME	1	/* Fragment Reass time exceeded	*/
71
 
72
/*
73
 * Lower bounds on packet lengths for various types.
74
 * For the error advice packets must first insure that the
75
 * packet is large enough to contain the returned ip header.
76
 * Only then can we do the check to see if 64 bits of packet
77
 * data have been returned, since we need to check the returned
78
 * ip header length.
79
 */
80
#define	ICMP_MINLEN	8				/* abs minimum */
81
#define	ICMP_TSLEN	(8 + 3 * sizeof (n_time))	/* timestamp */
82
#define	ICMP_MASKLEN	12				/* address mask */
83
#define	ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)	/* min */
84
#ifndef _IP_VHL
85
#define	ICMP_ADVLEN(p)	(8 + ((p)->icmp_ip.ip_hl << 2) + 8)
86
	/* N.B.: must separately check that ip_hl >= 5 */
87
#else
88
#define	ICMP_ADVLEN(p)	(8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8)
89
	/* N.B.: must separately check that header length >= 5 */
90
#endif
91
 
92
/* Definition of type and code fields. */
93
/* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */
94
#define	ICMP_UNREACH		3		/* dest unreachable, codes: */
95
#define	ICMP_SOURCEQUENCH	4		/* packet lost, slow down */
96
#define	ICMP_ROUTERADVERT	9		/* router advertisement */
97
#define	ICMP_ROUTERSOLICIT	10		/* router solicitation */
98
#define	ICMP_TIMXCEED		11		/* time exceeded, code: */
99
#define	ICMP_PARAMPROB		12		/* ip header bad */
100
#define	ICMP_TSTAMP		13		/* timestamp request */
101
#define	ICMP_TSTAMPREPLY	14		/* timestamp reply */
102
#define	ICMP_IREQ		15		/* information request */
103
#define	ICMP_IREQREPLY		16		/* information reply */
104
#define	ICMP_MASKREQ		17		/* address mask request */
105
#define	ICMP_MASKREPLY		18		/* address mask reply */
106
 
107
#define	ICMP_MAXTYPE		18
108
 
109
/* UNREACH codes */
110
#define	ICMP_UNREACH_NET	        0	/* bad net */
111
#define	ICMP_UNREACH_HOST	        1	/* bad host */
112
#define	ICMP_UNREACH_PROTOCOL	        2	/* bad protocol */
113
#define	ICMP_UNREACH_PORT	        3	/* bad port */
114
#define	ICMP_UNREACH_NEEDFRAG	        4	/* IP_DF caused drop */
115
#define	ICMP_UNREACH_SRCFAIL	        5	/* src route failed */
116
#define	ICMP_UNREACH_NET_UNKNOWN        6	/* unknown net */
117
#define	ICMP_UNREACH_HOST_UNKNOWN       7	/* unknown host */
118
#define	ICMP_UNREACH_ISOLATED	        8	/* src host isolated */
119
#define	ICMP_UNREACH_NET_PROHIB	        9	/* net denied */
120
#define	ICMP_UNREACH_HOST_PROHIB        10	/* host denied */
121
#define	ICMP_UNREACH_TOSNET	        11	/* bad tos for net */
122
#define	ICMP_UNREACH_TOSHOST	        12	/* bad tos for host */
123
#define	ICMP_UNREACH_FILTER_PROHIB      13	/* admin prohib */
124
#define	ICMP_UNREACH_HOST_PRECEDENCE    14	/* host prec vio. */
125
#define	ICMP_UNREACH_PRECEDENCE_CUTOFF  15	/* prec cutoff */
126
 
127
/* REDIRECT codes */
128
#define	ICMP_REDIRECT_NET	0		/* for network */
129
#define	ICMP_REDIRECT_HOST	1		/* for host */
130
#define	ICMP_REDIRECT_TOSNET	2		/* for tos and net */
131
#define	ICMP_REDIRECT_TOSHOST	3		/* for tos and host */
132
 
133
/* TIMEXCEED codes */
134
#define	ICMP_TIMXCEED_INTRANS	0		/* ttl==0 in transit */
135
#define	ICMP_TIMXCEED_REASS	1		/* ttl==0 in reass */
136
 
137
/* PARAMPROB code */
138
#define	ICMP_PARAMPROB_OPTABSENT 1		/* req. opt. absent */
139
 
140
#define	ICMP_INFOTYPE(type) \
141
	((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
142
	(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
143
	(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
144
	(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
145
	(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
146
 
147
__END_DECLS
148
 
149
#endif