]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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 License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Copyright (c) 1998 Apple Computer, Inc. | |
30 | */ | |
31 | ||
91447636 A |
32 | #ifndef _NETAT_AT_VAR_H_ |
33 | #define _NETAT_AT_VAR_H_ | |
34 | ||
9bccf70c | 35 | #include <sys/appleapiopts.h> |
91447636 | 36 | #ifdef __APPLE_API_OBSOLETE |
1c79356b A |
37 | #include <sys/queue.h> |
38 | ||
39 | /* at_var.h */ | |
40 | ||
41 | /* at_var.h contains definitions formerly found in: at/at_lap.h & at/elap.h */ | |
42 | ||
43 | /* multicast tracking */ | |
44 | #define MAX_MCASTS 25 /* #multicast addrs tracked per i/f */ | |
45 | #define MCAST_TRACK_ADD 1 | |
46 | #define MCAST_TRACK_DELETE 2 | |
47 | #define MCAST_TRACK_CHECK 3 | |
48 | ||
1c79356b A |
49 | /* maximum number of I/F's allowed */ |
50 | #define IF_TOTAL_MAX 17 /* max count of any combination of I/F's */ | |
51 | /* 17 == (1+(4*4)); 9 and 13 would also be | |
52 | reasonable values */ | |
53 | ||
54 | #define FDDI_OR_TOKENRING(i) ((i == IFT_FDDI) || (i == IFT_ISO88025)) | |
91447636 A |
55 | #define ETHERNET_ADDR_LEN 6 |
56 | #define IFNAMESIZ 16 | |
1c79356b A |
57 | typedef struct etalk_addr { |
58 | u_char etalk_addr_octet[ETHERNET_ADDR_LEN]; | |
59 | } etalk_addr_t; | |
1c79356b A |
60 | typedef char if_name_t[IFNAMESIZ]; |
61 | typedef struct at_ifname_list { | |
62 | if_name_t at_if[IF_TOTAL_MAX]; | |
63 | } at_ifnames_t; | |
64 | ||
65 | typedef struct at_if_statstics { | |
66 | u_long fwdBytes; /* bytes received & forwarded */ | |
67 | u_long fwdPkts; /* pkts received & forwarded */ | |
68 | u_long droppedBytes; /* bytes received & dropped */ | |
69 | u_long droppedPkts; /* pkts received & dropped */ | |
70 | u_long outBytes; /* bytes sent */ | |
71 | u_long outPkts; /* pkts sent */ | |
72 | u_long routes; /* count of routes in rtmptable */ | |
73 | } at_if_statistics_t; | |
74 | ||
75 | typedef struct { | |
76 | u_int unknown_mblks; /* number of unknown streams msgs */ | |
77 | u_int rcv_bytes; /* number of data bytes received */ | |
78 | u_int rcv_packets; /* number of packets received */ | |
79 | u_int xmit_bytes; /* number of data bytes xmited */ | |
80 | u_int xmit_packets; /* number of packets xmited */ | |
81 | } at_elap_stats_t; | |
82 | ||
83 | typedef struct { | |
84 | char ifr_name[IFNAMESIZ]; | |
85 | u_int flags; /* misc. port flags, | |
86 | (ELAP_CFG_xxx on input | |
87 | ifFlags on output) */ | |
88 | struct at_addr node; /* Our node number. */ | |
89 | struct at_addr router; /* Our router. */ | |
90 | u_short netStart; /* network start range */ | |
91 | u_short netEnd; /* network ending range */ | |
92 | at_nvestr_t zonename; | |
93 | } at_if_cfg_t; | |
94 | ||
95 | typedef struct { | |
96 | at_entity_t name; | |
97 | at_inet_t addr; /* net and node are ignored, except in | |
98 | multihoming mode where "addr" is used | |
99 | to specify the interface. */ | |
100 | u_char ddptype; | |
101 | long unique_nbp_id; | |
102 | } at_nbp_reg_t; | |
103 | ||
104 | typedef struct { | |
105 | char ifr_name[IFNAMESIZ]; | |
106 | at_nvestr_t zonename; | |
107 | } at_def_zone_t; | |
108 | ||
109 | typedef struct zone_usage { | |
110 | int zone_index; /* index in local_zones */ | |
111 | at_nvestr_t zone_name; /* the zone name & len */ | |
112 | int zone_home; /* used only to set zones in | |
113 | router mode */ | |
114 | at_ifnames_t zone_iflist; /* list of interfaces for | |
115 | this zone. */ | |
116 | char usage[IF_TOTAL_MAX]; /* I/F usage (set if | |
117 | I/F in this zone) */ | |
118 | } zone_usage_t; | |
119 | ||
120 | typedef struct { | |
121 | short multihome; | |
122 | short rtmp_table_sz; | |
123 | short zone_table_sz; | |
124 | short router_mix; | |
125 | } at_router_params_t; | |
126 | ||
91447636 | 127 | |
1c79356b A |
128 | typedef struct at_kern_err { |
129 | int error; /* kernel error # (KE_xxx) */ | |
130 | int port1; | |
131 | int port2; | |
132 | char name1[IFNAMESIZ]; | |
133 | char name2[IFNAMESIZ]; | |
134 | u_short net; | |
135 | u_char node; | |
136 | u_short netr1b, netr1e; /* net range 1 begin & end */ | |
137 | u_short netr2b, netr2e; /* net range 2 begin & end */ | |
138 | u_char rtmp_id; | |
139 | } at_kern_err_t; | |
140 | ||
141 | #define KE_CONF_RANGE 1 | |
142 | #define KE_CONF_SEED_RNG 2 | |
143 | #define KE_CONF_SEED1 3 | |
144 | #define KE_CONF_SEED_NODE 4 | |
145 | #define KE_NO_ZONES_FOUND 5 | |
146 | #define KE_NO_SEED 6 | |
147 | #define KE_INVAL_RANGE 7 | |
148 | #define KE_SEED_STARTUP 8 | |
149 | #define KE_BAD_VER 9 | |
150 | #define KE_RTMP_OVERFLOW 10 | |
151 | #define KE_ZIP_OVERFLOW 11 | |
152 | ||
91447636 | 153 | #ifdef KERNEL_PRIVATE |
1c79356b A |
154 | /* |
155 | * Interface address, AppleTalk version. One of these structures | |
156 | * is allocated for each AppleTalk address on an interface. | |
157 | * | |
158 | * The ifaddr structure contains the protocol-independent part | |
159 | * of the structure and is assumed to be first, as it is in | |
160 | * "struct in_ifaddr", defined in bsd/netinet/in_var.h. | |
161 | */ | |
162 | typedef struct at_ifaddr { | |
163 | struct ifaddr aa_ifa; | |
164 | #define aa_ifp aa_ifa.ifa_ifp | |
165 | #define aa_flags aa_ifa.ifa_flags | |
166 | ||
167 | TAILQ_ENTRY(at_ifaddr) aa_link; /* tailq macro glue */ | |
2d21ac55 | 168 | int at_was_attached; /* 1=attached, 0=detached */ |
1c79356b A |
169 | |
170 | /* from pat_unit_t */ | |
171 | unsigned char mcast[MAX_MCASTS]; | |
172 | char xaddr[ETHERNET_ADDR_LEN]; | |
173 | ||
174 | /* from elap_specifics_t */ | |
175 | at_elap_stats_t stats; | |
176 | ||
177 | /* The DDP sets these values: */ | |
178 | u_char ifState; /* State of the interface LAP_* */ | |
179 | u_short ifThisCableStart; | |
180 | u_short ifThisCableEnd; | |
181 | struct at_addr ifARouter; | |
182 | u_char ifRouterState; | |
183 | u_int ifFlags; /* Flags, see AT_IFF_* */ | |
184 | struct sockaddr_at ifNodeAddress; | |
185 | #define ifThisNode ifNodeAddress.sat_addr | |
186 | /* AppleTalk node ID is ifNodeAddress.sat_addr*/ | |
187 | ||
188 | /* for use by ZIP */ | |
189 | u_char ifNumRetries; | |
91447636 | 190 | u_char ifGNIScheduled; /* to keep getnetinfo from being scheduled more than once */ |
1c79356b A |
191 | at_nvestr_t ifZoneName; |
192 | ||
193 | /* Added for routing support */ | |
194 | int ifPort; /* the unique ddp logical port | |
195 | number, also index into | |
196 | at_interfaces[] and ifID_table[] */ | |
197 | char ifName[IFNAMESIZ]; | |
198 | /* added to support LAP_IOC_GET_IFID */ | |
199 | u_short ifDefZone; /* Default Zone index in ZoneTable; used | |
200 | only in routing/multihome modes to be | |
201 | able to answer a ZIP GetNetInfo request */ | |
202 | char ifZipNeedQueries; | |
203 | /* ZIP/RTMP Query flag */ | |
204 | char ifRoutingState; /* Port (as a router) state */ | |
205 | at_if_statistics_t | |
206 | ifStatistics; /* statistics */ | |
207 | /* end of elap_if structure */ | |
208 | ||
209 | u_short flags; /* port specific flags */ | |
210 | struct etalk_addr ZoneMcastAddr; | |
211 | /* zone multicast addr */ | |
212 | struct etalk_addr cable_multicast_addr; | |
213 | /* AppleTalk broadcast addr */ | |
214 | ||
215 | struct at_addr initial_addr; /* temporary value used during startup */ | |
216 | at_nvestr_t startup_zone; | |
217 | int startup_error, /* to get error code back from | |
218 | ZIPwakeup() / AARPwakeup() */ | |
219 | startup_inprogress; /* to decide whether it's the | |
220 | middle of an elap_online operation */ | |
221 | ||
222 | } at_ifaddr_t; | |
91447636 | 223 | #endif /* KERNEL_PRIVATE */ |
1c79356b A |
224 | |
225 | #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */ | |
226 | #define LAP_ONLINE 1 | |
227 | #define LAP_ONLINE_FOR_ZIP 2 | |
228 | #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */ | |
229 | ||
230 | #define NO_ROUTER 1 /* there's no router around */ | |
231 | #define ROUTER_WARNING 2 /* there's a router around that */ | |
232 | /* we are ignoring, warning has */ | |
233 | /* been issued to the user */ | |
234 | #define ROUTER_AROUND 3 /* A router is around and we've */ | |
235 | /* noted its presence */ | |
236 | #define ROUTER_UPDATED 4 /* for mh tracking of routers. Value decremented | |
237 | with rtmp aging timer, a value of 4 allows a | |
238 | minimum of 40 secs to laps before we decide | |
239 | to revert to cable multicasts */ | |
240 | ||
241 | /* AppleTalk IOCTLs */ | |
242 | ||
243 | ||
244 | #define AIOCSTOPATALK _IOWR('a', 1, int) /* stop AppleTalk */ | |
245 | #define AIOCGETIFCFG _IOWR('a', 2, at_if_cfg_t) /* get AT interface cfg */ | |
246 | #define AIOCNBPREG _IOWR('a', 3, at_nbp_reg_t) /* NBP register */ | |
247 | #define AIOCNBPREMOVE _IOW('a', 4, at_nbp_reg_t) /* NBP remove */ | |
248 | #define AIOCGETSTATE _IOR('a', 5, at_state_t) /* get AT global state */ | |
249 | #define AIOCSETDEFZONE _IOW('a', 6, at_def_zone_t) | |
250 | /* in single-port, router, and multihome modes, set default zone */ | |
251 | #define AIOCSETROUTER _IOW('a', 7, at_router_params_t) | |
252 | #define AIOCGETROUTER _IOR('a', 8, at_router_params_t) | |
253 | #define AIOCSIFADDR _IOW('a', 9, at_if_cfg_t) /* init AT interface */ | |
254 | #define AIOCSTARTROUTER _IOR('a',10, at_kern_err_t) /* start AT routing */ | |
255 | #define AIOCREGLOCALZN _IOW('a',11, at_nvestr_t) | |
256 | /* in single-port mode, register local zone in kernel table for | |
257 | future use in error checking NBP registration */ | |
258 | #define AIOCSETZNUSAGE _IOW('a',12, zone_usage_t) | |
259 | /* in router mode, set up each zone for interfaces being seeded */ | |
260 | #define AIOCGETZNUSAGE _IOWR('a',13, zone_usage_t) | |
261 | /* in router and multihome modes, given a zone index, report zone name | |
262 | and interfaces corresponding to that zone */ | |
263 | ||
264 | /* values for ifFlags */ | |
265 | #define LAP_STATE_MASK 0xf /* low order bits used to report | |
266 | IF state, by AIOCGETIFCFG */ | |
267 | #define AT_IFF_DEFAULT 0x40000 | |
268 | #define AT_IFF_AURP 0x20000 | |
269 | #define RTR_NXNET_PORT 0x10000000 /* Non Extended net port */ | |
270 | #define RTR_XNET_PORT 0x20000000 /* Extended net port */ | |
271 | #define RTR_SEED_PORT 0x40000000 /* Seed port require config net values*/ | |
272 | ||
273 | /* elap_cfg 'flags' defines */ | |
274 | #define ELAP_CFG_ZONELESS 0x01 /* true if we shouldn't set a zone | |
275 | (to avoid generating a zip_getnetinfo | |
276 | when routing) */ | |
277 | #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */ | |
278 | #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */ | |
279 | ||
91447636 | 280 | #ifdef KERNEL_PRIVATE |
1c79356b A |
281 | extern TAILQ_HEAD(at_ifQueueHd, at_ifaddr) at_ifQueueHd; |
282 | ||
91447636 A |
283 | int at_control(struct socket *, u_long, caddr_t, struct ifnet *); |
284 | int ddp_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, | |
285 | struct mbuf *); | |
286 | int ddp_ctloutput(struct socket *, struct sockopt *); | |
2d21ac55 | 287 | void ddp_init(void); |
91447636 A |
288 | void ddp_slowtimo(void); |
289 | #endif /* KERNEL_PRIVATE */ | |
9bccf70c A |
290 | |
291 | /* | |
292 | * Define AppleTalk event subclass and specific AppleTalk events. | |
293 | */ | |
294 | ||
295 | #define KEV_ATALK_SUBCLASS 5 | |
296 | ||
297 | #define KEV_ATALK_ENABLED 1 /* AppleTalk enabled from user space - node/net set and valid */ | |
298 | #define KEV_ATALK_DISABLED 2 /* AppleTalk disabled from user space */ | |
299 | #define KEV_ATALK_ZONEUPDATED 3 /* Zone for this node set/changed */ | |
300 | #define KEV_ATALK_ROUTERUP 4 /* Seed router found with valid cable range */ | |
301 | #define KEV_ATALK_ROUTERUP_INVALID 5 /* Seed router found with invalid cable range */ | |
302 | #define KEV_ATALK_ROUTERDOWN 6 /* Seed router down */ | |
303 | #define KEV_ATALK_ZONELISTCHANGED 7 /* Zone list changed by router */ | |
304 | ||
305 | struct kev_atalk_data { | |
306 | struct net_event_data link_data; | |
307 | union { | |
308 | struct at_addr address; | |
309 | at_nvestr_t zone; | |
310 | } node_data; | |
311 | }; | |
312 | ||
91447636 A |
313 | #ifdef KERNEL_PRIVATE |
314 | ||
55e303ae A |
315 | void atalk_post_msg(struct ifnet *ifp, u_long event_code, struct at_addr *address, at_nvestr_t *zone); |
316 | void aarp_sched_probe(void *); | |
0c530ab8 A |
317 | void atalk_lock(void); |
318 | void atalk_unlock(void); | |
2d21ac55 A |
319 | void appletalk_hack_start(void); |
320 | void ddp_input(gbuf_t *, at_ifaddr_t *); | |
321 | struct etalk_addr; | |
322 | void ddp_glean(gbuf_t *, at_ifaddr_t *, struct etalk_addr *); | |
323 | ||
324 | int pat_output(at_ifaddr_t *, struct mbuf *, unsigned char *, int); | |
325 | ||
326 | void ep_input(gbuf_t *, at_ifaddr_t *); | |
327 | void zip_router_input(gbuf_t *, at_ifaddr_t *); | |
328 | void nbp_input(gbuf_t *, at_ifaddr_t *); | |
329 | void sip_input(gbuf_t *, at_ifaddr_t *); | |
330 | ||
331 | void ioc_ack(int, gbuf_t *, gref_t *); | |
332 | int ddp_adjmsg(gbuf_t *, int ); | |
333 | gbuf_t *ddp_growmsg(gbuf_t *, int ); | |
334 | ||
335 | struct proc; | |
336 | int atalk_openref(gref_t *, int *, struct proc *); | |
337 | ||
338 | struct fileglob; | |
339 | int atalk_closeref(struct fileglob *, gref_t **); | |
340 | ||
341 | int _ATputmsg(int, strbuf_t *, strbuf_t *, int , int *, void *); | |
342 | int _ATgetmsg(int, strbuf_t *, strbuf_t *, int *, int *, void *); | |
343 | int _ATsocket(int, int *, void *); | |
344 | ||
345 | void ddp_start(void); | |
346 | ||
347 | typedef void (*ddp_handler_func)(gbuf_t *, at_ifaddr_t *); | |
348 | void add_ddp_handler(u_char, ddp_handler_func); | |
349 | void init_ddp_handler(void); | |
350 | ||
351 | int elap_wput(gref_t *gref, gbuf_t *m); | |
352 | int at_ioctl(struct atpcb *, u_long, caddr_t, int ); | |
353 | ||
354 | ||
55e303ae | 355 | |
91447636 A |
356 | #endif /* KERNEL_PRIVATE */ |
357 | #endif /* __APPLE_API_OBSOLETE */ | |
358 | #endif /* _NETAT_AT_VAR_H_ */ |