ip_mroute.h revision 1.12 1 /* $NetBSD: ip_mroute.h,v 1.12 1996/09/09 17:14:05 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 * The kernel's virtual-interface structure.
118 */
119 struct vif {
120 struct mbuf *tbf_q, **tbf_t; /* packet queue */
121 struct timeval tbf_last_pkt_t; /* arr. time of last pkt */
122 u_int32_t tbf_n_tok; /* no of tokens in bucket */
123 u_int32_t tbf_q_len; /* length of queue at this vif */
124 u_int32_t tbf_max_q_len; /* max. queue length */
125
126 u_int8_t v_flags; /* VIFF_ flags defined above */
127 u_int8_t v_threshold; /* min ttl required to forward on vif */
128 u_int32_t v_rate_limit; /* max rate */
129 struct in_addr v_lcl_addr; /* local interface address */
130 struct in_addr v_rmt_addr; /* remote address (tunnels only) */
131 struct ifnet *v_ifp; /* pointer to interface */
132 u_long v_pkt_in; /* # pkts in on interface */
133 u_long v_pkt_out; /* # pkts out on interface */
134 u_long v_bytes_in; /* # bytes in on interface */
135 u_long v_bytes_out; /* # bytes out on interface */
136 struct route v_route; /* cached route if this is a tunnel */
137 #ifdef RSVP_ISI
138 int v_rsvp_on; /* # RSVP listening on this vif */
139 struct socket *v_rsvpd; /* # RSVPD daemon */
140 #endif /* RSVP_ISI */
141 };
142
143 /*
144 * The kernel's multicast forwarding cache entry structure.
145 * (A field for the type of service (mfc_tos) is to be added
146 * at a future point.)
147 */
148 struct mfc {
149 LIST_ENTRY(mfc) mfc_hash;
150 struct in_addr mfc_origin; /* ip origin of mcasts */
151 struct in_addr mfc_mcastgrp; /* multicast group associated */
152 vifi_t mfc_parent; /* incoming vif */
153 u_int8_t mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
154 u_long mfc_pkt_cnt; /* pkt count for src-grp */
155 u_long mfc_byte_cnt; /* byte count for src-grp */
156 u_long mfc_wrong_if; /* wrong if for src-grp */
157 int mfc_expire; /* time to clean entry up */
158 struct timeval mfc_last_assert; /* last time I sent an assert */
159 struct rtdetq *mfc_stall; /* pkts waiting for route */
160 };
161
162 /*
163 * Structure used to communicate from kernel to multicast router.
164 * (Note the convenient similarity to an IP packet.)
165 */
166 struct igmpmsg {
167 u_int32_t unused1;
168 u_int32_t unused2;
169 u_int8_t im_msgtype; /* what type of message */
170 #define IGMPMSG_NOCACHE 1
171 #define IGMPMSG_WRONGVIF 2
172 u_int8_t im_mbz; /* must be zero */
173 u_int8_t im_vif; /* vif rec'd on */
174 u_int8_t unused3;
175 struct in_addr im_src, im_dst;
176 };
177
178 /*
179 * Argument structure used for pkt info. while upcall is made.
180 */
181 struct rtdetq {
182 struct mbuf *m; /* a copy of the packet */
183 struct ifnet *ifp; /* interface pkt came in on */
184 #ifdef UPCALL_TIMING
185 struct timeval t; /* timestamp */
186 #endif /* UPCALL_TIMING */
187 struct rtdetq *next;
188 };
189
190 #define MFCTBLSIZ 256
191 #define MAX_UPQ 4 /* max. no of pkts in upcall Q */
192
193 /*
194 * Token bucket filter code
195 */
196 #define MAX_BKT_SIZE 10000 /* 10K bytes size */
197 #define MAXQSIZE 10 /* max. no of pkts in token queue */
198
199
200 int ip_mrouter_set __P((struct socket *, int, struct mbuf **));
201 int ip_mrouter_get __P((struct socket *, int, struct mbuf **));
202 int mrt_ioctl __P((struct socket *, u_long, caddr_t));
203 int ip_mrouter_done __P((void));
204 void reset_vif __P((struct vif *));
205 #ifdef RSVP_ISI
206 int ip_mforward __P((struct mbuf *, struct ifnet *, struct ip_moptions *));
207 int legal_vif_num __P((int));
208 int ip_rsvp_vif_init __P((struct socket *, struct mbuf *));
209 int ip_rsvp_vif_done __P((struct socket *, struct mbuf *));
210 void ip_rsvp_force_done __P((struct socket *));
211 void rsvp_input __P((struct mbuf *, struct ifnet *));
212 #else
213 int ip_mforward __P((struct mbuf *, struct ifnet *));
214 #endif
215 void ipip_input __P((struct mbuf *, ...));
216
217 #endif /* _KERNEL */
218