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