191ec0a1eSYoshinobu Inoue /* 291ec0a1eSYoshinobu Inoue * Copyright (C) 1998 WIDE Project. 391ec0a1eSYoshinobu Inoue * All rights reserved. 491ec0a1eSYoshinobu Inoue * 591ec0a1eSYoshinobu Inoue * Redistribution and use in source and binary forms, with or without 691ec0a1eSYoshinobu Inoue * modification, are permitted provided that the following conditions 791ec0a1eSYoshinobu Inoue * are met: 891ec0a1eSYoshinobu Inoue * 1. Redistributions of source code must retain the above copyright 991ec0a1eSYoshinobu Inoue * notice, this list of conditions and the following disclaimer. 1091ec0a1eSYoshinobu Inoue * 2. Redistributions in binary form must reproduce the above copyright 1191ec0a1eSYoshinobu Inoue * notice, this list of conditions and the following disclaimer in the 1291ec0a1eSYoshinobu Inoue * documentation and/or other materials provided with the distribution. 1391ec0a1eSYoshinobu Inoue * 3. Neither the name of the project nor the names of its contributors 1491ec0a1eSYoshinobu Inoue * may be used to endorse or promote products derived from this software 1591ec0a1eSYoshinobu Inoue * without specific prior written permission. 1691ec0a1eSYoshinobu Inoue * 1791ec0a1eSYoshinobu Inoue * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 1891ec0a1eSYoshinobu Inoue * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1991ec0a1eSYoshinobu Inoue * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2091ec0a1eSYoshinobu Inoue * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2191ec0a1eSYoshinobu Inoue * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2291ec0a1eSYoshinobu Inoue * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2391ec0a1eSYoshinobu Inoue * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2491ec0a1eSYoshinobu Inoue * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2591ec0a1eSYoshinobu Inoue * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2691ec0a1eSYoshinobu Inoue * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2791ec0a1eSYoshinobu Inoue * SUCH DAMAGE. 2891ec0a1eSYoshinobu Inoue * 2991ec0a1eSYoshinobu Inoue * $FreeBSD$ 3091ec0a1eSYoshinobu Inoue */ 3191ec0a1eSYoshinobu Inoue 3291ec0a1eSYoshinobu Inoue /* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */ 3391ec0a1eSYoshinobu Inoue 3491ec0a1eSYoshinobu Inoue /* 3591ec0a1eSYoshinobu Inoue * Definitions for IP multicast forwarding. 3691ec0a1eSYoshinobu Inoue * 3791ec0a1eSYoshinobu Inoue * Written by David Waitzman, BBN Labs, August 1988. 3891ec0a1eSYoshinobu Inoue * Modified by Steve Deering, Stanford, February 1989. 3991ec0a1eSYoshinobu Inoue * Modified by Ajit Thyagarajan, PARC, August 1993. 4091ec0a1eSYoshinobu Inoue * Modified by Ajit Thyagarajan, PARC, August 1994. 4191ec0a1eSYoshinobu Inoue * Modified by Ahmed Helmy, USC, September 1996. 4291ec0a1eSYoshinobu Inoue * 4391ec0a1eSYoshinobu Inoue * MROUTING Revision: 1.2 4491ec0a1eSYoshinobu Inoue */ 4591ec0a1eSYoshinobu Inoue 4691ec0a1eSYoshinobu Inoue #ifndef _NETINET6_IP6_MROUTE_H_ 4791ec0a1eSYoshinobu Inoue #define _NETINET6_IP6_MROUTE_H_ 4891ec0a1eSYoshinobu Inoue 4991ec0a1eSYoshinobu Inoue /* 5091ec0a1eSYoshinobu Inoue * Multicast Routing set/getsockopt commands. 5191ec0a1eSYoshinobu Inoue */ 5291ec0a1eSYoshinobu Inoue #define MRT6_INIT 100 /* initialize forwarder */ 5391ec0a1eSYoshinobu Inoue #define MRT6_DONE 101 /* shut down forwarder */ 5491ec0a1eSYoshinobu Inoue #define MRT6_ADD_MIF 102 /* add multicast interface */ 5591ec0a1eSYoshinobu Inoue #define MRT6_DEL_MIF 103 /* delete multicast interface */ 5691ec0a1eSYoshinobu Inoue #define MRT6_ADD_MFC 104 /* insert forwarding cache entry */ 5791ec0a1eSYoshinobu Inoue #define MRT6_DEL_MFC 105 /* delete forwarding cache entry */ 5891ec0a1eSYoshinobu Inoue #define MRT6_PIM 107 /* enable pim code */ 5991ec0a1eSYoshinobu Inoue 6091ec0a1eSYoshinobu Inoue #define GET_TIME(t) microtime(&t) 6191ec0a1eSYoshinobu Inoue 6291ec0a1eSYoshinobu Inoue /* 6391ec0a1eSYoshinobu Inoue * Types and macros for handling bitmaps with one bit per multicast interface. 6491ec0a1eSYoshinobu Inoue */ 6591ec0a1eSYoshinobu Inoue typedef u_short mifi_t; /* type of a mif index */ 6691ec0a1eSYoshinobu Inoue #define MAXMIFS 64 6791ec0a1eSYoshinobu Inoue 6891ec0a1eSYoshinobu Inoue #ifndef IF_SETSIZE 6991ec0a1eSYoshinobu Inoue #define IF_SETSIZE 256 7091ec0a1eSYoshinobu Inoue #endif 7191ec0a1eSYoshinobu Inoue 7291ec0a1eSYoshinobu Inoue typedef long if_mask; 7391ec0a1eSYoshinobu Inoue #define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */ 7491ec0a1eSYoshinobu Inoue 7591ec0a1eSYoshinobu Inoue #ifndef howmany 7691ec0a1eSYoshinobu Inoue #define howmany(x, y) (((x) + ((y) - 1)) / (y)) 7791ec0a1eSYoshinobu Inoue #endif 7891ec0a1eSYoshinobu Inoue 7991ec0a1eSYoshinobu Inoue typedef struct if_set { 8091ec0a1eSYoshinobu Inoue fd_mask ifs_bits[howmany(IF_SETSIZE, NIFBITS)]; 8191ec0a1eSYoshinobu Inoue } if_set; 8291ec0a1eSYoshinobu Inoue 8391ec0a1eSYoshinobu Inoue #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS))) 8491ec0a1eSYoshinobu Inoue #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS))) 8591ec0a1eSYoshinobu Inoue #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS))) 8691ec0a1eSYoshinobu Inoue #define IF_COPY(f, t) bcopy(f, t, sizeof(*(f))) 8791ec0a1eSYoshinobu Inoue #define IF_ZERO(p) bzero(p, sizeof(*(p))) 8891ec0a1eSYoshinobu Inoue 8991ec0a1eSYoshinobu Inoue /* 9091ec0a1eSYoshinobu Inoue * Argument structure for MRT6_ADD_IF. 9191ec0a1eSYoshinobu Inoue */ 9291ec0a1eSYoshinobu Inoue struct mif6ctl { 9391ec0a1eSYoshinobu Inoue mifi_t mif6c_mifi; /* the index of the mif to be added */ 9491ec0a1eSYoshinobu Inoue u_char mif6c_flags; /* MIFF_ flags defined below */ 9591ec0a1eSYoshinobu Inoue u_short mif6c_pifi; /* the index of the physical IF */ 9691ec0a1eSYoshinobu Inoue }; 9791ec0a1eSYoshinobu Inoue 9891ec0a1eSYoshinobu Inoue #define MIFF_REGISTER 0x1 /* mif represents a register end-point */ 9991ec0a1eSYoshinobu Inoue 10091ec0a1eSYoshinobu Inoue /* 10191ec0a1eSYoshinobu Inoue * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC 10291ec0a1eSYoshinobu Inoue */ 10391ec0a1eSYoshinobu Inoue struct mf6cctl { 10491ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6cc_origin; /* IPv6 origin of mcasts */ 10591ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */ 10691ec0a1eSYoshinobu Inoue mifi_t mf6cc_parent; /* incoming ifindex */ 10791ec0a1eSYoshinobu Inoue struct if_set mf6cc_ifset; /* set of forwarding ifs */ 10891ec0a1eSYoshinobu Inoue }; 10991ec0a1eSYoshinobu Inoue 11091ec0a1eSYoshinobu Inoue /* 11191ec0a1eSYoshinobu Inoue * The kernel's multicast routing statistics. 11291ec0a1eSYoshinobu Inoue */ 11391ec0a1eSYoshinobu Inoue struct mrt6stat { 11491ec0a1eSYoshinobu Inoue u_quad_t mrt6s_mfc_lookups; /* # forw. cache hash table hits */ 11591ec0a1eSYoshinobu Inoue u_quad_t mrt6s_mfc_misses; /* # forw. cache hash table misses */ 11691ec0a1eSYoshinobu Inoue u_quad_t mrt6s_upcalls; /* # calls to mrouted */ 11791ec0a1eSYoshinobu Inoue u_quad_t mrt6s_no_route; /* no route for packet's origin */ 11891ec0a1eSYoshinobu Inoue u_quad_t mrt6s_bad_tunnel; /* malformed tunnel options */ 11991ec0a1eSYoshinobu Inoue u_quad_t mrt6s_cant_tunnel; /* no room for tunnel options */ 12091ec0a1eSYoshinobu Inoue u_quad_t mrt6s_wrong_if; /* arrived on wrong interface */ 12191ec0a1eSYoshinobu Inoue u_quad_t mrt6s_upq_ovflw; /* upcall Q overflow */ 12291ec0a1eSYoshinobu Inoue u_quad_t mrt6s_cache_cleanups; /* # entries with no upcalls */ 12391ec0a1eSYoshinobu Inoue u_quad_t mrt6s_drop_sel; /* pkts dropped selectively */ 12491ec0a1eSYoshinobu Inoue u_quad_t mrt6s_q_overflow; /* pkts dropped - Q overflow */ 12591ec0a1eSYoshinobu Inoue u_quad_t mrt6s_pkt2large; /* pkts dropped - size > BKT SIZE */ 12691ec0a1eSYoshinobu Inoue u_quad_t mrt6s_upq_sockfull; /* upcalls dropped - socket full */ 12791ec0a1eSYoshinobu Inoue }; 12891ec0a1eSYoshinobu Inoue 12991ec0a1eSYoshinobu Inoue /* 13091ec0a1eSYoshinobu Inoue * Struct used to communicate from kernel to multicast router 13191ec0a1eSYoshinobu Inoue * note the convenient similarity to an IPv6 header. 13291ec0a1eSYoshinobu Inoue */ 13391ec0a1eSYoshinobu Inoue struct mrt6msg { 13491ec0a1eSYoshinobu Inoue u_long unused1; 13591ec0a1eSYoshinobu Inoue u_char im6_msgtype; /* what type of message */ 13691ec0a1eSYoshinobu Inoue #define MRT6MSG_NOCACHE 1 13791ec0a1eSYoshinobu Inoue #define MRT6MSG_WRONGMIF 2 13891ec0a1eSYoshinobu Inoue #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/ 13991ec0a1eSYoshinobu Inoue u_char im6_mbz; /* must be zero */ 14091ec0a1eSYoshinobu Inoue u_char im6_mif; /* mif rec'd on */ 14191ec0a1eSYoshinobu Inoue u_char unused2; 14291ec0a1eSYoshinobu Inoue struct in6_addr im6_src, im6_dst; 14391ec0a1eSYoshinobu Inoue }; 14491ec0a1eSYoshinobu Inoue 14591ec0a1eSYoshinobu Inoue /* 14691ec0a1eSYoshinobu Inoue * Argument structure used by multicast routing daemon to get src-grp 14791ec0a1eSYoshinobu Inoue * packet counts 14891ec0a1eSYoshinobu Inoue */ 14991ec0a1eSYoshinobu Inoue struct sioc_sg_req6 { 15091ec0a1eSYoshinobu Inoue struct sockaddr_in6 src; 15191ec0a1eSYoshinobu Inoue struct sockaddr_in6 grp; 15291ec0a1eSYoshinobu Inoue u_quad_t pktcnt; 15391ec0a1eSYoshinobu Inoue u_quad_t bytecnt; 15491ec0a1eSYoshinobu Inoue u_quad_t wrong_if; 15591ec0a1eSYoshinobu Inoue }; 15691ec0a1eSYoshinobu Inoue 15791ec0a1eSYoshinobu Inoue /* 15891ec0a1eSYoshinobu Inoue * Argument structure used by mrouted to get mif pkt counts 15991ec0a1eSYoshinobu Inoue */ 16091ec0a1eSYoshinobu Inoue struct sioc_mif_req6 { 16191ec0a1eSYoshinobu Inoue mifi_t mifi; /* mif number */ 16291ec0a1eSYoshinobu Inoue u_quad_t icount; /* Input packet count on mif */ 16391ec0a1eSYoshinobu Inoue u_quad_t ocount; /* Output packet count on mif */ 16491ec0a1eSYoshinobu Inoue u_quad_t ibytes; /* Input byte count on mif */ 16591ec0a1eSYoshinobu Inoue u_quad_t obytes; /* Output byte count on mif */ 16691ec0a1eSYoshinobu Inoue }; 16791ec0a1eSYoshinobu Inoue 16891ec0a1eSYoshinobu Inoue #if defined(_KERNEL) || defined(KERNEL) 16991ec0a1eSYoshinobu Inoue /* 17091ec0a1eSYoshinobu Inoue * The kernel's multicast-interface structure. 17191ec0a1eSYoshinobu Inoue */ 17291ec0a1eSYoshinobu Inoue struct mif6 { 17391ec0a1eSYoshinobu Inoue u_char m6_flags; /* MIFF_ flags defined above */ 17491ec0a1eSYoshinobu Inoue u_int m6_rate_limit; /* max rate */ 17591ec0a1eSYoshinobu Inoue struct in6_addr m6_lcl_addr; /* local interface address */ 17691ec0a1eSYoshinobu Inoue struct ifnet *m6_ifp; /* pointer to interface */ 17791ec0a1eSYoshinobu Inoue u_quad_t m6_pkt_in; /* # pkts in on interface */ 17891ec0a1eSYoshinobu Inoue u_quad_t m6_pkt_out; /* # pkts out on interface */ 17991ec0a1eSYoshinobu Inoue u_quad_t m6_bytes_in; /* # bytes in on interface */ 18091ec0a1eSYoshinobu Inoue u_quad_t m6_bytes_out; /* # bytes out on interface */ 18191ec0a1eSYoshinobu Inoue struct route_in6 m6_route;/* cached route if this is a tunnel */ 18291ec0a1eSYoshinobu Inoue }; 18391ec0a1eSYoshinobu Inoue 18491ec0a1eSYoshinobu Inoue /* 18591ec0a1eSYoshinobu Inoue * The kernel's multicast forwarding cache entry structure 18691ec0a1eSYoshinobu Inoue */ 18791ec0a1eSYoshinobu Inoue struct mf6c { 18891ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6c_origin; /* IPv6 origin of mcasts */ 18991ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6c_mcastgrp; /* multicast group associated*/ 19091ec0a1eSYoshinobu Inoue mifi_t mf6c_parent; /* incoming IF */ 19191ec0a1eSYoshinobu Inoue struct if_set mf6c_ifset; /* set of outgoing IFs */ 19291ec0a1eSYoshinobu Inoue u_quad_t mf6c_pkt_cnt; /* pkt count for src-grp */ 19391ec0a1eSYoshinobu Inoue u_quad_t mf6c_byte_cnt; /* byte count for src-grp */ 19491ec0a1eSYoshinobu Inoue u_quad_t mf6c_wrong_if; /* wrong if for src-grp */ 19591ec0a1eSYoshinobu Inoue int mf6c_expire; /* time to clean entry up */ 19691ec0a1eSYoshinobu Inoue struct timeval mf6c_last_assert; /* last time I sent an assert*/ 19791ec0a1eSYoshinobu Inoue struct rtdetq *mf6c_stall; /* pkts waiting for route */ 19891ec0a1eSYoshinobu Inoue struct mf6c *mf6c_next; /* hash table linkage */ 19991ec0a1eSYoshinobu Inoue }; 20091ec0a1eSYoshinobu Inoue 20191ec0a1eSYoshinobu Inoue #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1) 20291ec0a1eSYoshinobu Inoue 20391ec0a1eSYoshinobu Inoue /* 20491ec0a1eSYoshinobu Inoue * Argument structure used for pkt info. while upcall is made 20591ec0a1eSYoshinobu Inoue */ 20691ec0a1eSYoshinobu Inoue #ifndef _NETINET_IP_MROUTE_H_ 20791ec0a1eSYoshinobu Inoue struct rtdetq { /* XXX: rtdetq is also defined in ip_mroute.h */ 20891ec0a1eSYoshinobu Inoue struct mbuf *m; /* A copy of the packet */ 20991ec0a1eSYoshinobu Inoue struct ifnet *ifp; /* Interface pkt came in on */ 21091ec0a1eSYoshinobu Inoue #ifdef UPCALL_TIMING 21191ec0a1eSYoshinobu Inoue struct timeval t; /* Timestamp */ 21291ec0a1eSYoshinobu Inoue #endif /* UPCALL_TIMING */ 21391ec0a1eSYoshinobu Inoue struct rtdetq *next; 21491ec0a1eSYoshinobu Inoue }; 21591ec0a1eSYoshinobu Inoue #endif /* _NETINET_IP_MROUTE_H_ */ 21691ec0a1eSYoshinobu Inoue 21791ec0a1eSYoshinobu Inoue #define MF6CTBLSIZ 256 21891ec0a1eSYoshinobu Inoue #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */ 21991ec0a1eSYoshinobu Inoue #define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1)) 22091ec0a1eSYoshinobu Inoue #else 22191ec0a1eSYoshinobu Inoue #define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ) 22291ec0a1eSYoshinobu Inoue #endif 22391ec0a1eSYoshinobu Inoue 22491ec0a1eSYoshinobu Inoue #define MAX_UPQ6 4 /* max. no of pkts in upcall Q */ 22591ec0a1eSYoshinobu Inoue 22691ec0a1eSYoshinobu Inoue int ip6_mrouter_set __P((struct socket *so, struct sockopt *sopt)); 22791ec0a1eSYoshinobu Inoue int ip6_mrouter_get __P((struct socket *so, struct sockopt *sopt)); 22891ec0a1eSYoshinobu Inoue int ip6_mrouter_done __P((void)); 22991ec0a1eSYoshinobu Inoue int mrt6_ioctl __P((int, caddr_t)); 23091ec0a1eSYoshinobu Inoue #endif /* _KERNEL */ 23191ec0a1eSYoshinobu Inoue 23291ec0a1eSYoshinobu Inoue #endif /* !_NETINET6_IP6_MROUTE_H_ */ 23391ec0a1eSYoshinobu Inoue /* 23491ec0a1eSYoshinobu Inoue * Copyright (C) 1998 WIDE Project. 23591ec0a1eSYoshinobu Inoue * All rights reserved. 23691ec0a1eSYoshinobu Inoue * 23791ec0a1eSYoshinobu Inoue * Redistribution and use in source and binary forms, with or without 23891ec0a1eSYoshinobu Inoue * modification, are permitted provided that the following conditions 23991ec0a1eSYoshinobu Inoue * are met: 24091ec0a1eSYoshinobu Inoue * 1. Redistributions of source code must retain the above copyright 24191ec0a1eSYoshinobu Inoue * notice, this list of conditions and the following disclaimer. 24291ec0a1eSYoshinobu Inoue * 2. Redistributions in binary form must reproduce the above copyright 24391ec0a1eSYoshinobu Inoue * notice, this list of conditions and the following disclaimer in the 24491ec0a1eSYoshinobu Inoue * documentation and/or other materials provided with the distribution. 24591ec0a1eSYoshinobu Inoue * 3. Neither the name of the project nor the names of its contributors 24691ec0a1eSYoshinobu Inoue * may be used to endorse or promote products derived from this software 24791ec0a1eSYoshinobu Inoue * without specific prior written permission. 24891ec0a1eSYoshinobu Inoue * 24991ec0a1eSYoshinobu Inoue * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25091ec0a1eSYoshinobu Inoue * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25191ec0a1eSYoshinobu Inoue * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25291ec0a1eSYoshinobu Inoue * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 25391ec0a1eSYoshinobu Inoue * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25491ec0a1eSYoshinobu Inoue * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25591ec0a1eSYoshinobu Inoue * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25691ec0a1eSYoshinobu Inoue * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25791ec0a1eSYoshinobu Inoue * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25891ec0a1eSYoshinobu Inoue * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25991ec0a1eSYoshinobu Inoue * SUCH DAMAGE. 26091ec0a1eSYoshinobu Inoue */ 26191ec0a1eSYoshinobu Inoue 26291ec0a1eSYoshinobu Inoue /* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */ 26391ec0a1eSYoshinobu Inoue 26491ec0a1eSYoshinobu Inoue /* 26591ec0a1eSYoshinobu Inoue * Definitions for IP multicast forwarding. 26691ec0a1eSYoshinobu Inoue * 26791ec0a1eSYoshinobu Inoue * Written by David Waitzman, BBN Labs, August 1988. 26891ec0a1eSYoshinobu Inoue * Modified by Steve Deering, Stanford, February 1989. 26991ec0a1eSYoshinobu Inoue * Modified by Ajit Thyagarajan, PARC, August 1993. 27091ec0a1eSYoshinobu Inoue * Modified by Ajit Thyagarajan, PARC, August 1994. 27191ec0a1eSYoshinobu Inoue * Modified by Ahmed Helmy, USC, September 1996. 27291ec0a1eSYoshinobu Inoue * 27391ec0a1eSYoshinobu Inoue * MROUTING Revision: 1.2 27491ec0a1eSYoshinobu Inoue */ 27591ec0a1eSYoshinobu Inoue 27691ec0a1eSYoshinobu Inoue #ifndef _NETINET6_IP6_MROUTE_H_ 27791ec0a1eSYoshinobu Inoue #define _NETINET6_IP6_MROUTE_H_ 27891ec0a1eSYoshinobu Inoue 27991ec0a1eSYoshinobu Inoue /* 28091ec0a1eSYoshinobu Inoue * Multicast Routing set/getsockopt commands. 28191ec0a1eSYoshinobu Inoue */ 28291ec0a1eSYoshinobu Inoue #define MRT6_INIT 100 /* initialize forwarder */ 28391ec0a1eSYoshinobu Inoue #define MRT6_DONE 101 /* shut down forwarder */ 28491ec0a1eSYoshinobu Inoue #define MRT6_ADD_MIF 102 /* add multicast interface */ 28591ec0a1eSYoshinobu Inoue #define MRT6_DEL_MIF 103 /* delete multicast interface */ 28691ec0a1eSYoshinobu Inoue #define MRT6_ADD_MFC 104 /* insert forwarding cache entry */ 28791ec0a1eSYoshinobu Inoue #define MRT6_DEL_MFC 105 /* delete forwarding cache entry */ 28891ec0a1eSYoshinobu Inoue #define MRT6_PIM 107 /* enable pim code */ 28991ec0a1eSYoshinobu Inoue 29091ec0a1eSYoshinobu Inoue #if BSD >= 199103 29191ec0a1eSYoshinobu Inoue #define GET_TIME(t) microtime(&t) 29291ec0a1eSYoshinobu Inoue #elif defined(sun) 29391ec0a1eSYoshinobu Inoue #define GET_TIME(t) uniqtime(&t) 29491ec0a1eSYoshinobu Inoue #else 29591ec0a1eSYoshinobu Inoue #define GET_TIME(t) ((t) = time) 29691ec0a1eSYoshinobu Inoue #endif 29791ec0a1eSYoshinobu Inoue 29891ec0a1eSYoshinobu Inoue /* 29991ec0a1eSYoshinobu Inoue * Types and macros for handling bitmaps with one bit per multicast interface. 30091ec0a1eSYoshinobu Inoue */ 30191ec0a1eSYoshinobu Inoue typedef u_short mifi_t; /* type of a mif index */ 30291ec0a1eSYoshinobu Inoue #define MAXMIFS 64 30391ec0a1eSYoshinobu Inoue 30491ec0a1eSYoshinobu Inoue #ifndef IF_SETSIZE 30591ec0a1eSYoshinobu Inoue #define IF_SETSIZE 256 30691ec0a1eSYoshinobu Inoue #endif 30791ec0a1eSYoshinobu Inoue 30891ec0a1eSYoshinobu Inoue typedef long if_mask; 30991ec0a1eSYoshinobu Inoue #define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */ 31091ec0a1eSYoshinobu Inoue 31191ec0a1eSYoshinobu Inoue #ifndef howmany 31291ec0a1eSYoshinobu Inoue #define howmany(x, y) (((x) + ((y) - 1)) / (y)) 31391ec0a1eSYoshinobu Inoue #endif 31491ec0a1eSYoshinobu Inoue 31591ec0a1eSYoshinobu Inoue typedef struct if_set { 31691ec0a1eSYoshinobu Inoue fd_mask ifs_bits[howmany(IF_SETSIZE, NIFBITS)]; 31791ec0a1eSYoshinobu Inoue } if_set; 31891ec0a1eSYoshinobu Inoue 31991ec0a1eSYoshinobu Inoue #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS))) 32091ec0a1eSYoshinobu Inoue #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS))) 32191ec0a1eSYoshinobu Inoue #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS))) 32291ec0a1eSYoshinobu Inoue #define IF_COPY(f, t) bcopy(f, t, sizeof(*(f))) 32391ec0a1eSYoshinobu Inoue #define IF_ZERO(p) bzero(p, sizeof(*(p))) 32491ec0a1eSYoshinobu Inoue 32591ec0a1eSYoshinobu Inoue /* 32691ec0a1eSYoshinobu Inoue * Argument structure for MRT6_ADD_IF. 32791ec0a1eSYoshinobu Inoue */ 32891ec0a1eSYoshinobu Inoue struct mif6ctl { 32991ec0a1eSYoshinobu Inoue mifi_t mif6c_mifi; /* the index of the mif to be added */ 33091ec0a1eSYoshinobu Inoue u_char mif6c_flags; /* MIFF_ flags defined below */ 33191ec0a1eSYoshinobu Inoue u_short mif6c_pifi; /* the index of the physical IF */ 33291ec0a1eSYoshinobu Inoue #ifdef notyet 33391ec0a1eSYoshinobu Inoue u_int mif6c_rate_limit; /* max rate */ 33491ec0a1eSYoshinobu Inoue #endif 33591ec0a1eSYoshinobu Inoue }; 33691ec0a1eSYoshinobu Inoue 33791ec0a1eSYoshinobu Inoue #define MIFF_REGISTER 0x1 /* mif represents a register end-point */ 33891ec0a1eSYoshinobu Inoue 33991ec0a1eSYoshinobu Inoue /* 34091ec0a1eSYoshinobu Inoue * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC 34191ec0a1eSYoshinobu Inoue */ 34291ec0a1eSYoshinobu Inoue struct mf6cctl { 34391ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6cc_origin; /* IPv6 origin of mcasts */ 34491ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */ 34591ec0a1eSYoshinobu Inoue mifi_t mf6cc_parent; /* incoming ifindex */ 34691ec0a1eSYoshinobu Inoue struct if_set mf6cc_ifset; /* set of forwarding ifs */ 34791ec0a1eSYoshinobu Inoue }; 34891ec0a1eSYoshinobu Inoue 34991ec0a1eSYoshinobu Inoue /* 35091ec0a1eSYoshinobu Inoue * The kernel's multicast routing statistics. 35191ec0a1eSYoshinobu Inoue */ 35291ec0a1eSYoshinobu Inoue struct mrt6stat { 35391ec0a1eSYoshinobu Inoue u_quad_t mrt6s_mfc_lookups; /* # forw. cache hash table hits */ 35491ec0a1eSYoshinobu Inoue u_quad_t mrt6s_mfc_misses; /* # forw. cache hash table misses */ 35591ec0a1eSYoshinobu Inoue u_quad_t mrt6s_upcalls; /* # calls to mrouted */ 35691ec0a1eSYoshinobu Inoue u_quad_t mrt6s_no_route; /* no route for packet's origin */ 35791ec0a1eSYoshinobu Inoue u_quad_t mrt6s_bad_tunnel; /* malformed tunnel options */ 35891ec0a1eSYoshinobu Inoue u_quad_t mrt6s_cant_tunnel; /* no room for tunnel options */ 35991ec0a1eSYoshinobu Inoue u_quad_t mrt6s_wrong_if; /* arrived on wrong interface */ 36091ec0a1eSYoshinobu Inoue u_quad_t mrt6s_upq_ovflw; /* upcall Q overflow */ 36191ec0a1eSYoshinobu Inoue u_quad_t mrt6s_cache_cleanups; /* # entries with no upcalls */ 36291ec0a1eSYoshinobu Inoue u_quad_t mrt6s_drop_sel; /* pkts dropped selectively */ 36391ec0a1eSYoshinobu Inoue u_quad_t mrt6s_q_overflow; /* pkts dropped - Q overflow */ 36491ec0a1eSYoshinobu Inoue u_quad_t mrt6s_pkt2large; /* pkts dropped - size > BKT SIZE */ 36591ec0a1eSYoshinobu Inoue u_quad_t mrt6s_upq_sockfull; /* upcalls dropped - socket full */ 36691ec0a1eSYoshinobu Inoue }; 36791ec0a1eSYoshinobu Inoue 36891ec0a1eSYoshinobu Inoue /* 36991ec0a1eSYoshinobu Inoue * Struct used to communicate from kernel to multicast router 37091ec0a1eSYoshinobu Inoue * note the convenient similarity to an IPv6 header. 37191ec0a1eSYoshinobu Inoue */ 37291ec0a1eSYoshinobu Inoue struct mrt6msg { 37391ec0a1eSYoshinobu Inoue u_long unused1; 37491ec0a1eSYoshinobu Inoue u_char im6_msgtype; /* what type of message */ 37591ec0a1eSYoshinobu Inoue #define MRT6MSG_NOCACHE 1 37691ec0a1eSYoshinobu Inoue #define MRT6MSG_WRONGMIF 2 37791ec0a1eSYoshinobu Inoue #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/ 37891ec0a1eSYoshinobu Inoue u_char im6_mbz; /* must be zero */ 37991ec0a1eSYoshinobu Inoue u_char im6_mif; /* mif rec'd on */ 38091ec0a1eSYoshinobu Inoue u_char unused2; 38191ec0a1eSYoshinobu Inoue struct in6_addr im6_src, im6_dst; 38291ec0a1eSYoshinobu Inoue }; 38391ec0a1eSYoshinobu Inoue 38491ec0a1eSYoshinobu Inoue /* 38591ec0a1eSYoshinobu Inoue * Argument structure used by multicast routing daemon to get src-grp 38691ec0a1eSYoshinobu Inoue * packet counts 38791ec0a1eSYoshinobu Inoue */ 38891ec0a1eSYoshinobu Inoue struct sioc_sg_req6 { 38991ec0a1eSYoshinobu Inoue struct sockaddr_in6 src; 39091ec0a1eSYoshinobu Inoue struct sockaddr_in6 grp; 39191ec0a1eSYoshinobu Inoue u_quad_t pktcnt; 39291ec0a1eSYoshinobu Inoue u_quad_t bytecnt; 39391ec0a1eSYoshinobu Inoue u_quad_t wrong_if; 39491ec0a1eSYoshinobu Inoue }; 39591ec0a1eSYoshinobu Inoue 39691ec0a1eSYoshinobu Inoue /* 39791ec0a1eSYoshinobu Inoue * Argument structure used by mrouted to get mif pkt counts 39891ec0a1eSYoshinobu Inoue */ 39991ec0a1eSYoshinobu Inoue struct sioc_mif_req6 { 40091ec0a1eSYoshinobu Inoue mifi_t mifi; /* mif number */ 40191ec0a1eSYoshinobu Inoue u_quad_t icount; /* Input packet count on mif */ 40291ec0a1eSYoshinobu Inoue u_quad_t ocount; /* Output packet count on mif */ 40391ec0a1eSYoshinobu Inoue u_quad_t ibytes; /* Input byte count on mif */ 40491ec0a1eSYoshinobu Inoue u_quad_t obytes; /* Output byte count on mif */ 40591ec0a1eSYoshinobu Inoue }; 40691ec0a1eSYoshinobu Inoue 40791ec0a1eSYoshinobu Inoue #if defined(_KERNEL) || defined(KERNEL) 40891ec0a1eSYoshinobu Inoue /* 40991ec0a1eSYoshinobu Inoue * The kernel's multicast-interface structure. 41091ec0a1eSYoshinobu Inoue */ 41191ec0a1eSYoshinobu Inoue struct mif6 { 41291ec0a1eSYoshinobu Inoue u_char m6_flags; /* MIFF_ flags defined above */ 41391ec0a1eSYoshinobu Inoue u_int m6_rate_limit; /* max rate */ 41491ec0a1eSYoshinobu Inoue #ifdef notyet 41591ec0a1eSYoshinobu Inoue struct tbf *m6_tbf; /* token bucket structure at intf. */ 41691ec0a1eSYoshinobu Inoue #endif 41791ec0a1eSYoshinobu Inoue struct in6_addr m6_lcl_addr; /* local interface address */ 41891ec0a1eSYoshinobu Inoue struct ifnet *m6_ifp; /* pointer to interface */ 41991ec0a1eSYoshinobu Inoue u_quad_t m6_pkt_in; /* # pkts in on interface */ 42091ec0a1eSYoshinobu Inoue u_quad_t m6_pkt_out; /* # pkts out on interface */ 42191ec0a1eSYoshinobu Inoue u_quad_t m6_bytes_in; /* # bytes in on interface */ 42291ec0a1eSYoshinobu Inoue u_quad_t m6_bytes_out; /* # bytes out on interface */ 42391ec0a1eSYoshinobu Inoue struct route_in6 m6_route;/* cached route if this is a tunnel */ 42491ec0a1eSYoshinobu Inoue #ifdef notyet 42591ec0a1eSYoshinobu Inoue u_int m6_rsvp_on; /* RSVP listening on this vif */ 42691ec0a1eSYoshinobu Inoue struct socket *m6_rsvpd; /* RSVP daemon socket */ 42791ec0a1eSYoshinobu Inoue #endif 42891ec0a1eSYoshinobu Inoue }; 42991ec0a1eSYoshinobu Inoue 43091ec0a1eSYoshinobu Inoue /* 43191ec0a1eSYoshinobu Inoue * The kernel's multicast forwarding cache entry structure 43291ec0a1eSYoshinobu Inoue */ 43391ec0a1eSYoshinobu Inoue struct mf6c { 43491ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6c_origin; /* IPv6 origin of mcasts */ 43591ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6c_mcastgrp; /* multicast group associated*/ 43691ec0a1eSYoshinobu Inoue mifi_t mf6c_parent; /* incoming IF */ 43791ec0a1eSYoshinobu Inoue struct if_set mf6c_ifset; /* set of outgoing IFs */ 43891ec0a1eSYoshinobu Inoue 43991ec0a1eSYoshinobu Inoue u_quad_t mf6c_pkt_cnt; /* pkt count for src-grp */ 44091ec0a1eSYoshinobu Inoue u_quad_t mf6c_byte_cnt; /* byte count for src-grp */ 44191ec0a1eSYoshinobu Inoue u_quad_t mf6c_wrong_if; /* wrong if for src-grp */ 44291ec0a1eSYoshinobu Inoue int mf6c_expire; /* time to clean entry up */ 44391ec0a1eSYoshinobu Inoue struct timeval mf6c_last_assert; /* last time I sent an assert*/ 44491ec0a1eSYoshinobu Inoue struct rtdetq *mf6c_stall; /* pkts waiting for route */ 44591ec0a1eSYoshinobu Inoue struct mf6c *mf6c_next; /* hash table linkage */ 44691ec0a1eSYoshinobu Inoue }; 44791ec0a1eSYoshinobu Inoue 44891ec0a1eSYoshinobu Inoue #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1) 44991ec0a1eSYoshinobu Inoue 45091ec0a1eSYoshinobu Inoue /* 45191ec0a1eSYoshinobu Inoue * Argument structure used for pkt info. while upcall is made 45291ec0a1eSYoshinobu Inoue */ 45391ec0a1eSYoshinobu Inoue #ifndef _NETINET_IP_MROUTE_H_ 45491ec0a1eSYoshinobu Inoue struct rtdetq { /* XXX: rtdetq is also defined in ip_mroute.h */ 45591ec0a1eSYoshinobu Inoue struct mbuf *m; /* A copy of the packet */ 45691ec0a1eSYoshinobu Inoue struct ifnet *ifp; /* Interface pkt came in on */ 45791ec0a1eSYoshinobu Inoue #ifdef UPCALL_TIMING 45891ec0a1eSYoshinobu Inoue struct timeval t; /* Timestamp */ 45991ec0a1eSYoshinobu Inoue #endif /* UPCALL_TIMING */ 46091ec0a1eSYoshinobu Inoue struct rtdetq *next; 46191ec0a1eSYoshinobu Inoue }; 46291ec0a1eSYoshinobu Inoue #endif /* _NETINET_IP_MROUTE_H_ */ 46391ec0a1eSYoshinobu Inoue 46491ec0a1eSYoshinobu Inoue #define MF6CTBLSIZ 256 46591ec0a1eSYoshinobu Inoue #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */ 46691ec0a1eSYoshinobu Inoue #define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1)) 46791ec0a1eSYoshinobu Inoue #else 46891ec0a1eSYoshinobu Inoue #define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ) 46991ec0a1eSYoshinobu Inoue #endif 47091ec0a1eSYoshinobu Inoue 47191ec0a1eSYoshinobu Inoue #define MAX_UPQ6 4 /* max. no of pkts in upcall Q */ 47291ec0a1eSYoshinobu Inoue 47391ec0a1eSYoshinobu Inoue #if defined(__FreeBSD__) && __FreeBSD__ >= 3 47491ec0a1eSYoshinobu Inoue int ip6_mrouter_set __P((struct socket *so, struct sockopt *sopt)); 47591ec0a1eSYoshinobu Inoue int ip6_mrouter_get __P((struct socket *so, struct sockopt *sopt)); 47691ec0a1eSYoshinobu Inoue #else 47791ec0a1eSYoshinobu Inoue int ip6_mrouter_set __P((int, struct socket *, struct mbuf *)); 47891ec0a1eSYoshinobu Inoue int ip6_mrouter_get __P((int, struct socket *, struct mbuf **)); 47991ec0a1eSYoshinobu Inoue #endif 48091ec0a1eSYoshinobu Inoue int ip6_mrouter_done __P((void)); 48191ec0a1eSYoshinobu Inoue int mrt6_ioctl __P((int, caddr_t)); 48291ec0a1eSYoshinobu Inoue #endif /* _KERNEL */ 48391ec0a1eSYoshinobu Inoue 48491ec0a1eSYoshinobu Inoue #endif /* !_NETINET6_IP6_MROUTE_H_ */ 485