Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet IPv4 PIM support, based on submission from Pavli...



details:   https://anonhg.NetBSD.org/src/rev/63dfb7cfa0cb
branches:  trunk
changeset: 569762:63dfb7cfa0cb
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Sep 04 23:32:29 2004 +0000

description:
IPv4 PIM support, based on submission from Pavlin Radoslavov on tech-net@ :
two new files I forgot to add on the first cvs commit.

diffstat:

 sys/netinet/pim.h     |  121 ++++++++++++++++++++++++++++++++++++++++++++++++++
 sys/netinet/pim_var.h |   81 +++++++++++++++++++++++++++++++++
 2 files changed, 202 insertions(+), 0 deletions(-)

diffs (210 lines):

diff -r 2550a93ae5d8 -r 63dfb7cfa0cb sys/netinet/pim.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/netinet/pim.h Sat Sep 04 23:32:29 2004 +0000
@@ -0,0 +1,121 @@
+/*     $NetBSD: pim.h,v 1.1 2004/09/04 23:32:29 manu Exp $     */
+
+/*
+ * Copyright (c) 1996-2000
+ * University of Southern California/Information Sciences Institute.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: /repoman/r/ncvs/src/sys/netinet/pim.h,v 1.2 2004/03/08 07:45:32 hsu Exp $
+ */
+
+#ifndef _NETINET_PIM_H_
+#define _NETINET_PIM_H_
+
+/*
+ * Protocol Independent Multicast (PIM) definitions.
+ * RFC 2362, June 1998.
+ *
+ * Written by Ahmed Helmy, USC/SGI, July 1996.
+ * Modified by George Edmond Eddy (Rusty), ISI, February 1998.
+ * Modified by Pavlin Radoslavov, USC/ISI, May 1998, October 2000.
+ */
+
+#include <sys/types.h>
+
+#ifndef _PIM_VT
+#ifndef BYTE_ORDER
+# error BYTE_ORDER is not defined!
+#endif
+#if (BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN)
+# error BYTE_ORDER must be defined to either BIG_ENDIAN or LITTLE_ENDIAN
+#endif
+#endif /* ! _PIM_VT */
+
+/*
+ * PIM packet header
+ */
+struct pim {
+#ifdef _PIM_VT
+       uint8_t         pim_vt;         /* PIM version and message type */
+#else /* ! _PIM_VT   */
+#if BYTE_ORDER == BIG_ENDIAN
+       u_int           pim_vers:4,     /* PIM protocol version         */
+                       pim_type:4;     /* PIM message type             */
+#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+       u_int           pim_type:4,     /* PIM message type             */
+                       pim_vers:4;     /* PIM protocol version         */
+#endif
+#endif /* ! _PIM_VT  */
+       uint8_t         pim_reserved;   /* Reserved                     */
+       uint16_t        pim_cksum;      /* IP-style checksum            */
+};
+/* KAME-related name backward compatibility */
+#define pim_ver pim_vers
+#define pim_rsv pim_reserved
+
+#ifdef _PIM_VT
+#define PIM_MAKE_VT(v, t)      (0xff & (((v) << 4) | (0x0f & (t))))
+#define PIM_VT_V(x)            (((x) >> 4) & 0x0f)
+#define PIM_VT_T(x)            ((x) & 0x0f)
+#endif /* _PIM_VT */
+
+#define PIM_VERSION            2
+#define PIM_MINLEN             8       /* PIM message min. length      */
+#define PIM_REG_MINLEN (PIM_MINLEN+20) /* PIM Register hdr + inner IPv4 hdr */
+#define PIM6_REG_MINLEN        (PIM_MINLEN+40) /* PIM Register hdr + inner IPv6 hdr */
+
+/*
+ * PIM message types
+ */
+#define PIM_HELLO              0x0     /* PIM-SM and PIM-DM            */
+#define PIM_REGISTER           0x1     /* PIM-SM only                  */
+#define PIM_REGISTER_STOP      0x2     /* PIM-SM only                  */
+#define PIM_JOIN_PRUNE         0x3     /* PIM-SM and PIM-DM            */
+#define PIM_BOOTSTRAP          0x4     /* PIM-SM only                  */
+#define PIM_ASSERT             0x5     /* PIM-SM and PIM-DM            */
+#define PIM_GRAFT              0x6     /* PIM-DM only                  */
+#define PIM_GRAFT_ACK          0x7     /* PIM-DM only                  */
+#define PIM_CAND_RP_ADV                0x8     /* PIM-SM only                  */
+#define PIM_ALL_DF_ELECTION    0xa     /* Bidir-PIM-SM only            */
+
+/*
+ * PIM-Register message flags
+ */
+#define PIM_BORDER_REGISTER 0x80000000U        /* The Border bit (host-order)  */
+#define PIM_NULL_REGISTER   0x40000000U        /* The Null-Register bit (host-order)*/
+
+/*
+ * All-PIM-Routers IPv4 and IPv6 multicast addresses
+ */
+#define INADDR_ALLPIM_ROUTERS_GROUP    (uint32_t)0xe000000dU  /* 224.0.0.13 */
+#define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS       "ff02::d"
+#define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS_INIT                          \
+       {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,             \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d }}}
+
+#endif /* _NETINET_PIM_H_ */
diff -r 2550a93ae5d8 -r 63dfb7cfa0cb sys/netinet/pim_var.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/netinet/pim_var.h     Sat Sep 04 23:32:29 2004 +0000
@@ -0,0 +1,81 @@
+/*     $NetBSD: pim_var.h,v 1.1 2004/09/04 23:32:29 manu Exp $ */
+
+/*
+ * Copyright (c) 1998-2000
+ * University of Southern California/Information Sciences Institute.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: /repoman/r/ncvs/src/sys/netinet/pim_var.h,v 1.1 2003/08/07 18:17:43 hsu Exp $
+ */
+
+#ifndef _NETINET_PIM_VAR_H_
+#define _NETINET_PIM_VAR_H_
+
+/*
+ * Protocol Independent Multicast (PIM),
+ * kernel variables and implementation-specific definitions.
+ *
+ * Written by George Edmond Eddy (Rusty), ISI, February 1998.
+ * Modified by Pavlin Radoslavov, USC/ISI, May 1998, Aug 1999, October 2000.
+ * Modified by Hitoshi Asaeda, WIDE, August 1998.
+ */
+
+/*
+ * PIM statistics kept in the kernel
+ */
+struct pimstat {
+       u_quad_t pims_rcv_total_msgs;      /* total PIM messages received    */
+       u_quad_t pims_rcv_total_bytes;     /* total PIM bytes received       */
+       u_quad_t pims_rcv_tooshort;        /* rcvd with too few bytes        */
+       u_quad_t pims_rcv_badsum;          /* rcvd with bad checksum         */
+       u_quad_t pims_rcv_badversion;      /* rcvd bad PIM version           */
+       u_quad_t pims_rcv_registers_msgs;  /* rcvd regs. msgs (data only)    */
+       u_quad_t pims_rcv_registers_bytes; /* rcvd regs. bytes (data only)   */
+       u_quad_t pims_rcv_registers_wrongiif; /* rcvd regs. on wrong iif     */
+       u_quad_t pims_rcv_badregisters;    /* rcvd invalid registers         */
+       u_quad_t pims_snd_registers_msgs;  /* sent regs. msgs (data only)    */
+       u_quad_t pims_snd_registers_bytes; /* sent regs. bytes (data only)   */
+};
+
+/*
+ * Names for PIM sysctl objects
+ */
+#define PIMCTL_STATS           1       /* statistics (read-only) */
+#define PIMCTL_MAXID           2
+
+#define PIMCTL_NAMES {                 \
+       { 0, 0 },                       \
+       { "stats", CTLTYPE_STRUCT },    \
+}
+
+#ifdef _KERNEL
+extern struct pimstat pimstat;
+
+void   pim_input(struct mbuf *, ...);
+#endif
+
+#endif /* _NETINET_PIM_VAR_H_ */



Home | Main Index | Thread Index | Old Index