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