pim.h revision 1.2 1 1.2 elad /* $NetBSD: pim.h,v 1.2 2005/12/10 23:36:23 elad Exp $ */
2 1.1 manu
3 1.1 manu /*
4 1.1 manu * Copyright (c) 1996-2000
5 1.1 manu * University of Southern California/Information Sciences Institute.
6 1.1 manu * All rights reserved.
7 1.1 manu *
8 1.1 manu * Redistribution and use in source and binary forms, with or without
9 1.1 manu * modification, are permitted provided that the following conditions
10 1.1 manu * are met:
11 1.1 manu * 1. Redistributions of source code must retain the above copyright
12 1.1 manu * notice, this list of conditions and the following disclaimer.
13 1.1 manu * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 manu * notice, this list of conditions and the following disclaimer in the
15 1.1 manu * documentation and/or other materials provided with the distribution.
16 1.1 manu * 3. Neither the name of the project nor the names of its contributors
17 1.1 manu * may be used to endorse or promote products derived from this software
18 1.1 manu * without specific prior written permission.
19 1.1 manu *
20 1.1 manu * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 1.1 manu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 1.1 manu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 1.1 manu * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 1.1 manu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 1.1 manu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 1.1 manu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 1.1 manu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 1.1 manu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 1.1 manu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 1.1 manu * SUCH DAMAGE.
31 1.1 manu *
32 1.1 manu * $FreeBSD: /repoman/r/ncvs/src/sys/netinet/pim.h,v 1.2 2004/03/08 07:45:32 hsu Exp $
33 1.1 manu */
34 1.1 manu
35 1.1 manu #ifndef _NETINET_PIM_H_
36 1.1 manu #define _NETINET_PIM_H_
37 1.1 manu
38 1.1 manu /*
39 1.1 manu * Protocol Independent Multicast (PIM) definitions.
40 1.1 manu * RFC 2362, June 1998.
41 1.1 manu *
42 1.1 manu * Written by Ahmed Helmy, USC/SGI, July 1996.
43 1.1 manu * Modified by George Edmond Eddy (Rusty), ISI, February 1998.
44 1.1 manu * Modified by Pavlin Radoslavov, USC/ISI, May 1998, October 2000.
45 1.1 manu */
46 1.1 manu
47 1.1 manu #include <sys/types.h>
48 1.1 manu
49 1.1 manu #ifndef _PIM_VT
50 1.1 manu #ifndef BYTE_ORDER
51 1.1 manu # error BYTE_ORDER is not defined!
52 1.1 manu #endif
53 1.1 manu #if (BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN)
54 1.1 manu # error BYTE_ORDER must be defined to either BIG_ENDIAN or LITTLE_ENDIAN
55 1.1 manu #endif
56 1.1 manu #endif /* ! _PIM_VT */
57 1.1 manu
58 1.1 manu /*
59 1.1 manu * PIM packet header
60 1.1 manu */
61 1.1 manu struct pim {
62 1.1 manu #ifdef _PIM_VT
63 1.1 manu uint8_t pim_vt; /* PIM version and message type */
64 1.1 manu #else /* ! _PIM_VT */
65 1.1 manu #if BYTE_ORDER == BIG_ENDIAN
66 1.1 manu u_int pim_vers:4, /* PIM protocol version */
67 1.1 manu pim_type:4; /* PIM message type */
68 1.1 manu #endif
69 1.1 manu #if BYTE_ORDER == LITTLE_ENDIAN
70 1.1 manu u_int pim_type:4, /* PIM message type */
71 1.1 manu pim_vers:4; /* PIM protocol version */
72 1.1 manu #endif
73 1.1 manu #endif /* ! _PIM_VT */
74 1.1 manu uint8_t pim_reserved; /* Reserved */
75 1.1 manu uint16_t pim_cksum; /* IP-style checksum */
76 1.1 manu };
77 1.1 manu /* KAME-related name backward compatibility */
78 1.1 manu #define pim_ver pim_vers
79 1.1 manu #define pim_rsv pim_reserved
80 1.1 manu
81 1.1 manu #ifdef _PIM_VT
82 1.1 manu #define PIM_MAKE_VT(v, t) (0xff & (((v) << 4) | (0x0f & (t))))
83 1.1 manu #define PIM_VT_V(x) (((x) >> 4) & 0x0f)
84 1.1 manu #define PIM_VT_T(x) ((x) & 0x0f)
85 1.1 manu #endif /* _PIM_VT */
86 1.1 manu
87 1.1 manu #define PIM_VERSION 2
88 1.1 manu #define PIM_MINLEN 8 /* PIM message min. length */
89 1.1 manu #define PIM_REG_MINLEN (PIM_MINLEN+20) /* PIM Register hdr + inner IPv4 hdr */
90 1.1 manu #define PIM6_REG_MINLEN (PIM_MINLEN+40) /* PIM Register hdr + inner IPv6 hdr */
91 1.1 manu
92 1.1 manu /*
93 1.1 manu * PIM message types
94 1.1 manu */
95 1.1 manu #define PIM_HELLO 0x0 /* PIM-SM and PIM-DM */
96 1.1 manu #define PIM_REGISTER 0x1 /* PIM-SM only */
97 1.1 manu #define PIM_REGISTER_STOP 0x2 /* PIM-SM only */
98 1.1 manu #define PIM_JOIN_PRUNE 0x3 /* PIM-SM and PIM-DM */
99 1.1 manu #define PIM_BOOTSTRAP 0x4 /* PIM-SM only */
100 1.1 manu #define PIM_ASSERT 0x5 /* PIM-SM and PIM-DM */
101 1.1 manu #define PIM_GRAFT 0x6 /* PIM-DM only */
102 1.1 manu #define PIM_GRAFT_ACK 0x7 /* PIM-DM only */
103 1.1 manu #define PIM_CAND_RP_ADV 0x8 /* PIM-SM only */
104 1.1 manu #define PIM_ALL_DF_ELECTION 0xa /* Bidir-PIM-SM only */
105 1.1 manu
106 1.1 manu /*
107 1.1 manu * PIM-Register message flags
108 1.1 manu */
109 1.1 manu #define PIM_BORDER_REGISTER 0x80000000U /* The Border bit (host-order) */
110 1.1 manu #define PIM_NULL_REGISTER 0x40000000U /* The Null-Register bit (host-order)*/
111 1.1 manu
112 1.1 manu /*
113 1.1 manu * All-PIM-Routers IPv4 and IPv6 multicast addresses
114 1.1 manu */
115 1.1 manu #define INADDR_ALLPIM_ROUTERS_GROUP (uint32_t)0xe000000dU /* 224.0.0.13 */
116 1.1 manu #define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS "ff02::d"
117 1.1 manu #define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS_INIT \
118 1.1 manu {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
119 1.1 manu 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d }}}
120 1.1 manu
121 1.2 elad #endif /* !_NETINET_PIM_H_ */
122