Watt-32 tcp/ip  2.2 dev-rel.10
ip6_mrou.h
Go to the documentation of this file.
1 
5 /* $FreeBSD: src/sys/netinet6/ip6_mroute.h,v 1.5 2002/04/19 04:46:23 suz Exp $ */
6 /* $KAME: ip6_mroute.h,v 1.19 2001/06/14 06:12:55 suz Exp $ */
7 
8 /*
9  * Copyright (C) 1998 WIDE Project.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of the project nor the names of its contributors
21  * may be used to endorse or promote products derived from this software
22  * without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36 
37 /* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */
38 
39 /*
40  * Definitions for IP multicast forwarding.
41  *
42  * Written by David Waitzman, BBN Labs, August 1988.
43  * Modified by Steve Deering, Stanford, February 1989.
44  * Modified by Ajit Thyagarajan, PARC, August 1993.
45  * Modified by Ajit Thyagarajan, PARC, August 1994.
46  * Modified by Ahmed Helmy, USC, September 1996.
47  *
48  * MROUTING Revision: 1.2
49  */
50 
51 #ifndef _NETINET6_IP6_MROUTE_H_
52 #define _NETINET6_IP6_MROUTE_H_
53 
54 #ifndef __SYS_MBUF_H
55 #include <sys/mbuf.h>
56 #endif
57 
58 /*
59  * Multicast Routing set/getsockopt commands.
60  */
61 #ifdef _KERNEL
62 #define MRT6_OINIT 100 /* initialize forwarder (omrt6msg) */
63 #endif
64 #define MRT6_DONE 101 /* shut down forwarder */
65 #define MRT6_ADD_MIF 102 /* add multicast interface */
66 #define MRT6_DEL_MIF 103 /* delete multicast interface */
67 #define MRT6_ADD_MFC 104 /* insert forwarding cache entry */
68 #define MRT6_DEL_MFC 105 /* delete forwarding cache entry */
69 #define MRT6_PIM 107 /* enable pim code */
70 #define MRT6_INIT 108 /* initialize forwarder (mrt6msg) */
71 
72 #if BSD >= 199103
73 #define GET_TIME(t) microtime(&t)
74 #elif defined(sun)
75 #define GET_TIME(t) uniqtime(&t)
76 #else
77 #define GET_TIME(t) ((t) = time)
78 #endif
79 
80 /*
81  * Types and macros for handling bitmaps with one bit per multicast interface.
82  */
83 typedef u_short mifi_t; /* type of a mif index */
84 #define MAXMIFS 64
85 
86 #ifndef IF_SETSIZE
87 #define IF_SETSIZE 256
88 #endif
89 
90 typedef u_int32_t if_mask;
91 #define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */
92 
93 #ifndef howmany
94 #define howmany(x, y) (((x) + ((y) - 1)) / (y))
95 #endif
96 
97 typedef struct if_set {
98  if_mask ifs_bits[howmany(IF_SETSIZE, NIFBITS)];
99 } if_set;
100 
101 #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
102 #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
103 #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
104 #define IF_COPY(f, t) bcopy(f, t, sizeof(*(f)))
105 #define IF_ZERO(p) bzero(p, sizeof(*(p)))
106 
107 /*
108  * Argument structure for MRT6_ADD_IF.
109  */
110 struct mif6ctl {
111  mifi_t mif6c_mifi; /* the index of the mif to be added */
112  u_char mif6c_flags; /* MIFF_ flags defined below */
113  u_short mif6c_pifi; /* the index of the physical IF */
114 #ifdef notyet
115  u_int mif6c_rate_limit; /* max rate */
116 #endif
117 };
118 
119 #define MIFF_REGISTER 0x1 /* mif represents a register end-point */
120 
121 /*
122  * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC
123  */
124 struct mf6cctl {
125  struct sockaddr_in6 mf6cc_origin; /* IPv6 origin of mcasts */
126  struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */
127  mifi_t mf6cc_parent; /* incoming ifindex */
128  struct if_set mf6cc_ifset; /* set of forwarding ifs */
129 };
130 
131 /*
132  * The kernel's multicast routing statistics.
133  */
134 struct mrt6stat {
135  u_quad_t mrt6s_mfc_lookups; /* # forw. cache hash table hits */
136  u_quad_t mrt6s_mfc_misses; /* # forw. cache hash table misses */
137  u_quad_t mrt6s_upcalls; /* # calls to mrouted */
138  u_quad_t mrt6s_no_route; /* no route for packet's origin */
139  u_quad_t mrt6s_bad_tunnel; /* malformed tunnel options */
140  u_quad_t mrt6s_cant_tunnel; /* no room for tunnel options */
141  u_quad_t mrt6s_wrong_if; /* arrived on wrong interface */
142  u_quad_t mrt6s_upq_ovflw; /* upcall Q overflow */
143  u_quad_t mrt6s_cache_cleanups; /* # entries with no upcalls */
144  u_quad_t mrt6s_drop_sel; /* pkts dropped selectively */
145  u_quad_t mrt6s_q_overflow; /* pkts dropped - Q overflow */
146  u_quad_t mrt6s_pkt2large; /* pkts dropped - size > BKT SIZE */
147  u_quad_t mrt6s_upq_sockfull; /* upcalls dropped - socket full */
148 };
149 
150 #ifdef MRT6_OINIT
151 /*
152  * Struct used to communicate from kernel to multicast router
153  * note the convenient similarity to an IPv6 header.
154  * XXX old version, superseded by mrt6msg.
155  */
156 struct omrt6msg {
157  u_long unused1;
158  u_char im6_msgtype; /* what type of message */
159 #if 0
160 #define MRT6MSG_NOCACHE 1
161 #define MRT6MSG_WRONGMIF 2
162 #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
163 #endif
164  u_char im6_mbz; /* must be zero */
165  u_char im6_mif; /* mif rec'd on */
166  u_char unused2;
167  struct in6_addr im6_src, im6_dst;
168 };
169 #endif
170 
171 /*
172  * Structure used to communicate from kernel to multicast router.
173  * We'll overlay the structure onto an MLD header (not an IPv6 header
174  * like igmpmsg{} used for IPv4 implementation). This is because this
175  * structure will be passed via an IPv6 raw socket, on which an application
176  * will only receive the payload i.e. the data after the IPv6 header and all
177  * the extension headers. (see Section 3 of draft-ietf-ipngwg-2292bis-01)
178  */
179 struct mrt6msg {
180 #define MRT6MSG_NOCACHE 1
181 #define MRT6MSG_WRONGMIF 2
182 #define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
183  u_char im6_mbz; /* must be zero */
184  u_char im6_msgtype; /* what type of message */
185  u_int16_t im6_mif; /* mif rec'd on */
186  u_int32_t im6_pad; /* padding for 64bit arch */
187  struct in6_addr im6_src, im6_dst;
188 };
189 
190 /*
191  * Argument structure used by multicast routing daemon to get src-grp
192  * packet counts
193  */
194 struct sioc_sg_req6 {
195  struct sockaddr_in6 src;
196  struct sockaddr_in6 grp;
197  u_quad_t pktcnt;
198  u_quad_t bytecnt;
199  u_quad_t wrong_if;
200 };
201 
202 /*
203  * Argument structure used by mrouted to get mif pkt counts
204  */
206  mifi_t mifi; /* mif number */
207  u_quad_t icount; /* Input packet count on mif */
208  u_quad_t ocount; /* Output packet count on mif */
209  u_quad_t ibytes; /* Input byte count on mif */
210  u_quad_t obytes; /* Output byte count on mif */
211 };
212 
213 #if defined(_KERNEL) || defined(KERNEL)
214 /*
215  * The kernel's multicast-interface structure.
216  */
217 struct mif6 {
218  u_char m6_flags; /* MIFF_ flags defined above */
219  u_int m6_rate_limit; /* max rate */
220 #ifdef notyet
221  struct tbf *m6_tbf; /* token bucket structure at intf. */
222 #endif
223  struct in6_addr m6_lcl_addr; /* local interface address */
224  struct ifnet *m6_ifp; /* pointer to interface */
225  u_quad_t m6_pkt_in; /* # pkts in on interface */
226  u_quad_t m6_pkt_out; /* # pkts out on interface */
227  u_quad_t m6_bytes_in; /* # bytes in on interface */
228  u_quad_t m6_bytes_out; /* # bytes out on interface */
229  struct route_in6 m6_route;/* cached route if this is a tunnel */
230 #ifdef notyet
231  u_int m6_rsvp_on; /* RSVP listening on this vif */
232  struct socket *m6_rsvpd; /* RSVP daemon socket */
233 #endif
234 };
235 
236 /*
237  * The kernel's multicast forwarding cache entry structure
238  */
239 struct mf6c {
240  struct sockaddr_in6 mf6c_origin; /* IPv6 origin of mcasts */
241  struct sockaddr_in6 mf6c_mcastgrp; /* multicast group associated*/
242  mifi_t mf6c_parent; /* incoming IF */
243  struct if_set mf6c_ifset; /* set of outgoing IFs */
244 
245  u_quad_t mf6c_pkt_cnt; /* pkt count for src-grp */
246  u_quad_t mf6c_byte_cnt; /* byte count for src-grp */
247  u_quad_t mf6c_wrong_if; /* wrong if for src-grp */
248  int mf6c_expire; /* time to clean entry up */
249  struct timeval mf6c_last_assert; /* last time I sent an assert*/
250  struct rtdetq *mf6c_stall; /* pkts waiting for route */
251  struct mf6c *mf6c_next; /* hash table linkage */
252 };
253 
254 #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1)
255 
256 /*
257  * Argument structure used for pkt info. while upcall is made
258  */
259 #ifndef _NETINET_IP_MROUTE_H_
260 struct rtdetq { /* XXX: rtdetq is also defined in ip_mroute.h */
261  struct mbuf *m; /* A copy of the packet */
262  struct ifnet *ifp; /* Interface pkt came in on */
263 #ifdef UPCALL_TIMING
264  struct timeval t; /* Timestamp */
265 #endif /* UPCALL_TIMING */
266  struct rtdetq *next;
267 };
268 #endif /* _NETINET_IP_MROUTE_H_ */
269 
270 #define MF6CTBLSIZ 256
271 #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */
272 #define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1))
273 #else
274 #define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ)
275 #endif
276 
277 #define MAX_UPQ6 4 /* max. no of pkts in upcall Q */
278 
279 int ip6_mrouter_set __P((struct socket *so, struct sockopt *sopt));
280 int ip6_mrouter_get __P((struct socket *so, struct sockopt *sopt));
281 int ip6_mrouter_done __P((void));
282 int mrt6_ioctl __P((int, caddr_t));
283 #endif /* _KERNEL */
284 
285 #endif /* !_NETINET6_IP6_MROUTE_H_ */
Definition: if.h:84
Definition: in.h:153
Definition: ip6_mrou.h:217
Definition: wtime.h:38
Definition: if.h:130
Definition: ip6_mrou.h:239
Definition: mbuf.h:6
Definition: in6.h:395
Definition: ip_mrout.h:247