Watt-32 tcp/ip  2.2 dev-rel.10
ip_mrout.h
Go to the documentation of this file.
1 
5 /*
6  * Copyright (c) 1989 Stephen Deering.
7  * Copyright (c) 1992, 1993
8  * The Regents of the University of California. All rights reserved.
9  *
10  * This code is derived from software contributed to Berkeley by
11  * Stephen Deering of Stanford University.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution.
21  * 3. All advertising materials mentioning features or use of this software
22  * must display the following acknowledgement:
23  * This product includes software developed by the University of
24  * California, Berkeley and its contributors.
25  * 4. Neither the name of the University nor the names of its contributors
26  * may be used to endorse or promote products derived from this software
27  * without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39  * SUCH DAMAGE.
40  *
41  * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93
42  * $Id: ip_mroute.h,v 1.10.4.1 1997/02/22 19:47:28 joerg Exp $
43  */
44 
45 #ifndef __NETINET_IP_MROUTE_H
46 #define __NETINET_IP_MROUTE_H
47 
48 #ifndef __SYS_MBUF_H
49 #include <sys/mbuf.h>
50 #endif
51 
52 /*
53  * Definitions for IP multicast forwarding.
54  *
55  * Written by David Waitzman, BBN Labs, August 1988.
56  * Modified by Steve Deering, Stanford, February 1989.
57  * Modified by Ajit Thyagarajan, PARC, August 1993.
58  * Modified by Ajit Thyagarajan, PARC, August 1994.
59  *
60  * MROUTING Revision: 3.3.1.3
61  */
62 
63 
64 /*
65  * Multicast Routing set/getsockopt commands.
66  */
67 #define MRT_INIT 100 /* initialize forwarder */
68 #define MRT_DONE 101 /* shut down forwarder */
69 #define MRT_ADD_VIF 102 /* create virtual interface */
70 #define MRT_DEL_VIF 103 /* delete virtual interface */
71 #define MRT_ADD_MFC 104 /* insert forwarding cache entry */
72 #define MRT_DEL_MFC 105 /* delete forwarding cache entry */
73 #define MRT_VERSION 106 /* get kernel version number */
74 #define MRT_ASSERT 107 /* enable PIM assert processing */
75 
76 
77 #define GET_TIME(t) microtime(&t)
78 
79 /*
80  * Types and macros for handling bitmaps with one bit per virtual interface.
81  */
82 #define MAXVIFS 32
83 typedef u_long vifbitmap_t;
84 typedef u_short vifi_t; /* type of a vif index */
85 #define ALL_VIFS (vifi_t)-1
86 
87 #define VIFM_SET(n, m) ((m) |= (1 << (n)))
88 #define VIFM_CLR(n, m) ((m) &= ~(1 << (n)))
89 #define VIFM_ISSET(n, m) ((m) & (1 << (n)))
90 #define VIFM_CLRALL(m) ((m) = 0x00000000)
91 #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom))
92 #define VIFM_SAME(m1, m2) ((m1) == (m2))
93 
94 
95 /*
96  * Argument structure for MRT_ADD_VIF.
97  * (MRT_DEL_VIF takes a single vifi_t argument.)
98  */
99 struct vifctl {
100  vifi_t vifc_vifi; /* the index of the vif to be added */
101  u_char vifc_flags; /* VIFF_ flags defined below */
102  u_char vifc_threshold; /* min ttl required to forward on vif */
103  u_int vifc_rate_limit; /* max rate */
104  struct in_addr vifc_lcl_addr; /* local interface address */
105  struct in_addr vifc_rmt_addr; /* remote address (tunnels only) */
106 };
107 
108 #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
109 #define VIFF_SRCRT 0x2 /* tunnel uses IP source routing */
110 
111 /*
112  * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC
113  * (mfcc_tos to be added at a future point)
114  */
115 struct mfcctl {
116  struct in_addr mfcc_origin; /* ip origin of mcasts */
117  struct in_addr mfcc_mcastgrp; /* multicast group associated*/
118  vifi_t mfcc_parent; /* incoming vif */
119  u_char mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
120 };
121 
122 /*
123  * The kernel's multicast routing statistics.
124  */
125 struct mrtstat {
126  u_long mrts_mfc_lookups; /* # forw. cache hash table hits */
127  u_long mrts_mfc_misses; /* # forw. cache hash table misses */
128  u_long mrts_upcalls; /* # calls to mrouted */
129  u_long mrts_no_route; /* no route for packet's origin */
130  u_long mrts_bad_tunnel; /* malformed tunnel options */
131  u_long mrts_cant_tunnel; /* no room for tunnel options */
132  u_long mrts_wrong_if; /* arrived on wrong interface */
133  u_long mrts_upq_ovflw; /* upcall Q overflow */
134  u_long mrts_cache_cleanups; /* # entries with no upcalls */
135  u_long mrts_drop_sel; /* pkts dropped selectively */
136  u_long mrts_q_overflow; /* pkts dropped - Q overflow */
137  u_long mrts_pkt2large; /* pkts dropped - size > BKT SIZE */
138  u_long mrts_upq_sockfull; /* upcalls dropped - socket full */
139 };
140 
141 /*
142  * Argument structure used by mrouted to get src-grp pkt counts
143  */
144 struct sioc_sg_req {
145  struct in_addr src;
146  struct in_addr grp;
147  u_long pktcnt;
148  u_long bytecnt;
149  u_long wrong_if;
150 };
151 
152 /*
153  * Argument structure used by mrouted to get vif pkt counts
154  */
155 struct sioc_vif_req {
156  vifi_t vifi; /* vif number */
157  u_long icount; /* Input packet count on vif */
158  u_long ocount; /* Output packet count on vif */
159  u_long ibytes; /* Input byte count on vif */
160  u_long obytes; /* Output byte count on vif */
161 };
162 
163 
164 /*
165  * The kernel's virtual-interface structure.
166  */
167 struct vif {
168  u_char v_flags; /* VIFF_ flags defined above */
169  u_char v_threshold; /* min ttl required to forward on vif*/
170  u_int v_rate_limit; /* max rate */
171  struct tbf *v_tbf; /* token bucket structure at intf. */
172  struct in_addr v_lcl_addr; /* local interface address */
173  struct in_addr v_rmt_addr; /* remote address (tunnels only) */
174  struct ifnet *v_ifp; /* pointer to interface */
175  u_long v_pkt_in; /* # pkts in on interface */
176  u_long v_pkt_out; /* # pkts out on interface */
177  u_long v_bytes_in; /* # bytes in on interface */
178  u_long v_bytes_out; /* # bytes out on interface */
179  struct route v_route; /* cached route if this is a tunnel */
180  u_int v_rsvp_on; /* RSVP listening on this vif */
181  struct socket *v_rsvpd; /* RSVP daemon socket */
182 };
183 
184 /*
185  * The kernel's multicast forwarding cache entry structure
186  * (A field for the type of service (mfc_tos) is to be added
187  * at a future point)
188  */
189 struct mfc {
190  struct in_addr mfc_origin; /* IP origin of mcasts */
191  struct in_addr mfc_mcastgrp; /* multicast group associated*/
192  vifi_t mfc_parent; /* incoming vif */
193  u_char mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
194  u_long mfc_pkt_cnt; /* pkt count for src-grp */
195  u_long mfc_byte_cnt; /* byte count for src-grp */
196  u_long mfc_wrong_if; /* wrong if for src-grp */
197  int mfc_expire; /* time to clean entry up */
198  struct timeval mfc_last_assert; /* last time I sent an assert*/
199 };
200 
201 /*
202  * Struct used to communicate from kernel to multicast router
203  * note the convenient similarity to an IP packet
204  */
205 struct igmpmsg {
206  u_long unused1;
207  u_long unused2;
208  u_char im_msgtype; /* what type of message */
209 #define IGMPMSG_NOCACHE 1
210 #define IGMPMSG_WRONGVIF 2
211  u_char im_mbz; /* must be zero */
212  u_char im_vif; /* vif rec'd on */
213  u_char unused3;
214  struct in_addr im_src, im_dst;
215 };
216 
217 /*
218  * Argument structure used for pkt info. while upcall is made
219  */
220 struct rtdetq {
221  struct mbuf *m; /* A copy of the packet */
222  struct ifnet *ifp; /* Interface pkt came in on */
223  vifi_t xmt_vif; /* Saved copy of imo_multicast_vif */
224 #ifdef UPCALL_TIMING
225  struct timeval t; /* Timestamp */
226 #endif
227 };
228 
229 #define MFCTBLSIZ 256
230 #if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */
231 #define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1))
232 #else
233 #define MFCHASHMOD(h) ((h) % MFCTBLSIZ)
234 #endif
235 
236 #define MAX_UPQ 4 /* max. no of pkts in upcall Q */
237 
238 /*
239  * Token Bucket filter code
240  */
241 #define MAX_BKT_SIZE 10000 /* 10K bytes size */
242 #define MAXQSIZE 10 /* max # of pkts in queue */
243 
244 /*
245  * the token bucket filter at each vif
246  */
247 struct tbf
248 {
249  struct timeval tbf_last_pkt_t; /* arr. time of last pkt */
250  u_long tbf_n_tok; /* no of tokens in bucket */
251  u_long tbf_q_len; /* length of queue at this vif */
252  u_long tbf_max_q_len; /* max. queue length */
253  struct mbuf *tbf_q; /* Packet queue */
254  struct mbuf *tbf_t; /* tail-insertion pointer */
255 };
256 
257 #endif
Definition: if.h:84
Definition: ip_mrout.h:189
Definition: route.h:56
Definition: ip_mrout.h:167
Definition: in.h:146
Definition: wtime.h:38
Definition: if.h:130
Definition: mbuf.h:6
Definition: ip_mrout.h:247