1 /* $NetBSD: ip6_mroute.h,v 1.16 2009/03/18 16:00:23 cegger Exp $ */
2 /* $KAME: ip6_mroute.h,v 1.17 2001/02/10 02:05:52 itojun Exp $ */
5 * Copyright (C) 1998 WIDE Project.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 /* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */
36 * Definitions for IP multicast forwarding.
38 * Written by David Waitzman, BBN Labs, August 1988.
39 * Modified by Steve Deering, Stanford, February 1989.
40 * Modified by Ajit Thyagarajan, PARC, August 1993.
41 * Modified by Ajit Thyagarajan, PARC, August 1994.
42 * Modified by Ahmed Helmy, USC, September 1996.
44 * MROUTING Revision: 1.2
47 #ifndef _NETINET6_IP6_MROUTE_H_
48 #define _NETINET6_IP6_MROUTE_H_
51 * Multicast Routing set/getsockopt commands.
54 #define MRT6_OINIT 100 /* initialize forwarder (omrt6msg) */
56 #define MRT6_DONE 101 /* shut down forwarder */
57 #define MRT6_ADD_MIF 102 /* add multicast interface */
58 #define MRT6_DEL_MIF 103 /* delete multicast interface */
59 #define MRT6_ADD_MFC 104 /* insert forwarding cache entry */
60 #define MRT6_DEL_MFC 105 /* delete forwarding cache entry */
61 #define MRT6_PIM 107 /* enable pim code */
62 #define MRT6_INIT 108 /* initialize forwarder (mrt6msg) */
65 #define GET_TIME(t) microtime(&t)
67 #define GET_TIME(t) uniqtime(&t)
69 #define GET_TIME(t) ((t) = time)
73 * Types and macros for handling bitmaps with one bit per multicast interface.
75 typedef u_short mifi_t
; /* type of a mif index */
79 #define IF_SETSIZE 256
82 typedef u_int32_t if_mask
;
83 #define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */
86 #define howmany(x, y) (((x) + ((y) - 1)) / (y))
89 typedef struct if_set
{
90 if_mask ifs_bits
[howmany(IF_SETSIZE
, NIFBITS
)];
93 #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
94 #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
95 #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
96 #define IF_COPY(f, t) memcpy( t, f, sizeof(*(f)))
97 #define IF_ZERO(p) memset(p, 0, sizeof(*(p)))
100 * Argument structure for MRT6_ADD_IF.
103 mifi_t mif6c_mifi
; /* the index of the mif to be added */
104 u_char mif6c_flags
; /* MIFF_ flags defined below */
105 u_short mif6c_pifi
; /* the index of the physical IF */
107 u_int mif6c_rate_limit
; /* max rate */
111 #define MIFF_REGISTER 0x1 /* mif represents a register end-point */
114 * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC
117 struct sockaddr_in6 mf6cc_origin
; /* IPv6 origin of mcasts */
118 struct sockaddr_in6 mf6cc_mcastgrp
; /* multicast group associated */
119 mifi_t mf6cc_parent
; /* incoming ifindex */
120 struct if_set mf6cc_ifset
; /* set of forwarding ifs */
124 * The kernel's multicast routing statistics.
127 u_quad_t mrt6s_mfc_lookups
; /* # forw. cache hash table hits */
128 u_quad_t mrt6s_mfc_misses
; /* # forw. cache hash table misses */
129 u_quad_t mrt6s_upcalls
; /* # calls to mrouted */
130 u_quad_t mrt6s_no_route
; /* no route for packet's origin */
131 u_quad_t mrt6s_bad_tunnel
; /* malformed tunnel options */
132 u_quad_t mrt6s_cant_tunnel
; /* no room for tunnel options */
133 u_quad_t mrt6s_wrong_if
; /* arrived on wrong interface */
134 u_quad_t mrt6s_upq_ovflw
; /* upcall Q overflow */
135 u_quad_t mrt6s_cache_cleanups
; /* # entries with no upcalls */
136 u_quad_t mrt6s_drop_sel
; /* pkts dropped selectively */
137 u_quad_t mrt6s_q_overflow
; /* pkts dropped - Q overflow */
138 u_quad_t mrt6s_pkt2large
; /* pkts dropped - size > BKT SIZE */
139 u_quad_t mrt6s_upq_sockfull
; /* upcalls dropped - socket full */
144 * Struct used to communicate from kernel to multicast router
145 * note the convenient similarity to an IPv6 header.
146 * XXX old version, superseded by mrt6msg.
150 u_char im6_msgtype
; /* what type of message */
152 #define MRT6MSG_NOCACHE 1
153 #define MRT6MSG_WRONGMIF 2
154 #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
156 u_char im6_mbz
; /* must be zero */
157 u_char im6_mif
; /* mif rec'd on */
159 struct in6_addr im6_src
, im6_dst
;
164 * Structure used to communicate from kernel to multicast router.
165 * We'll overlay the structure onto an MLD header (not an IPv6 header
166 * like igmpmsg{} used for IPv4 implementation). This is because this
167 * structure will be passed via an IPv6 raw socket, on which an application
168 * will only receive the payload i.e. the data after the IPv6 header and all
169 * the extension headers. (see Section 3 of draft-ietf-ipngwg-2292bis-01)
172 #define MRT6MSG_NOCACHE 1
173 #define MRT6MSG_WRONGMIF 2
174 #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
175 u_char im6_mbz
; /* must be zero */
176 u_char im6_msgtype
; /* what type of message */
177 u_int16_t im6_mif
; /* mif rec'd on */
178 u_int32_t im6_pad
; /* padding for 64bit arch */
179 struct in6_addr im6_src
, im6_dst
;
183 * Argument structure used by multicast routing daemon to get src-grp
186 struct sioc_sg_req6
{
187 struct sockaddr_in6 src
;
188 struct sockaddr_in6 grp
;
195 * Argument structure used by mrouted to get mif pkt counts
197 struct sioc_mif_req6
{
198 mifi_t mifi
; /* mif number */
199 u_quad_t icount
; /* Input packet count on mif */
200 u_quad_t ocount
; /* Output packet count on mif */
201 u_quad_t ibytes
; /* Input byte count on mif */
202 u_quad_t obytes
; /* Output byte count on mif */
207 * The kernel's multicast-interface structure.
210 u_char m6_flags
; /* MIFF_ flags defined above */
211 u_int m6_rate_limit
; /* max rate */
213 struct tbf
*m6_tbf
; /* token bucket structure at intf. */
215 struct in6_addr m6_lcl_addr
; /* local interface address */
216 struct ifnet
*m6_ifp
; /* pointer to interface */
217 u_quad_t m6_pkt_in
; /* # pkts in on interface */
218 u_quad_t m6_pkt_out
; /* # pkts out on interface */
219 u_quad_t m6_bytes_in
; /* # bytes in on interface */
220 u_quad_t m6_bytes_out
; /* # bytes out on interface */
222 u_int m6_rsvp_on
; /* RSVP listening on this vif */
223 struct socket
*m6_rsvpd
; /* RSVP daemon socket */
228 * The kernel's multicast forwarding cache entry structure
231 struct sockaddr_in6 mf6c_origin
; /* IPv6 origin of mcasts */
232 struct sockaddr_in6 mf6c_mcastgrp
; /* multicast group associated*/
233 mifi_t mf6c_parent
; /* incoming IF */
234 struct if_set mf6c_ifset
; /* set of outgoing IFs */
236 u_quad_t mf6c_pkt_cnt
; /* pkt count for src-grp */
237 u_quad_t mf6c_byte_cnt
; /* byte count for src-grp */
238 u_quad_t mf6c_wrong_if
; /* wrong if for src-grp */
239 int mf6c_expire
; /* time to clean entry up */
240 struct timeval mf6c_last_assert
; /* last time I sent an assert*/
241 struct rtdetq
*mf6c_stall
; /* pkts waiting for route */
242 struct mf6c
*mf6c_next
; /* hash table linkage */
245 #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1)
248 * Argument structure used for pkt info. while upcall is made
250 #ifndef _NETINET_IP_MROUTE_H_
251 struct rtdetq
{ /* XXX: rtdetq is also defined in ip_mroute.h */
252 struct mbuf
*m
; /* A copy of the packet */
253 struct ifnet
*ifp
; /* Interface pkt came in on */
255 struct timeval t
; /* Timestamp */
256 #endif /* UPCALL_TIMING */
259 #endif /* _NETINET_IP_MROUTE_H_ */
261 #define MF6CTBLSIZ 256
262 #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */
263 #define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1))
265 #define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ)
268 #define MAX_UPQ6 4 /* max. no of pkts in upcall Q */
270 int ip6_mrouter_set(struct socket
*, struct sockopt
*);
271 int ip6_mrouter_get(struct socket
*, struct sockopt
*);
272 int ip6_mrouter_done(void);
273 void ip6_mrouter_detach(struct ifnet
*);
274 int mrt6_ioctl(u_long
, void *);
277 #endif /* !_NETINET6_IP6_MROUTE_H_ */