Subversion Repositories SvarDOS

Rev

Rev 616 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
207 mateuszvis 1
/*!\file netinet/icmp6.h
2
 * ICMP for IPv6.
3
 */
4
 
5
/*      $FreeBSD: src/sys/netinet/icmp6.h,v 1.8 2002/05/06 16:28:25 ume Exp $   */
6
/*      $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $  */
7
 
8
/*
9
 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
10
 * All rights reserved.
11
 *
12
 * Redistribution and use in source and binary forms, with or without
13
 * modification, are permitted provided that the following conditions
14
 * are met:
15
 * 1. Redistributions of source code must retain the above copyright
16
 *    notice, this list of conditions and the following disclaimer.
17
 * 2. Redistributions in binary form must reproduce the above copyright
18
 *    notice, this list of conditions and the following disclaimer in the
19
 *    documentation and/or other materials provided with the distribution.
20
 * 3. Neither the name of the project nor the names of its contributors
21
 *    may be used to endorse or promote products derived from this software
22
 *    without specific prior written permission.
23
 *
24
 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
25
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
28
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34
 * SUCH DAMAGE.
35
 */
36
 
37
/*
38
 * Copyright (c) 1982, 1986, 1993
39
 *      The Regents of the University of California.  All rights reserved.
40
 *
41
 * Redistribution and use in source and binary forms, with or without
42
 * modification, are permitted provided that the following conditions
43
 * are met:
44
 * 1. Redistributions of source code must retain the above copyright
45
 *    notice, this list of conditions and the following disclaimer.
46
 * 2. Redistributions in binary form must reproduce the above copyright
47
 *    notice, this list of conditions and the following disclaimer in the
48
 *    documentation and/or other materials provided with the distribution.
49
 * 3. All advertising materials mentioning features or use of this software
50
 *    must display the following acknowledgement:
51
 *      This product includes software developed by the University of
52
 *      California, Berkeley and its contributors.
53
 * 4. Neither the name of the University nor the names of its contributors
54
 *    may be used to endorse or promote products derived from this software
55
 *    without specific prior written permission.
56
 *
57
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
58
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
61
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
62
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
63
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
65
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
66
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67
 * SUCH DAMAGE.
68
 *
69
 *      @(#)ip_icmp.h   8.1 (Berkeley) 6/10/93
70
 */
71
 
72
#ifndef _NETINET_ICMP6_H_
73
#define _NETINET_ICMP6_H_
74
 
75
#ifndef __SYS_WTYPES_H
76
#include <sys/wtypes.h>
77
#endif
78
 
79
#define ICMPV6_PLD_MAXLEN       1232    /* IPV6_MMTU - sizeof(struct ip6_hdr)
80
                                           - sizeof(struct icmp6_hdr) */
81
#include <sys/packon.h>
82
 
83
struct icmp6_hdr {
84
        u_int8_t        icmp6_type;     /* type field */
85
        u_int8_t        icmp6_code;     /* code field */
86
        u_int16_t       icmp6_cksum;    /* checksum field */
87
        union {
88
          u_int32_t     icmp6_un_data32[1]; /* type-specific field */
89
          u_int16_t     icmp6_un_data16[2]; /* type-specific field */
90
          u_int8_t      icmp6_un_data8[4];  /* type-specific field */
91
        } icmp6_dataun;
92
};
93
 
94
#define icmp6_data32    icmp6_dataun.icmp6_un_data32
95
#define icmp6_data16    icmp6_dataun.icmp6_un_data16
96
#define icmp6_data8     icmp6_dataun.icmp6_un_data8
97
#define icmp6_pptr      icmp6_data32[0]         /* parameter prob */
98
#define icmp6_mtu       icmp6_data32[0]         /* packet too big */
99
#define icmp6_id        icmp6_data16[0]         /* echo request/reply */
100
#define icmp6_seq       icmp6_data16[1]         /* echo request/reply */
101
#define icmp6_maxdelay  icmp6_data16[0]         /* mcast group membership */
102
 
103
#define ICMP6_DST_UNREACH               1       /* dest unreachable, codes: */
104
#define ICMP6_PACKET_TOO_BIG            2       /* packet too big */
105
#define ICMP6_TIME_EXCEEDED             3       /* time exceeded, code: */
106
#define ICMP6_PARAM_PROB                4       /* ip6 header bad */
107
 
