1caf43b02SWarner Losh /*- 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. 28b48287a3SDavid E. O'Brien * 29b48287a3SDavid E. O'Brien * $KAME: ip6_mroute.h,v 1.19 2001/06/14 06:12:55 suz Exp $ 30b48287a3SDavid E. O'Brien * $FreeBSD$ 3191ec0a1eSYoshinobu Inoue */ 3291ec0a1eSYoshinobu Inoue 3391ec0a1eSYoshinobu Inoue /* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */ 3491ec0a1eSYoshinobu Inoue 3591ec0a1eSYoshinobu Inoue /* 3691ec0a1eSYoshinobu Inoue * Definitions for IP multicast forwarding. 3791ec0a1eSYoshinobu Inoue * 3891ec0a1eSYoshinobu Inoue * Written by David Waitzman, BBN Labs, August 1988. 3991ec0a1eSYoshinobu Inoue * Modified by Steve Deering, Stanford, February 1989. 4091ec0a1eSYoshinobu Inoue * Modified by Ajit Thyagarajan, PARC, August 1993. 4191ec0a1eSYoshinobu Inoue * Modified by Ajit Thyagarajan, PARC, August 1994. 4291ec0a1eSYoshinobu Inoue * Modified by Ahmed Helmy, USC, September 1996. 4391ec0a1eSYoshinobu Inoue * 4491ec0a1eSYoshinobu Inoue * MROUTING Revision: 1.2 4591ec0a1eSYoshinobu Inoue */ 4691ec0a1eSYoshinobu Inoue 4791ec0a1eSYoshinobu Inoue #ifndef _NETINET6_IP6_MROUTE_H_ 4891ec0a1eSYoshinobu Inoue #define _NETINET6_IP6_MROUTE_H_ 4991ec0a1eSYoshinobu Inoue 5091ec0a1eSYoshinobu Inoue /* 5191ec0a1eSYoshinobu Inoue * Multicast Routing set/getsockopt commands. 5291ec0a1eSYoshinobu Inoue */ 53686cdd19SJun-ichiro itojun Hagino #ifdef _KERNEL 54686cdd19SJun-ichiro itojun Hagino #define MRT6_OINIT 100 /* initialize forwarder (omrt6msg) */ 55686cdd19SJun-ichiro itojun Hagino #endif 5691ec0a1eSYoshinobu Inoue #define MRT6_DONE 101 /* shut down forwarder */ 5791ec0a1eSYoshinobu Inoue #define MRT6_ADD_MIF 102 /* add multicast interface */ 5891ec0a1eSYoshinobu Inoue #define MRT6_DEL_MIF 103 /* delete multicast interface */ 5991ec0a1eSYoshinobu Inoue #define MRT6_ADD_MFC 104 /* insert forwarding cache entry */ 6091ec0a1eSYoshinobu Inoue #define MRT6_DEL_MFC 105 /* delete forwarding cache entry */ 6191ec0a1eSYoshinobu Inoue #define MRT6_PIM 107 /* enable pim code */ 62686cdd19SJun-ichiro itojun Hagino #define MRT6_INIT 108 /* initialize forwarder (mrt6msg) */ 6391ec0a1eSYoshinobu Inoue 6491ec0a1eSYoshinobu Inoue #if BSD >= 199103 6591ec0a1eSYoshinobu Inoue #define GET_TIME(t) microtime(&t) 6691ec0a1eSYoshinobu Inoue #elif defined(sun) 6791ec0a1eSYoshinobu Inoue #define GET_TIME(t) uniqtime(&t) 6891ec0a1eSYoshinobu Inoue #else 6991ec0a1eSYoshinobu Inoue #define GET_TIME(t) ((t) = time) 7091ec0a1eSYoshinobu Inoue #endif 7191ec0a1eSYoshinobu Inoue 7291ec0a1eSYoshinobu Inoue /* 7391ec0a1eSYoshinobu Inoue * Types and macros for handling bitmaps with one bit per multicast interface. 7491ec0a1eSYoshinobu Inoue */ 7591ec0a1eSYoshinobu Inoue typedef u_short mifi_t; /* type of a mif index */ 7691ec0a1eSYoshinobu Inoue #define MAXMIFS 64 7791ec0a1eSYoshinobu Inoue 7891ec0a1eSYoshinobu Inoue #ifndef IF_SETSIZE 7991ec0a1eSYoshinobu Inoue #define IF_SETSIZE 256 8091ec0a1eSYoshinobu Inoue #endif 8191ec0a1eSYoshinobu Inoue 8233841545SHajimu UMEMOTO typedef u_int32_t if_mask; 8391ec0a1eSYoshinobu Inoue #define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */ 8491ec0a1eSYoshinobu Inoue 8591ec0a1eSYoshinobu Inoue #ifndef howmany 8691ec0a1eSYoshinobu Inoue #define howmany(x, y) (((x) + ((y) - 1)) / (y)) 8791ec0a1eSYoshinobu Inoue #endif 8891ec0a1eSYoshinobu Inoue 8991ec0a1eSYoshinobu Inoue typedef struct if_set { 9033841545SHajimu UMEMOTO if_mask ifs_bits[howmany(IF_SETSIZE, NIFBITS)]; 9191ec0a1eSYoshinobu Inoue } if_set; 9291ec0a1eSYoshinobu Inoue 9391ec0a1eSYoshinobu Inoue #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS))) 9491ec0a1eSYoshinobu Inoue #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS))) 9591ec0a1eSYoshinobu Inoue #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS))) 9691ec0a1eSYoshinobu Inoue #define IF_COPY(f, t) bcopy(f, t, sizeof(*(f))) 9791ec0a1eSYoshinobu Inoue #define IF_ZERO(p) bzero(p, sizeof(*(p))) 9891ec0a1eSYoshinobu Inoue 9991ec0a1eSYoshinobu Inoue /* 10091ec0a1eSYoshinobu Inoue * Argument structure for MRT6_ADD_IF. 10191ec0a1eSYoshinobu Inoue */ 10291ec0a1eSYoshinobu Inoue struct mif6ctl { 10391ec0a1eSYoshinobu Inoue mifi_t mif6c_mifi; /* the index of the mif to be added */ 10491ec0a1eSYoshinobu Inoue u_char mif6c_flags; /* MIFF_ flags defined below */ 10591ec0a1eSYoshinobu Inoue u_short mif6c_pifi; /* the index of the physical IF */ 10691ec0a1eSYoshinobu Inoue }; 10791ec0a1eSYoshinobu Inoue 10891ec0a1eSYoshinobu Inoue #define MIFF_REGISTER 0x1 /* mif represents a register end-point */ 10991ec0a1eSYoshinobu Inoue 11091ec0a1eSYoshinobu Inoue /* 11191ec0a1eSYoshinobu Inoue * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC 11291ec0a1eSYoshinobu Inoue */ 11391ec0a1eSYoshinobu Inoue struct mf6cctl { 11491ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6cc_origin; /* IPv6 origin of mcasts */ 11591ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */ 11691ec0a1eSYoshinobu Inoue mifi_t mf6cc_parent; /* incoming ifindex */ 11791ec0a1eSYoshinobu Inoue struct if_set mf6cc_ifset; /* set of forwarding ifs */ 11891ec0a1eSYoshinobu Inoue }; 11991ec0a1eSYoshinobu Inoue 12091ec0a1eSYoshinobu Inoue /* 12191ec0a1eSYoshinobu Inoue * The kernel's multicast routing statistics. 12291ec0a1eSYoshinobu Inoue */ 12391ec0a1eSYoshinobu Inoue struct mrt6stat { 124*c80211e3SAndrey V. Elsukov uint64_t mrt6s_mfc_lookups; /* # forw. cache hash table hits */ 125*c80211e3SAndrey V. Elsukov uint64_t mrt6s_mfc_misses; /* # forw. cache hash table misses */ 126*c80211e3SAndrey V. Elsukov uint64_t mrt6s_upcalls; /* # calls to multicast routing daemon */ 127*c80211e3SAndrey V. Elsukov uint64_t mrt6s_no_route; /* no route for packet's origin */ 128*c80211e3SAndrey V. Elsukov uint64_t mrt6s_bad_tunnel; /* malformed tunnel options */ 129*c80211e3SAndrey V. Elsukov uint64_t mrt6s_cant_tunnel; /* no room for tunnel options */ 130*c80211e3SAndrey V. Elsukov uint64_t mrt6s_wrong_if; /* arrived on wrong interface */ 131*c80211e3SAndrey V. Elsukov uint64_t mrt6s_upq_ovflw; /* upcall Q overflow */ 132*c80211e3SAndrey V. Elsukov uint64_t mrt6s_cache_cleanups; /* # entries with no upcalls */ 133*c80211e3SAndrey V. Elsukov uint64_t mrt6s_drop_sel; /* pkts dropped selectively */ 134*c80211e3SAndrey V. Elsukov uint64_t mrt6s_q_overflow; /* pkts dropped - Q overflow */ 135*c80211e3SAndrey V. Elsukov uint64_t mrt6s_pkt2large; /* pkts dropped - size > BKT SIZE */ 136*c80211e3SAndrey V. Elsukov uint64_t mrt6s_upq_sockfull; /* upcalls dropped - socket full */ 13791ec0a1eSYoshinobu Inoue }; 13891ec0a1eSYoshinobu Inoue 139686cdd19SJun-ichiro itojun Hagino #ifdef MRT6_OINIT 14091ec0a1eSYoshinobu Inoue /* 14191ec0a1eSYoshinobu Inoue * Struct used to communicate from kernel to multicast router 14291ec0a1eSYoshinobu Inoue * note the convenient similarity to an IPv6 header. 143686cdd19SJun-ichiro itojun Hagino * XXX old version, superseded by mrt6msg. 14491ec0a1eSYoshinobu Inoue */ 145686cdd19SJun-ichiro itojun Hagino struct omrt6msg { 14691ec0a1eSYoshinobu Inoue u_long unused1; 14791ec0a1eSYoshinobu Inoue u_char im6_msgtype; /* what type of message */ 148686cdd19SJun-ichiro itojun Hagino #if 0 149686cdd19SJun-ichiro itojun Hagino #define MRT6MSG_NOCACHE 1 150686cdd19SJun-ichiro itojun Hagino #define MRT6MSG_WRONGMIF 2 151686cdd19SJun-ichiro itojun Hagino #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/ 152686cdd19SJun-ichiro itojun Hagino #endif 153686cdd19SJun-ichiro itojun Hagino u_char im6_mbz; /* must be zero */ 154686cdd19SJun-ichiro itojun Hagino u_char im6_mif; /* mif rec'd on */ 155686cdd19SJun-ichiro itojun Hagino u_char unused2; 156686cdd19SJun-ichiro itojun Hagino struct in6_addr im6_src, im6_dst; 157686cdd19SJun-ichiro itojun Hagino }; 158686cdd19SJun-ichiro itojun Hagino #endif 159686cdd19SJun-ichiro itojun Hagino 160686cdd19SJun-ichiro itojun Hagino /* 161686cdd19SJun-ichiro itojun Hagino * Structure used to communicate from kernel to multicast router. 162686cdd19SJun-ichiro itojun Hagino * We'll overlay the structure onto an MLD header (not an IPv6 header 163686cdd19SJun-ichiro itojun Hagino * like igmpmsg{} used for IPv4 implementation). This is because this 164686cdd19SJun-ichiro itojun Hagino * structure will be passed via an IPv6 raw socket, on which an application 165686cdd19SJun-ichiro itojun Hagino * will only receive the payload i.e. the data after the IPv6 header and all 16618b35df8SHajimu UMEMOTO * the extension headers. (see Section 3 of RFC3542) 167686cdd19SJun-ichiro itojun Hagino */ 168686cdd19SJun-ichiro itojun Hagino struct mrt6msg { 16991ec0a1eSYoshinobu Inoue #define MRT6MSG_NOCACHE 1 17091ec0a1eSYoshinobu Inoue #define MRT6MSG_WRONGMIF 2 17191ec0a1eSYoshinobu Inoue #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/ 17291ec0a1eSYoshinobu Inoue u_char im6_mbz; /* must be zero */ 173686cdd19SJun-ichiro itojun Hagino u_char im6_msgtype; /* what type of message */ 174686cdd19SJun-ichiro itojun Hagino u_int16_t im6_mif; /* mif rec'd on */ 175686cdd19SJun-ichiro itojun Hagino u_int32_t im6_pad; /* padding for 64bit arch */ 17691ec0a1eSYoshinobu Inoue struct in6_addr im6_src, im6_dst; 17791ec0a1eSYoshinobu Inoue }; 17891ec0a1eSYoshinobu Inoue 17991ec0a1eSYoshinobu Inoue /* 18091ec0a1eSYoshinobu Inoue * Argument structure used by multicast routing daemon to get src-grp 18191ec0a1eSYoshinobu Inoue * packet counts 18291ec0a1eSYoshinobu Inoue */ 18391ec0a1eSYoshinobu Inoue struct sioc_sg_req6 { 18491ec0a1eSYoshinobu Inoue struct sockaddr_in6 src; 18591ec0a1eSYoshinobu Inoue struct sockaddr_in6 grp; 18691ec0a1eSYoshinobu Inoue u_quad_t pktcnt; 18791ec0a1eSYoshinobu Inoue u_quad_t bytecnt; 18891ec0a1eSYoshinobu Inoue u_quad_t wrong_if; 18991ec0a1eSYoshinobu Inoue }; 19091ec0a1eSYoshinobu Inoue 19191ec0a1eSYoshinobu Inoue /* 19291ec0a1eSYoshinobu Inoue * Argument structure used by mrouted to get mif pkt counts 19391ec0a1eSYoshinobu Inoue */ 19491ec0a1eSYoshinobu Inoue struct sioc_mif_req6 { 19591ec0a1eSYoshinobu Inoue mifi_t mifi; /* mif number */ 19691ec0a1eSYoshinobu Inoue u_quad_t icount; /* Input packet count on mif */ 19791ec0a1eSYoshinobu Inoue u_quad_t ocount; /* Output packet count on mif */ 19891ec0a1eSYoshinobu Inoue u_quad_t ibytes; /* Input byte count on mif */ 19991ec0a1eSYoshinobu Inoue u_quad_t obytes; /* Output byte count on mif */ 20091ec0a1eSYoshinobu Inoue }; 20191ec0a1eSYoshinobu Inoue 20291ec0a1eSYoshinobu Inoue #if defined(_KERNEL) || defined(KERNEL) 20391ec0a1eSYoshinobu Inoue /* 20491ec0a1eSYoshinobu Inoue * The kernel's multicast-interface structure. 20591ec0a1eSYoshinobu Inoue */ 20691ec0a1eSYoshinobu Inoue struct mif6 { 20791ec0a1eSYoshinobu Inoue u_char m6_flags; /* MIFF_ flags defined above */ 20891ec0a1eSYoshinobu Inoue u_int m6_rate_limit; /* max rate */ 20991ec0a1eSYoshinobu Inoue struct in6_addr m6_lcl_addr; /* local interface address */ 21091ec0a1eSYoshinobu Inoue struct ifnet *m6_ifp; /* pointer to interface */ 21191ec0a1eSYoshinobu Inoue u_quad_t m6_pkt_in; /* # pkts in on interface */ 21291ec0a1eSYoshinobu Inoue u_quad_t m6_pkt_out; /* # pkts out on interface */ 21391ec0a1eSYoshinobu Inoue u_quad_t m6_bytes_in; /* # bytes in on interface */ 21491ec0a1eSYoshinobu Inoue u_quad_t m6_bytes_out; /* # bytes out on interface */ 21591ec0a1eSYoshinobu Inoue #ifdef notyet 21691ec0a1eSYoshinobu Inoue u_int m6_rsvp_on; /* RSVP listening on this vif */ 21791ec0a1eSYoshinobu Inoue struct socket *m6_rsvpd; /* RSVP daemon socket */ 21891ec0a1eSYoshinobu Inoue #endif 21991ec0a1eSYoshinobu Inoue }; 22091ec0a1eSYoshinobu Inoue 22191ec0a1eSYoshinobu Inoue /* 22291ec0a1eSYoshinobu Inoue * The kernel's multicast forwarding cache entry structure 22391ec0a1eSYoshinobu Inoue */ 22491ec0a1eSYoshinobu Inoue struct mf6c { 22591ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6c_origin; /* IPv6 origin of mcasts */ 22691ec0a1eSYoshinobu Inoue struct sockaddr_in6 mf6c_mcastgrp; /* multicast group associated*/ 22791ec0a1eSYoshinobu Inoue mifi_t mf6c_parent; /* incoming IF */ 22891ec0a1eSYoshinobu Inoue struct if_set mf6c_ifset; /* set of outgoing IFs */ 22991ec0a1eSYoshinobu Inoue 23091ec0a1eSYoshinobu Inoue u_quad_t mf6c_pkt_cnt; /* pkt count for src-grp */ 23191ec0a1eSYoshinobu Inoue u_quad_t mf6c_byte_cnt; /* byte count for src-grp */ 23291ec0a1eSYoshinobu Inoue u_quad_t mf6c_wrong_if; /* wrong if for src-grp */ 23391ec0a1eSYoshinobu Inoue int mf6c_expire; /* time to clean entry up */ 23491ec0a1eSYoshinobu Inoue struct timeval mf6c_last_assert; /* last time I sent an assert*/ 23591ec0a1eSYoshinobu Inoue struct rtdetq *mf6c_stall; /* pkts waiting for route */ 23691ec0a1eSYoshinobu Inoue struct mf6c *mf6c_next; /* hash table linkage */ 23791ec0a1eSYoshinobu Inoue }; 23891ec0a1eSYoshinobu Inoue 23991ec0a1eSYoshinobu Inoue #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1) 24091ec0a1eSYoshinobu Inoue 24191ec0a1eSYoshinobu Inoue /* 24291ec0a1eSYoshinobu Inoue * Argument structure used for pkt info. while upcall is made 24391ec0a1eSYoshinobu Inoue */ 24491ec0a1eSYoshinobu Inoue #ifndef _NETINET_IP_MROUTE_H_ 24591ec0a1eSYoshinobu Inoue struct rtdetq { /* XXX: rtdetq is also defined in ip_mroute.h */ 24691ec0a1eSYoshinobu Inoue struct mbuf *m; /* A copy of the packet */ 24791ec0a1eSYoshinobu Inoue struct ifnet *ifp; /* Interface pkt came in on */ 24891ec0a1eSYoshinobu Inoue #ifdef UPCALL_TIMING 24991ec0a1eSYoshinobu Inoue struct timeval t; /* Timestamp */ 25091ec0a1eSYoshinobu Inoue #endif /* UPCALL_TIMING */ 25191ec0a1eSYoshinobu Inoue struct rtdetq *next; 25291ec0a1eSYoshinobu Inoue }; 25391ec0a1eSYoshinobu Inoue #endif /* _NETINET_IP_MROUTE_H_ */ 25491ec0a1eSYoshinobu Inoue 25591ec0a1eSYoshinobu Inoue #define MF6CTBLSIZ 256 25691ec0a1eSYoshinobu Inoue #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */ 25791ec0a1eSYoshinobu Inoue #define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1)) 25891ec0a1eSYoshinobu Inoue #else 25991ec0a1eSYoshinobu Inoue #define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ) 26091ec0a1eSYoshinobu Inoue #endif 26191ec0a1eSYoshinobu Inoue 26291ec0a1eSYoshinobu Inoue #define MAX_UPQ6 4 /* max. no of pkts in upcall Q */ 26391ec0a1eSYoshinobu Inoue 2646be2e366SBruce M Simpson extern int (*ip6_mrouter_set)(struct socket *so, struct sockopt *sopt); 2656be2e366SBruce M Simpson extern int (*ip6_mrouter_get)(struct socket *so, struct sockopt *sopt); 2666be2e366SBruce M Simpson extern int (*ip6_mrouter_done)(void); 267e40bae9aSRoman Divacky extern int (*mrt6_ioctl)(u_long, caddr_t); 26891ec0a1eSYoshinobu Inoue #endif /* _KERNEL */ 26991ec0a1eSYoshinobu Inoue 27091ec0a1eSYoshinobu Inoue #endif /* !_NETINET6_IP6_MROUTE_H_ */ 271