icmp6.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
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;
042: uint8_t icmp6_code;
043: uint16_t icmp6_cksum;
044: union
045: {
046: uint32_t icmp6_un_data32[1];
047: uint16_t icmp6_un_data16[2];
048: uint8_t icmp6_un_data8[4];
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]
056: #define icmp6_mtu icmp6_data32[0]
057: #define icmp6_id icmp6_data16[0]
058: #define icmp6_seq icmp6_data16[1]
059: #define icmp6_maxdelay icmp6_data16[0]
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
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
075: #define ICMP6_DST_UNREACH_ADMIN 1
076:
077: #define ICMP6_DST_UNREACH_BEYONDSCOPE 2
078: #define ICMP6_DST_UNREACH_ADDR 3
079: #define ICMP6_DST_UNREACH_NOPORT 4
080:
081: #define ICMP6_TIME_EXCEED_TRANSIT 0
082: #define ICMP6_TIME_EXCEED_REASSEMBLY 1
083:
084: #define ICMP6_PARAMPROB_HEADER 0
085: #define ICMP6_PARAMPROB_NEXTHEADER 1
086: #define ICMP6_PARAMPROB_OPTION 2
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
113: {
114: struct icmp6_hdr nd_rs_hdr;
115:
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
124: {
125: struct icmp6_hdr nd_ra_hdr;
126: uint32_t nd_ra_reachable;
127: uint32_t nd_ra_retransmit;
128:
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
142: {
143: struct icmp6_hdr nd_ns_hdr;
144: struct in6_addr nd_ns_target;
145:
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
154: {
155: struct icmp6_hdr nd_na_hdr;
156: struct in6_addr nd_na_target;
157:
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
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
175: {
176: struct icmp6_hdr nd_rd_hdr;
177: struct in6_addr nd_rd_target;
178: struct in6_addr nd_rd_dst;
179:
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
188: {
189: uint8_t nd_opt_type;
190: uint8_t nd_opt_len;
191:
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
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
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:
225: };
226:
227: struct nd_opt_mtu
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;
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
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:
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
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:
283: #define RPM_PCO_ADD 1
284: #define RPM_PCO_CHANGE 2
285: #define RPM_PCO_SETGLOBAL 3
286:
287: struct rr_pco_use
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
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:
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:
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
347:
© Andrew Scott 2006 -
2025,
All Rights Reserved