108
#define ICMP6_ECHO_REQUEST              128     /* echo service */
109
#define ICMP6_ECHO_REPLY                129     /* echo reply */
110
#define ICMP6_MEMBERSHIP_QUERY          130     /* group membership query */
111
#define MLD_LISTENER_QUERY              130     /* multicast listener query */
112
#define ICMP6_MEMBERSHIP_REPORT         131     /* group membership report */
113
#define MLD_LISTENER_REPORT             131     /* multicast listener report */
114
#define ICMP6_MEMBERSHIP_REDUCTION      132     /* group membership termination */
115
#define MLD_LISTENER_DONE               132     /* multicast listener done */
116
 
117
#ifndef _KERNEL
118
/* the followings are for backward compatibility to old KAME apps. */
119
#define MLD6_LISTENER_QUERY     MLD_LISTENER_QUERY
120
#define MLD6_LISTENER_REPORT    MLD_LISTENER_REPORT
121
#define MLD6_LISTENER_DONE      MLD_LISTENER_DONE
122
#endif
123
 
124
#define ND_ROUTER_SOLICIT               133     /* router solicitation */
125
#define ND_ROUTER_ADVERT                134     /* router advertisment */
126
#define ND_NEIGHBOR_SOLICIT             135     /* neighbor solicitation */
127
#define ND_NEIGHBOR_ADVERT              136     /* neighbor advertisment */
128
#define ND_REDIRECT                     137     /* redirect */
129
 
130
#define ICMP6_ROUTER_RENUMBERING        138     /* router renumbering */
131
 
132
#define ICMP6_WRUREQUEST                139     /* who are you request */
133
#define ICMP6_WRUREPLY                  140     /* who are you reply */
134
#define ICMP6_FQDN_QUERY                139     /* FQDN query */
135
#define ICMP6_FQDN_REPLY                140     /* FQDN reply */
136
#define ICMP6_NI_QUERY                  139     /* node information request */
137
#define ICMP6_NI_REPLY                  140     /* node information reply */
138
 
139
/* The definitions below are experimental. TBA */
140
#define MLD_MTRACE_RESP                 200     /* mtrace resp (to sender) */
141
#define MLD_MTRACE                      201     /* mtrace messages */
142
 
143
#define ICMP6_HADISCOV_REQUEST          202     /* XXX To be defined */
144
#define ICMP6_HADISCOV_REPLY            203     /* XXX To be defined */
145
 
146
#ifndef _KERNEL
147
#define MLD6_MTRACE_RESP        MLD_MTRACE_RESP
148
#define MLD6_MTRACE             MLD_MTRACE
149
#endif
150
 
151
#define ICMP6_MAXTYPE                   203
152
 
153
#define ICMP6_DST_UNREACH_NOROUTE       0       /* no route to destination */
154
#define ICMP6_DST_UNREACH_ADMIN         1       /* administratively prohibited */
155
#define ICMP6_DST_UNREACH_NOTNEIGHBOR   2       /* not a neighbor(obsolete) */
156
#define ICMP6_DST_UNREACH_BEYONDSCOPE   2       /* beyond scope of source address */
157
#define ICMP6_DST_UNREACH_ADDR          3       /* address unreachable */
158
#define ICMP6_DST_UNREACH_NOPORT        4       /* port unreachable */
159
 
160
#define ICMP6_TIME_EXCEED_TRANSIT       0       /* ttl==0 in transit */
161
#define ICMP6_TIME_EXCEED_REASSEMBLY    1       /* ttl==0 in reass */
162
 
163
#define ICMP6_PARAMPROB_HEADER          0       /* erroneous header field */
164
#define ICMP6_PARAMPROB_NEXTHEADER      1       /* unrecognized next header */
165
#define ICMP6_PARAMPROB_OPTION          2       /* unrecognized option */
166
 
167
#define ICMP6_INFOMSG_MASK              0x80    /* all informational messages */
168
 
169
#define ICMP6_NI_SUBJ_IPV6      0       /* Query Subject is an IPv6 address */
170
#define ICMP6_NI_SUBJ_FQDN      1       /* Query Subject is a Domain name */
171
#define ICMP6_NI_SUBJ_IPV4      2       /* Query Subject is an IPv4 address */
172
 
173
#define ICMP6_NI_SUCCESS        0       /* node information successful reply */
174
#define ICMP6_NI_REFUSED        1       /* node information request is refused */
175
#define ICMP6_NI_UNKNOWN        2       /* unknown Qtype */
176
 
177
#define ICMP6_ROUTER_RENUMBERING_COMMAND  0     /* rr command */
178
#define ICMP6_ROUTER_RENUMBERING_RESULT   1     /* rr result */
179
#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET   255     /* rr seq num reset */
180
 
