Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 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 1 2 3 4 5 6


icmp6.h
001: /* Copyright (C) 1991-1997,2000,2006,2009 Free Software Foundation, Inc.
002:    This file is part of the GNU C Library.
003: 
004:    The GNU C Library is free software; you can redistribute it and/or
005:    modify it under the terms of the GNU Lesser General Public
006:    License as published by the Free Software Foundation; either
007:    version 2.1 of the License, or (at your option) any later version.
008: 
009:    The GNU C Library is distributed in the hope that it will be useful,
010:    but WITHOUT ANY WARRANTY; without even the implied warranty of
011:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:    Lesser General Public License for more details.
013: 
014:    You should have received a copy of the GNU Lesser General Public
015:    License along with the GNU C Library; if not, write to the Free
016:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
017:    02111-1307 USA.  */
018: 
019: #ifndef _NETINET_ICMP6_H
020: #define _NETINET_ICMP6_H 1
021: 
022: #include <inttypes.h>
023: #include <string.h>
024: #include <sys/types.h>
025: #include <netinet/in.h>
026: 
027: #define ICMP6_FILTER 1
028: 
029: #define ICMP6_FILTER_BLOCK              1
030: #define ICMP6_FILTER_PASS               2
031: #define ICMP6_FILTER_BLOCKOTHERS        3
032: #define ICMP6_FILTER_PASSONLY           4
033: 
034: struct icmp6_filter
035:   {
036:     uint32_t icmp6_filt[8];
037:   };
038: 
039: struct icmp6_hdr
040:   {
041:     uint8_t     icmp6_type;   /* type field */
042:     uint8_t     icmp6_code;   /* code field */
043:     uint16_t    icmp6_cksum;  /* checksum field */
044:     union
045:       {
046:         uint32_t  icmp6_un_data32[1]; /* type-specific field */
047:         uint16_t  icmp6_un_data16[2]; /* type-specific field */
048:         uint8_t   icmp6_un_data8[4];  /* type-specific field */
049:       } icmp6_dataun;
050:   };
051: 
052: #define icmp6_data32    icmp6_dataun.icmp6_un_data32
053: #define icmp6_data16    icmp6_dataun.icmp6_un_data16
054: #define icmp6_data8     icmp6_dataun.icmp6_un_data8
055: #define icmp6_pptr      icmp6_data32[0]  /* parameter prob */
056: #define icmp6_mtu       icmp6_data32[0]  /* packet too big */
057: #define icmp6_id        icmp6_data16[0]  /* echo request/reply */
058: #define icmp6_seq       icmp6_data16[1]  /* echo request/reply */
059: #define icmp6_maxdelay  icmp6_data16[0]  /* mcast group membership */
060: 
061: #define ICMP6_DST_UNREACH             1
062: #define ICMP6_PACKET_TOO_BIG          2
063: #define ICMP6_TIME_EXCEEDED           3
064: #define ICMP6_PARAM_PROB              4
065: 
066: #define ICMP6_INFOMSG_MASK  0x80    /* all informational messages */
067: 
068: #define ICMP6_ECHO_REQUEST          128
069: #define ICMP6_ECHO_REPLY            129
070: #define MLD_LISTENER_QUERY          130
071: #define MLD_LISTENER_REPORT         131
072: #define MLD_LISTENER_REDUCTION      132
073: 
074: #define ICMP6_DST_UNREACH_NOROUTE     0 /* no route to destination */
075: #define ICMP6_DST_UNREACH_ADMIN       1 /* communication with destination */
076:                                         /* administratively prohibited */
077: #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
078: #define ICMP6_DST_UNREACH_ADDR        3 /* address unreachable */
079: #define ICMP6_DST_UNREACH_NOPORT      4 /* bad port */
080: 
081: #define ICMP6_TIME_EXCEED_TRANSIT     0 /* Hop Limit == 0 in transit */
082: #define ICMP6_TIME_EXCEED_REASSEMBLY  1 /* Reassembly time out */
083: 
084: #define ICMP6_PARAMPROB_HEADER        0 /* erroneous header field */
085: #define ICMP6_PARAMPROB_NEXTHEADER    1 /* unrecognized Next Header */
086: #define ICMP6_PARAMPROB_OPTION        2 /* unrecognized IPv6 option */
087: 
088: #define ICMP6_FILTER_WILLPASS(type, filterp) \
089:         ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
090: 
091: #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
092:         ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
093: 
094: #define ICMP6_FILTER_SETPASS(type, filterp) \
095:         ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
096: 
097: #define ICMP6_FILTER_SETBLOCK(type, filterp) \
098:         ((((filterp)->icmp6_filt[(type) >> 5]) |=  (1 << ((type) & 31))))
099: 
100: #define ICMP6_FILTER_SETPASSALL(filterp) \
101:         memset (filterp, 0, sizeof (struct icmp6_filter));
102: 
103: #define ICMP6_FILTER_SETBLOCKALL(filterp) \
104:         memset (filterp, 0xFF, sizeof (struct icmp6_filter));
105: 
106: #define ND_ROUTER_SOLICIT           133
107: #define ND_ROUTER_ADVERT            134
108: #define ND_NEIGHBOR_SOLICIT         135
109: #define ND_NEIGHBOR_ADVERT          136
110: #define ND_REDIRECT                 137
111: 
112: struct nd_router_solicit      /* router solicitation */
113:   {
114:     struct icmp6_hdr  nd_rs_hdr;
115:     /* could be followed by options */
116:   };
117: 
118: #define nd_rs_type               nd_rs_hdr.icmp6_type
119: #define nd_rs_code               nd_rs_hdr.icmp6_code
120: #define nd_rs_cksum              nd_rs_hdr.icmp6_cksum
121: #define nd_rs_reserved           nd_rs_hdr.icmp6_data32[0]
122: 
123: struct nd_router_advert       /* router advertisement */
124:   {
125:     struct icmp6_hdr  nd_ra_hdr;
126:     uint32_t   nd_ra_reachable;   /* reachable time */
127:     uint32_t   nd_ra_retransmit;  /* retransmit timer */
128:     /* could be followed by options */
129:   };
130: 
131: #define nd_ra_type               nd_ra_hdr.icmp6_type
132: #define nd_ra_code               nd_ra_hdr.icmp6_code
133: #define nd_ra_cksum              nd_ra_hdr.icmp6_cksum
134: #define nd_ra_curhoplimit        nd_ra_hdr.icmp6_data8[0]
135: #define nd_ra_flags_reserved     nd_ra_hdr.icmp6_data8[1]
136: #define ND_RA_FLAG_MANAGED       0x80
137: #define ND_RA_FLAG_OTHER         0x40
138: #define ND_RA_FLAG_HOME_AGENT    0x20
139: #define nd_ra_router_lifetime    nd_ra_hdr.icmp6_data16[1]
140: 
141: struct nd_neighbor_solicit    /* neighbor solicitation */
142:   {
143:     struct icmp6_hdr  nd_ns_hdr;
144:     struct in6_addr   nd_ns_target; /* target address */
145:     /* could be followed by options */
146:   };
147: 
148: #define nd_ns_type               nd_ns_hdr.icmp6_type
149: #define nd_ns_code               nd_ns_hdr.icmp6_code
150: #define nd_ns_cksum              nd_ns_hdr.icmp6_cksum
151: #define nd_ns_reserved           nd_ns_hdr.icmp6_data32[0]
152: 
153: struct nd_neighbor_advert     /* neighbor advertisement */
154:   {
155:     struct icmp6_hdr  nd_na_hdr;
156:     struct in6_addr   nd_na_target; /* target address */
157:     /* could be followed by options */
158:   };
159: 
160: #define nd_na_type               nd_na_hdr.icmp6_type
161: #define nd_na_code               nd_na_hdr.icmp6_code
162: #define nd_na_cksum              nd_na_hdr.icmp6_cksum
163: #define nd_na_flags_reserved     nd_na_hdr.icmp6_data32[0]
164: #if     BYTE_ORDER == BIG_ENDIAN
165: #define ND_NA_FLAG_ROUTER        0x80000000
166: #define ND_NA_FLAG_SOLICITED     0x40000000
167: #define ND_NA_FLAG_OVERRIDE      0x20000000
168: #else   /* BYTE_ORDER == LITTLE_ENDIAN */
169: #define ND_NA_FLAG_ROUTER        0x00000080
170: #define ND_NA_FLAG_SOLICITED     0x00000040
171: #define ND_NA_FLAG_OVERRIDE      0x00000020
172: #endif
173: 
174: struct nd_redirect            /* redirect */
175:   {
176:     struct icmp6_hdr  nd_rd_hdr;
177:     struct in6_addr   nd_rd_target; /* target address */
178:     struct in6_addr   nd_rd_dst;    /* destination address */
179:     /* could be followed by options */
180:   };
181: 
182: #define nd_rd_type               nd_rd_hdr.icmp6_type
183: #define nd_rd_code               nd_rd_hdr.icmp6_code
184: #define nd_rd_cksum              nd_rd_hdr.icmp6_cksum
185: #define nd_rd_reserved           nd_rd_hdr.icmp6_data32[0]
186: 
187: struct nd_opt_hdr             /* Neighbor discovery option header */
188:   {
189:     uint8_t  nd_opt_type;
190:     uint8_t  nd_opt_len;        /* in units of 8 octets */
191:     /* followed by option specific data */
192:   };
193: 
194: #define ND_OPT_SOURCE_LINKADDR          1
195: #define ND_OPT_TARGET_LINKADDR          2
196: #define ND_OPT_PREFIX_INFORMATION       3
197: #define ND_OPT_REDIRECTED_HEADER        4
198: #define ND_OPT_MTU                      5
199: #define ND_OPT_RTR_ADV_INTERVAL         7
200: #define ND_OPT_HOME_AGENT_INFO          8
201: 
202: struct nd_opt_prefix_info     /* prefix information */
203:   {
204:     uint8_t   nd_opt_pi_type;
205:     uint8_t   nd_opt_pi_len;
206:     uint8_t   nd_opt_pi_prefix_len;
207:     uint8_t   nd_opt_pi_flags_reserved;
208:     uint32_t  nd_opt_pi_valid_time;
209:     uint32_t  nd_opt_pi_preferred_time;
210:     uint32_t  nd_opt_pi_reserved2;
211:     struct in6_addr  nd_opt_pi_prefix;
212:   };
213: 
214: #define ND_OPT_PI_FLAG_ONLINK   0x80
215: #define ND_OPT_PI_FLAG_AUTO     0x40
216: #define ND_OPT_PI_FLAG_RADDR    0x20
217: 
218: struct nd_opt_rd_hdr          /* redirected header */
219:   {
220:     uint8_t   nd_opt_rh_type;
221:     uint8_t   nd_opt_rh_len;
222:     uint16_t  nd_opt_rh_reserved1;
223:     uint32_t  nd_opt_rh_reserved2;
224:     /* followed by IP header and data */
225:   };
226: 
227: struct nd_opt_mtu             /* MTU option */
228:   {
229:     uint8_t   nd_opt_mtu_type;
230:     uint8_t   nd_opt_mtu_len;
231:     uint16_t  nd_opt_mtu_reserved;
232:     uint32_t  nd_opt_mtu_mtu;
233:   };
234: 
235: struct mld_hdr
236:   {
237:     struct icmp6_hdr    mld_icmp6_hdr;
238:     struct in6_addr     mld_addr; /* multicast address */
239:   };
240: 
241: #define mld_type        mld_icmp6_hdr.icmp6_type
242: #define mld_code        mld_icmp6_hdr.icmp6_code
243: #define mld_cksum       mld_icmp6_hdr.icmp6_cksum
244: #define mld_maxdelay    mld_icmp6_hdr.icmp6_data16[0]
245: #define mld_reserved    mld_icmp6_hdr.icmp6_data16[1]
246: 
247: #define ICMP6_ROUTER_RENUMBERING    138
248: 
249: struct icmp6_router_renum    /* router renumbering header */
250:   {
251:     struct icmp6_hdr    rr_hdr;
252:     uint8_t             rr_segnum;
253:     uint8_t             rr_flags;
254:     uint16_t            rr_maxdelay;
255:     uint32_t            rr_reserved;
256:   };
257: 
258: #define rr_type         rr_hdr.icmp6_type
259: #define rr_code         rr_hdr.icmp6_code
260: #define rr_cksum        rr_hdr.icmp6_cksum
261: #define rr_seqnum       rr_hdr.icmp6_data32[0]
262: 
263: /* Router renumbering flags */
264: #define ICMP6_RR_FLAGS_TEST             0x80
265: #define ICMP6_RR_FLAGS_REQRESULT        0x40
266: #define ICMP6_RR_FLAGS_FORCEAPPLY       0x20
267: #define ICMP6_RR_FLAGS_SPECSITE         0x10
268: #define ICMP6_RR_FLAGS_PREVDONE         0x08
269: 
270: struct rr_pco_match    /* match prefix part */
271:   {
272:     uint8_t             rpm_code;
273:     uint8_t             rpm_len;
274:     uint8_t             rpm_ordinal;
275:     uint8_t             rpm_matchlen;
276:     uint8_t             rpm_minlen;
277:     uint8_t             rpm_maxlen;
278:     uint16_t            rpm_reserved;
279:     struct in6_addr     rpm_prefix;
280:   };
281: 
282: /* PCO code values */
283: #define RPM_PCO_ADD             1
284: #define RPM_PCO_CHANGE          2
285: #define RPM_PCO_SETGLOBAL       3
286: 
287: struct rr_pco_use      /* use prefix part */
288:   {
289:     uint8_t             rpu_uselen;
290:     uint8_t             rpu_keeplen;
291:     uint8_t             rpu_ramask;
292:     uint8_t             rpu_raflags;
293:     uint32_t            rpu_vltime;
294:     uint32_t            rpu_pltime;
295:     uint32_t            rpu_flags;
296:     struct in6_addr     rpu_prefix;
297:   };
298: 
299: #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK  0x20
300: #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO    0x10
301: 
302: #if BYTE_ORDER == BIG_ENDIAN
303: # define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
304: # define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
305: #elif BYTE_ORDER == LITTLE_ENDIAN
306: # define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
307: # define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
308: #endif
309: 
310: struct rr_result       /* router renumbering result message */
311:   {
312:     uint16_t            rrr_flags;
313:     uint8_t             rrr_ordinal;
314:     uint8_t             rrr_matchedlen;
315:     uint32_t            rrr_ifid;
316:     struct in6_addr     rrr_prefix;
317:   };
318: 
319: #if BYTE_ORDER == BIG_ENDIAN
320: # define ICMP6_RR_RESULT_FLAGS_OOB       0x0002
321: # define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
322: #elif BYTE_ORDER == LITTLE_ENDIAN
323: # define ICMP6_RR_RESULT_FLAGS_OOB       0x0200
324: # define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
325: #endif
326: 
327: /* Mobile IPv6 extension: Advertisement Interval.  */
328: struct nd_opt_adv_interval
329:   {
330:     uint8_t   nd_opt_adv_interval_type;
331:     uint8_t   nd_opt_adv_interval_len;
332:     uint16_t  nd_opt_adv_interval_reserved;
333:     uint32_t  nd_opt_adv_interval_ival;
334:   };
335: 
336: /* Mobile IPv6 extension: Home Agent Info.  */
337: struct nd_opt_home_agent_info
338:   {
339:     uint8_t   nd_opt_home_agent_info_type;
340:     uint8_t   nd_opt_home_agent_info_len;
341:     uint16_t  nd_opt_home_agent_info_reserved;
342:     uint16_t  nd_opt_home_agent_info_preference;
343:     uint16_t  nd_opt_home_agent_info_lifetime;
344:   };
345: 
346: #endif /* netinet/icmpv6.h */
347: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/