1c398230bSWarner Losh /*- 2*51369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*51369649SPedro F. Giffuni * 459ca77f4SJeffrey Hsu * Copyright (c) 1996-2000 559ca77f4SJeffrey Hsu * University of Southern California/Information Sciences Institute. 659ca77f4SJeffrey Hsu * All rights reserved. 759ca77f4SJeffrey Hsu * 859ca77f4SJeffrey Hsu * Redistribution and use in source and binary forms, with or without 959ca77f4SJeffrey Hsu * modification, are permitted provided that the following conditions 1059ca77f4SJeffrey Hsu * are met: 1159ca77f4SJeffrey Hsu * 1. Redistributions of source code must retain the above copyright 1259ca77f4SJeffrey Hsu * notice, this list of conditions and the following disclaimer. 1359ca77f4SJeffrey Hsu * 2. Redistributions in binary form must reproduce the above copyright 1459ca77f4SJeffrey Hsu * notice, this list of conditions and the following disclaimer in the 1559ca77f4SJeffrey Hsu * documentation and/or other materials provided with the distribution. 1659ca77f4SJeffrey Hsu * 3. Neither the name of the project nor the names of its contributors 1759ca77f4SJeffrey Hsu * may be used to endorse or promote products derived from this software 1859ca77f4SJeffrey Hsu * without specific prior written permission. 1959ca77f4SJeffrey Hsu * 2059ca77f4SJeffrey Hsu * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2159ca77f4SJeffrey Hsu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2259ca77f4SJeffrey Hsu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2359ca77f4SJeffrey Hsu * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2459ca77f4SJeffrey Hsu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2559ca77f4SJeffrey Hsu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2659ca77f4SJeffrey Hsu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2759ca77f4SJeffrey Hsu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2859ca77f4SJeffrey Hsu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2959ca77f4SJeffrey Hsu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3059ca77f4SJeffrey Hsu * SUCH DAMAGE. 3159ca77f4SJeffrey Hsu */ 3259ca77f4SJeffrey Hsu 3359ca77f4SJeffrey Hsu #ifndef _NETINET_PIM_H_ 3459ca77f4SJeffrey Hsu #define _NETINET_PIM_H_ 3559ca77f4SJeffrey Hsu 3659ca77f4SJeffrey Hsu /* 3759ca77f4SJeffrey Hsu * Protocol Independent Multicast (PIM) definitions. 3859ca77f4SJeffrey Hsu * RFC 2362, June 1998. 3959ca77f4SJeffrey Hsu * 4059ca77f4SJeffrey Hsu * Written by Ahmed Helmy, USC/SGI, July 1996. 4159ca77f4SJeffrey Hsu * Modified by George Edmond Eddy (Rusty), ISI, February 1998. 4259ca77f4SJeffrey Hsu * Modified by Pavlin Radoslavov, USC/ISI, May 1998, October 2000. 4359ca77f4SJeffrey Hsu */ 4459ca77f4SJeffrey Hsu 454c9792f9SJeffrey Hsu #include <sys/types.h> 464c9792f9SJeffrey Hsu 4759ca77f4SJeffrey Hsu #ifndef _PIM_VT 4859ca77f4SJeffrey Hsu #ifndef BYTE_ORDER 4959ca77f4SJeffrey Hsu # error BYTE_ORDER is not defined! 5059ca77f4SJeffrey Hsu #endif 5159ca77f4SJeffrey Hsu #if (BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN) 5259ca77f4SJeffrey Hsu # error BYTE_ORDER must be defined to either BIG_ENDIAN or LITTLE_ENDIAN 5359ca77f4SJeffrey Hsu #endif 5459ca77f4SJeffrey Hsu #endif /* ! _PIM_VT */ 5559ca77f4SJeffrey Hsu 5659ca77f4SJeffrey Hsu /* 5759ca77f4SJeffrey Hsu * PIM packet header 5859ca77f4SJeffrey Hsu */ 5959ca77f4SJeffrey Hsu struct pim { 6059ca77f4SJeffrey Hsu #ifdef _PIM_VT 6159ca77f4SJeffrey Hsu uint8_t pim_vt; /* PIM version and message type */ 6259ca77f4SJeffrey Hsu #else /* ! _PIM_VT */ 6359ca77f4SJeffrey Hsu #if BYTE_ORDER == BIG_ENDIAN 6459ca77f4SJeffrey Hsu u_int pim_vers:4, /* PIM protocol version */ 6559ca77f4SJeffrey Hsu pim_type:4; /* PIM message type */ 6659ca77f4SJeffrey Hsu #endif 6759ca77f4SJeffrey Hsu #if BYTE_ORDER == LITTLE_ENDIAN 6859ca77f4SJeffrey Hsu u_int pim_type:4, /* PIM message type */ 6959ca77f4SJeffrey Hsu pim_vers:4; /* PIM protocol version */ 7059ca77f4SJeffrey Hsu #endif 7159ca77f4SJeffrey Hsu #endif /* ! _PIM_VT */ 7259ca77f4SJeffrey Hsu uint8_t pim_reserved; /* Reserved */ 7359ca77f4SJeffrey Hsu uint16_t pim_cksum; /* IP-style checksum */ 7459ca77f4SJeffrey Hsu }; 7559ca77f4SJeffrey Hsu /* KAME-related name backward compatibility */ 7659ca77f4SJeffrey Hsu #define pim_ver pim_vers 7759ca77f4SJeffrey Hsu #define pim_rsv pim_reserved 7859ca77f4SJeffrey Hsu 7959ca77f4SJeffrey Hsu #ifdef _PIM_VT 8059ca77f4SJeffrey Hsu #define PIM_MAKE_VT(v, t) (0xff & (((v) << 4) | (0x0f & (t)))) 8159ca77f4SJeffrey Hsu #define PIM_VT_V(x) (((x) >> 4) & 0x0f) 8259ca77f4SJeffrey Hsu #define PIM_VT_T(x) ((x) & 0x0f) 8359ca77f4SJeffrey Hsu #endif /* _PIM_VT */ 8459ca77f4SJeffrey Hsu 8559ca77f4SJeffrey Hsu #define PIM_VERSION 2 8659ca77f4SJeffrey Hsu #define PIM_MINLEN 8 /* PIM message min. length */ 8759ca77f4SJeffrey Hsu #define PIM_REG_MINLEN (PIM_MINLEN+20) /* PIM Register hdr + inner IPv4 hdr */ 8859ca77f4SJeffrey Hsu #define PIM6_REG_MINLEN (PIM_MINLEN+40) /* PIM Register hdr + inner IPv6 hdr */ 8959ca77f4SJeffrey Hsu 9059ca77f4SJeffrey Hsu /* 9159ca77f4SJeffrey Hsu * PIM message types 9259ca77f4SJeffrey Hsu */ 9359ca77f4SJeffrey Hsu #define PIM_HELLO 0x0 /* PIM-SM and PIM-DM */ 9459ca77f4SJeffrey Hsu #define PIM_REGISTER 0x1 /* PIM-SM only */ 9559ca77f4SJeffrey Hsu #define PIM_REGISTER_STOP 0x2 /* PIM-SM only */ 9659ca77f4SJeffrey Hsu #define PIM_JOIN_PRUNE 0x3 /* PIM-SM and PIM-DM */ 9759ca77f4SJeffrey Hsu #define PIM_BOOTSTRAP 0x4 /* PIM-SM only */ 9859ca77f4SJeffrey Hsu #define PIM_ASSERT 0x5 /* PIM-SM and PIM-DM */ 9959ca77f4SJeffrey Hsu #define PIM_GRAFT 0x6 /* PIM-DM only */ 10059ca77f4SJeffrey Hsu #define PIM_GRAFT_ACK 0x7 /* PIM-DM only */ 10159ca77f4SJeffrey Hsu #define PIM_CAND_RP_ADV 0x8 /* PIM-SM only */ 10259ca77f4SJeffrey Hsu #define PIM_ALL_DF_ELECTION 0xa /* Bidir-PIM-SM only */ 10359ca77f4SJeffrey Hsu 10459ca77f4SJeffrey Hsu /* 10559ca77f4SJeffrey Hsu * PIM-Register message flags 10659ca77f4SJeffrey Hsu */ 10759ca77f4SJeffrey Hsu #define PIM_BORDER_REGISTER 0x80000000U /* The Border bit (host-order) */ 10859ca77f4SJeffrey Hsu #define PIM_NULL_REGISTER 0x40000000U /* The Null-Register bit (host-order)*/ 10959ca77f4SJeffrey Hsu 11059ca77f4SJeffrey Hsu /* 11159ca77f4SJeffrey Hsu * All-PIM-Routers IPv4 and IPv6 multicast addresses 11259ca77f4SJeffrey Hsu */ 11359ca77f4SJeffrey Hsu #define INADDR_ALLPIM_ROUTERS_GROUP (uint32_t)0xe000000dU /* 224.0.0.13 */ 11459ca77f4SJeffrey Hsu #define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS "ff02::d" 11559ca77f4SJeffrey Hsu #define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS_INIT \ 11659ca77f4SJeffrey Hsu {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 11759ca77f4SJeffrey Hsu 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d }}} 11859ca77f4SJeffrey Hsu 11959ca77f4SJeffrey Hsu #endif /* _NETINET_PIM_H_ */ 120