Commit | Line | Data |
---|---|---|
2c74c1da KS |
1 | /* |
2 | * Copyright (c) 1989 Stephen Deering. | |
3 | * Copyright (c) 1992 Regents of the University of California. | |
4 | * All rights reserved. | |
5 | * | |
6 | * This code is derived from software contributed to Berkeley by | |
7 | * Stephen Deering of Stanford University. | |
8 | * | |
9 | * %sccs.include.redist.c% | |
10 | * | |
ec5578a1 | 11 | * @(#)ip_mroute.h 7.2 (Berkeley) %G% |
2c74c1da KS |
12 | */ |
13 | ||
14 | /* | |
15 | * Definitions for the kernel part of DVMRP, | |
16 | * a Distance-Vector Multicast Routing Protocol. | |
17 | * (See RFC-1075.) | |
18 | * | |
19 | * Written by David Waitzman, BBN Labs, August 1988. | |
20 | * Modified by Steve Deering, Stanford, February 1989. | |
21 | * | |
22 | * MROUTING 1.0 | |
23 | */ | |
24 | ||
2c74c1da KS |
25 | |
26 | /* | |
27 | * DVMRP-specific setsockopt commands. | |
28 | */ | |
29 | #define DVMRP_INIT 100 | |
30 | #define DVMRP_DONE 101 | |
31 | #define DVMRP_ADD_VIF 102 | |
32 | #define DVMRP_DEL_VIF 103 | |
33 | #define DVMRP_ADD_LGRP 104 | |
34 | #define DVMRP_DEL_LGRP 105 | |
35 | #define DVMRP_ADD_MRT 106 | |
36 | #define DVMRP_DEL_MRT 107 | |
37 | ||
38 | ||
39 | /* | |
40 | * Types and macros for handling bitmaps with one bit per virtual interface. | |
41 | */ | |
42 | #define MAXVIFS 32 | |
43 | typedef u_long vifbitmap_t; | |
44 | typedef u_short vifi_t; /* type of a vif index */ | |
45 | ||
46 | #define VIFM_SET(n, m) ((m) |= (1 << (n))) | |
47 | #define VIFM_CLR(n, m) ((m) &= ~(1 << (n))) | |
48 | #define VIFM_ISSET(n, m) ((m) & (1 << (n))) | |
49 | #define VIFM_CLRALL(m) ((m) = 0x00000000) | |
50 | #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom)) | |
51 | #define VIFM_SAME(m1, m2) ((m1) == (m2)) | |
52 | ||
53 | ||
54 | /* | |
55 | * Agument structure for DVMRP_ADD_VIF. | |
56 | * (DVMRP_DEL_VIF takes a single vifi_t argument.) | |
57 | */ | |
58 | struct vifctl { | |
59 | vifi_t vifc_vifi; /* the index of the vif to be added */ | |
60 | u_char vifc_flags; /* VIFF_ flags defined below */ | |
61 | u_char vifc_threshold; /* min ttl required to forward on vif */ | |
62 | struct in_addr vifc_lcl_addr; /* local interface address */ | |
63 | struct in_addr vifc_rmt_addr; /* remote address (tunnels only) */ | |
64 | }; | |
65 | ||
66 | #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ | |
67 | ||
68 | ||
69 | /* | |
70 | * Argument structure for DVMRP_ADD_LGRP and DVMRP_DEL_LGRP. | |
71 | */ | |
72 | struct lgrplctl { | |
73 | vifi_t lgc_vifi; | |
74 | struct in_addr lgc_gaddr; | |
75 | }; | |
76 | ||
77 | ||
78 | /* | |
79 | * Argument structure for DVMRP_ADD_MRT. | |
80 | * (DVMRP_DEL_MRT takes a single struct in_addr argument, containing origin.) | |
81 | */ | |
82 | struct mrtctl { | |
83 | struct in_addr mrtc_origin; /* subnet origin of multicasts */ | |
84 | struct in_addr mrtc_originmask; /* subnet mask for origin */ | |
85 | vifi_t mrtc_parent; /* incoming vif */ | |
86 | vifbitmap_t mrtc_children; /* outgoing children vifs */ | |
87 | vifbitmap_t mrtc_leaves; /* subset of outgoing children vifs */ | |
88 | }; | |
89 | ||
90 | ||
91 | #ifdef KERNEL | |
92 | ||
93 | /* | |
94 | * The kernel's virtual-interface structure. | |
95 | */ | |
96 | struct vif { | |
97 | u_char v_flags; /* VIFF_ flags defined above */ | |
98 | u_char v_threshold; /* min ttl required to forward on vif */ | |
99 | struct in_addr v_lcl_addr; /* local interface address */ | |
100 | struct in_addr v_rmt_addr; /* remote address (tunnels only) */ | |
101 | struct ifnet *v_ifp; /* pointer to interface */ | |
102 | struct in_addr *v_lcl_grps; /* list of local grps (phyints only) */ | |
103 | int v_lcl_grps_max; /* malloc'ed number of v_lcl_grps */ | |
104 | int v_lcl_grps_n; /* used number of v_lcl_grps */ | |
105 | u_long v_cached_group; /* last grp looked-up (phyints only) */ | |
106 | int v_cached_result; /* last look-up result (phyints only) */ | |
107 | }; | |
108 | ||
109 | /* | |
110 | * The kernel's multicast route structure. | |
111 | */ | |
112 | struct mrt { | |
113 | struct in_addr mrt_origin; /* subnet origin of multicasts */ | |
114 | struct in_addr mrt_originmask; /* subnet mask for origin */ | |
115 | vifi_t mrt_parent; /* incoming vif */ | |
116 | vifbitmap_t mrt_children; /* outgoing children vifs */ | |
117 | vifbitmap_t mrt_leaves; /* subset of outgoing children vifs */ | |
118 | struct mrt *mrt_next; /* forward link */ | |
119 | }; | |
120 | ||
121 | ||
122 | #define MRTHASHSIZ 64 | |
123 | #if (MRTHASHSIZ & (MRTHASHSIZ - 1)) == 0 /* from sys:route.h */ | |
124 | #define MRTHASHMOD(h) ((h) & (MRTHASHSIZ - 1)) | |
125 | #else | |
126 | #define MRTHASHMOD(h) ((h) % MRTHASHSIZ) | |
127 | #endif | |
128 | ||
129 | /* | |
130 | * The kernel's multicast routing statistics. | |
131 | */ | |
132 | struct mrtstat { | |
133 | u_long mrts_mrt_lookups; /* # multicast route lookups */ | |
134 | u_long mrts_mrt_misses; /* # multicast route cache misses */ | |
135 | u_long mrts_grp_lookups; /* # group address lookups */ | |
136 | u_long mrts_grp_misses; /* # group address cache misses */ | |
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 | }; | |
141 | ||
142 | ||
143 | int ip_mrouter_cmd __P((int, struct socket *, struct mbuf *)); | |
144 | int ip_mrouter_done __P(()); | |
145 | ||
146 | #endif /* KERNEL */ | |
147 |