2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1989 Stephen Deering.
24 * Copyright (c) 1992, 1993
25 * The Regents of the University of California. All rights reserved.
27 * This code is derived from software contributed to Berkeley by
28 * Stephen Deering of Stanford University.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 * This product includes software developed by the University of
41 * California, Berkeley and its contributors.
42 * 4. Neither the name of the University nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93
61 #ifndef _NETINET_IP_MROUTE_H_
62 #define _NETINET_IP_MROUTE_H_
63 #include <sys/appleapiopts.h>
66 * Definitions for IP multicast forwarding.
68 * Written by David Waitzman, BBN Labs, August 1988.
69 * Modified by Steve Deering, Stanford, February 1989.
70 * Modified by Ajit Thyagarajan, PARC, August 1993.
71 * Modified by Ajit Thyagarajan, PARC, August 1994.
73 * MROUTING Revision: 3.3.1.3
78 * Multicast Routing set/getsockopt commands.
80 #define MRT_INIT 100 /* initialize forwarder */
81 #define MRT_DONE 101 /* shut down forwarder */
82 #define MRT_ADD_VIF 102 /* create virtual interface */
83 #define MRT_DEL_VIF 103 /* delete virtual interface */
84 #define MRT_ADD_MFC 104 /* insert forwarding cache entry */
85 #define MRT_DEL_MFC 105 /* delete forwarding cache entry */
86 #define MRT_VERSION 106 /* get kernel version number */
87 #define MRT_ASSERT 107 /* enable PIM assert processing */
90 #define GET_TIME(t) microtime(&t)
93 * Types and macros for handling bitmaps with one bit per virtual interface.
96 typedef u_long vifbitmap_t
;
97 typedef u_short vifi_t
; /* type of a vif index */
98 #define ALL_VIFS (vifi_t)-1
100 #define VIFM_SET(n, m) ((m) |= (1 << (n)))
101 #define VIFM_CLR(n, m) ((m) &= ~(1 << (n)))
102 #define VIFM_ISSET(n, m) ((m) & (1 << (n)))
103 #define VIFM_CLRALL(m) ((m) = 0x00000000)
104 #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom))
105 #define VIFM_SAME(m1, m2) ((m1) == (m2))
109 * Argument structure for MRT_ADD_VIF.
110 * (MRT_DEL_VIF takes a single vifi_t argument.)
113 vifi_t vifc_vifi
; /* the index of the vif to be added */
114 u_char vifc_flags
; /* VIFF_ flags defined below */
115 u_char vifc_threshold
; /* min ttl required to forward on vif */
116 u_int vifc_rate_limit
; /* max rate */
117 struct in_addr vifc_lcl_addr
; /* local interface address */
118 struct in_addr vifc_rmt_addr
; /* remote address (tunnels only) */
121 #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
122 #define VIFF_SRCRT 0x2 /* tunnel uses IP source routing */
125 * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC
126 * (mfcc_tos to be added at a future point)
129 struct in_addr mfcc_origin
; /* ip origin of mcasts */
130 struct in_addr mfcc_mcastgrp
; /* multicast group associated*/
131 vifi_t mfcc_parent
; /* incoming vif */
132 u_char mfcc_ttls
[MAXVIFS
]; /* forwarding ttls on vifs */
136 * The kernel's multicast routing statistics.
139 u_long mrts_mfc_lookups
; /* # forw. cache hash table hits */
140 u_long mrts_mfc_misses
; /* # forw. cache hash table misses */
141 u_long mrts_upcalls
; /* # calls to mrouted */
142 u_long mrts_no_route
; /* no route for packet's origin */
143 u_long mrts_bad_tunnel
; /* malformed tunnel options */
144 u_long mrts_cant_tunnel
; /* no room for tunnel options */
145 u_long mrts_wrong_if
; /* arrived on wrong interface */
146 u_long mrts_upq_ovflw
; /* upcall Q overflow */
147 u_long mrts_cache_cleanups
; /* # entries with no upcalls */
148 u_long mrts_drop_sel
; /* pkts dropped selectively */
149 u_long mrts_q_overflow
; /* pkts dropped - Q overflow */
150 u_long mrts_pkt2large
; /* pkts dropped - size > BKT SIZE */
151 u_long mrts_upq_sockfull
; /* upcalls dropped - socket full */
155 * Argument structure used by mrouted to get src-grp pkt counts
166 * Argument structure used by mrouted to get vif pkt counts
168 struct sioc_vif_req
{
169 vifi_t vifi
; /* vif number */
170 u_long icount
; /* Input packet count on vif */
171 u_long ocount
; /* Output packet count on vif */
172 u_long ibytes
; /* Input byte count on vif */
173 u_long obytes
; /* Output byte count on vif */
178 * The kernel's virtual-interface structure.
181 u_char v_flags
; /* VIFF_ flags defined above */
182 u_char v_threshold
; /* min ttl required to forward on vif*/
183 u_int v_rate_limit
; /* max rate */
184 struct tbf
*v_tbf
; /* token bucket structure at intf. */
185 struct in_addr v_lcl_addr
; /* local interface address */
186 struct in_addr v_rmt_addr
; /* remote address (tunnels only) */
187 struct ifnet
*v_ifp
; /* pointer to interface */
188 u_long v_pkt_in
; /* # pkts in on interface */
189 u_long v_pkt_out
; /* # pkts out on interface */
190 u_long v_bytes_in
; /* # bytes in on interface */
191 u_long v_bytes_out
; /* # bytes out on interface */
192 struct route v_route
; /* cached route if this is a tunnel */
193 u_int v_rsvp_on
; /* RSVP listening on this vif */
194 struct socket
*v_rsvpd
; /* RSVP daemon socket */
198 * The kernel's multicast forwarding cache entry structure
199 * (A field for the type of service (mfc_tos) is to be added
203 struct in_addr mfc_origin
; /* IP origin of mcasts */
204 struct in_addr mfc_mcastgrp
; /* multicast group associated*/
205 vifi_t mfc_parent
; /* incoming vif */
206 u_char mfc_ttls
[MAXVIFS
]; /* forwarding ttls on vifs */
207 u_long mfc_pkt_cnt
; /* pkt count for src-grp */
208 u_long mfc_byte_cnt
; /* byte count for src-grp */
209 u_long mfc_wrong_if
; /* wrong if for src-grp */
210 int mfc_expire
; /* time to clean entry up */
211 struct timeval mfc_last_assert
; /* last time I sent an assert*/
212 struct rtdetq
*mfc_stall
; /* q of packets awaiting mfc */
213 struct mfc
*mfc_next
; /* next mfc entry */
217 * Struct used to communicate from kernel to multicast router
218 * note the convenient similarity to an IP packet
223 u_char im_msgtype
; /* what type of message */
224 #define IGMPMSG_NOCACHE 1
225 #define IGMPMSG_WRONGVIF 2
226 u_char im_mbz
; /* must be zero */
227 u_char im_vif
; /* vif rec'd on */
229 struct in_addr im_src
, im_dst
;
233 * Argument structure used for pkt info. while upcall is made
236 struct mbuf
*m
; /* A copy of the packet */
237 struct ifnet
*ifp
; /* Interface pkt came in on */
238 vifi_t xmt_vif
; /* Saved copy of imo_multicast_vif */
240 struct timeval t
; /* Timestamp */
241 #endif /* UPCALL_TIMING */
242 struct rtdetq
*next
; /* Next in list of packets */
245 #define MFCTBLSIZ 256
246 #if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */
247 #define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1))
249 #define MFCHASHMOD(h) ((h) % MFCTBLSIZ)
252 #define MAX_UPQ 4 /* max. no of pkts in upcall Q */
255 * Token Bucket filter code
257 #define MAX_BKT_SIZE 10000 /* 10K bytes size */
258 #define MAXQSIZE 10 /* max # of pkts in queue */
261 * the token bucket filter at each vif
265 struct timeval tbf_last_pkt_t
; /* arr. time of last pkt */
266 u_long tbf_n_tok
; /* no of tokens in bucket */
267 u_long tbf_q_len
; /* length of queue at this vif */
268 u_long tbf_max_q_len
; /* max. queue length */
269 struct mbuf
*tbf_q
; /* Packet queue */
270 struct mbuf
*tbf_t
; /* tail-insertion pointer */
274 #ifdef __APPLE_API_PRIVATE
278 extern int (*ip_mrouter_set
) __P((struct socket
*, struct sockopt
*));
279 extern int (*ip_mrouter_get
) __P((struct socket
*, struct sockopt
*));
280 extern int (*ip_mrouter_done
) __P((void));
282 extern int (*mrt_ioctl
) __P((int, caddr_t
));
284 extern int (*mrt_ioctl
) __P((int, caddr_t
, struct proc
*));
287 #endif /* __APPLE_API_PRIVATE */
290 #endif /* _NETINET_IP_MROUTE_H_ */