181
/* Used in kernel only */
182
#define ND_REDIRECT_ONLINK      0       /* redirect to an on-link node */
183
#define ND_REDIRECT_ROUTER      1       /* redirect to a better router */
184
 
185
/*
186
 * Multicast Listener Discovery
187
 */
188
struct mld_hdr {
189
       struct icmp6_hdr  mld_icmp6_hdr;
190
       struct in6_addr   mld_addr; /* multicast address */
191
      };
192
 
193
/* definitions to provide backward compatibility to old KAME applications */
194
#ifndef _KERNEL
195
#define mld6_hdr        mld_hdr
196
#define mld6_type       mld_type
197
#define mld6_code       mld_code
198
#define mld6_cksum      mld_cksum
199
#define mld6_maxdelay   mld_maxdelay
200
#define mld6_reserved   mld_reserved
201
#define mld6_addr       mld_addr
202
#endif
203
 
204
/* shortcut macro definitions */
205
#define mld_type        mld_icmp6_hdr.icmp6_type
206
#define mld_code        mld_icmp6_hdr.icmp6_code
207
#define mld_cksum       mld_icmp6_hdr.icmp6_cksum
208
#define mld_maxdelay    mld_icmp6_hdr.icmp6_data16[0]
209
#define mld_reserved    mld_icmp6_hdr.icmp6_data16[1]
210
 
211
/*
212
 * Neighbor Discovery
213
 */
214
 
215
struct nd_router_solicit {      /* router solicitation */
216
       struct icmp6_hdr        nd_rs_hdr;
217
       /* could be followed by options */
218
     };
219
 
220
#define nd_rs_type      nd_rs_hdr.icmp6_type
221
#define nd_rs_code      nd_rs_hdr.icmp6_code
222
#define nd_rs_cksum     nd_rs_hdr.icmp6_cksum
223
#define nd_rs_reserved  nd_rs_hdr.icmp6_data32[0]
224
 
225
struct nd_router_advert {       /* router advertisement */
226
       struct icmp6_hdr nd_ra_hdr;
227
       u_int32_t        nd_ra_reachable;        /* reachable time */
228
       u_int32_t        nd_ra_retransmit;       /* retransmit timer */
229
       /* could be followed by options */
230
     };
231
 
232
#define nd_ra_type              nd_ra_hdr.icmp6_type
233
#define nd_ra_code              nd_ra_hdr.icmp6_code
234
#define nd_ra_cksum             nd_ra_hdr.icmp6_cksum
235
#define nd_ra_curhoplimit       nd_ra_hdr.icmp6_data8[0]
236
#define nd_ra_flags_reserved    nd_ra_hdr.icmp6_data8[1]
237
#define ND_RA_FLAG_MANAGED      0x80
238
#define ND_RA_FLAG_OTHER        0x40
239
#define ND_RA_FLAG_HA           0x20
240
 
241
/*
242
 * Router preference values based on draft-draves-ipngwg-router-selection-01.
243
 * These are non-standard definitions.
244
 */
245
#define ND_RA_FLAG_RTPREF_MASK  0x18 /* 00011000 */
246
 
247
#define ND_RA_FLAG_RTPREF_HIGH  0x08 /* 00001000 */
248
#define ND_RA_FLAG_RTPREF_MEDIUM        0x00 /* 00000000 */
249
#define ND_RA_FLAG_RTPREF_LOW   0x18 /* 00011000 */
250
#define ND_RA_FLAG_RTPREF_RSV   0x10 /* 00010000 */
251
 
252
#define nd_ra_router_lifetime   nd_ra_hdr.icmp6_data16[1]
253
 
254
struct nd_neighbor_solicit {    /* neighbor solicitation */
255
       struct icmp6_hdr  nd_ns_hdr;
256
       struct in6_addr   nd_ns_target;   /*target address */
257
       /* could be followed by options */
258
     };
259
 
260
#define nd_ns_type              nd_ns_hdr.icmp6_type
261
#define nd_ns_code              nd_ns_hdr.icmp6_code
262
#define nd_ns_cksum             nd_ns_hdr.icmp6_cksum
263
#define nd_ns_reserved          nd_ns_hdr.icmp6_data32[0]
264
 
265
struct nd_neighbor_advert {     /* neighbor advertisement */
266
       struct icmp6_hdr  nd_na_hdr;
267
       struct in6_addr   nd_na_target;   /* target address */
268
       /* could be followed by options */
269
     };
270
 
