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