]> git.saurik.com Git - apple/xnu.git/blob - bsd/netat/routing_tables.h
xnu-201.19.tar.gz
[apple/xnu.git] / bsd / netat / routing_tables.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * This include file defines the RTMP table and ZIP table
24 * for the AppleTalk AIX router
25 *
26 *
27 * 0.01 03/16/94 LD Creation
28 * 0.10 08/19/94 LD merged
29 *
30 */
31
32 #ifndef _NETAT_ROUTING_TABLES_H_
33 #define _NETAT_ROUTING_TABLES_H_
34
35 /* RTMP table entry state bitmap (EntryState) values */
36
37 #define RTE_STATE_UNUSED 0 /* this entry is not in used */
38 #define RTE_STATE_BAD 2 /* The route is almost ready to be removed */
39 #define RTE_STATE_SUSPECT 4 /* didn't received an update for route */
40 #define RTE_STATE_GOOD 8 /* this route is 100% valid */
41 #define RTE_STATE_ZKNOWN 16 /* we know the zones for this entry */
42 #define RTE_STATE_UPDATED 32 /* set when updated from received rtmp table */
43 #define RTE_STATE_BKUP 64 /* for future use : AURP */
44 #define RTE_STATE_PERMANENT 128 /* This is a directly attached route */
45
46 #define PORT_ONLINE 32 /* router port in forwarding state */
47 #define PORT_SEEDING 31 /* router port seeding */
48 #define PORT_ACTIVATING 16 /* router port waiting for net infos */
49 #define PORT_ERR_NOZONE 6 /* router no zones for non seed port*/
50 #define PORT_ERR_BADRTMP 5 /* router problem bad rtmp version*/
51 #define PORT_ERR_STARTUP 4 /* router problem cable in start range*/
52 #define PORT_ERR_CABLER 3 /* router problem bad cable range*/
53 #define PORT_ERR_SEED 2 /* router startup seeding problem */
54 #define PORT_ONERROR 1 /* router port with generic problem*/
55 #define PORT_OFFLINE 0 /* router port disabled/not ready */
56
57 #define ZT_MAX 1024 /* Don't allow more zones than that */
58 #define ZT_MIN 32 /* Minimum for a good behaviour*/
59 #define ZT_DEFAULT 512 /* Minimum for a good behaviour*/
60 #define RT_MAX 4096 /* Don't allow more entries than that */
61 #define RT_MIN 128 /* Minimum for a good behaviour*/
62 #define RT_DEFAULT 1024 /* Minimum for a good behaviour*/
63 #define ZT_BYTES (ZT_MAX/8) /* Bytes in Zone Bitmap */
64 #define ZT_MAXEDOUT ZT_MAX+1 /* reached the entry limit.. */
65 #define RT_MIX_DEFAULT 2000 /* default for nbr of ppsec */
66
67
68 #define NOTIFY_N_DIST 31 /* Notify Neighbor distance (when shutdown or so) */
69
70 /* Useful macros to access the RTMP tuple fields */
71
72 #define TUPLENET(x) NET_VALUE(((at_rtmp_tuple *)(x))->at_rtmp_net)
73 #define TUPLEDIST(x) ((((at_rtmp_tuple *)(x))->at_rtmp_data) & RTMP_DISTANCE)
74 #define TUPLERANGE(x) ((((at_rtmp_tuple *)(x))->at_rtmp_data) & RTMP_RANGE_FLAG)
75
76 #define CableStart ifID->ifThisCableStart
77 #define CableStop ifID->ifThisCableEnd
78
79 #define RTMP_IDLENGTH 4 /* RTMP packet Node header length */
80
81
82 #define RTMP_VERSION_NUMBER 0x82 /* V2 only version of RTMP supported */
83
84 #define ERTR_SEED_CONFLICT 0x101 /* Conflict between port information and net
85 * value received for the port (fatal for Rtr)
86 */
87 #define ERTR_CABLE_CONFLICT 0x102 /* Conflict between port information and net
88 * information received in a RTMP packet
89 */
90
91 #define ERTR_RTMP_BAD_VERSION 0x103 /* We received a non phase-II RTMP packet
92 * that's bad... We can't deal with it
93 */
94
95 #define ERTR_CABLE_STARTUP 0x104 /* the cable range we're on happen to
96 * be in the startup range. Shouldn't
97 */
98
99 #define ERTR_CABLE_NOZONE 0x105 /* We haven't found any zones for that port
100 * after all the timeout expired
101 */
102
103
104 /* RTMP table entry */
105
106 typedef struct rt_entry {
107
108 struct rt_entry *left; /* btree left pointer */
109 struct rt_entry *right; /* btree right pointer */
110
111 at_net_al NetStop; /* Last net # in the range, or network # if
112 non extended network */
113 at_net_al NetStart; /* Starting network number in the range, 0
114 non extended network */
115 at_net_al NextIRNet; /* Network number of next Internet Router */
116 at_node NextIRNode; /* Node ID of next Router */
117 u_char ZoneBitMap[ZT_BYTES]; /* One bit per Zone defined for this entry */
118 u_char NetDist; /* Distance in hops of the destination net */
119 u_char NetPort; /* Physical port number to forward to */
120 u_char EntryState; /* State of the entry bitmap field */
121 u_char RTMPFlag;
122 u_char AURPFlag;
123
124 } RT_entry;
125
126
127 /* ZIP Table entry */
128
129 typedef struct {
130
131 u_short ZoneCount; /* Count of reference to zone entry */
132 at_nvestr_t Zone; /* zone name as a Network Visible Entity */
133
134 } ZT_entry;
135
136 /* for zone retrieval to user space only */
137 typedef struct {
138 unsigned short entryno; /* zone table entry number (1st = 0) */
139 ZT_entry zt; /* the zone table entry */
140 } ZT_entryno;
141
142 #ifdef KERNEL
143
144 /* Macros for Routing table B-tree easy access */
145
146 #define RT_DELETE(NetStop, NetStart) {\
147 RT_entry *found; \
148 if ((found = rt_bdelete(NetStop, NetStart))) { \
149 memset(found, '\0', sizeof(RT_entry)); \
150 found->right = RT_table_freelist; \
151 RT_table_freelist = found; \
152 } \
153 }
154
155 /* Set/Reset and test the All zones known bit in for the entry field */
156
157 #define RT_ALL_ZONES_KNOWN(entry) ((entry)->EntryState & RTE_STATE_ZKNOWN)
158 #define RT_SET_ZONE_KNOWN(entry) ((entry)->EntryState |= RTE_STATE_ZKNOWN)
159 #define RT_CLR_ZONE_KNOWN(entry) ((entry)->EntryState ^= RTE_STATE_ZKNOWN)
160
161 /*
162 * check if a zone number is in a given zone map
163 */
164 #define ZT_ISIN_ZMAP(znum, zmap) ((zmap)[(znum-1) >> 3] & 0x80 >> (znum-1) % 8)
165
166 /* remove a zone from the zone bitmap, and check if the zone
167 * is still in use by someone else.
168 */
169
170 #define ZT_CLR_ZMAP(num, zmap) { \
171 if ((zmap)[(num-1) >> 3] & 0x80 >> (num-1) % 8) { \
172 (zmap)[(num-1) >> 3] ^= 0x80 >> (num-1) % 8; \
173 ZT_table[(num-1)].ZoneCount-- ; \
174 } \
175 }
176
177 /* set a bit in an entry bit map */
178
179 #define ZT_SET_ZMAP(num, zmap) { \
180 if (!zmap[(num-1) >> 3] & 0x80 >> (num-1) % 8) { \
181 zmap[(num-1) >> 3] |= 0x80 >> (num-1) % 8; \
182 ZT_table[(num-1)].ZoneCount++ ; \
183 } \
184 }
185
186 extern int regDefaultZone(at_ifaddr_t *);
187 extern int zonename_equal(at_nvestr_t *, at_nvestr_t *);
188
189 extern RT_entry *RT_table_freelist;
190 extern RT_entry RT_table_start;
191 extern RT_entry *RT_table;
192 extern RT_entry *rt_binsert();
193 extern RT_entry *rt_insert();
194 extern RT_entry *rt_bdelete();
195 extern RT_entry *rt_blookup(int);
196 extern RT_entry *rt_getNextRoute(int);
197
198 extern ZT_entry *ZT_table;
199 extern short RT_maxentry;
200 extern short ZT_maxentry;
201
202 extern volatile int RouterMix;
203
204 extern int zt_add_zone(char *, short);
205 extern int zt_add_zonename(at_nvestr_t *);
206 extern int zt_ent_zindex(u_char *);
207 extern ZT_entryno *zt_getNextZone(int);
208 extern void zt_remove_zones(u_char *);
209 extern void zt_set_zmap(u_short, char *);
210 extern void rtmp_router_input();
211
212 #endif /* KERNEL */
213
214 #endif /* _NETAT_ROUTING_TABLES_H_ */