2 * Copyright (c) 2008 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 /* $FreeBSD: src/sys/netinet6/ip6_mroute.h,v 1.2.2.2 2001/07/03 11:01:53 ume Exp $ */
30 /* $KAME: ip6_mroute.h,v 1.17 2001/02/10 02:05:52 itojun Exp $ */
33 * Copyright (C) 1998 WIDE Project.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the project nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 /* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */
64 * Definitions for IP multicast forwarding.
66 * Written by David Waitzman, BBN Labs, August 1988.
67 * Modified by Steve Deering, Stanford, February 1989.
68 * Modified by Ajit Thyagarajan, PARC, August 1993.
69 * Modified by Ajit Thyagarajan, PARC, August 1994.
70 * Modified by Ahmed Helmy, USC, September 1996.
72 * MROUTING Revision: 1.2
75 #ifndef _NETINET6_IP6_MROUTE_H_
76 #define _NETINET6_IP6_MROUTE_H_
77 #include <sys/appleapiopts.h>
80 * Multicast Routing set/getsockopt commands.
82 #ifdef XNU_KERNEL_PRIVATE
83 #define MRT6_OINIT 100 /* initialize forwarder (omrt6msg) */
84 #endif /* XNU_KERNEL_PRIVATE */
85 #define MRT6_DONE 101 /* shut down forwarder */
86 #define MRT6_ADD_MIF 102 /* add multicast interface */
87 #define MRT6_DEL_MIF 103 /* delete multicast interface */
88 #define MRT6_ADD_MFC 104 /* insert forwarding cache entry */
89 #define MRT6_DEL_MFC 105 /* delete forwarding cache entry */
90 #define MRT6_PIM 107 /* enable pim code */
91 #define MRT6_INIT 108 /* initialize forwarder (mrt6msg) */
94 #define GET_TIME(t) getmicrotime(&t)
98 * Types and macros for handling bitmaps with one bit per multicast interface.
100 typedef u_short mifi_t
; /* type of a mif index */
104 #define IF_SETSIZE 256
107 typedef u_int32_t if_mask
;
108 #define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */
111 #define howmany(x, y) ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1))
114 typedef struct if_set
{
115 if_mask ifs_bits
[howmany(IF_SETSIZE
, NIFBITS
)];
118 #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
119 #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
120 #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
121 #define IF_COPY(f, t) bcopy(f, t, sizeof(*(f)))
122 #define IF_ZERO(p) bzero(p, sizeof(*(p)))
125 * Argument structure for MRT6_ADD_IF.
128 mifi_t mif6c_mifi
; /* the index of the mif to be added */
129 u_char mif6c_flags
; /* MIFF_ flags defined below */
130 u_short mif6c_pifi
; /* the index of the physical IF */
132 u_int mif6c_rate_limit
; /* max rate */
136 #define MIFF_REGISTER 0x1 /* mif represents a register end-point */
139 * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC
142 struct sockaddr_in6 mf6cc_origin
; /* IPv6 origin of mcasts */
143 struct sockaddr_in6 mf6cc_mcastgrp
; /* multicast group associated */
144 mifi_t mf6cc_parent
; /* incoming ifindex */
145 struct if_set mf6cc_ifset
; /* set of forwarding ifs */
149 * The kernel's multicast routing statistics.
152 u_quad_t mrt6s_mfc_lookups
; /* # forw. cache hash table hits */
153 u_quad_t mrt6s_mfc_misses
; /* # forw. cache hash table misses */
154 u_quad_t mrt6s_upcalls
; /* # calls to mrouted */
155 u_quad_t mrt6s_no_route
; /* no route for packet's origin */
156 u_quad_t mrt6s_bad_tunnel
; /* malformed tunnel options */
157 u_quad_t mrt6s_cant_tunnel
; /* no room for tunnel options */
158 u_quad_t mrt6s_wrong_if
; /* arrived on wrong interface */
159 u_quad_t mrt6s_upq_ovflw
; /* upcall Q overflow */
160 u_quad_t mrt6s_cache_cleanups
; /* # entries with no upcalls */
161 u_quad_t mrt6s_drop_sel
; /* pkts dropped selectively */
162 u_quad_t mrt6s_q_overflow
; /* pkts dropped - Q overflow */
163 u_quad_t mrt6s_pkt2large
; /* pkts dropped - size > BKT SIZE */
164 u_quad_t mrt6s_upq_sockfull
; /* upcalls dropped - socket full */
167 #ifdef XNU_KERNEL_PRIVATE
170 * Struct used to communicate from kernel to multicast router
171 * note the convenient similarity to an IPv6 header.
172 * XXX old version, superseded by mrt6msg.
176 u_char im6_msgtype
; /* what type of message */
178 #define MRT6MSG_NOCACHE 1
179 #define MRT6MSG_WRONGMIF 2
180 #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
182 u_char im6_mbz
; /* must be zero */
183 u_char im6_mif
; /* mif rec'd on */
185 struct in6_addr im6_src
, im6_dst
;
188 #endif /* XNU_KERNEL_PRIVATE */
191 * Structure used to communicate from kernel to multicast router.
192 * We'll overlay the structure onto an MLD header (not an IPv6 header
193 * like igmpmsg{} used for IPv4 implementation). This is because this
194 * structure will be passed via an IPv6 raw socket, on which an application
195 * will only receive the payload i.e. the data after the IPv6 header and all
196 * the extension headers. (see Section 3 of draft-ietf-ipngwg-2292bis-01)
199 #define MRT6MSG_NOCACHE 1
200 #define MRT6MSG_WRONGMIF 2
201 #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
202 u_char im6_mbz
; /* must be zero */
203 u_char im6_msgtype
; /* what type of message */
204 u_int16_t im6_mif
; /* mif rec'd on */
205 u_int32_t im6_pad
; /* padding for 64bit arch */
206 struct in6_addr im6_src
, im6_dst
;
210 * Argument structure used by multicast routing daemon to get src-grp
213 struct sioc_sg_req6
{
214 struct sockaddr_in6 src
;
215 struct sockaddr_in6 grp
;
222 * Argument structure used by mrouted to get mif pkt counts
224 struct sioc_mif_req6
{
225 mifi_t mifi
; /* mif number */
226 u_quad_t icount
; /* Input packet count on mif */
227 u_quad_t ocount
; /* Output packet count on mif */
228 u_quad_t ibytes
; /* Input byte count on mif */
229 u_quad_t obytes
; /* Output byte count on mif */
232 #if defined(XNU_KERNEL_PRIVATE)
233 struct sioc_mif_req6_32
{
239 } __attribute__((aligned(4), packed
));
241 struct sioc_mif_req6_64
{
243 u_quad_t icount
__attribute__((aligned(8)));
247 } __attribute__((aligned(8)));
248 #endif /* XNU_KERNEL_PRIVATE */
252 * The kernel's multicast-interface structure.
255 u_char m6_flags
; /* MIFF_ flags defined above */
256 u_int m6_rate_limit
; /* max rate */
258 struct tbf
*m6_tbf
; /* token bucket structure at intf. */
260 struct in6_addr m6_lcl_addr
; /* local interface address */
261 struct ifnet
*m6_ifp
; /* pointer to interface */
262 u_quad_t m6_pkt_in
; /* # pkts in on interface */
263 u_quad_t m6_pkt_out
; /* # pkts out on interface */
264 u_quad_t m6_bytes_in
; /* # bytes in on interface */
265 u_quad_t m6_bytes_out
; /* # bytes out on interface */
266 struct route_in6 m6_route
;/* cached route if this is a tunnel */
268 u_int m6_rsvp_on
; /* RSVP listening on this vif */
269 struct socket
*m6_rsvpd
; /* RSVP daemon socket */
274 * The kernel's multicast forwarding cache entry structure
277 struct sockaddr_in6 mf6c_origin
; /* IPv6 origin of mcasts */
278 struct sockaddr_in6 mf6c_mcastgrp
; /* multicast group associated*/
279 mifi_t mf6c_parent
; /* incoming IF */
280 struct if_set mf6c_ifset
; /* set of outgoing IFs */
282 u_quad_t mf6c_pkt_cnt
; /* pkt count for src-grp */
283 u_quad_t mf6c_byte_cnt
; /* byte count for src-grp */
284 u_quad_t mf6c_wrong_if
; /* wrong if for src-grp */
285 int mf6c_expire
; /* time to clean entry up */
286 struct timeval mf6c_last_assert
; /* last time I sent an assert*/
287 struct rtdetq
*mf6c_stall
; /* pkts waiting for route */
288 struct mf6c
*mf6c_next
; /* hash table linkage */
291 #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1)
293 #define MF6CTBLSIZ 256
294 #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */
295 #define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1))
297 #define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ)
300 #define MAX_UPQ6 4 /* max. no of pkts in upcall Q */
303 * Argument structure used for pkt info. while upcall is made
305 #ifndef _NETINET_IP_MROUTE_H_
306 struct rtdetq
{ /* XXX: rtdetq is also defined in ip_mroute.h */
307 struct mbuf
*m
; /* A copy of the packet */
308 struct ifnet
*ifp
; /* Interface pkt came in on */
310 struct timeval t
; /* Timestamp */
311 #endif /* UPCALL_TIMING */
314 #endif /* _NETINET_IP_MROUTE_H_ */
317 #ifdef XNU_KERNEL_PRIVATE
318 extern struct mrt6stat mrt6stat
;
320 extern int ip6_mrouter_set(struct socket
*, struct sockopt
*);
321 extern int ip6_mrouter_get(struct socket
*, struct sockopt
*);
322 extern int ip6_mrouter_done(void);
323 extern int mrt6_ioctl(u_long
, caddr_t
);
324 #endif /* XNU_KERNEL_PRIVATE */
328 #endif /* !_NETINET6_IP6_MROUTE_H_ */