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 */
91 #define GET_TIME(t) microtime(&t)
95 * Types and macros for handling bitmaps with one bit per virtual interface.
98 typedef u_long vifbitmap_t
;
99 typedef u_short vifi_t
; /* type of a vif index */
100 #define ALL_VIFS (vifi_t)-1
102 #define VIFM_SET(n, m) ((m) |= (1 << (n)))
103 #define VIFM_CLR(n, m) ((m) &= ~(1 << (n)))
104 #define VIFM_ISSET(n, m) ((m) & (1 << (n)))
105 #define VIFM_CLRALL(m) ((m) = 0x00000000)
106 #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom))
107 #define VIFM_SAME(m1, m2) ((m1) == (m2))
111 * Argument structure for MRT_ADD_VIF.
112 * (MRT_DEL_VIF takes a single vifi_t argument.)
115 vifi_t vifc_vifi
; /* the index of the vif to be added */
116 u_char vifc_flags
; /* VIFF_ flags defined below */
117 u_char vifc_threshold
; /* min ttl required to forward on vif */
118 u_int vifc_rate_limit
; /* max rate */
119 struct in_addr vifc_lcl_addr
; /* local interface address */
120 struct in_addr vifc_rmt_addr
; /* remote address (tunnels only) */
123 #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
124 #define VIFF_SRCRT 0x2 /* tunnel uses IP source routing */
127 * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC
128 * (mfcc_tos to be added at a future point)
131 struct in_addr mfcc_origin
; /* ip origin of mcasts */
132 struct in_addr mfcc_mcastgrp
; /* multicast group associated*/
133 vifi_t mfcc_parent
; /* incoming vif */
134 u_char mfcc_ttls
[MAXVIFS
]; /* forwarding ttls on vifs */
138 * The kernel's multicast routing statistics.
141 u_long mrts_mfc_lookups
; /* # forw. cache hash table hits */
142 u_long mrts_mfc_misses
; /* # forw. cache hash table misses */
143 u_long mrts_upcalls
; /* # calls to mrouted */
144 u_long mrts_no_route
; /* no route for packet's origin */
145 u_long mrts_bad_tunnel
; /* malformed tunnel options */
146 u_long mrts_cant_tunnel
; /* no room for tunnel options */
147 u_long mrts_wrong_if
; /* arrived on wrong interface */
148 u_long mrts_upq_ovflw
; /* upcall Q overflow */
149 u_long mrts_cache_cleanups
; /* # entries with no upcalls */
150 u_long mrts_drop_sel
; /* pkts dropped selectively */
151 u_long mrts_q_overflow
; /* pkts dropped - Q overflow */
152 u_long mrts_pkt2large
; /* pkts dropped - size > BKT SIZE */
153 u_long mrts_upq_sockfull
; /* upcalls dropped - socket full */
157 * Argument structure used by mrouted to get src-grp pkt counts
168 * Argument structure used by mrouted to get vif pkt counts
170 struct sioc_vif_req
{
171 vifi_t vifi
; /* vif number */
172 u_long icount
; /* Input packet count on vif */
173 u_long ocount
; /* Output packet count on vif */
174 u_long ibytes
; /* Input byte count on vif */
175 u_long obytes
; /* Output byte count on vif */
180 * The kernel's virtual-interface structure.
186 u_char v_flags
; /* VIFF_ flags defined above */
187 u_char v_threshold
; /* min ttl required to forward on vif*/
188 u_int v_rate_limit
; /* max rate */
189 struct tbf
*v_tbf
; /* token bucket structure at intf. */
190 struct in_addr v_lcl_addr
; /* local interface address */
191 struct in_addr v_rmt_addr
; /* remote address (tunnels only) */
192 struct ifnet
*v_ifp
; /* pointer to interface */
193 u_long v_pkt_in
; /* # pkts in on interface */
194 u_long v_pkt_out
; /* # pkts out on interface */
195 u_long v_bytes_in
; /* # bytes in on interface */
196 u_long v_bytes_out
; /* # bytes out on interface */
197 struct route v_route
; /* cached route if this is a tunnel */
198 u_int v_rsvp_on
; /* RSVP listening on this vif */
199 struct socket
*v_rsvpd
; /* RSVP daemon socket */
204 * The kernel's multicast forwarding cache entry structure
205 * (A field for the type of service (mfc_tos) is to be added
209 struct in_addr mfc_origin
; /* IP origin of mcasts */
210 struct in_addr mfc_mcastgrp
; /* multicast group associated*/
211 vifi_t mfc_parent
; /* incoming vif */
212 u_char mfc_ttls
[MAXVIFS
]; /* forwarding ttls on vifs */
213 u_long mfc_pkt_cnt
; /* pkt count for src-grp */
214 u_long mfc_byte_cnt
; /* byte count for src-grp */
215 u_long mfc_wrong_if
; /* wrong if for src-grp */
216 int mfc_expire
; /* time to clean entry up */
217 struct timeval mfc_last_assert
; /* last time I sent an assert*/
218 struct rtdetq
*mfc_stall
; /* q of packets awaiting mfc */
219 struct mfc
*mfc_next
; /* next mfc entry */
223 * Struct used to communicate from kernel to multicast router
224 * note the convenient similarity to an IP packet
229 u_char im_msgtype
; /* what type of message */
230 #define IGMPMSG_NOCACHE 1
231 #define IGMPMSG_WRONGVIF 2
232 u_char im_mbz
; /* must be zero */
233 u_char im_vif
; /* vif rec'd on */
235 struct in_addr im_src
, im_dst
;
237 #define MFCTBLSIZ 256
239 #ifdef KERNEL_PRIVATE
241 * Argument structure used for pkt info. while upcall is made
244 struct mbuf
*m
; /* A copy of the packet */
245 struct ifnet
*ifp
; /* Interface pkt came in on */
246 vifi_t xmt_vif
; /* Saved copy of imo_multicast_vif */
248 struct timeval t
; /* Timestamp */
249 #endif /* UPCALL_TIMING */
250 struct rtdetq
*next
; /* Next in list of packets */
253 #if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */
254 #define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1))
256 #define MFCHASHMOD(h) ((h) % MFCTBLSIZ)
259 #define MAX_UPQ 4 /* max. no of pkts in upcall Q */
262 * Token Bucket filter code
264 #define MAX_BKT_SIZE 10000 /* 10K bytes size */
265 #define MAXQSIZE 10 /* max # of pkts in queue */
268 * the token bucket filter at each vif
272 struct timeval tbf_last_pkt_t
; /* arr. time of last pkt */
273 u_long tbf_n_tok
; /* no of tokens in bucket */
274 u_long tbf_q_len
; /* length of queue at this vif */
275 u_long tbf_max_q_len
; /* max. queue length */
276 struct mbuf
*tbf_q
; /* Packet queue */
277 struct mbuf
*tbf_t
; /* tail-insertion pointer */
283 extern int (*ip_mrouter_set
)(struct socket
*, struct sockopt
*);
284 extern int (*ip_mrouter_get
)(struct socket
*, struct sockopt
*);
285 extern int (*ip_mrouter_done
)(void);
287 extern int (*mrt_ioctl
)(int, caddr_t
);
289 extern int (*mrt_ioctl
)(int, caddr_t
, struct proc
*);
292 #endif KERNEL_PRIVATE
293 #endif _NETINET_IP_MROUTE_H_