]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
de355530 A |
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. | |
1c79356b | 11 | * |
de355530 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
de355530 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * Copyright (c) 1989 Stephen Deering. | |
24 | * Copyright (c) 1992, 1993 | |
25 | * The Regents of the University of California. All rights reserved. | |
26 | * | |
27 | * This code is derived from software contributed to Berkeley by | |
28 | * Stephen Deering of Stanford University. | |
29 | * | |
30 | * Redistribution and use in source and binary forms, with or without | |
31 | * modification, are permitted provided that the following conditions | |
32 | * are met: | |
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. | |
45 | * | |
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 | |
56 | * SUCH DAMAGE. | |
57 | * | |
58 | * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93 | |
59 | */ | |
60 | ||
61 | #ifndef _NETINET_IP_MROUTE_H_ | |
62 | #define _NETINET_IP_MROUTE_H_ | |
9bccf70c | 63 | #include <sys/appleapiopts.h> |
1c79356b A |
64 | |
65 | /* | |
66 | * Definitions for IP multicast forwarding. | |
67 | * | |
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. | |
72 | * | |
73 | * MROUTING Revision: 3.3.1.3 | |
74 | */ | |
75 | ||
76 | ||
77 | /* | |
78 | * Multicast Routing set/getsockopt commands. | |
79 | */ | |
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 */ | |
88 | ||
89 | ||
90 | #define GET_TIME(t) microtime(&t) | |
91 | ||
92 | /* | |
93 | * Types and macros for handling bitmaps with one bit per virtual interface. | |
94 | */ | |
95 | #define MAXVIFS 32 | |
96 | typedef u_long vifbitmap_t; | |
97 | typedef u_short vifi_t; /* type of a vif index */ | |
98 | #define ALL_VIFS (vifi_t)-1 | |
99 | ||
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)) | |
106 | ||
107 | ||
108 | /* | |
109 | * Argument structure for MRT_ADD_VIF. | |
110 | * (MRT_DEL_VIF takes a single vifi_t argument.) | |
111 | */ | |
112 | struct vifctl { | |
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) */ | |
119 | }; | |
120 | ||
121 | #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ | |
122 | #define VIFF_SRCRT 0x2 /* tunnel uses IP source routing */ | |
123 | ||
124 | /* | |
125 | * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC | |
126 | * (mfcc_tos to be added at a future point) | |
127 | */ | |
128 | struct mfcctl { | |
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 */ | |
133 | }; | |
134 | ||
135 | /* | |
136 | * The kernel's multicast routing statistics. | |
137 | */ | |
138 | struct mrtstat { | |
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 */ | |
152 | }; | |
153 | ||
154 | /* | |
155 | * Argument structure used by mrouted to get src-grp pkt counts | |
156 | */ | |
157 | struct sioc_sg_req { | |
158 | struct in_addr src; | |
159 | struct in_addr grp; | |
160 | u_long pktcnt; | |
161 | u_long bytecnt; | |
162 | u_long wrong_if; | |
163 | }; | |
164 | ||
165 | /* | |
166 | * Argument structure used by mrouted to get vif pkt counts | |
167 | */ | |
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 */ | |
174 | }; | |
175 | ||
176 | ||
177 | /* | |
178 | * The kernel's virtual-interface structure. | |
179 | */ | |
180 | struct vif { | |
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 */ | |
195 | }; | |
196 | ||
197 | /* | |
198 | * The kernel's multicast forwarding cache entry structure | |
199 | * (A field for the type of service (mfc_tos) is to be added | |
200 | * at a future point) | |
201 | */ | |
202 | struct mfc { | |
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 */ | |
214 | }; | |
215 | ||
216 | /* | |
217 | * Struct used to communicate from kernel to multicast router | |
218 | * note the convenient similarity to an IP packet | |
219 | */ | |
220 | struct igmpmsg { | |
221 | u_long unused1; | |
222 | u_long unused2; | |
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 */ | |
228 | u_char unused3; | |
229 | struct in_addr im_src, im_dst; | |
230 | }; | |
231 | ||
232 | /* | |
233 | * Argument structure used for pkt info. while upcall is made | |
234 | */ | |
235 | struct rtdetq { | |
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 */ | |
239 | #if UPCALL_TIMING | |
240 | struct timeval t; /* Timestamp */ | |
241 | #endif /* UPCALL_TIMING */ | |
242 | struct rtdetq *next; /* Next in list of packets */ | |
243 | }; | |
244 | ||
245 | #define MFCTBLSIZ 256 | |
246 | #if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */ | |
247 | #define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1)) | |
248 | #else | |
249 | #define MFCHASHMOD(h) ((h) % MFCTBLSIZ) | |
250 | #endif | |
251 | ||
252 | #define MAX_UPQ 4 /* max. no of pkts in upcall Q */ | |
253 | ||
254 | /* | |
255 | * Token Bucket filter code | |
256 | */ | |
257 | #define MAX_BKT_SIZE 10000 /* 10K bytes size */ | |
258 | #define MAXQSIZE 10 /* max # of pkts in queue */ | |
259 | ||
260 | /* | |
261 | * the token bucket filter at each vif | |
262 | */ | |
263 | struct tbf | |
264 | { | |
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 */ | |
271 | }; | |
272 | ||
273 | #ifdef KERNEL | |
9bccf70c | 274 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
275 | |
276 | struct sockopt; | |
277 | ||
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)); | |
1c79356b A |
281 | #if MROUTING |
282 | extern int (*mrt_ioctl) __P((int, caddr_t)); | |
283 | #else | |
284 | extern int (*mrt_ioctl) __P((int, caddr_t, struct proc *)); | |
285 | #endif | |
286 | ||
9bccf70c | 287 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b A |
288 | #endif /* KERNEL */ |
289 | ||
290 | #endif /* _NETINET_IP_MROUTE_H_ */ |