Annotation of embedaddon/pimdd/pimdd.h, revision 1.1.1.1.2.1
1.1 misho 1: /*
2: * Copyright (c) 1998 by the University of Oregon.
3: * All rights reserved.
4: *
5: * Permission to use, copy, modify, and distribute this software and
6: * its documentation in source and binary forms for lawful
7: * purposes and without fee is hereby granted, provided
8: * that the above copyright notice appear in all copies and that both
9: * the copyright notice and this permission notice appear in supporting
10: * documentation, and that any documentation, advertising materials,
11: * and other materials related to such distribution and use acknowledge
12: * that the software was developed by the University of Oregon.
13: * The name of the University of Oregon may not be used to endorse or
14: * promote products derived from this software without specific prior
15: * written permission.
16: *
17: * THE UNIVERSITY OF OREGON DOES NOT MAKE ANY REPRESENTATIONS
18: * ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS
19: * PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
20: * INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
22: * NON-INFRINGEMENT.
23: *
24: * IN NO EVENT SHALL UO, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
25: * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT,
26: * TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH,
27: * THE USE OR PERFORMANCE OF THIS SOFTWARE.
28: *
29: * Other copyrights might apply to parts of this software and are so
30: * noted when applicable.
31: */
32: /*
33: * Questions concerning this software should be directed to
34: * Kurt Windisch (kurtw@antc.uoregon.edu)
35: *
1.1.1.1.2.1! misho 36: * $Id: pimdd.h,v 1.1.1.1 2017/06/12 07:58:55 misho Exp $
1.1 misho 37: */
38: /*
39: * Part of this program has been derived from PIM sparse-mode pimd.
40: * The pimd program is covered by the license in the accompanying file
41: * named "LICENSE.pimd".
42: *
43: * The pimd program is COPYRIGHT 1998 by University of Southern California.
44: *
45: * Part of this program has been derived from mrouted.
46: * The mrouted program is covered by the license in the accompanying file
47: * named "LICENSE.mrouted".
48: *
49: * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
50: * Leland Stanford Junior University.
51: *
52: */
53:
54: #include <netinet/pim.h>
55:
56: #define PIM_PROTOCOL_VERSION 2
57: #define PIMD_VERSION PIM_PROTOCOL_VERSION
58: #define PIMD_SUBVERSION 1
59: #if 0
60: #define PIM_CONSTANT 0x000eff00 /* constant portion of 'group' field */
61: #endif
62: #define PIM_CONSTANT 0
63: #define PIMD_LEVEL (PIM_CONSTANT | PIMD_VERSION | (PIMD_SUBVERSION << 8))
64:
65: #define INADDR_ALL_PIM_ROUTERS (u_int32)0xe000000D /* 224.0.0.13 */
66:
67:
68: /* PIM protocol timers (in seconds) */
69: #ifndef TIMER_INTERVAL
70: #define TIMER_INTERVAL 5 /* virtual timer granularity */
71: #endif /* TIMER_INTERVAL */
72:
73: #define PIM_DATA_TIMEOUT 210
74: #define PIM_TIMER_HELLO_PERIOD 30
75: #define PIM_JOIN_PRUNE_HOLDTIME 210
76: #define PIM_RANDOM_DELAY_JOIN_TIMEOUT 3
77: #define PIM_GRAFT_RETRANS_PERIOD 3
78: #define PIM_TIMER_HELLO_HOLDTIME (3.5 * PIM_TIMER_HELLO_PERIOD)
79: #define PIM_ASSERT_TIMEOUT 210
80:
81:
82: /* Misc definitions */
83: #define SINGLE_SRC_MSKLEN 32 /* the single source mask length */
84: #define SINGLE_GRP_MSKLEN 32 /* the single group mask length */
85: /* TODO: change? */
86: #define PIM_GROUP_PREFIX_DEFAULT_MASKLEN 16 /* The default group masklen if
87: * omitted in the config file.
88: */
89:
90: #define UCAST_ROUTING_CHECK_INTERVAL 20 /* Unfortunately, if the unicast
91: * routing changes, the kernel
92: * or any of the existing
93: * unicast routing daemons
94: * don't send us a signal.
95: * Have to ask periodically the
96: * kernel for any route changes.
97: * Default: every 20 seconds.
98: * Sigh.
99: */
100:
101:
102: #define DEFAULT_PHY_RATE_LIMIT 0 /* default phyint rate limit */
103:
104: #define DEFAULT_LOCAL_PREF 101 /* Default assert preference */
105: #define DEFAULT_LOCAL_METRIC 1024 /* Default assert metric */
106:
107: /**************************************************************************
108: * PIM Encoded-Unicast, Encoded-Group and Encoded-Source Address formats *
109: *************************************************************************/
110: /* Address families definition */
111: #define ADDRF_RESERVED 0
112: #define ADDRF_IPv4 1
113: #define ADDRF_IPv6 2
114: #define ADDRF_NSAP 3
115: #define ADDRF_HDLC 4
116: #define ADDRF_BBN1822 5
117: #define ADDRF_802 6
118: #define ADDRF_ETHERNET ADDRF_802
119: #define ADDRF_E163 7
120: #define ADDRF_E164 8
121: #define ADDRF_SMDS ADDRF_E164
122: #define ADDRF_ATM ADDRF_E164
123: #define ADDRF_F69 9
124: #define ADDRF_TELEX ADDRF_F69
125: #define ADDRF_X121 10
126: #define ADDRF_X25 ADDRF_X121
127: #define ADDRF_IPX 11
128: #define ADDRF_APPLETALK 12
129: #define ADDRF_DECNET_IV 13
130: #define ADDRF_BANYAN 14
131: #define ADDRF_E164_NSAP 15
132:
133: /* Addresses Encoding Type (specific for each Address Family */
134: #define ADDRT_IPv4 0
135:
136:
137: /* Encoded-Unicast: 6 bytes long */
138: typedef struct pim_encod_uni_addr_ {
139: u_int8 addr_family;
140: u_int8 encod_type;
141: u_int32 unicast_addr; /* XXX: Note the 32-bit boundary
142: * misalignment for the unicast
143: * address when placed in the
144: * memory. Must read it byte-by-byte!
145: */
146: } pim_encod_uni_addr_t;
147:
148: /* Encoded-Group */
149: typedef struct pim_encod_grp_addr_ {
150: u_int8 addr_family;
151: u_int8 encod_type;
152: u_int8 reserved;
153: u_int8 masklen;
154: u_int32 mcast_addr;
155: } pim_encod_grp_addr_t;
156:
157: /* Encoded-Source */
158: typedef struct pim_encod_src_addr_ {
159: u_int8 addr_family;
160: u_int8 encod_type;
161: u_int8 flags;
162: u_int8 masklen;
163: u_int32 src_addr;
164: } pim_encod_src_addr_t;
165: #define USADDR_RP_BIT 0x1
166: #define USADDR_WC_BIT 0x2
167: #define USADDR_S_BIT 0x4
168:
169: /**************************************************************************
170: * PIM Messages formats *
171: *************************************************************************/
172: /* TODO: XXX: some structures are probably not used at all */
173:
174: typedef struct pim pim_header_t;
175:
176: /* PIM Hello */
177: typedef struct pim_hello_ {
178: u_int16 option_type; /* Option type */
179: u_int16 option_length; /* Length of the Option Value field in bytes */
180: } pim_hello_t;
181:
182: /* PIM Join/Prune: XXX: all 32-bit addresses misaligned! */
183: typedef struct pim_jp_header_ {
184: pim_encod_uni_addr_t encod_upstream_nbr;
185: u_int8 reserved;
186: u_int8 num_groups;
187: u_int16 holdtime;
188: } pim_jp_header_t;
189:
190: typedef struct pim_jp_encod_grp_ {
191: pim_encod_grp_addr_t encod_grp;
192: u_int16 number_join_src;
193: u_int16 number_prune_src;
194: } pim_jp_encod_grp_t;
195:
196: #define PIM_ACTION_NOTHING 0
197: #define PIM_ACTION_JOIN 1
198: #define PIM_ACTION_PRUNE 2
199:
200: #define PIM_IIF_SOURCE 1
201: #define PIM_IIF_RP 2
202:
203: #define PIM_ASSERT_RPT_BIT 0x80000000
204:
1.1.1.1.2.1! misho 205: #if 0
1.1 misho 206: /* PIM messages type */
207: #define PIM_HELLO 0
208: #ifndef PIM_REGISTER
209: #define PIM_REGISTER 1
210: #endif
211: #define PIM_REGISTER_STOP 2
212: #define PIM_JOIN_PRUNE 3
213: #define PIM_BOOTSTRAP 4
214: #define PIM_ASSERT 5
215: #define PIM_GRAFT 6
216: #define PIM_GRAFT_ACK 7
217: #define PIM_CAND_RP_ADV 8
1.1.1.1.2.1! misho 218: #endif
1.1 misho 219:
220: #define PIM_V2_HELLO PIM_HELLO
221: #define PIM_V2_REGISTER PIM_REGISTER
222: #define PIM_V2_REGISTER_STOP PIM_REGISTER_STOP
223: #define PIM_V2_JOIN_PRUNE PIM_JOIN_PRUNE
224: #define PIM_V2_BOOTSTRAP PIM_BOOTSTRAP
225: #define PIM_V2_ASSERT PIM_ASSERT
226: #define PIM_V2_GRAFT PIM_GRAFT
227: #define PIM_V2_GRAFT_ACK PIM_GRAFT_ACK
228: #define PIM_V2_CAND_RP_ADV PIM_CAND_RP_ADV
229:
230: #define PIM_V1_QUERY 0
231: #define PIM_V1_REGISTER 1
232: #define PIM_V1_REGISTER_STOP 2
233: #define PIM_V1_JOIN_PRUNE 3
234: #define PIM_V1_RP_REACHABILITY 4
235: #define PIM_V1_ASSERT 5
236: #define PIM_V1_GRAFT 6
237: #define PIM_V1_GRAFT_ACK 7
238:
239: /* Vartious options from PIM messages definitions */
240: /* PIM_HELLO definitions */
241: #define PIM_MESSAGE_HELLO_HOLDTIME 1
242: #define PIM_MESSAGE_HELLO_HOLDTIME_LENGTH 2
243: #define PIM_MESSAGE_HELLO_HOLDTIME_FOREVER 0xffff
244:
245:
246: #define MASK_TO_MASKLEN(mask, masklen) \
247: do { \
248: register u_int32 tmp_mask = ntohl((mask)); \
249: register u_int8 tmp_masklen = sizeof((mask)) << 3; \
250: for ( ; tmp_masklen > 0; tmp_masklen--, tmp_mask >>= 1) \
251: if (tmp_mask & 0x1) \
252: break; \
253: (masklen) = tmp_masklen; \
254: } while (0)
255:
256: #define MASKLEN_TO_MASK(masklen, mask) \
257: do { \
258: (mask) = (masklen)? htonl(~0 << ((sizeof((mask)) << 3) - (masklen))) : 0;\
259: } while (0)
260:
261:
262: /*
263: * A bunch of macros because of the lack of 32-bit boundary alignment.
264: * All because of one misalligned address format. Hopefully this will be
265: * fixed in PIMv3. (cp) must be (u_int8 *) .
266: */
267: /* Originates from Eddy Rusty's (eddy@isi.edu) PIM-SM implementation for
268: * gated.
269: */
270:
271: /* PUT_NETLONG puts "network ordered" data to the datastream.
272: * PUT_HOSTLONG puts "host ordered" data to the datastream.
273: * GET_NETLONG gets the data and keeps it in "network order" in the memory
274: * GET_HOSTLONG gets the data, but in the memory it is in "host order"
275: * The same for all {PUT,GET}_{NET,HOST}{SHORT,LONG}
276: */
277: #define GET_BYTE(val, cp) ((val) = *(cp)++)
278: #define PUT_BYTE(val, cp) (*(cp)++ = (u_int8)(val))
279:
280: #define GET_HOSTSHORT(val, cp) \
281: do { \
282: register u_int16 Xv; \
283: Xv = (*(cp)++) << 8; \
284: Xv |= *(cp)++; \
285: (val) = Xv; \
286: } while (0)
287:
288: #define PUT_HOSTSHORT(val, cp) \
289: do { \
290: register u_int16 Xv; \
291: Xv = (u_int16)(val); \
292: *(cp)++ = (u_int8)(Xv >> 8); \
293: *(cp)++ = (u_int8)Xv; \
294: } while (0)
295:
296: #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
297: #define GET_NETSHORT(val, cp) \
298: do { \
299: register u_int16 Xv; \
300: Xv = *(cp)++; \
301: Xv |= (*(cp)++) << 8; \
302: (val) = Xv; \
303: } while (0)
304: #define PUT_NETSHORT(val, cp) \
305: do { \
306: register u_int16 Xv; \
307: Xv = (u_int16)(val); \
308: *(cp)++ = (u_int8)Xv; \
309: *(cp)++ = (u_int8)(Xv >> 8); \
310: } while (0)
311: #else
312: #define GET_NETSHORT(val, cp) GET_HOSTSHORT(val, cp)
313: #define PUT_NETSHORT(val, cp) PUT_HOSTSHORT(val, cp)
314: #endif /* {GET,PUT}_NETSHORT */
315:
316: #define GET_HOSTLONG(val, cp) \
317: do { \
318: register u_long Xv; \
319: Xv = (*(cp)++) << 24; \
320: Xv |= (*(cp)++) << 16; \
321: Xv |= (*(cp)++) << 8; \
322: Xv |= *(cp)++; \
323: (val) = Xv; \
324: } while (0)
325:
326: #define PUT_HOSTLONG(val, cp) \
327: do { \
328: register u_int32 Xv; \
329: Xv = (u_int32)(val); \
330: *(cp)++ = (u_int8)(Xv >> 24); \
331: *(cp)++ = (u_int8)(Xv >> 16); \
332: *(cp)++ = (u_int8)(Xv >> 8); \
333: *(cp)++ = (u_int8)Xv; \
334: } while (0)
335:
336: #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
337: #define GET_NETLONG(val, cp) \
338: do { \
339: register u_long Xv; \
340: Xv = *(cp)++; \
341: Xv |= (*(cp)++) << 8; \
342: Xv |= (*(cp)++) << 16; \
343: Xv |= (*(cp)++) << 24; \
344: (val) = Xv; \
345: } while (0)
346:
347: #define PUT_NETLONG(val, cp) \
348: do { \
349: register u_int32 Xv; \
350: Xv = (u_int32)(val); \
351: *(cp)++ = (u_int8)Xv; \
352: *(cp)++ = (u_int8)(Xv >> 8); \
353: *(cp)++ = (u_int8)(Xv >> 16); \
354: *(cp)++ = (u_int8)(Xv >> 24); \
355: } while (0)
356: #else
357: #define GET_NETLONG(val, cp) GET_HOSTLONG(val, cp)
358: #define PUT_NETLONG(val, cp) PUT_HOSTLONG(val, cp)
359: #endif /* {GET,PUT}_HOSTLONG */
360:
361:
362: #define GET_ESADDR(esa, cp) \
363: do { \
364: (esa)->addr_family = *(cp)++; \
365: (esa)->encod_type = *(cp)++; \
366: (esa)->flags = *(cp)++; \
367: (esa)->masklen = *(cp)++; \
368: GET_NETLONG((esa)->src_addr, (cp)); \
369: } while(0)
370:
371: #define PUT_ESADDR(addr, masklen, flags, cp) \
372: do { \
373: u_int32 mask; \
374: MASKLEN_TO_MASK((masklen), mask); \
375: *(cp)++ = ADDRF_IPv4; /* family */ \
376: *(cp)++ = ADDRT_IPv4; /* type */ \
377: *(cp)++ = (flags); /* flags */ \
378: *(cp)++ = (masklen); \
379: PUT_NETLONG((addr) & mask, (cp)); \
380: } while(0)
381:
382: #define GET_EGADDR(ega, cp) \
383: do { \
384: (ega)->addr_family = *(cp)++; \
385: (ega)->encod_type = *(cp)++; \
386: (ega)->reserved = *(cp)++; \
387: (ega)->masklen = *(cp)++; \
388: GET_NETLONG((ega)->mcast_addr, (cp)); \
389: } while(0)
390:
391: #define PUT_EGADDR(addr, masklen, reserved, cp) \
392: do { \
393: u_int32 mask; \
394: MASKLEN_TO_MASK((masklen), mask); \
395: *(cp)++ = ADDRF_IPv4; /* family */ \
396: *(cp)++ = ADDRT_IPv4; /* type */ \
397: *(cp)++ = (reserved); /* reserved; should be 0 */ \
398: *(cp)++ = (masklen); \
399: PUT_NETLONG((addr) & mask, (cp)); \
400: } while(0)
401:
402: #define GET_EUADDR(eua, cp) \
403: do { \
404: (eua)->addr_family = *(cp)++; \
405: (eua)->encod_type = *(cp)++; \
406: GET_NETLONG((eua)->unicast_addr, (cp)); \
407: } while(0)
408:
409: #define PUT_EUADDR(addr, cp) \
410: do { \
411: *(cp)++ = ADDRF_IPv4; /* family */ \
412: *(cp)++ = ADDRT_IPv4; /* type */ \
413: PUT_NETLONG((addr), (cp)); \
414: } while(0)
415:
416:
417: /* TODO: Currently not used. Probably not need at all. Delete! */
418: #ifdef NOSUCHDEF
419: /* This is completely IGMP related stuff? */
420: #define PIM_LEAF_TIMEOUT (3.5 * IGMP_QUERY_INTERVAL)
421: #endif /* NOSUCHDEF */
422:
423: #if (defined(BSDI) || defined(NetBSD) || defined(IRIX))
424: /*
425: * Struct used to communicate from kernel to multicast router
426: * note the convenient similarity to an IP packet
427: */
428: struct igmpmsg {
429: u_long unused1;
430: u_long unused2;
431: u_char im_msgtype; /* what type of message */
432: #define IGMPMSG_NOCACHE 1
433: #define IGMPMSG_WRONGVIF 2
434: #define IGMPMSG_WHOLEPKT 3 /* used for user level encap*/
435: u_char im_mbz; /* must be zero */
436: u_char im_vif; /* vif rec'd on */
437: u_char unused3;
438: struct in_addr im_src, im_dst;
439: };
440: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>