8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / uts / common / netinet / ip_mroute.h
blobb1dde41b1f3cd32bd87f81f405370fe8c2621729
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 /* Copyright (c) 1990 Mentat Inc. */
28 #ifndef _NETINET_IP_MROUTE_H
29 #define _NETINET_IP_MROUTE_H
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
36 * Definitions for the kernel part of DVMRP,
37 * a Distance-Vector Multicast Routing Protocol.
38 * (See RFC-1075.)
40 * Written by David Waitzman, BBN Labs, August 1988.
41 * Modified by Steve Deering, Stanford, February 1989.
42 * Modified by Ajit Thyagarajan, PARC, August 1993.
43 * Modified by Ajit Thyagarajan, PARC, August 1994.
45 * MROUTING 3.5
49 * DVMRP-specific setsockopt commands.
52 #define MRT_INIT 100 /* initialize forwarder */
53 #define MRT_DONE 101 /* shut down forwarder */
54 #define MRT_ADD_VIF 102 /* create virtual interface */
55 #define MRT_DEL_VIF 103 /* delete virtual interface */
56 #define MRT_ADD_MFC 104 /* insert forwarding cache entry */
57 #define MRT_DEL_MFC 105 /* delete forwarding cache entry */
58 #define MRT_VERSION 106 /* get kernel version number */
59 #define MRT_ASSERT 107 /* enable PIM assert processing */
62 * Types and macros for handling bitmaps with one bit per virtual interface.
64 #define MAXVIFS 32
65 typedef uint_t vifbitmap_t;
66 typedef ushort_t vifi_t; /* type of a vif index */
67 #define ALL_VIFS (vifi_t)-1
69 #define VIFM_SET(n, m) ((m) |= (1 << (n)))
70 #define VIFM_CLR(n, m) ((m) &= ~(1 << (n)))
71 #define VIFM_ISSET(n, m) ((m) & (1 << (n)))
72 #define VIFM_CLRALL(m) ((m) = 0x00000000)
73 #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom))
74 #define VIFM_SAME(m1, m2) ((m1) == (m2))
78 * Argument structure for MRT_ADD_VIF. Also used for netstat.
79 * (MRT_DEL_VIF takes a single vifi_t argument.)
81 struct vifctl {
82 vifi_t vifc_vifi; /* the index of the vif to be added */
83 uchar_t vifc_flags; /* VIFF_ flags defined below */
84 uchar_t vifc_threshold; /* min ttl required to forward on vif */
85 uint_t vifc_rate_limit; /* max rate */
86 struct in_addr vifc_lcl_addr; /* local interface address */
87 struct in_addr vifc_rmt_addr; /* remote address(tunnels only) */
89 * vifc_pkt_in/out in Solaris, to report out of the kernel.
90 * Not nec. in BSD.
92 uint_t vifc_pkt_in; /* # Pkts in on interface */
93 uint_t vifc_pkt_out; /* # Pkts out on interface */
96 #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
97 #define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */
98 #define VIFF_REGISTER 0x4 /* for RPF check of PIM Register msg */
101 * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC
102 * (mfcc_tos to be added at a future point)
104 struct mfcctl {
105 struct in_addr mfcc_origin; /* ip origin of mcasts */
106 struct in_addr mfcc_mcastgrp; /* multicast group associated */
107 vifi_t mfcc_parent; /* incoming vif */
108 uint_t mfcc_pkt_cnt; /* pkt count for src-grp */
109 uchar_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
113 * The kernel's multicast routing statistics.
115 struct mrtstat {
116 uint_t mrts_mfcfind_lookups; /* #forwarding cache table lookups */
117 uint_t mrts_mfcfind_misses; /* # forwarding cache table misses */
118 uint_t mrts_mfc_hits; /* forwarding pkt mfctable hits */
119 uint_t mrts_mfc_misses; /* forwarding pkt mfctable misses */
120 uint_t mrts_upcalls; /* # calls to mrouted */
121 uint_t mrts_fwd_in; /* # packets potentially forwarded */
122 uint_t mrts_fwd_out; /* # resulting outgoing packets */
123 uint_t mrts_fwd_drop; /* # dropped for lack of resources */
124 uint_t mrts_bad_tunnel; /* malformed tunnel options */
125 uint_t mrts_cant_tunnel; /* no room for tunnel options */
126 uint_t mrts_wrong_if; /* arrived on wrong interface */
127 uint_t mrts_upq_ovflw; /* upcall Q overflow */
128 uint_t mrts_cache_cleanups; /* # entries with no upcalls */
129 uint_t mrts_drop_sel; /* pkts dropped selectively */
130 uint_t mrts_q_overflow; /* pkts dropped - Q overflow */
131 uint_t mrts_pkt2large; /* pkts dropped - size > BKT SIZE */
132 uint_t mrts_vifctlSize; /* Size of vifctl */
133 uint_t mrts_mfcctlSize; /* Size of mfcctl */
134 uint_t mrts_pim_badversion; /* dtgrms dropped - bad version */
135 uint_t mrts_pim_rcv_badcsum; /* dtgrms dropped - bad checksum */
136 uint_t mrts_pim_badregisters; /* dtgrms dropped - bad register pkts */
137 uint_t mrts_pim_regforwards; /* dtgrms to be forwd - register pkts */
138 uint_t mrts_pim_regsend_drops; /* dtgrms dropped - register send */
139 uint_t mrts_pim_malformed; /* dtgrms dropped - packet malformed */
140 uint_t mrts_pim_nomemory; /* dtgrms dropped - no memory to fwd. */
144 * Argument structure used by mrouted to get src-grp pkt counts
146 struct sioc_sg_req {
147 struct in_addr src;
148 struct in_addr grp;
149 uint_t pktcnt;
150 uint_t bytecnt;
151 uint_t wrong_if;
155 * Argument structure used by mrouted to get vif pkt counts
157 struct sioc_vif_req {
158 vifi_t vifi; /* vif number */
159 uint_t icount; /* Input packet count on vif */
160 uint_t ocount; /* Output packet count on vif */
161 uint_t ibytes; /* Input byte count on vif */
162 uint_t obytes; /* Output byte count on vif */
165 #ifdef _KERNEL
167 * The kernel's virtual-interface structure.
169 struct vif {
170 uchar_t v_flags; /* VIFF_ flags defined above */
171 uchar_t v_threshold; /* Min ttl required to forward on vif */
172 uint_t v_rate_limit; /* Max rate, in kbits/sec */
173 struct tbf *v_tbf; /* Token bkt structure at intf. */
174 struct in_addr v_lcl_addr; /* Local interface address */
175 struct in_addr v_rmt_addr; /* Remote address(tunnels only) */
176 struct ipif_s *v_ipif; /* Pointer to logical interface */
177 uint_t v_pkt_in; /* # Pkts in on interface */
178 uint_t v_pkt_out; /* # Pkts out on interface */
179 uint_t v_bytes_in; /* # Bytes in on interface */
180 uint_t v_bytes_out; /* # Bytes out on interface */
181 timeout_id_t v_timeout_id; /* Qtimeout return id */
183 * struct route v_route; Cached route if this is a tunnel
184 * Used in bsd for performance
186 uint_t v_refcnt;
187 uchar_t v_marks;
188 kmutex_t v_lock;
189 ilm_t *v_ilm; /* allmulti join */
193 * vif is not being used. However if refcnt != 0 than its being initalized.
195 #define VIF_MARK_NOTINUSE 0x0 /* see comment above */
197 #define VIF_MARK_CONDEMNED 0x1 /* delete when refcnt goes to zero. */
199 #define VIF_MARK_GOOD 0x2 /* vif is good */
201 #define VIF_MARK_INUSE VIF_MARK_CONDEMNED | VIF_MARK_GOOD
204 * The kernel's multicast forwarding cache entry structure
205 * (A field for the type of service (mfc_tos) is to be added
206 * at a future point)
208 struct mfc {
209 struct in_addr mfc_origin; /* ip origin of mcasts */
210 struct in_addr mfc_mcastgrp; /* multicast group associated */
211 vifi_t mfc_parent; /* incoming vif */
212 uchar_t mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
213 uint_t mfc_pkt_cnt; /* pkt count for src-grp */
214 uint_t mfc_byte_cnt; /* byte count for src-grp */
215 uint_t mfc_wrong_if; /* wrong if for src-grp */
216 struct timespec mfc_last_assert; /* last time I sent an assert */
217 struct rtdetq *mfc_rte; /* pending upcall */
218 timeout_id_t mfc_timeout_id; /* qtimeout return id */
219 struct mfc *mfc_next;
220 uchar_t mfc_marks;
221 kmutex_t mfc_mutex; /* protects fields and rte list */
225 * mfc bucket structure.
227 struct mfcb {
228 struct mfc *mfcb_mfc; /* first mfc in this bucket */
229 kmutex_t mfcb_lock;
230 uint_t mfcb_refcnt; /* protected by mfcb_lock */
231 uchar_t mfcb_marks; /* protected by mfcb_lock */
234 #define MFCB_MARK_CONDEMNED 0x1
237 * Argument structure used for pkt info. while upcall is made
239 struct rtdetq {
240 mblk_t *mp; /* A copy of the packet */
241 ill_t *ill; /* Interface pkt came in on */
242 struct rtdetq *rte_next;
244 #endif
247 * Struct used to communicate from kernel to multicast router
248 * note the convenient similarity to an IP packet
250 struct igmpmsg {
251 uint_t unused1;
252 uint_t unused2;
253 uchar_t im_msgtype; /* what type of message */
254 #define IGMPMSG_NOCACHE 1
255 #define IGMPMSG_WRONGVIF 2
256 #define IGMPMSG_WHOLEPKT 3
257 uchar_t im_mbz; /* must be zero */
258 uchar_t im_vif; /* vif rec'd on */
259 uchar_t unused3;
260 struct in_addr im_src, im_dst;
263 #ifdef _KERNEL
264 #define MFCTBLSIZ 256
265 #if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */
266 #define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1))
267 #else
268 #define MFCHASHMOD(h) ((h) % MFCTBLSIZ)
269 #endif
271 #define MAX_UPQ 4 /* max. no of pkts in upcall Q */
274 * Token Bucket filter code
276 #define MAX_BKT_SIZE 10000 /* 10K bytes size */
277 #define MAXQSIZE 10 /* max # of pkts in queue */
278 #define TOKEN_SIZE 8 /* number of bits in token */
281 * The token bucket filter at each vif
283 struct tbf {
284 timespec_t tbf_last_pkt_t; /* arr. time of last pkt */
285 uint_t tbf_n_tok; /* no of tokens in bucket */
286 uint_t tbf_q_len; /* length of queue at this vif */
287 uint_t tbf_max_q_len; /* max queue length */
288 mblk_t *tbf_q; /* Packet queue */
289 mblk_t *tbf_t; /* Tail-insertion pointer */
290 kmutex_t tbf_lock; /* lock on the tbf */
293 #endif /* _KERNEL */
295 #ifdef __cplusplus
297 #endif
299 #endif /* _NETINET_IP_MROUTE_H */