1 //==========================================================================
3 // include/netinet/ip_mroute.h
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
10 // -------------------------------------------
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.
15 // -------------------------------------------
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
22 // Contributors: gthomas
28 //####DESCRIPTIONEND####
30 //==========================================================================
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 $ */
37 * Definitions for IP multicast forwarding.
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.
44 * MROUTING Revision: 1.2
47 #ifndef _NETINET_IP_MROUTE_H_
48 #define _NETINET_IP_MROUTE_H_
50 #include <sys/queue.h>
53 * Multicast Routing set/getsockopt commands.
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 */
66 * Types and macros for handling bitmaps with one bit per virtual interface.
69 typedef u_int32_t vifbitmap_t;
70 typedef u_int16_t vifi_t; /* type of a vif index */
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))
80 #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
81 #define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */
84 * Argument structure for MRT_ADD_VIF.
85 * (MRT_DEL_VIF takes a single vifi_t argument.)
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) */
97 * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC.
98 * (mfcc_tos to be added at a future point)
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 */
108 * Argument structure used by mrouted to get src-grp pkt counts.
119 * Argument structure used by mrouted to get vif pkt counts.
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 */
131 * The kernel's multicast routing statistics.
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 */
153 * Token bucket filter at each vif
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 */
162 * The kernel's virtual-interface structure.
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 */
178 int v_rsvp_on; /* # RSVP listening on this vif */
179 struct socket *v_rsvpd; /* # RSVPD daemon */
180 #endif /* RSVP_ISI */
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.)
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 */
203 * Structure used to communicate from kernel to multicast router.
204 * (Note the convenient similarity to an IP packet.)
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 */
215 struct in_addr im_src, im_dst;
219 * Argument structure used for pkt info. while upcall is made.
222 struct mbuf *m; /* a copy of the packet */
223 struct ifnet *ifp; /* interface pkt came in on */
225 struct timeval t; /* timestamp */
226 #endif /* UPCALL_TIMING */
230 #define MFCTBLSIZ 256
231 #define MAX_UPQ 4 /* max. no of pkts in upcall Q */
234 * Token bucket filter code
236 #define MAX_BKT_SIZE 10000 /* 10K bytes size */
237 #define MAXQSIZE 10 /* max. no of pkts in token queue */
240 * Queue structure at each vif
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 */
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 *));
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 *));
261 void rsvp_input __P((struct mbuf *, struct ifnet *));
263 void rsvp_input __P((struct mbuf *, int, int));
266 int ip_mforward __P((struct mbuf *, struct ifnet *));
268 void ipip_input __P((struct mbuf *, ...));
272 #endif // _NETINET_IP_MROUTE_H_