pim.h revision 118623
1118623Shsu/*
2118623Shsu * Copyright (c) 1996-2000
3118623Shsu * University of Southern California/Information Sciences Institute.
4118623Shsu * All rights reserved.
5118623Shsu *
6118623Shsu * Redistribution and use in source and binary forms, with or without
7118623Shsu * modification, are permitted provided that the following conditions
8118623Shsu * are met:
9118623Shsu * 1. Redistributions of source code must retain the above copyright
10118623Shsu *    notice, this list of conditions and the following disclaimer.
11118623Shsu * 2. Redistributions in binary form must reproduce the above copyright
12118623Shsu *    notice, this list of conditions and the following disclaimer in the
13118623Shsu *    documentation and/or other materials provided with the distribution.
14118623Shsu * 3. Neither the name of the project nor the names of its contributors
15118623Shsu *    may be used to endorse or promote products derived from this software
16118623Shsu *    without specific prior written permission.
17118623Shsu *
18118623Shsu * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
19118623Shsu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20118623Shsu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21118623Shsu * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
22118623Shsu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23118623Shsu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24118623Shsu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25118623Shsu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26118623Shsu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27118623Shsu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28118623Shsu * SUCH DAMAGE.
29118623Shsu *
30118623Shsu * $FreeBSD: head/sys/netinet/pim.h 118623 2003-08-07 18:17:43Z hsu $
31118623Shsu */
32118623Shsu
33118623Shsu#ifndef _NETINET_PIM_H_
34118623Shsu#define _NETINET_PIM_H_
35118623Shsu
36118623Shsu/*
37118623Shsu * Protocol Independent Multicast (PIM) definitions.
38118623Shsu * RFC 2362, June 1998.
39118623Shsu *
40118623Shsu * Written by Ahmed Helmy, USC/SGI, July 1996.
41118623Shsu * Modified by George Edmond Eddy (Rusty), ISI, February 1998.
42118623Shsu * Modified by Pavlin Radoslavov, USC/ISI, May 1998, October 2000.
43118623Shsu */
44118623Shsu
45118623Shsu#ifndef _PIM_VT
46118623Shsu#ifndef BYTE_ORDER
47118623Shsu# error BYTE_ORDER is not defined!
48118623Shsu#endif
49118623Shsu#if (BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN)
50118623Shsu# error BYTE_ORDER must be defined to either BIG_ENDIAN or LITTLE_ENDIAN
51118623Shsu#endif
52118623Shsu#endif /* ! _PIM_VT */
53118623Shsu
54118623Shsu/*
55118623Shsu * PIM packet header
56118623Shsu */
57118623Shsustruct pim {
58118623Shsu#ifdef _PIM_VT
59118623Shsu	uint8_t		pim_vt;		/* PIM version and message type	*/
60118623Shsu#else /* ! _PIM_VT   */
61118623Shsu#if BYTE_ORDER == BIG_ENDIAN
62118623Shsu	u_int		pim_vers:4,	/* PIM protocol version		*/
63118623Shsu			pim_type:4;	/* PIM message type		*/
64118623Shsu#endif
65118623Shsu#if BYTE_ORDER == LITTLE_ENDIAN
66118623Shsu	u_int		pim_type:4,	/* PIM message type		*/
67118623Shsu			pim_vers:4;	/* PIM protocol version		*/
68118623Shsu#endif
69118623Shsu#endif /* ! _PIM_VT  */
70118623Shsu	uint8_t		pim_reserved;	/* Reserved			*/
71118623Shsu	uint16_t	pim_cksum;	/* IP-style checksum		*/
72118623Shsu};
73118623Shsu/* KAME-related name backward compatibility */
74118623Shsu#define pim_ver pim_vers
75118623Shsu#define pim_rsv pim_reserved
76118623Shsu
77118623Shsu#ifdef _PIM_VT
78118623Shsu#define PIM_MAKE_VT(v, t)	(0xff & (((v) << 4) | (0x0f & (t))))
79118623Shsu#define PIM_VT_V(x)		(((x) >> 4) & 0x0f)
80118623Shsu#define PIM_VT_T(x)		((x) & 0x0f)
81118623Shsu#endif /* _PIM_VT */
82118623Shsu
83118623Shsu#define PIM_VERSION		2
84118623Shsu#define PIM_MINLEN		8	/* PIM message min. length	*/
85118623Shsu#define PIM_REG_MINLEN	(PIM_MINLEN+20)	/* PIM Register hdr + inner IPv4 hdr */
86118623Shsu#define PIM6_REG_MINLEN	(PIM_MINLEN+40)	/* PIM Register hdr + inner IPv6 hdr */
87118623Shsu
88118623Shsu/*
89118623Shsu * PIM message types
90118623Shsu */
91118623Shsu#define PIM_HELLO		0x0	/* PIM-SM and PIM-DM		*/
92118623Shsu#define PIM_REGISTER		0x1	/* PIM-SM only			*/
93118623Shsu#define PIM_REGISTER_STOP	0x2	/* PIM-SM only			*/
94118623Shsu#define PIM_JOIN_PRUNE		0x3	/* PIM-SM and PIM-DM		*/
95118623Shsu#define PIM_BOOTSTRAP		0x4	/* PIM-SM only			*/
96118623Shsu#define PIM_ASSERT		0x5	/* PIM-SM and PIM-DM		*/
97118623Shsu#define PIM_GRAFT		0x6	/* PIM-DM only			*/
98118623Shsu#define PIM_GRAFT_ACK		0x7	/* PIM-DM only			*/
99118623Shsu#define PIM_CAND_RP_ADV		0x8	/* PIM-SM only			*/
100118623Shsu#define PIM_ALL_DF_ELECTION	0xa	/* Bidir-PIM-SM only		*/
101118623Shsu
102118623Shsu/*
103118623Shsu * PIM-Register message flags
104118623Shsu */
105118623Shsu#define PIM_BORDER_REGISTER 0x80000000U	/* The Border bit (host-order)	*/
106118623Shsu#define PIM_NULL_REGISTER   0x40000000U	/* The Null-Register bit (host-order)*/
107118623Shsu
108118623Shsu/*
109118623Shsu * All-PIM-Routers IPv4 and IPv6 multicast addresses
110118623Shsu */
111118623Shsu#define INADDR_ALLPIM_ROUTERS_GROUP	(uint32_t)0xe000000dU  /* 224.0.0.13 */
112118623Shsu#define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS	"ff02::d"
113118623Shsu#define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS_INIT				\
114118623Shsu	{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,		\
115118623Shsu	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d }}}
116118623Shsu
117118623Shsu#endif /* _NETINET_PIM_H_ */
118