271
#define nd_na_type              nd_na_hdr.icmp6_type
272
#define nd_na_code              nd_na_hdr.icmp6_code
273
#define nd_na_cksum             nd_na_hdr.icmp6_cksum
274
#define nd_na_flags_reserved    nd_na_hdr.icmp6_data32[0]
275
#if BYTE_ORDER == BIG_ENDIAN
276
#define ND_NA_FLAG_ROUTER               0x80000000
277
#define ND_NA_FLAG_SOLICITED            0x40000000
278
#define ND_NA_FLAG_OVERRIDE             0x20000000
279
#else
280
#if BYTE_ORDER == LITTLE_ENDIAN
281
#define ND_NA_FLAG_ROUTER               0x80
282
#define ND_NA_FLAG_SOLICITED            0x40
283
#define ND_NA_FLAG_OVERRIDE             0x20
284
#endif
285
#endif
286
 
287
struct nd_redirect {            /* redirect */
288
       struct icmp6_hdr nd_rd_hdr;
289
       struct in6_addr  nd_rd_target;   /* target address */
290
       struct in6_addr  nd_rd_dst;      /* destination address */
291
       /* could be followed by options */
292
     };
293
 
294
#define nd_rd_type      nd_rd_hdr.icmp6_type
295
#define nd_rd_code      nd_rd_hdr.icmp6_code
296
#define nd_rd_cksum     nd_rd_hdr.icmp6_cksum
297
#define nd_rd_reserved  nd_rd_hdr.icmp6_data32[0]
298
 
299
struct nd_opt_hdr {             /* Neighbor discovery option header */
300
       u_int8_t  nd_opt_type;
301
       u_int8_t  nd_opt_len;
302
       /* followed by option specific data*/
303
     };
304
 
305
#define ND_OPT_SOURCE_LINKADDR          1
306
#define ND_OPT_TARGET_LINKADDR          2
307
#define ND_OPT_PREFIX_INFORMATION       3
308
#define ND_OPT_REDIRECTED_HEADER        4
309
#define ND_OPT_MTU                      5
310
 
311
#define ND_OPT_ROUTE_INFO               200     /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
312
 
313
struct nd_opt_prefix_info {     /* prefix information */
314
       u_int8_t        nd_opt_pi_type;
315
       u_int8_t        nd_opt_pi_len;
316
       u_int8_t        nd_opt_pi_prefix_len;
317
       u_int8_t        nd_opt_pi_flags_reserved;
318
       u_int32_t       nd_opt_pi_valid_time;
319
       u_int32_t       nd_opt_pi_preferred_time;
320
       u_int32_t       nd_opt_pi_reserved2;
321
       struct in6_addr nd_opt_pi_prefix;
322
     };
323
 
324
#define ND_OPT_PI_FLAG_ONLINK           0x80
325
#define ND_OPT_PI_FLAG_AUTO             0x40
326
 
327
struct nd_opt_rd_hdr {          /* redirected header */
328
       u_int8_t        nd_opt_rh_type;
329
       u_int8_t        nd_opt_rh_len;
330
       u_int16_t       nd_opt_rh_reserved1;
331
       u_int32_t       nd_opt_rh_reserved2;
332
       /* followed by IP header and data */
333
     };
334
 
335
struct nd_opt_mtu {             /* MTU option */
336
       u_int8_t        nd_opt_mtu_type;
337
       u_int8_t        nd_opt_mtu_len;
338
       u_int16_t       nd_opt_mtu_reserved;
339
       u_int32_t       nd_opt_mtu_mtu;
340
     };
341
 
342
struct nd_opt_route_info {      /* route info */
343
       u_int8_t        nd_opt_rti_type;
344
       u_int8_t        nd_opt_rti_len;
345
       u_int8_t        nd_opt_rti_prefixlen;
346
       u_int8_t        nd_opt_rti_flags;
347
       u_int32_t       nd_opt_rti_lifetime;
348
       /* prefix follows */
349
     };
350
 
351
/*
352
 * icmp6 namelookup
353
 */
354
 
355
struct icmp6_namelookup {
356
       struct icmp6_hdr icmp6_nl_hdr;
357
       u_int8_t         icmp6_nl_nonce[8];
358
       int32_t          icmp6_nl_ttl;
359
#if 0
360
       u_int8_t         icmp6_nl_len;
361
       u_int8_t         icmp6_nl_name[3];
362
#endif
363
       /* could be followed by options */
364
     };
365
 
366
/*
367
 * icmp6 node information
368
 */
