1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #ifndef _NETINET_IP_ICMP_H_
36 #define _NETINET_IP_ICMP_H_
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 struct icmp_ra_addr {
54 n_long ira_addr;
55 n_long ira_preference;
56 };
57
58
59
60
61 struct icmp {
62 u_int8_t icmp_type;
63 u_int8_t icmp_code;
64 u_int16_t icmp_cksum;
65 union {
66 u_int8_t ih_pptr;
67 struct in_addr ih_gwaddr;
68 struct ih_idseq {
69 n_short icd_id;
70 n_short icd_seq;
71 } ih_idseq;
72 int32_t ih_void;
73
74
75 struct ih_pmtu {
76 n_short ipm_void;
77 n_short ipm_nextmtu;
78 } ih_pmtu;
79
80 struct ih_rtradv {
81 u_int8_t irt_num_addrs;
82 u_int8_t irt_wpa;
83 n_short irt_lifetime;
84 } ih_rtradv;
85 } icmp_hun;
86 #define icmp_pptr icmp_hun.ih_pptr
87 #define icmp_gwaddr icmp_hun.ih_gwaddr
88 #define icmp_id icmp_hun.ih_idseq.icd_id
89 #define icmp_seq icmp_hun.ih_idseq.icd_seq
90 #define icmp_void icmp_hun.ih_void
91 #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
92 #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
93 #define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
94 #define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
95 #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
96 union {
97 struct id_ts {
98 n_time its_otime;
99 n_time its_rtime;
100 n_time its_ttime;
101 } id_ts;
102 struct id_ip {
103 struct ip idi_ip;
104
105 } id_ip;
106 u_int32_t id_mask;
107 int8_t id_data[1];
108 } icmp_dun;
109 #define icmp_otime icmp_dun.id_ts.its_otime
110 #define icmp_rtime icmp_dun.id_ts.its_rtime
111 #define icmp_ttime icmp_dun.id_ts.its_ttime
112 #define icmp_ip icmp_dun.id_ip.idi_ip
113 #define icmp_mask icmp_dun.id_mask
114 #define icmp_data icmp_dun.id_data
115 };
116
117
118
119
120 #define ICMP_V6ADVLENMIN (8 + sizeof(struct ip) + 40)
121 #define ICMP_V6ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 40)
122
123
124
125
126
127
128
129
130
131 #define ICMP_MINLEN 8
132 #define ICMP_TSLEN (8 + 3 * sizeof (n_time))
133 #define ICMP_MASKLEN 12
134 #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8)
135 #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
136
137
138
139
140
141
142 #define ICMP_ECHOREPLY 0
143 #define ICMP_UNREACH 3
144 #define ICMP_UNREACH_NET 0
145 #define ICMP_UNREACH_HOST 1
146 #define ICMP_UNREACH_PROTOCOL 2
147 #define ICMP_UNREACH_PORT 3
148 #define ICMP_UNREACH_NEEDFRAG 4
149 #define ICMP_UNREACH_SRCFAIL 5
150 #define ICMP_UNREACH_NET_UNKNOWN 6
151 #define ICMP_UNREACH_HOST_UNKNOWN 7
152 #define ICMP_UNREACH_ISOLATED 8
153 #define ICMP_UNREACH_NET_PROHIB 9
154 #define ICMP_UNREACH_HOST_PROHIB 10
155 #define ICMP_UNREACH_TOSNET 11
156 #define ICMP_UNREACH_TOSHOST 12
157 #define ICMP_UNREACH_FILTER_PROHIB 13
158 #define ICMP_UNREACH_HOST_PRECEDENCE 14
159 #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
160 #define ICMP_SOURCEQUENCH 4
161 #define ICMP_REDIRECT 5
162 #define ICMP_REDIRECT_NET 0
163 #define ICMP_REDIRECT_HOST 1
164 #define ICMP_REDIRECT_TOSNET 2
165 #define ICMP_REDIRECT_TOSHOST 3
166 #define ICMP_ALTHOSTADDR 6
167 #define ICMP_ECHO 8
168 #define ICMP_ROUTERADVERT 9
169 #define ICMP_ROUTERADVERT_NORMAL 0
170 #define ICMP_ROUTERADVERT_NOROUTE_COMMON 16
171 #define ICMP_ROUTERSOLICIT 10
172 #define ICMP_TIMXCEED 11
173 #define ICMP_TIMXCEED_INTRANS 0
174 #define ICMP_TIMXCEED_REASS 1
175 #define ICMP_PARAMPROB 12
176 #define ICMP_PARAMPROB_ERRATPTR 0
177 #define ICMP_PARAMPROB_OPTABSENT 1
178 #define ICMP_PARAMPROB_LENGTH 2
179 #define ICMP_TSTAMP 13
180 #define ICMP_TSTAMPREPLY 14
181 #define ICMP_IREQ 15
182 #define ICMP_IREQREPLY 16
183 #define ICMP_MASKREQ 17
184 #define ICMP_MASKREPLY 18
185 #define ICMP_TRACEROUTE 30
186 #define ICMP_DATACONVERR 31
187 #define ICMP_MOBILE_REDIRECT 32
188 #define ICMP_IPV6_WHEREAREYOU 33
189 #define ICMP_IPV6_IAMHERE 34
190 #define ICMP_MOBILE_REGREQUEST 35
191 #define ICMP_MOBILE_REGREPLY 36
192 #define ICMP_SKIP 39
193 #define ICMP_PHOTURIS 40
194 #define ICMP_PHOTURIS_UNKNOWN_INDEX 1
195 #define ICMP_PHOTURIS_AUTH_FAILED 2
196 #define ICMP_PHOTURIS_DECRYPT_FAILED 3
197
198 #define ICMP_MAXTYPE 40
199
200 #define ICMP_INFOTYPE(type) \
201 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
202 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
203 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
204 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
205 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
206
207 #ifdef _KERNEL
208 struct mbuf *
209 icmp_do_error(struct mbuf *, int, int, n_long, int);
210 void icmp_error(struct mbuf *, int, int, n_long, int);
211 void icmp_input(struct mbuf *, ...);
212 void icmp_init(void);
213 void icmp_reflect(struct mbuf *);
214 void icmp_send(struct mbuf *, struct mbuf *);
215 int icmp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
216 struct rtentry *
217 icmp_mtudisc_clone(struct sockaddr *);
218 void icmp_mtudisc(struct icmp *);
219 #endif
220 #endif