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