369
struct icmp6_nodeinfo {
370
       struct icmp6_hdr icmp6_ni_hdr;
371
       u_int8_t icmp6_ni_nonce[8];
372
       /* could be followed by reply data */
373
     };
374
 
375
#define ni_type         icmp6_ni_hdr.icmp6_type
376
#define ni_code         icmp6_ni_hdr.icmp6_code
377
#define ni_cksum        icmp6_ni_hdr.icmp6_cksum
378
#define ni_qtype        icmp6_ni_hdr.icmp6_data16[0]
379
#define ni_flags        icmp6_ni_hdr.icmp6_data16[1]
380
 
381
#define NI_QTYPE_NOOP           0 /* NOOP  */
382
#define NI_QTYPE_SUPTYPES       1 /* Supported Qtypes */
383
#define NI_QTYPE_FQDN           2 /* FQDN (draft 04) */
384
#define NI_QTYPE_DNSNAME        2 /* DNS Name */
385
#define NI_QTYPE_NODEADDR       3 /* Node Addresses */
386
#define NI_QTYPE_IPV4ADDR       4 /* IPv4 Addresses */
387
 
388
#if BYTE_ORDER == BIG_ENDIAN
389
#define NI_SUPTYPE_FLAG_COMPRESS        0x1
390
#define NI_FQDN_FLAG_VALIDTTL           0x1
391
#elif BYTE_ORDER == LITTLE_ENDIAN
392
#define NI_SUPTYPE_FLAG_COMPRESS        0x0100
393
#define NI_FQDN_FLAG_VALIDTTL           0x0100
394
#endif
395
 
396
#ifdef NAME_LOOKUPS_04
397
#if BYTE_ORDER == BIG_ENDIAN
398
#define NI_NODEADDR_FLAG_LINKLOCAL      0x1
399
#define NI_NODEADDR_FLAG_SITELOCAL      0x2
400
#define NI_NODEADDR_FLAG_GLOBAL         0x4
401
#define NI_NODEADDR_FLAG_ALL            0x8
402
#define NI_NODEADDR_FLAG_TRUNCATE       0x10
403
#define NI_NODEADDR_FLAG_ANYCAST        0x20 /* just experimental. not in spec */
404
#elif BYTE_ORDER == LITTLE_ENDIAN
405
#define NI_NODEADDR_FLAG_LINKLOCAL      0x0100
406
#define NI_NODEADDR_FLAG_SITELOCAL      0x0200
407
#define NI_NODEADDR_FLAG_GLOBAL         0x0400
408
#define NI_NODEADDR_FLAG_ALL            0x0800
409
#define NI_NODEADDR_FLAG_TRUNCATE       0x1000
410
#define NI_NODEADDR_FLAG_ANYCAST        0x2000 /* just experimental. not in spec */
411
#endif
412
#else  /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
413
#if BYTE_ORDER == BIG_ENDIAN
414
#define NI_NODEADDR_FLAG_TRUNCATE       0x1
415
#define NI_NODEADDR_FLAG_ALL            0x2
416
#define NI_NODEADDR_FLAG_COMPAT         0x4
417
#define NI_NODEADDR_FLAG_LINKLOCAL      0x8
418
#define NI_NODEADDR_FLAG_SITELOCAL      0x10
419
#define NI_NODEADDR_FLAG_GLOBAL         0x20
420
#define NI_NODEADDR_FLAG_ANYCAST        0x40 /* just experimental. not in spec */
421
#elif BYTE_ORDER == LITTLE_ENDIAN
422
#define NI_NODEADDR_FLAG_TRUNCATE       0x0100
423
#define NI_NODEADDR_FLAG_ALL            0x0200
424
#define NI_NODEADDR_FLAG_COMPAT         0x0400
425
#define NI_NODEADDR_FLAG_LINKLOCAL      0x0800
426
#define NI_NODEADDR_FLAG_SITELOCAL      0x1000
427
#define NI_NODEADDR_FLAG_GLOBAL         0x2000
428
#define NI_NODEADDR_FLAG_ANYCAST        0x4000 /* just experimental. not in spec */
429
#endif
430
#endif
431
 
432
struct ni_reply_fqdn {
433
       u_int32_t ni_fqdn_ttl;      /* TTL */
434
       u_int8_t  ni_fqdn_namelen;  /* length in octets of the FQDN */
435
       u_int8_t  ni_fqdn_name[3];  /* XXX: alignment */
436
     };
437
 
438
/*
439
 * Router Renumbering. as router-renum-08.txt
440
 */
