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