ip_mroute.h revision 1.1 1 1.1 hpeyerl /*
2 1.1 hpeyerl * Copyright (c) 1989 Stephen Deering.
3 1.1 hpeyerl * Copyright (c) 1992 Regents of the University of California.
4 1.1 hpeyerl * All rights reserved.
5 1.1 hpeyerl *
6 1.1 hpeyerl * This code is derived from software contributed to Berkeley by
7 1.1 hpeyerl * Stephen Deering of Stanford University.
8 1.1 hpeyerl *
9 1.1 hpeyerl * Redistribution and use in source and binary forms, with or without
10 1.1 hpeyerl * modification, are permitted provided that the following conditions
11 1.1 hpeyerl * are met:
12 1.1 hpeyerl * 1. Redistributions of source code must retain the above copyright
13 1.1 hpeyerl * notice, this list of conditions and the following disclaimer.
14 1.1 hpeyerl * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 hpeyerl * notice, this list of conditions and the following disclaimer in the
16 1.1 hpeyerl * documentation and/or other materials provided with the distribution.
17 1.1 hpeyerl * 3. All advertising materials mentioning features or use of this software
18 1.1 hpeyerl * must display the following acknowledgement:
19 1.1 hpeyerl * This product includes software developed by the University of
20 1.1 hpeyerl * California, Berkeley and its contributors.
21 1.1 hpeyerl * 4. Neither the name of the University nor the names of its contributors
22 1.1 hpeyerl * may be used to endorse or promote products derived from this software
23 1.1 hpeyerl * without specific prior written permission.
24 1.1 hpeyerl *
25 1.1 hpeyerl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.1 hpeyerl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.1 hpeyerl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.1 hpeyerl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.1 hpeyerl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.1 hpeyerl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.1 hpeyerl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.1 hpeyerl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.1 hpeyerl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.1 hpeyerl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.1 hpeyerl * SUCH DAMAGE.
36 1.1 hpeyerl *
37 1.1 hpeyerl * @(#)ip_mroute.h 7.2 (Berkeley) 7/8/92
38 1.1 hpeyerl */
39 1.1 hpeyerl
40 1.1 hpeyerl /*
41 1.1 hpeyerl * Definitions for the kernel part of DVMRP,
42 1.1 hpeyerl * a Distance-Vector Multicast Routing Protocol.
43 1.1 hpeyerl * (See RFC-1075.)
44 1.1 hpeyerl *
45 1.1 hpeyerl * Written by David Waitzman, BBN Labs, August 1988.
46 1.1 hpeyerl * Modified by Steve Deering, Stanford, February 1989.
47 1.1 hpeyerl *
48 1.1 hpeyerl * MROUTING 1.0
49 1.1 hpeyerl */
50 1.1 hpeyerl
51 1.1 hpeyerl
52 1.1 hpeyerl /*
53 1.1 hpeyerl * DVMRP-specific setsockopt commands.
54 1.1 hpeyerl */
55 1.1 hpeyerl #define DVMRP_INIT 100
56 1.1 hpeyerl #define DVMRP_DONE 101
57 1.1 hpeyerl #define DVMRP_ADD_VIF 102
58 1.1 hpeyerl #define DVMRP_DEL_VIF 103
59 1.1 hpeyerl #define DVMRP_ADD_LGRP 104
60 1.1 hpeyerl #define DVMRP_DEL_LGRP 105
61 1.1 hpeyerl #define DVMRP_ADD_MRT 106
62 1.1 hpeyerl #define DVMRP_DEL_MRT 107
63 1.1 hpeyerl
64 1.1 hpeyerl
65 1.1 hpeyerl /*
66 1.1 hpeyerl * Types and macros for handling bitmaps with one bit per virtual interface.
67 1.1 hpeyerl */
68 1.1 hpeyerl #define MAXVIFS 32
69 1.1 hpeyerl typedef u_long vifbitmap_t;
70 1.1 hpeyerl typedef u_short vifi_t; /* type of a vif index */
71 1.1 hpeyerl
72 1.1 hpeyerl #define VIFM_SET(n, m) ((m) |= (1 << (n)))
73 1.1 hpeyerl #define VIFM_CLR(n, m) ((m) &= ~(1 << (n)))
74 1.1 hpeyerl #define VIFM_ISSET(n, m) ((m) & (1 << (n)))
75 1.1 hpeyerl #define VIFM_CLRALL(m) ((m) = 0x00000000)
76 1.1 hpeyerl #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom))
77 1.1 hpeyerl #define VIFM_SAME(m1, m2) ((m1) == (m2))
78 1.1 hpeyerl
79 1.1 hpeyerl
80 1.1 hpeyerl /*
81 1.1 hpeyerl * Agument structure for DVMRP_ADD_VIF.
82 1.1 hpeyerl * (DVMRP_DEL_VIF takes a single vifi_t argument.)
83 1.1 hpeyerl */
84 1.1 hpeyerl struct vifctl {
85 1.1 hpeyerl vifi_t vifc_vifi; /* the index of the vif to be added */
86 1.1 hpeyerl u_char vifc_flags; /* VIFF_ flags defined below */
87 1.1 hpeyerl u_char vifc_threshold; /* min ttl required to forward on vif */
88 1.1 hpeyerl struct in_addr vifc_lcl_addr; /* local interface address */
89 1.1 hpeyerl struct in_addr vifc_rmt_addr; /* remote address (tunnels only) */
90 1.1 hpeyerl };
91 1.1 hpeyerl
92 1.1 hpeyerl #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
93 1.1 hpeyerl #define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */
94 1.1 hpeyerl
95 1.1 hpeyerl
96 1.1 hpeyerl /*
97 1.1 hpeyerl * Argument structure for DVMRP_ADD_LGRP and DVMRP_DEL_LGRP.
98 1.1 hpeyerl */
99 1.1 hpeyerl struct lgrplctl {
100 1.1 hpeyerl vifi_t lgc_vifi;
101 1.1 hpeyerl struct in_addr lgc_gaddr;
102 1.1 hpeyerl };
103 1.1 hpeyerl
104 1.1 hpeyerl
105 1.1 hpeyerl /*
106 1.1 hpeyerl * Argument structure for DVMRP_ADD_MRT.
107 1.1 hpeyerl * (DVMRP_DEL_MRT takes a single struct in_addr argument, containing origin.)
108 1.1 hpeyerl */
109 1.1 hpeyerl struct mrtctl {
110 1.1 hpeyerl struct in_addr mrtc_origin; /* subnet origin of multicasts */
111 1.1 hpeyerl struct in_addr mrtc_originmask; /* subnet mask for origin */
112 1.1 hpeyerl vifi_t mrtc_parent; /* incoming vif */
113 1.1 hpeyerl vifbitmap_t mrtc_children; /* outgoing children vifs */
114 1.1 hpeyerl vifbitmap_t mrtc_leaves; /* subset of outgoing children vifs */
115 1.1 hpeyerl };
116 1.1 hpeyerl
117 1.1 hpeyerl
118 1.1 hpeyerl #ifdef KERNEL
119 1.1 hpeyerl
120 1.1 hpeyerl /*
121 1.1 hpeyerl * The kernel's virtual-interface structure.
122 1.1 hpeyerl */
123 1.1 hpeyerl struct vif {
124 1.1 hpeyerl u_char v_flags; /* VIFF_ flags defined above */
125 1.1 hpeyerl u_char v_threshold; /* min ttl required to forward on vif */
126 1.1 hpeyerl struct in_addr v_lcl_addr; /* local interface address */
127 1.1 hpeyerl struct in_addr v_rmt_addr; /* remote address (tunnels only) */
128 1.1 hpeyerl struct ifnet *v_ifp; /* pointer to interface */
129 1.1 hpeyerl struct in_addr *v_lcl_grps; /* list of local grps (phyints only) */
130 1.1 hpeyerl int v_lcl_grps_max; /* malloc'ed number of v_lcl_grps */
131 1.1 hpeyerl int v_lcl_grps_n; /* used number of v_lcl_grps */
132 1.1 hpeyerl u_long v_cached_group; /* last grp looked-up (phyints only) */
133 1.1 hpeyerl int v_cached_result; /* last look-up result (phyints only) */
134 1.1 hpeyerl };
135 1.1 hpeyerl
136 1.1 hpeyerl /*
137 1.1 hpeyerl * The kernel's multicast route structure.
138 1.1 hpeyerl */
139 1.1 hpeyerl struct mrt {
140 1.1 hpeyerl struct in_addr mrt_origin; /* subnet origin of multicasts */
141 1.1 hpeyerl struct in_addr mrt_originmask; /* subnet mask for origin */
142 1.1 hpeyerl vifi_t mrt_parent; /* incoming vif */
143 1.1 hpeyerl vifbitmap_t mrt_children; /* outgoing children vifs */
144 1.1 hpeyerl vifbitmap_t mrt_leaves; /* subset of outgoing children vifs */
145 1.1 hpeyerl struct mrt *mrt_next; /* forward link */
146 1.1 hpeyerl };
147 1.1 hpeyerl
148 1.1 hpeyerl
149 1.1 hpeyerl #define MRTHASHSIZ 256
150 1.1 hpeyerl #if (MRTHASHSIZ & (MRTHASHSIZ - 1)) == 0 /* from sys:route.h */
151 1.1 hpeyerl #define MRTHASHMOD(h) ((h) & (MRTHASHSIZ - 1))
152 1.1 hpeyerl #else
153 1.1 hpeyerl #define MRTHASHMOD(h) ((h) % MRTHASHSIZ)
154 1.1 hpeyerl #endif
155 1.1 hpeyerl
156 1.1 hpeyerl /*
157 1.1 hpeyerl * The kernel's multicast routing statistics.
158 1.1 hpeyerl */
159 1.1 hpeyerl struct mrtstat {
160 1.1 hpeyerl u_long mrts_mrt_lookups; /* # multicast route lookups */
161 1.1 hpeyerl u_long mrts_mrt_misses; /* # multicast route cache misses */
162 1.1 hpeyerl u_long mrts_grp_lookups; /* # group address lookups */
163 1.1 hpeyerl u_long mrts_grp_misses; /* # group address cache misses */
164 1.1 hpeyerl u_long mrts_no_route; /* no route for packet's origin */
165 1.1 hpeyerl u_long mrts_bad_tunnel; /* malformed tunnel options */
166 1.1 hpeyerl u_long mrts_cant_tunnel; /* no room for tunnel options */
167 1.1 hpeyerl u_long mrts_wrong_if; /* arrived on wrong interface */
168 1.1 hpeyerl };
169 1.1 hpeyerl
170 1.1 hpeyerl int ip_mrouter_cmd __P((int, struct socket *, struct mbuf *));
171 1.1 hpeyerl int ip_mrouter_done __P(());
172 1.1 hpeyerl
173 1.1 hpeyerl #endif /* KERNEL */
174 1.1 hpeyerl
175