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