1 |
1254 |
phoenix |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// include/netinet/ip_mroute.h
|
4 |
|
|
//
|
5 |
|
|
//
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
9 |
|
|
//
|
10 |
|
|
// -------------------------------------------
|
11 |
|
|
//
|
12 |
|
|
// Portions of this software may have been derived from OpenBSD or other sources,
|
13 |
|
|
// and are covered by the appropriate copyright disclaimers included herein.
|
14 |
|
|
//
|
15 |
|
|
// -------------------------------------------
|
16 |
|
|
//
|
17 |
|
|
//####BSDCOPYRIGHTEND####
|
18 |
|
|
//==========================================================================
|
19 |
|
|
//#####DESCRIPTIONBEGIN####
|
20 |
|
|
//
|
21 |
|
|
// Author(s): gthomas
|
22 |
|
|
// Contributors: gthomas
|
23 |
|
|
// Date: 2000-01-10
|
24 |
|
|
// Purpose:
|
25 |
|
|
// Description:
|
26 |
|
|
//
|
27 |
|
|
//
|
28 |
|
|
//####DESCRIPTIONEND####
|
29 |
|
|
//
|
30 |
|
|
//==========================================================================
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/* $OpenBSD: ip_mroute.h,v 1.5 1999/12/08 06:50:20 itojun Exp $ */
|
34 |
|
|
/* $NetBSD: ip_mroute.h,v 1.10 1996/02/13 23:42:55 christos Exp $ */
|
35 |
|
|
|
36 |
|
|
/*
|
37 |
|
|
* Definitions for IP multicast forwarding.
|
38 |
|
|
*
|
39 |
|
|
* Written by David Waitzman, BBN Labs, August 1988.
|
40 |
|
|
* Modified by Steve Deering, Stanford, February 1989.
|
41 |
|
|
* Modified by Ajit Thyagarajan, PARC, August 1993.
|
42 |
|
|
* Modified by Ajit Thyagarajan, PARC, August 1994.
|
43 |
|
|
*
|
44 |
|
|
* MROUTING Revision: 1.2
|
45 |
|
|
*/
|
46 |
|
|
|
47 |
|
|
#ifndef _NETINET_IP_MROUTE_H_
|
48 |
|
|
#define _NETINET_IP_MROUTE_H_
|
49 |
|
|
|
50 |
|
|
#include <sys/queue.h>
|
51 |
|
|
|
52 |
|
|
/*
|
53 |
|
|
* Multicast Routing set/getsockopt commands.
|
54 |
|
|
*/
|
55 |
|
|
#define MRT_INIT 100 /* initialize forwarder */
|
56 |
|
|
#define MRT_DONE 101 /* shut down forwarder */
|
57 |
|
|
#define MRT_ADD_VIF 102 /* create virtual interface */
|
58 |
|
|
#define MRT_DEL_VIF 103 /* delete virtual interface */
|
59 |
|
|
#define MRT_ADD_MFC 104 /* insert forwarding cache entry */
|
60 |
|
|
#define MRT_DEL_MFC 105 /* delete forwarding cache entry */
|
61 |
|
|
#define MRT_VERSION 106 /* get kernel version number */
|
62 |
|
|
#define MRT_ASSERT 107 /* enable PIM assert processing */
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
/*
|
66 |
|
|
* Types and macros for handling bitmaps with one bit per virtual interface.
|
67 |
|
|
*/
|
68 |
|
|
#define MAXVIFS 32
|
69 |
|
|
typedef u_int32_t vifbitmap_t;
|
70 |
|
|
typedef u_int16_t vifi_t; /* type of a vif index */
|
71 |
|
|
|
72 |
|
|
#define VIFM_SET(n, m) ((m) |= (1 << (n)))
|
73 |
|
|
#define VIFM_CLR(n, m) ((m) &= ~(1 << (n)))
|
74 |
|
|
#define VIFM_ISSET(n, m) ((m) & (1 << (n)))
|
75 |
|
|
#define VIFM_SETALL(m) ((m) = 0xffffffff)
|
76 |
|
|
#define VIFM_CLRALL(m) ((m) = 0x00000000)
|
77 |
|
|
#define VIFM_COPY(mfrom, mto) ((mto) = (mfrom))
|
78 |
|
|
#define VIFM_SAME(m1, m2) ((m1) == (m2))
|
79 |
|
|
|
80 |
|
|
#define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
|
81 |
|
|
#define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */
|
82 |
|
|
|
83 |
|
|
/*
|
84 |
|
|
* Argument structure for MRT_ADD_VIF.
|
85 |
|
|
* (MRT_DEL_VIF takes a single vifi_t argument.)
|
86 |
|
|
*/
|
87 |
|
|
struct vifctl {
|
88 |
|
|
vifi_t vifc_vifi; /* the index of the vif to be added */
|
89 |
|
|
u_int8_t vifc_flags; /* VIFF_ flags defined below */
|
90 |
|
|
u_int8_t vifc_threshold; /* min ttl required to forward on vif */
|
91 |
|
|
u_int32_t vifc_rate_limit; /* max rate */
|
92 |
|
|
struct in_addr vifc_lcl_addr;/* local interface address */
|
93 |
|
|
struct in_addr vifc_rmt_addr;/* remote address (tunnels only) */
|
94 |
|
|
};
|
95 |
|
|
|
96 |
|
|
/*
|
97 |
|
|
* Argument structure for MRT_ADD_MFC and MRT_DEL_MFC.
|
98 |
|
|
* (mfcc_tos to be added at a future point)
|
99 |
|
|
*/
|
100 |
|
|
struct mfcctl {
|
101 |
|
|
struct in_addr mfcc_origin; /* ip origin of mcasts */
|
102 |
|
|
struct in_addr mfcc_mcastgrp; /* multicast group associated */
|
103 |
|
|
vifi_t mfcc_parent; /* incoming vif */
|
104 |
|
|
u_int8_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
|
105 |
|
|
};
|
106 |
|
|
|
107 |
|
|
/*
|
108 |
|
|
* Argument structure used by mrouted to get src-grp pkt counts.
|
109 |
|
|
*/
|
110 |
|
|
struct sioc_sg_req {
|
111 |
|
|
struct in_addr src;
|
112 |
|
|
struct in_addr grp;
|
113 |
|
|
u_long pktcnt;
|
114 |
|
|
u_long bytecnt;
|
115 |
|
|
u_long wrong_if;
|
116 |
|
|
};
|
117 |
|
|
|
118 |
|
|
/*
|
119 |
|
|
* Argument structure used by mrouted to get vif pkt counts.
|
120 |
|
|
*/
|
121 |
|
|
struct sioc_vif_req {
|
122 |
|
|
vifi_t vifi; /* vif number */
|
123 |
|
|
u_long icount; /* input packet count on vif */
|
124 |
|
|
u_long ocount; /* output packet count on vif */
|
125 |
|
|
u_long ibytes; /* input byte count on vif */
|
126 |
|
|
u_long obytes; /* output byte count on vif */
|
127 |
|
|
};
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
/*
|
131 |
|
|
* The kernel's multicast routing statistics.
|
132 |
|
|
*/
|
133 |
|
|
struct mrtstat {
|
134 |
|
|
u_long mrts_mfc_lookups; /* # forw. cache hash table hits */
|
135 |
|
|
u_long mrts_mfc_misses; /* # forw. cache hash table misses */
|
136 |
|
|
u_long mrts_upcalls; /* # calls to mrouted */
|
137 |
|
|
u_long mrts_no_route; /* no route for packet's origin */
|
138 |
|
|
u_long mrts_bad_tunnel; /* malformed tunnel options */
|
139 |
|
|
u_long mrts_cant_tunnel; /* no room for tunnel options */
|
140 |
|
|
u_long mrts_wrong_if; /* arrived on wrong interface */
|
141 |
|
|
u_long mrts_upq_ovflw; /* upcall Q overflow */
|
142 |
|
|
u_long mrts_cache_cleanups; /* # entries with no upcalls */
|
143 |
|
|
u_long mrts_drop_sel; /* pkts dropped selectively */
|
144 |
|
|
u_long mrts_q_overflow; /* pkts dropped - Q overflow */
|
145 |
|
|
u_long mrts_pkt2large; /* pkts dropped - size > BKT SIZE */
|
146 |
|
|
u_long mrts_upq_sockfull; /* upcalls dropped - socket full */
|
147 |
|
|
};
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
#ifdef _KERNEL
|
151 |
|
|
|
152 |
|
|
/*
|
153 |
|
|
* Token bucket filter at each vif
|
154 |
|
|
*/
|
155 |
|
|
struct tbf {
|
156 |
|
|
u_int32_t last_pkt_t; /* arr. time of last pkt */
|
157 |
|
|
u_int32_t n_tok; /* no of tokens in bucket */
|
158 |
|
|
u_int32_t q_len; /* length of queue at this vif */
|
159 |
|
|
};
|
160 |
|
|
|
161 |
|
|
/*
|
162 |
|
|
* The kernel's virtual-interface structure.
|
163 |
|
|
*/
|
164 |
|
|
struct vif {
|
165 |
|
|
u_int8_t v_flags; /* VIFF_ flags defined above */
|
166 |
|
|
u_int8_t v_threshold; /* min ttl required to forward on vif */
|
167 |
|
|
u_int32_t v_rate_limit; /* max rate */
|
168 |
|
|
struct tbf v_tbf; /* token bucket structure at intf. */
|
169 |
|
|
struct in_addr v_lcl_addr; /* local interface address */
|
170 |
|
|
struct in_addr v_rmt_addr; /* remote address (tunnels only) */
|
171 |
|
|
struct ifnet *v_ifp; /* pointer to interface */
|
172 |
|
|
u_long v_pkt_in; /* # pkts in on interface */
|
173 |
|
|
u_long v_pkt_out; /* # pkts out on interface */
|
174 |
|
|
u_long v_bytes_in; /* # bytes in on interface */
|
175 |
|
|
u_long v_bytes_out; /* # bytes out on interface */
|
176 |
|
|
struct route v_route; /* cached route if this is a tunnel */
|
177 |
|
|
#ifdef RSVP_ISI
|
178 |
|
|
int v_rsvp_on; /* # RSVP listening on this vif */
|
179 |
|
|
struct socket *v_rsvpd; /* # RSVPD daemon */
|
180 |
|
|
#endif /* RSVP_ISI */
|
181 |
|
|
};
|
182 |
|
|
|
183 |
|
|
/*
|
184 |
|
|
* The kernel's multicast forwarding cache entry structure.
|
185 |
|
|
* (A field for the type of service (mfc_tos) is to be added
|
186 |
|
|
* at a future point.)
|
187 |
|
|
*/
|
188 |
|
|
struct mfc {
|
189 |
|
|
LIST_ENTRY(mfc) mfc_hash;
|
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_int8_t 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 |
|
|
struct rtdetq *mfc_stall; /* pkts waiting for route */
|
200 |
|
|
};
|
201 |
|
|
|
202 |
|
|
/*
|
203 |
|
|
* Structure used to communicate from kernel to multicast router.
|
204 |
|
|
* (Note the convenient similarity to an IP packet.)
|
205 |
|
|
*/
|
206 |
|
|
struct igmpmsg {
|
207 |
|
|
u_int32_t unused1;
|
208 |
|
|
u_int32_t unused2;
|
209 |
|
|
u_int8_t im_msgtype; /* what type of message */
|
210 |
|
|
#define IGMPMSG_NOCACHE 1
|
211 |
|
|
#define IGMPMSG_WRONGVIF 2
|
212 |
|
|
u_int8_t im_mbz; /* must be zero */
|
213 |
|
|
u_int8_t im_vif; /* vif rec'd on */
|
214 |
|
|
u_int8_t unused3;
|
215 |
|
|
struct in_addr im_src, im_dst;
|
216 |
|
|
};
|
217 |
|
|
|
218 |
|
|
/*
|
219 |
|
|
* Argument structure used for pkt info. while upcall is made.
|
220 |
|
|
*/
|
221 |
|
|
struct rtdetq {
|
222 |
|
|
struct mbuf *m; /* a copy of the packet */
|
223 |
|
|
struct ifnet *ifp; /* interface pkt came in on */
|
224 |
|
|
#ifdef UPCALL_TIMING
|
225 |
|
|
struct timeval t; /* timestamp */
|
226 |
|
|
#endif /* UPCALL_TIMING */
|
227 |
|
|
struct rtdetq *next;
|
228 |
|
|
};
|
229 |
|
|
|
230 |
|
|
#define MFCTBLSIZ 256
|
231 |
|
|
#define MAX_UPQ 4 /* max. no of pkts in upcall Q */
|
232 |
|
|
|
233 |
|
|
/*
|
234 |
|
|
* Token bucket filter code
|
235 |
|
|
*/
|
236 |
|
|
#define MAX_BKT_SIZE 10000 /* 10K bytes size */
|
237 |
|
|
#define MAXQSIZE 10 /* max. no of pkts in token queue */
|
238 |
|
|
|
239 |
|
|
/*
|
240 |
|
|
* Queue structure at each vif
|
241 |
|
|
*/
|
242 |
|
|
struct pkt_queue {
|
243 |
|
|
u_int32_t pkt_len; /* length of packet in queue */
|
244 |
|
|
struct mbuf *pkt_m; /* pointer to packet mbuf */
|
245 |
|
|
struct ip *pkt_ip; /* pointer to ip header */
|
246 |
|
|
};
|
247 |
|
|
|
248 |
|
|
int ip_mrouter_set __P((int, struct socket *, struct mbuf **));
|
249 |
|
|
int ip_mrouter_get __P((int, struct socket *, struct mbuf **));
|
250 |
|
|
int mrt_ioctl __P((u_long, caddr_t));
|
251 |
|
|
int ip_mrouter_done __P((void));
|
252 |
|
|
void reset_vif __P((struct vif *));
|
253 |
|
|
void vif_delete __P((struct ifnet *));
|
254 |
|
|
#ifdef RSVP_ISI
|
255 |
|
|
int ip_mforward __P((struct mbuf *, struct ifnet *, struct ip_moptions *));
|
256 |
|
|
int legal_vif_num __P((int));
|
257 |
|
|
int ip_rsvp_vif_init __P((struct socket *, struct mbuf *));
|
258 |
|
|
int ip_rsvp_vif_done __P((struct socket *, struct mbuf *));
|
259 |
|
|
void ip_rsvp_force_done __P((struct socket *));
|
260 |
|
|
#if 0
|
261 |
|
|
void rsvp_input __P((struct mbuf *, struct ifnet *));
|
262 |
|
|
#else
|
263 |
|
|
void rsvp_input __P((struct mbuf *, int, int));
|
264 |
|
|
#endif
|
265 |
|
|
#else
|
266 |
|
|
int ip_mforward __P((struct mbuf *, struct ifnet *));
|
267 |
|
|
#endif
|
268 |
|
|
void ipip_input __P((struct mbuf *, ...));
|
269 |
|
|
|
270 |
|
|
#endif /* _KERNEL */
|
271 |
|
|
|
272 |
|
|
#endif // _NETINET_IP_MROUTE_H_
|