]> git.saurik.com Git - apple/xnu.git/blob - bsd/netat/at_var.h
b9a3df2e2c8df6519b8942f8a69efce451aff943
[apple/xnu.git] / bsd / netat / at_var.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
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
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * Copyright (c) 1998 Apple Computer, Inc.
30 */
31
32 #ifndef _NETAT_AT_VAR_H_
33 #define _NETAT_AT_VAR_H_
34
35 #include <sys/appleapiopts.h>
36 #ifdef __APPLE_API_OBSOLETE
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
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))
55 #define ETHERNET_ADDR_LEN 6
56 #define IFNAMESIZ 16
57 typedef struct etalk_addr {
58 u_char etalk_addr_octet[ETHERNET_ADDR_LEN];
59 } etalk_addr_t;
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
127
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
153 #ifdef KERNEL_PRIVATE
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 */
168
169 u_long at_dl_tag; /* DLIL tag to be used in packet output */
170 u_long aarp_dl_tag; /* DLIL tag for Appletalk ARP */
171
172 /* from pat_unit_t */
173 unsigned char mcast[MAX_MCASTS];
174 char xaddr[ETHERNET_ADDR_LEN];
175
176 /* from elap_specifics_t */
177 at_elap_stats_t stats;
178
179 /* The DDP sets these values: */
180 u_char ifState; /* State of the interface LAP_* */
181 u_short ifThisCableStart;
182 u_short ifThisCableEnd;
183 struct at_addr ifARouter;
184 u_char ifRouterState;
185 u_int ifFlags; /* Flags, see AT_IFF_* */
186 struct sockaddr_at ifNodeAddress;
187 #define ifThisNode ifNodeAddress.sat_addr
188 /* AppleTalk node ID is ifNodeAddress.sat_addr*/
189
190 /* for use by ZIP */
191 u_char ifNumRetries;
192 u_char ifGNIScheduled; /* to keep getnetinfo from being scheduled more than once */
193 at_nvestr_t ifZoneName;
194
195 /* Added for routing support */
196 int ifPort; /* the unique ddp logical port
197 number, also index into
198 at_interfaces[] and ifID_table[] */
199 char ifName[IFNAMESIZ];
200 /* added to support LAP_IOC_GET_IFID */
201 u_short ifDefZone; /* Default Zone index in ZoneTable; used
202 only in routing/multihome modes to be
203 able to answer a ZIP GetNetInfo request */
204 char ifZipNeedQueries;
205 /* ZIP/RTMP Query flag */
206 char ifRoutingState; /* Port (as a router) state */
207 at_if_statistics_t
208 ifStatistics; /* statistics */
209 /* end of elap_if structure */
210
211 u_short flags; /* port specific flags */
212 struct etalk_addr ZoneMcastAddr;
213 /* zone multicast addr */
214 struct etalk_addr cable_multicast_addr;
215 /* AppleTalk broadcast addr */
216
217 struct at_addr initial_addr; /* temporary value used during startup */
218 at_nvestr_t startup_zone;
219 int startup_error, /* to get error code back from
220 ZIPwakeup() / AARPwakeup() */
221 startup_inprogress; /* to decide whether it's the
222 middle of an elap_online operation */
223
224 } at_ifaddr_t;
225 #endif /* KERNEL_PRIVATE */
226
227 #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */
228 #define LAP_ONLINE 1
229 #define LAP_ONLINE_FOR_ZIP 2
230 #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */
231
232 #define NO_ROUTER 1 /* there's no router around */
233 #define ROUTER_WARNING 2 /* there's a router around that */
234 /* we are ignoring, warning has */
235 /* been issued to the user */
236 #define ROUTER_AROUND 3 /* A router is around and we've */
237 /* noted its presence */
238 #define ROUTER_UPDATED 4 /* for mh tracking of routers. Value decremented
239 with rtmp aging timer, a value of 4 allows a
240 minimum of 40 secs to laps before we decide
241 to revert to cable multicasts */
242
243 /* AppleTalk IOCTLs */
244
245
246 #define AIOCSTOPATALK _IOWR('a', 1, int) /* stop AppleTalk */
247 #define AIOCGETIFCFG _IOWR('a', 2, at_if_cfg_t) /* get AT interface cfg */
248 #define AIOCNBPREG _IOWR('a', 3, at_nbp_reg_t) /* NBP register */
249 #define AIOCNBPREMOVE _IOW('a', 4, at_nbp_reg_t) /* NBP remove */
250 #define AIOCGETSTATE _IOR('a', 5, at_state_t) /* get AT global state */
251 #define AIOCSETDEFZONE _IOW('a', 6, at_def_zone_t)
252 /* in single-port, router, and multihome modes, set default zone */
253 #define AIOCSETROUTER _IOW('a', 7, at_router_params_t)
254 #define AIOCGETROUTER _IOR('a', 8, at_router_params_t)
255 #define AIOCSIFADDR _IOW('a', 9, at_if_cfg_t) /* init AT interface */
256 #define AIOCSTARTROUTER _IOR('a',10, at_kern_err_t) /* start AT routing */
257 #define AIOCREGLOCALZN _IOW('a',11, at_nvestr_t)
258 /* in single-port mode, register local zone in kernel table for
259 future use in error checking NBP registration */
260 #define AIOCSETZNUSAGE _IOW('a',12, zone_usage_t)
261 /* in router mode, set up each zone for interfaces being seeded */
262 #define AIOCGETZNUSAGE _IOWR('a',13, zone_usage_t)
263 /* in router and multihome modes, given a zone index, report zone name
264 and interfaces corresponding to that zone */
265
266 /* values for ifFlags */
267 #define LAP_STATE_MASK 0xf /* low order bits used to report
268 IF state, by AIOCGETIFCFG */
269 #define AT_IFF_DEFAULT 0x40000
270 #define AT_IFF_AURP 0x20000
271 #define RTR_NXNET_PORT 0x10000000 /* Non Extended net port */
272 #define RTR_XNET_PORT 0x20000000 /* Extended net port */
273 #define RTR_SEED_PORT 0x40000000 /* Seed port require config net values*/
274
275 /* elap_cfg 'flags' defines */
276 #define ELAP_CFG_ZONELESS 0x01 /* true if we shouldn't set a zone
277 (to avoid generating a zip_getnetinfo
278 when routing) */
279 #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */
280 #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */
281
282 #ifdef KERNEL_PRIVATE
283 extern TAILQ_HEAD(at_ifQueueHd, at_ifaddr) at_ifQueueHd;
284
285 int at_control(struct socket *, u_long, caddr_t, struct ifnet *);
286 int ddp_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
287 struct mbuf *);
288 int ddp_ctloutput(struct socket *, struct sockopt *);
289 void ddp_init(void);;
290 void ddp_slowtimo(void);
291 #endif /* KERNEL_PRIVATE */
292
293 /*
294 * Define AppleTalk event subclass and specific AppleTalk events.
295 */
296
297 #define KEV_ATALK_SUBCLASS 5
298
299 #define KEV_ATALK_ENABLED 1 /* AppleTalk enabled from user space - node/net set and valid */
300 #define KEV_ATALK_DISABLED 2 /* AppleTalk disabled from user space */
301 #define KEV_ATALK_ZONEUPDATED 3 /* Zone for this node set/changed */
302 #define KEV_ATALK_ROUTERUP 4 /* Seed router found with valid cable range */
303 #define KEV_ATALK_ROUTERUP_INVALID 5 /* Seed router found with invalid cable range */
304 #define KEV_ATALK_ROUTERDOWN 6 /* Seed router down */
305 #define KEV_ATALK_ZONELISTCHANGED 7 /* Zone list changed by router */
306
307 struct kev_atalk_data {
308 struct net_event_data link_data;
309 union {
310 struct at_addr address;
311 at_nvestr_t zone;
312 } node_data;
313 };
314
315 #ifdef KERNEL_PRIVATE
316
317 void atalk_post_msg(struct ifnet *ifp, u_long event_code, struct at_addr *address, at_nvestr_t *zone);
318 void aarp_sched_probe(void *);
319 void atalk_lock(void);
320 void atalk_unlock(void);
321
322 #endif /* KERNEL_PRIVATE */
323 #endif /* __APPLE_API_OBSOLETE */
324 #endif /* _NETAT_AT_VAR_H_ */