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