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