]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a 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. | |
8f6c56a5 | 11 | * |
6601e61a 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 | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a 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. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
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 | ||
91447636 | 90 | #ifdef KERNEL_PRIVATE |
1c79356b | 91 | #define GET_TIME(t) microtime(&t) |
91447636 | 92 | #endif KERNEL_PRIVATE |
1c79356b A |
93 | |
94 | /* | |
95 | * Types and macros for handling bitmaps with one bit per virtual interface. | |
96 | */ | |
97 | #define MAXVIFS 32 | |
98 | typedef u_long vifbitmap_t; | |
99 | typedef u_short vifi_t; /* type of a vif index */ | |
100 | #define ALL_VIFS (vifi_t)-1 | |
101 | ||
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)) | |
108 | ||
109 | ||
110 | /* | |
111 | * Argument structure for MRT_ADD_VIF. | |
112 | * (MRT_DEL_VIF takes a single vifi_t argument.) | |
113 | */ | |
114 | struct vifctl { | |
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) */ | |
121 | }; | |
122 | ||
123 | #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ | |
124 | #define VIFF_SRCRT 0x2 /* tunnel uses IP source routing */ | |
125 | ||
126 | /* | |
127 | * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC | |
128 | * (mfcc_tos to be added at a future point) | |
129 | */ | |
130 | struct mfcctl { | |
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 */ | |
135 | }; | |
136 | ||
137 | /* | |
138 | * The kernel's multicast routing statistics. | |
139 | */ | |
140 | struct mrtstat { | |
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 */ | |
154 | }; | |
155 | ||
156 | /* | |
157 | * Argument structure used by mrouted to get src-grp pkt counts | |
158 | */ | |
159 | struct sioc_sg_req { | |
160 | struct in_addr src; | |
161 | struct in_addr grp; | |
162 | u_long pktcnt; | |
163 | u_long bytecnt; | |
164 | u_long wrong_if; | |
165 | }; | |
166 | ||
167 | /* | |
168 | * Argument structure used by mrouted to get vif pkt counts | |
169 | */ | |
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 */ | |
176 | }; | |
1c79356b | 177 | |
91447636 | 178 | #ifdef PRIVATE |
1c79356b A |
179 | /* |
180 | * The kernel's virtual-interface structure. | |
181 | */ | |
91447636 A |
182 | struct tbf; |
183 | struct ifnet; | |
184 | struct socket; | |
1c79356b A |
185 | struct vif { |
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 */ | |
200 | }; | |
91447636 | 201 | #endif |
1c79356b A |
202 | |
203 | /* | |
204 | * The kernel's multicast forwarding cache entry structure | |
205 | * (A field for the type of service (mfc_tos) is to be added | |
206 | * at a future point) | |
207 | */ | |
208 | struct mfc { | |
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 */ | |
220 | }; | |
221 | ||
222 | /* | |
223 | * Struct used to communicate from kernel to multicast router | |
224 | * note the convenient similarity to an IP packet | |
225 | */ | |
226 | struct igmpmsg { | |
227 | u_long unused1; | |
228 | u_long unused2; | |
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 */ | |
234 | u_char unused3; | |
235 | struct in_addr im_src, im_dst; | |
236 | }; | |
91447636 | 237 | #define MFCTBLSIZ 256 |
1c79356b | 238 | |
91447636 | 239 | #ifdef KERNEL_PRIVATE |
1c79356b A |
240 | /* |
241 | * Argument structure used for pkt info. while upcall is made | |
242 | */ | |
243 | struct rtdetq { | |
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 */ | |
247 | #if UPCALL_TIMING | |
248 | struct timeval t; /* Timestamp */ | |
249 | #endif /* UPCALL_TIMING */ | |
250 | struct rtdetq *next; /* Next in list of packets */ | |
251 | }; | |
252 | ||
1c79356b A |
253 | #if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */ |
254 | #define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1)) | |
255 | #else | |
256 | #define MFCHASHMOD(h) ((h) % MFCTBLSIZ) | |
257 | #endif | |
258 | ||
259 | #define MAX_UPQ 4 /* max. no of pkts in upcall Q */ | |
260 | ||
261 | /* | |
262 | * Token Bucket filter code | |
263 | */ | |
264 | #define MAX_BKT_SIZE 10000 /* 10K bytes size */ | |
265 | #define MAXQSIZE 10 /* max # of pkts in queue */ | |
266 | ||
267 | /* | |
268 | * the token bucket filter at each vif | |
269 | */ | |
270 | struct tbf | |
271 | { | |
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 */ | |
278 | }; | |
279 | ||
1c79356b A |
280 | |
281 | struct sockopt; | |
282 | ||
91447636 A |
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); | |
1c79356b | 286 | #if MROUTING |
91447636 | 287 | extern int (*mrt_ioctl)(int, caddr_t); |
1c79356b | 288 | #else |
91447636 | 289 | extern int (*mrt_ioctl)(int, caddr_t, struct proc *); |
1c79356b A |
290 | #endif |
291 | ||
91447636 | 292 | #endif KERNEL_PRIVATE |
6601e61a | 293 | #endif _NETINET_IP_MROUTE_H_ |