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