441
struct icmp6_router_renum {     /* router renumbering header */
442
       struct icmp6_hdr        rr_hdr;
443
       u_int8_t        rr_segnum;
444
       u_int8_t        rr_flags;
445
       u_int16_t       rr_maxdelay;
446
       u_int32_t       rr_reserved;
447
     };
448
 
449
#define ICMP6_RR_FLAGS_TEST             0x80
450
#define ICMP6_RR_FLAGS_REQRESULT        0x40
451
#define ICMP6_RR_FLAGS_FORCEAPPLY       0x20
452
#define ICMP6_RR_FLAGS_SPECSITE         0x10
453
#define ICMP6_RR_FLAGS_PREVDONE         0x08
454
 
455
#define rr_type         rr_hdr.icmp6_type
456
#define rr_code         rr_hdr.icmp6_code
457
#define rr_cksum        rr_hdr.icmp6_cksum
458
#define rr_seqnum       rr_hdr.icmp6_data32[0]
459
 
460
struct rr_pco_match {           /* match prefix part */
461
       u_int8_t        rpm_code;
462
       u_int8_t        rpm_len;
463
       u_int8_t        rpm_ordinal;
464
       u_int8_t        rpm_matchlen;
465
       u_int8_t        rpm_minlen;
466
       u_int8_t        rpm_maxlen;
467
       u_int16_t       rpm_reserved;
468
       struct  in6_addr        rpm_prefix;
469
     };
470
 
471
#define RPM_PCO_ADD             1
472
#define RPM_PCO_CHANGE          2
473
#define RPM_PCO_SETGLOBAL       3
474
#define RPM_PCO_MAX             4
475
 
476
struct rr_pco_use {             /* use prefix part */
477
       u_int8_t        rpu_uselen;
478
       u_int8_t        rpu_keeplen;
479
       u_int8_t        rpu_ramask;
480
       u_int8_t        rpu_raflags;
481
       u_int32_t       rpu_vltime;
482
       u_int32_t       rpu_pltime;
483
       u_int32_t       rpu_flags;
484
       struct  in6_addr rpu_prefix;
485
     };
486
 
487
#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK  0x80
488
#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO    0x40
489
 
490
#if BYTE_ORDER == BIG_ENDIAN
491
#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80000000
492
#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40000000
493
#elif BYTE_ORDER == LITTLE_ENDIAN
494
#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80
495
#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40
496
#endif
497
 
498
struct rr_result {              /* router renumbering result message */
499
       u_int16_t       rrr_flags;
500
       u_int8_t        rrr_ordinal;
501
       u_int8_t        rrr_matchedlen;
502
       u_int32_t       rrr_ifid;
503
       struct  in6_addr rrr_prefix;
504
     };
505
 
506
#include <sys/packoff.h>
507
 
508
#if BYTE_ORDER == BIG_ENDIAN
509
#define ICMP6_RR_RESULT_FLAGS_OOB               0x0002
510
#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN         0x0001
511
#elif BYTE_ORDER == LITTLE_ENDIAN
512
#define ICMP6_RR_RESULT_FLAGS_OOB               0x0200
513
#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN         0x0100
514
#endif
515
 
516
/*
517
 * icmp6 filter structures.
518
 */
519
 
520
struct icmp6_filter {
521
       u_int32_t icmp6_filt[8];
522
     };
523
 
524
#define ICMP6_FILTER_SETPASSALL(filterp) \
525
        memset(filterp, 0xff, sizeof(struct icmp6_filter))
526
#define ICMP6_FILTER_SETBLOCKALL(filterp) \
527
        memset(filterp, 0x00, sizeof(struct icmp6_filter))
528
 
