]>
Commit | Line | Data |
---|---|---|
1c79356b A |
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 | * Copyright (c) 1998 Apple Computer, Inc. | |
24 | */ | |
25 | ||
26 | #include <sys/queue.h> | |
27 | ||
28 | /* at_var.h */ | |
29 | ||
30 | /* at_var.h contains definitions formerly found in: at/at_lap.h & at/elap.h */ | |
31 | ||
32 | /* multicast tracking */ | |
33 | #define MAX_MCASTS 25 /* #multicast addrs tracked per i/f */ | |
34 | #define MCAST_TRACK_ADD 1 | |
35 | #define MCAST_TRACK_DELETE 2 | |
36 | #define MCAST_TRACK_CHECK 3 | |
37 | ||
38 | #define ETHERNET_ADDR_LEN 6 | |
39 | #define IFNAMESIZ 16 | |
40 | ||
41 | /* maximum number of I/F's allowed */ | |
42 | #define IF_TOTAL_MAX 17 /* max count of any combination of I/F's */ | |
43 | /* 17 == (1+(4*4)); 9 and 13 would also be | |
44 | reasonable values */ | |
45 | ||
46 | #define FDDI_OR_TOKENRING(i) ((i == IFT_FDDI) || (i == IFT_ISO88025)) | |
47 | ||
48 | typedef struct etalk_addr { | |
49 | u_char etalk_addr_octet[ETHERNET_ADDR_LEN]; | |
50 | } etalk_addr_t; | |
51 | ||
52 | typedef char if_name_t[IFNAMESIZ]; | |
53 | typedef struct at_ifname_list { | |
54 | if_name_t at_if[IF_TOTAL_MAX]; | |
55 | } at_ifnames_t; | |
56 | ||
57 | typedef struct at_if_statstics { | |
58 | u_long fwdBytes; /* bytes received & forwarded */ | |
59 | u_long fwdPkts; /* pkts received & forwarded */ | |
60 | u_long droppedBytes; /* bytes received & dropped */ | |
61 | u_long droppedPkts; /* pkts received & dropped */ | |
62 | u_long outBytes; /* bytes sent */ | |
63 | u_long outPkts; /* pkts sent */ | |
64 | u_long routes; /* count of routes in rtmptable */ | |
65 | } at_if_statistics_t; | |
66 | ||
67 | typedef struct { | |
68 | u_int unknown_mblks; /* number of unknown streams msgs */ | |
69 | u_int rcv_bytes; /* number of data bytes received */ | |
70 | u_int rcv_packets; /* number of packets received */ | |
71 | u_int xmit_bytes; /* number of data bytes xmited */ | |
72 | u_int xmit_packets; /* number of packets xmited */ | |
73 | } at_elap_stats_t; | |
74 | ||
75 | typedef struct { | |
76 | char ifr_name[IFNAMESIZ]; | |
77 | u_int flags; /* misc. port flags, | |
78 | (ELAP_CFG_xxx on input | |
79 | ifFlags on output) */ | |
80 | struct at_addr node; /* Our node number. */ | |
81 | struct at_addr router; /* Our router. */ | |
82 | u_short netStart; /* network start range */ | |
83 | u_short netEnd; /* network ending range */ | |
84 | at_nvestr_t zonename; | |
85 | } at_if_cfg_t; | |
86 | ||
87 | typedef struct { | |
88 | at_entity_t name; | |
89 | at_inet_t addr; /* net and node are ignored, except in | |
90 | multihoming mode where "addr" is used | |
91 | to specify the interface. */ | |
92 | u_char ddptype; | |
93 | long unique_nbp_id; | |
94 | } at_nbp_reg_t; | |
95 | ||
96 | typedef struct { | |
97 | char ifr_name[IFNAMESIZ]; | |
98 | at_nvestr_t zonename; | |
99 | } at_def_zone_t; | |
100 | ||
101 | typedef struct zone_usage { | |
102 | int zone_index; /* index in local_zones */ | |
103 | at_nvestr_t zone_name; /* the zone name & len */ | |
104 | int zone_home; /* used only to set zones in | |
105 | router mode */ | |
106 | at_ifnames_t zone_iflist; /* list of interfaces for | |
107 | this zone. */ | |
108 | char usage[IF_TOTAL_MAX]; /* I/F usage (set if | |
109 | I/F in this zone) */ | |
110 | } zone_usage_t; | |
111 | ||
112 | typedef struct { | |
113 | short multihome; | |
114 | short rtmp_table_sz; | |
115 | short zone_table_sz; | |
116 | short router_mix; | |
117 | } at_router_params_t; | |
118 | ||
119 | typedef struct at_kern_err { | |
120 | int error; /* kernel error # (KE_xxx) */ | |
121 | int port1; | |
122 | int port2; | |
123 | char name1[IFNAMESIZ]; | |
124 | char name2[IFNAMESIZ]; | |
125 | u_short net; | |
126 | u_char node; | |
127 | u_short netr1b, netr1e; /* net range 1 begin & end */ | |
128 | u_short netr2b, netr2e; /* net range 2 begin & end */ | |
129 | u_char rtmp_id; | |
130 | } at_kern_err_t; | |
131 | ||
132 | #define KE_CONF_RANGE 1 | |
133 | #define KE_CONF_SEED_RNG 2 | |
134 | #define KE_CONF_SEED1 3 | |
135 | #define KE_CONF_SEED_NODE 4 | |
136 | #define KE_NO_ZONES_FOUND 5 | |
137 | #define KE_NO_SEED 6 | |
138 | #define KE_INVAL_RANGE 7 | |
139 | #define KE_SEED_STARTUP 8 | |
140 | #define KE_BAD_VER 9 | |
141 | #define KE_RTMP_OVERFLOW 10 | |
142 | #define KE_ZIP_OVERFLOW 11 | |
143 | ||
144 | /* | |
145 | * Interface address, AppleTalk version. One of these structures | |
146 | * is allocated for each AppleTalk address on an interface. | |
147 | * | |
148 | * The ifaddr structure contains the protocol-independent part | |
149 | * of the structure and is assumed to be first, as it is in | |
150 | * "struct in_ifaddr", defined in bsd/netinet/in_var.h. | |
151 | */ | |
152 | typedef struct at_ifaddr { | |
153 | struct ifaddr aa_ifa; | |
154 | #define aa_ifp aa_ifa.ifa_ifp | |
155 | #define aa_flags aa_ifa.ifa_flags | |
156 | ||
157 | TAILQ_ENTRY(at_ifaddr) aa_link; /* tailq macro glue */ | |
158 | ||
159 | u_long at_dl_tag; /* DLIL tag to be used in packet output */ | |
160 | u_long aarp_dl_tag; /* DLIL tag for Appletalk ARP */ | |
161 | ||
162 | /* from pat_unit_t */ | |
163 | unsigned char mcast[MAX_MCASTS]; | |
164 | char xaddr[ETHERNET_ADDR_LEN]; | |
165 | ||
166 | /* from elap_specifics_t */ | |
167 | at_elap_stats_t stats; | |
168 | ||
169 | /* The DDP sets these values: */ | |
170 | u_char ifState; /* State of the interface LAP_* */ | |
171 | u_short ifThisCableStart; | |
172 | u_short ifThisCableEnd; | |
173 | struct at_addr ifARouter; | |
174 | u_char ifRouterState; | |
175 | u_int ifFlags; /* Flags, see AT_IFF_* */ | |
176 | struct sockaddr_at ifNodeAddress; | |
177 | #define ifThisNode ifNodeAddress.sat_addr | |
178 | /* AppleTalk node ID is ifNodeAddress.sat_addr*/ | |
179 | ||
180 | /* for use by ZIP */ | |
181 | u_char ifNumRetries; | |
182 | at_nvestr_t ifZoneName; | |
183 | ||
184 | /* Added for routing support */ | |
185 | int ifPort; /* the unique ddp logical port | |
186 | number, also index into | |
187 | at_interfaces[] and ifID_table[] */ | |
188 | char ifName[IFNAMESIZ]; | |
189 | /* added to support LAP_IOC_GET_IFID */ | |
190 | u_short ifDefZone; /* Default Zone index in ZoneTable; used | |
191 | only in routing/multihome modes to be | |
192 | able to answer a ZIP GetNetInfo request */ | |
193 | char ifZipNeedQueries; | |
194 | /* ZIP/RTMP Query flag */ | |
195 | char ifRoutingState; /* Port (as a router) state */ | |
196 | at_if_statistics_t | |
197 | ifStatistics; /* statistics */ | |
198 | /* end of elap_if structure */ | |
199 | ||
200 | u_short flags; /* port specific flags */ | |
201 | struct etalk_addr ZoneMcastAddr; | |
202 | /* zone multicast addr */ | |
203 | struct etalk_addr cable_multicast_addr; | |
204 | /* AppleTalk broadcast addr */ | |
205 | ||
206 | struct at_addr initial_addr; /* temporary value used during startup */ | |
207 | at_nvestr_t startup_zone; | |
208 | int startup_error, /* to get error code back from | |
209 | ZIPwakeup() / AARPwakeup() */ | |
210 | startup_inprogress; /* to decide whether it's the | |
211 | middle of an elap_online operation */ | |
212 | ||
213 | } at_ifaddr_t; | |
214 | ||
215 | #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */ | |
216 | #define LAP_ONLINE 1 | |
217 | #define LAP_ONLINE_FOR_ZIP 2 | |
218 | #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */ | |
219 | ||
220 | #define NO_ROUTER 1 /* there's no router around */ | |
221 | #define ROUTER_WARNING 2 /* there's a router around that */ | |
222 | /* we are ignoring, warning has */ | |
223 | /* been issued to the user */ | |
224 | #define ROUTER_AROUND 3 /* A router is around and we've */ | |
225 | /* noted its presence */ | |
226 | #define ROUTER_UPDATED 4 /* for mh tracking of routers. Value decremented | |
227 | with rtmp aging timer, a value of 4 allows a | |
228 | minimum of 40 secs to laps before we decide | |
229 | to revert to cable multicasts */ | |
230 | ||
231 | /* AppleTalk IOCTLs */ | |
232 | ||
233 | ||
234 | #define AIOCSTOPATALK _IOWR('a', 1, int) /* stop AppleTalk */ | |
235 | #define AIOCGETIFCFG _IOWR('a', 2, at_if_cfg_t) /* get AT interface cfg */ | |
236 | #define AIOCNBPREG _IOWR('a', 3, at_nbp_reg_t) /* NBP register */ | |
237 | #define AIOCNBPREMOVE _IOW('a', 4, at_nbp_reg_t) /* NBP remove */ | |
238 | #define AIOCGETSTATE _IOR('a', 5, at_state_t) /* get AT global state */ | |
239 | #define AIOCSETDEFZONE _IOW('a', 6, at_def_zone_t) | |
240 | /* in single-port, router, and multihome modes, set default zone */ | |
241 | #define AIOCSETROUTER _IOW('a', 7, at_router_params_t) | |
242 | #define AIOCGETROUTER _IOR('a', 8, at_router_params_t) | |
243 | #define AIOCSIFADDR _IOW('a', 9, at_if_cfg_t) /* init AT interface */ | |
244 | #define AIOCSTARTROUTER _IOR('a',10, at_kern_err_t) /* start AT routing */ | |
245 | #define AIOCREGLOCALZN _IOW('a',11, at_nvestr_t) | |
246 | /* in single-port mode, register local zone in kernel table for | |
247 | future use in error checking NBP registration */ | |
248 | #define AIOCSETZNUSAGE _IOW('a',12, zone_usage_t) | |
249 | /* in router mode, set up each zone for interfaces being seeded */ | |
250 | #define AIOCGETZNUSAGE _IOWR('a',13, zone_usage_t) | |
251 | /* in router and multihome modes, given a zone index, report zone name | |
252 | and interfaces corresponding to that zone */ | |
253 | ||
254 | /* values for ifFlags */ | |
255 | #define LAP_STATE_MASK 0xf /* low order bits used to report | |
256 | IF state, by AIOCGETIFCFG */ | |
257 | #define AT_IFF_DEFAULT 0x40000 | |
258 | #define AT_IFF_AURP 0x20000 | |
259 | #define RTR_NXNET_PORT 0x10000000 /* Non Extended net port */ | |
260 | #define RTR_XNET_PORT 0x20000000 /* Extended net port */ | |
261 | #define RTR_SEED_PORT 0x40000000 /* Seed port require config net values*/ | |
262 | ||
263 | /* elap_cfg 'flags' defines */ | |
264 | #define ELAP_CFG_ZONELESS 0x01 /* true if we shouldn't set a zone | |
265 | (to avoid generating a zip_getnetinfo | |
266 | when routing) */ | |
267 | #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */ | |
268 | #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */ | |
269 | ||
270 | #ifdef KERNEL | |
271 | extern TAILQ_HEAD(at_ifQueueHd, at_ifaddr) at_ifQueueHd; | |
272 | ||
273 | int at_control __P((struct socket *, u_long, caddr_t, struct ifnet *)); | |
274 | int ddp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, | |
275 | struct mbuf *)); | |
276 | int ddp_ctloutput __P((struct socket *, struct sockopt *)); | |
277 | void ddp_init __P((void));; | |
278 | void ddp_slowtimo __P((void)); | |
279 | #endif |