1 /* $KAME: ip6_mroute.h,v 1.7 2000/02/22 14:04:22 itojun Exp $ */
4 * Copyright (C) 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 /* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */
35 * Definitions for IP multicast forwarding.
37 * Written by David Waitzman, BBN Labs, August 1988.
38 * Modified by Steve Deering, Stanford, February 1989.
39 * Modified by Ajit Thyagarajan, PARC, August 1993.
40 * Modified by Ajit Thyagarajan, PARC, August 1994.
41 * Modified by Ahmed Helmy, USC, September 1996.
43 * MROUTING Revision: 1.2
46 #ifndef _NETINET6_IP6_MROUTE_H_
47 #define _NETINET6_IP6_MROUTE_H_
50 * Multicast Routing set/getsockopt commands.
52 #define MRT6_INIT 100 /* initialize forwarder */
53 #define MRT6_DONE 101 /* shut down forwarder */
54 #define MRT6_ADD_MIF 102 /* add multicast interface */
55 #define MRT6_DEL_MIF 103 /* delete multicast interface */
56 #define MRT6_ADD_MFC 104 /* insert forwarding cache entry */
57 #define MRT6_DEL_MFC 105 /* delete forwarding cache entry */
58 #define MRT6_PIM 107 /* enable pim code */
61 #define GET_TIME(t) microtime(&t)
63 #define GET_TIME(t) uniqtime(&t)
65 #define GET_TIME(t) ((t) = time)
69 * Types and macros for handling bitmaps with one bit per multicast interface.
71 typedef u_short mifi_t
; /* type of a mif index */
75 #define IF_SETSIZE 256
79 #define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */
82 #define howmany(x, y) (((x) + ((y) - 1)) / (y))
85 typedef struct if_set
{
86 fd_mask ifs_bits
[howmany(IF_SETSIZE
, NIFBITS
)];
89 #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
90 #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
91 #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
92 #define IF_COPY(f, t) bcopy(f, t, sizeof(*(f)))
93 #define IF_ZERO(p) bzero(p, sizeof(*(p)))
96 * Argument structure for MRT6_ADD_IF.
99 mifi_t mif6c_mifi
; /* the index of the mif to be added */
100 u_char mif6c_flags
; /* MIFF_ flags defined below */
101 u_short mif6c_pifi
; /* the index of the physical IF */
103 u_int mif6c_rate_limit
; /* max rate */
107 #define MIFF_REGISTER 0x1 /* mif represents a register end-point */
110 * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC
113 struct sockaddr_in6 mf6cc_origin
; /* IPv6 origin of mcasts */
114 struct sockaddr_in6 mf6cc_mcastgrp
; /* multicast group associated */
115 mifi_t mf6cc_parent
; /* incoming ifindex */
116 struct if_set mf6cc_ifset
; /* set of forwarding ifs */
120 * The kernel's multicast routing statistics.
123 u_quad_t mrt6s_mfc_lookups
; /* # forw. cache hash table hits */
124 u_quad_t mrt6s_mfc_misses
; /* # forw. cache hash table misses */
125 u_quad_t mrt6s_upcalls
; /* # calls to mrouted */
126 u_quad_t mrt6s_no_route
; /* no route for packet's origin */
127 u_quad_t mrt6s_bad_tunnel
; /* malformed tunnel options */
128 u_quad_t mrt6s_cant_tunnel
; /* no room for tunnel options */
129 u_quad_t mrt6s_wrong_if
; /* arrived on wrong interface */
130 u_quad_t mrt6s_upq_ovflw
; /* upcall Q overflow */
131 u_quad_t mrt6s_cache_cleanups
; /* # entries with no upcalls */
132 u_quad_t mrt6s_drop_sel
; /* pkts dropped selectively */
133 u_quad_t mrt6s_q_overflow
; /* pkts dropped - Q overflow */
134 u_quad_t mrt6s_pkt2large
; /* pkts dropped - size > BKT SIZE */
135 u_quad_t mrt6s_upq_sockfull
; /* upcalls dropped - socket full */
139 * Struct used to communicate from kernel to multicast router
140 * note the convenient similarity to an IPv6 header.
144 u_char im6_msgtype
; /* what type of message */
145 #define MRT6MSG_NOCACHE 1
146 #define MRT6MSG_WRONGMIF 2
147 #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
148 u_char im6_mbz
; /* must be zero */
149 u_char im6_mif
; /* mif rec'd on */
151 struct in6_addr im6_src
, im6_dst
;
155 * Argument structure used by multicast routing daemon to get src-grp
158 struct sioc_sg_req6
{
159 struct sockaddr_in6 src
;
160 struct sockaddr_in6 grp
;
167 * Argument structure used by mrouted to get mif pkt counts
169 struct sioc_mif_req6
{
170 mifi_t mifi
; /* mif number */
171 u_quad_t icount
; /* Input packet count on mif */
172 u_quad_t ocount
; /* Output packet count on mif */
173 u_quad_t ibytes
; /* Input byte count on mif */
174 u_quad_t obytes
; /* Output byte count on mif */
179 * The kernel's multicast-interface structure.
182 u_char m6_flags
; /* MIFF_ flags defined above */
183 u_int m6_rate_limit
; /* max rate */
185 struct tbf
*m6_tbf
; /* token bucket structure at intf. */
187 struct in6_addr m6_lcl_addr
; /* local interface address */
188 struct ifnet
*m6_ifp
; /* pointer to interface */
189 u_quad_t m6_pkt_in
; /* # pkts in on interface */
190 u_quad_t m6_pkt_out
; /* # pkts out on interface */
191 u_quad_t m6_bytes_in
; /* # bytes in on interface */
192 u_quad_t m6_bytes_out
; /* # bytes out on interface */
193 struct route_in6 m6_route
;/* cached route if this is a tunnel */
195 u_int m6_rsvp_on
; /* RSVP listening on this vif */
196 struct socket
*m6_rsvpd
; /* RSVP daemon socket */
201 * The kernel's multicast forwarding cache entry structure
204 struct sockaddr_in6 mf6c_origin
; /* IPv6 origin of mcasts */
205 struct sockaddr_in6 mf6c_mcastgrp
; /* multicast group associated*/
206 mifi_t mf6c_parent
; /* incoming IF */
207 struct if_set mf6c_ifset
; /* set of outgoing IFs */
209 u_quad_t mf6c_pkt_cnt
; /* pkt count for src-grp */
210 u_quad_t mf6c_byte_cnt
; /* byte count for src-grp */
211 u_quad_t mf6c_wrong_if
; /* wrong if for src-grp */
212 int mf6c_expire
; /* time to clean entry up */
213 struct timeval mf6c_last_assert
; /* last time I sent an assert*/
214 struct rtdetq
*mf6c_stall
; /* pkts waiting for route */
215 struct mf6c
*mf6c_next
; /* hash table linkage */
218 #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1)
221 * Argument structure used for pkt info. while upcall is made
223 #ifndef _NETINET_IP_MROUTE_H_
224 struct rtdetq
{ /* XXX: rtdetq is also defined in ip_mroute.h */
225 struct mbuf
*m
; /* A copy of the packet */
226 struct ifnet
*ifp
; /* Interface pkt came in on */
228 struct timeval t
; /* Timestamp */
229 #endif /* UPCALL_TIMING */
232 #endif /* _NETINET_IP_MROUTE_H_ */
234 #define MF6CTBLSIZ 256
235 #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */
236 #define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1))
238 #define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ)
241 #define MAX_UPQ6 4 /* max. no of pkts in upcall Q */
243 int ip6_mrouter_set
__P((struct socket
*so
, struct sockopt
*sopt
));
244 int ip6_mrouter_get
__P((struct socket
*so
, struct sockopt
*sopt
));
245 int ip6_mrouter_done
__P((void));
246 int mrt6_ioctl
__P((int, caddr_t
));
249 #endif /* !_NETINET6_IP6_MROUTE_H_ */