529
#define ICMP6_FILTER_SETPASS(type, filterp) \
530
        (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
531
#define ICMP6_FILTER_SETBLOCK(type, filterp) \
532
        (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
533
#define ICMP6_FILTER_WILLPASS(type, filterp) \
534
        ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
535
#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
536
        ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
537
 
538
/*
539
 * Variables related to this implementation
540
 * of the internet control message protocol version 6.
541
 */
542
struct icmp6errstat {
543
       u_quad_t icp6errs_dst_unreach_noroute;
544
       u_quad_t icp6errs_dst_unreach_admin;
545
       u_quad_t icp6errs_dst_unreach_beyondscope;
546
       u_quad_t icp6errs_dst_unreach_addr;
547
       u_quad_t icp6errs_dst_unreach_noport;
548
       u_quad_t icp6errs_packet_too_big;
549
       u_quad_t icp6errs_time_exceed_transit;
550
       u_quad_t icp6errs_time_exceed_reassembly;
551
       u_quad_t icp6errs_paramprob_header;
552
       u_quad_t icp6errs_paramprob_nextheader;
553
       u_quad_t icp6errs_paramprob_option;
554
       u_quad_t icp6errs_redirect; /* we regard redirect as an error here */
555
       u_quad_t icp6errs_unknown;
556
     };
557
 
558
struct icmp6stat {
559
       /* statistics related to icmp6 packets generated */
560
       u_quad_t icp6s_error;           /* # of calls to icmp6_error */
561
       u_quad_t icp6s_canterror;       /* no error 'cuz old was icmp */
562
       u_quad_t icp6s_toofreq;         /* no error 'cuz rate limitation */
563
       u_quad_t icp6s_outhist[256];
564
 
565
       /* statistics related to input message processed */
566
       u_quad_t icp6s_badcode;         /* icmp6_code out of range */
567
       u_quad_t icp6s_tooshort;        /* packet < sizeof(struct icmp6_hdr) */
568
       u_quad_t icp6s_checksum;        /* bad checksum */
569
       u_quad_t icp6s_badlen;          /* calculated bound mismatch */
570
       /*
571
        * number of responses: this member is inherited from netinet code, but
572
        * for netinet6 code, it is already available in icp6s_outhist[].
573
        */
574
       u_quad_t icp6s_reflect;
575
       u_quad_t icp6s_inhist[256];
576
       u_quad_t icp6s_nd_toomanyopt;   /* too many ND options */
577
       struct icmp6errstat icp6s_outerrhist;
578
#define icp6s_odst_unreach_noroute \
579
        icp6s_outerrhist.icp6errs_dst_unreach_noroute
580
#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
581
#define icp6s_odst_unreach_beyondscope \
582
        icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
583
#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
584
#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
585
#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
586
#define icp6s_otime_exceed_transit \
587
        icp6s_outerrhist.icp6errs_time_exceed_transit
588
#define icp6s_otime_exceed_reassembly \
589
        icp6s_outerrhist.icp6errs_time_exceed_reassembly
590
#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
591
#define icp6s_oparamprob_nextheader \
592
        icp6s_outerrhist.icp6errs_paramprob_nextheader
593
#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
594
#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
595
#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
596
       u_quad_t icp6s_pmtuchg;         /* path MTU changes */
597
       u_quad_t icp6s_nd_badopt;       /* bad ND options */
598
       u_quad_t icp6s_badns;           /* bad neighbor solicitation */
599
       u_quad_t icp6s_badna;           /* bad neighbor advertisement */
600
       u_quad_t icp6s_badrs;           /* bad router advertisement */
601
       u_quad_t icp6s_badra;           /* bad router advertisement */
602
       u_quad_t icp6s_badredirect;     /* bad redirect message */
603
     };
604
 
605
/*
606
 * Names for ICMP sysctl objects
607
 */
608
#define ICMPV6CTL_STATS         1
609
#define ICMPV6CTL_REDIRACCEPT   2       /* accept/process redirects */
610
#define ICMPV6CTL_REDIRTIMEOUT  3       /* redirect cache time */
611
#define ICMPV6CTL_ND6_PRUNE     6
612
#define ICMPV6CTL_ND6_DELAY     8
613
#define ICMPV6CTL_ND6_UMAXTRIES 9
614
#define ICMPV6CTL_ND6_MMAXTRIES         10
615
#define ICMPV6CTL_ND6_USELOOPBACK       11
616
/*#define ICMPV6CTL_ND6_PROXYALL        12      obsoleted, do not reuse here */
617
#define ICMPV6CTL_NODEINFO      13
618
#define ICMPV6CTL_ERRPPSLIMIT   14      /* ICMPv6 error pps limitation */
619
#define ICMPV6CTL_ND6_MAXNUDHINT        15
620
#define ICMPV6CTL_MTUDISC_HIWAT 16
621
#define ICMPV6CTL_MTUDISC_LOWAT 17
622
#define ICMPV6CTL_ND6_DEBUG     18
623
#define ICMPV6CTL_ND6_DRLIST    19
624
#define ICMPV6CTL_ND6_PRLIST    20
625
#define ICMPV6CTL_MAXID         21
626
 
627
#define ICMPV6CTL_NAMES { \
628
        { 0, 0 }, \
629
        { 0, 0 }, \
630
        { "rediraccept", CTLTYPE_INT }, \
631
        { "redirtimeout", CTLTYPE_INT }, \
632
        { 0, 0 }, \
633
        { 0, 0 }, \
634
        { "nd6_prune", CTLTYPE_INT }, \
635
        { 0, 0 }, \
636
        { "nd6_delay", CTLTYPE_INT }, \
637
        { "nd6_umaxtries", CTLTYPE_INT }, \
638
        { "nd6_mmaxtries", CTLTYPE_INT }, \
639
        { "nd6_useloopback", CTLTYPE_INT }, \
640
        { 0, 0 }, \
641
        { "nodeinfo", CTLTYPE_INT }, \
642
        { "errppslimit", CTLTYPE_INT }, \
643
        { "nd6_maxnudhint", CTLTYPE_INT }, \
644
        { "mtudisc_hiwat", CTLTYPE_INT }, \
645
        { "mtudisc_lowat", CTLTYPE_INT }, \
646
        { "nd6_debug", CTLTYPE_INT }, \
647
        { 0, 0 }, \
648
        { 0, 0 }, \
649
}
650
 
651
#define RTF_PROBEMTU    RTF_PROTO1
652
 
653
#ifdef _KERNEL
654
# ifdef __STDC__
655
struct  rtentry;
656
struct  rttimer;
657
struct  in6_multi;
658
# endif
659
void    icmp6_init(void);
660
void    icmp6_paramerror(struct mbuf *, int);
661
void    icmp6_error(struct mbuf *, int, int, int);
662
int     icmp6_input(struct mbuf **, int *, int);
663
void    icmp6_fasttimo(void);
664
void    icmp6_reflect(struct mbuf *, size_t);
665
void    icmp6_prepare(struct mbuf *);
666
void    icmp6_redirect_input(struct mbuf *, int);
667
void    icmp6_redirect_output(struct mbuf *, struct rtentry *);
668
 
669
struct  ip6ctlparam;
670
void    icmp6_mtudisc_update(struct ip6ctlparam *, int);
671
 
672
/* XXX: is this the right place for these macros? */
673
#define icmp6_ifstat_inc(ifp, tag) \
674
do {                                                            \
675
        if ((ifp) && (ifp)->if_index <= if_index                        \
676
         && (ifp)->if_index < icmp6_ifstatmax                   \
677
         && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) {    \
678
                icmp6_ifstat[(ifp)->if_index]->tag++;           \
679
        }                                                       \
680
} while (0)
681
 
682
#define icmp6_ifoutstat_inc(ifp, type, code) \
683
do { \
684
                icmp6_ifstat_inc(ifp, ifs6_out_msg); \
685
                if (type < ICMP6_INFOMSG_MASK) \
686
                        icmp6_ifstat_inc(ifp, ifs6_out_error); \
687
                switch(type) { \
688
                 case ICMP6_DST_UNREACH: \
689
                         icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
690
                         if (code == ICMP6_DST_UNREACH_ADMIN) \
691
                                 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
692
                         break; \
693
                 case ICMP6_PACKET_TOO_BIG: \
694
                         icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
695
                         break; \
696
                 case ICMP6_TIME_EXCEEDED: \
697
                         icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
698
                         break; \
699
                 case ICMP6_PARAM_PROB: \
700
                         icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
701
                         break; \
702
                 case ICMP6_ECHO_REQUEST: \
703
                         icmp6_ifstat_inc(ifp, ifs6_out_echo); \
704
                         break; \
705
                 case ICMP6_ECHO_REPLY: \
706
                         icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
707
                         break; \
708
                 case MLD_LISTENER_QUERY: \
709
                         icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
710
                         break; \
711
                 case MLD_LISTENER_REPORT: \
712
                         icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
713
                         break; \
714
                 case MLD_LISTENER_DONE: \
715
                         icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
716
                         break; \
717
                 case ND_ROUTER_SOLICIT: \
718
                         icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
719
                         break; \
720
                 case ND_ROUTER_ADVERT: \
721
                         icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
722
                         break; \
723
                 case ND_NEIGHBOR_SOLICIT: \
724
                         icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
725
                         break; \
726
                 case ND_NEIGHBOR_ADVERT: \
727
                         icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
728
                         break; \
729
                 case ND_REDIRECT: \
730
                         icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
731
                         break; \
732
                } \
733
} while (0)
734
 
735
extern int      icmp6_rediraccept;      /* accept/process redirects */
736
extern int      icmp6_redirtimeout;     /* cache time for redirect routes */
737
#endif /* _KERNEL */
738
 
739
#endif /* not _NETINET_ICMP6_H_ */