]> git.saurik.com Git - apple/xnu.git/blob - bsd/netat/at_var.h
40c0fe6960a63d84a0770f79133d93f1785edb07
[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 #include <sys/appleapiopts.h>
27 #ifdef __APPLE_API_PRIVATE
28 #include <sys/queue.h>
29
30 /* at_var.h */
31
32 /* at_var.h contains definitions formerly found in: at/at_lap.h & at/elap.h */
33
34 /* multicast tracking */
35 #define MAX_MCASTS 25 /* #multicast addrs tracked per i/f */
36 #define MCAST_TRACK_ADD 1
37 #define MCAST_TRACK_DELETE 2
38 #define MCAST_TRACK_CHECK 3
39
40 #define ETHERNET_ADDR_LEN 6
41 #define IFNAMESIZ 16
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
50 typedef struct etalk_addr {
51 u_char etalk_addr_octet[ETHERNET_ADDR_LEN];
52 } etalk_addr_t;
53
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 typedef struct at_kern_err {
122 int error; /* kernel error # (KE_xxx) */
123 int port1;
124 int port2;
125 char name1[IFNAMESIZ];
126 char name2[IFNAMESIZ];
127 u_short net;
128 u_char node;
129 u_short netr1b, netr1e; /* net range 1 begin & end */
130 u_short netr2b, netr2e; /* net range 2 begin & end */
131 u_char rtmp_id;
132 } at_kern_err_t;
133
134 #define KE_CONF_RANGE 1
135 #define KE_CONF_SEED_RNG 2
136 #define KE_CONF_SEED1 3
137 #define KE_CONF_SEED_NODE 4
138 #define KE_NO_ZONES_FOUND 5
139 #define KE_NO_SEED 6
140 #define KE_INVAL_RANGE 7
141 #define KE_SEED_STARTUP 8
142 #define KE_BAD_VER 9
143 #define KE_RTMP_OVERFLOW 10
144 #define KE_ZIP_OVERFLOW 11
145
146 /*
147 * Interface address, AppleTalk version. One of these structures
148 * is allocated for each AppleTalk address on an interface.
149 *
150 * The ifaddr structure contains the protocol-independent part
151 * of the structure and is assumed to be first, as it is in
152 * "struct in_ifaddr", defined in bsd/netinet/in_var.h.
153 */
154 typedef struct at_ifaddr {
155 struct ifaddr aa_ifa;
156 #define aa_ifp aa_ifa.ifa_ifp
157 #define aa_flags aa_ifa.ifa_flags
158
159 TAILQ_ENTRY(at_ifaddr) aa_link; /* tailq macro glue */
160
161 u_long at_dl_tag; /* DLIL tag to be used in packet output */
162 u_long aarp_dl_tag; /* DLIL tag for Appletalk ARP */
163
164 /* from pat_unit_t */
165 unsigned char mcast[MAX_MCASTS];
166 char xaddr[ETHERNET_ADDR_LEN];
167
168 /* from elap_specifics_t */
169 at_elap_stats_t stats;
170
171 /* The DDP sets these values: */
172 u_char ifState; /* State of the interface LAP_* */
173 u_short ifThisCableStart;
174 u_short ifThisCableEnd;
175 struct at_addr ifARouter;
176 u_char ifRouterState;
177 u_int ifFlags; /* Flags, see AT_IFF_* */
178 struct sockaddr_at ifNodeAddress;
179 #define ifThisNode ifNodeAddress.sat_addr
180 /* AppleTalk node ID is ifNodeAddress.sat_addr*/
181
182 /* for use by ZIP */
183 u_char ifNumRetries;
184 at_nvestr_t ifZoneName;
185
186 /* Added for routing support */
187 int ifPort; /* the unique ddp logical port
188 number, also index into
189 at_interfaces[] and ifID_table[] */
190 char ifName[IFNAMESIZ];
191 /* added to support LAP_IOC_GET_IFID */
192 u_short ifDefZone; /* Default Zone index in ZoneTable; used
193 only in routing/multihome modes to be
194 able to answer a ZIP GetNetInfo request */
195 char ifZipNeedQueries;
196 /* ZIP/RTMP Query flag */
197 char ifRoutingState; /* Port (as a router) state */
198 at_if_statistics_t
199 ifStatistics; /* statistics */
200 /* end of elap_if structure */
201
202 u_short flags; /* port specific flags */
203 struct etalk_addr ZoneMcastAddr;
204 /* zone multicast addr */
205 struct etalk_addr cable_multicast_addr;
206 /* AppleTalk broadcast addr */
207
208 struct at_addr initial_addr; /* temporary value used during startup */
209 at_nvestr_t startup_zone;
210 int startup_error, /* to get error code back from
211 ZIPwakeup() / AARPwakeup() */
212 startup_inprogress; /* to decide whether it's the
213 middle of an elap_online operation */
214
215 } at_ifaddr_t;
216
217 #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */
218 #define LAP_ONLINE 1
219 #define LAP_ONLINE_FOR_ZIP 2
220 #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */
221
222 #define NO_ROUTER 1 /* there's no router around */
223 #define ROUTER_WARNING 2 /* there's a router around that */
224 /* we are ignoring, warning has */
225 /* been issued to the user */
226 #define ROUTER_AROUND 3 /* A router is around and we've */
227 /* noted its presence */
228 #define ROUTER_UPDATED 4 /* for mh tracking of routers. Value decremented
229 with rtmp aging timer, a value of 4 allows a
230 minimum of 40 secs to laps before we decide
231 to revert to cable multicasts */
232
233 /* AppleTalk IOCTLs */
234
235
236 #define AIOCSTOPATALK _IOWR('a', 1, int) /* stop AppleTalk */
237 #define AIOCGETIFCFG _IOWR('a', 2, at_if_cfg_t) /* get AT interface cfg */
238 #define AIOCNBPREG _IOWR('a', 3, at_nbp_reg_t) /* NBP register */
239 #define AIOCNBPREMOVE _IOW('a', 4, at_nbp_reg_t) /* NBP remove */
240 #define AIOCGETSTATE _IOR('a', 5, at_state_t) /* get AT global state */
241 #define AIOCSETDEFZONE _IOW('a', 6, at_def_zone_t)
242 /* in single-port, router, and multihome modes, set default zone */
243 #define AIOCSETROUTER _IOW('a', 7, at_router_params_t)
244 #define AIOCGETROUTER _IOR('a', 8, at_router_params_t)
245 #define AIOCSIFADDR _IOW('a', 9, at_if_cfg_t) /* init AT interface */
246 #define AIOCSTARTROUTER _IOR('a',10, at_kern_err_t) /* start AT routing */
247 #define AIOCREGLOCALZN _IOW('a',11, at_nvestr_t)
248 /* in single-port mode, register local zone in kernel table for
249 future use in error checking NBP registration */
250 #define AIOCSETZNUSAGE _IOW('a',12, zone_usage_t)
251 /* in router mode, set up each zone for interfaces being seeded */
252 #define AIOCGETZNUSAGE _IOWR('a',13, zone_usage_t)
253 /* in router and multihome modes, given a zone index, report zone name
254 and interfaces corresponding to that zone */
255
256 /* values for ifFlags */
257 #define LAP_STATE_MASK 0xf /* low order bits used to report
258 IF state, by AIOCGETIFCFG */
259 #define AT_IFF_DEFAULT 0x40000
260 #define AT_IFF_AURP 0x20000
261 #define RTR_NXNET_PORT 0x10000000 /* Non Extended net port */
262 #define RTR_XNET_PORT 0x20000000 /* Extended net port */
263 #define RTR_SEED_PORT 0x40000000 /* Seed port require config net values*/
264
265 /* elap_cfg 'flags' defines */
266 #define ELAP_CFG_ZONELESS 0x01 /* true if we shouldn't set a zone
267 (to avoid generating a zip_getnetinfo
268 when routing) */
269 #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */
270 #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */
271
272 #ifdef KERNEL
273 extern TAILQ_HEAD(at_ifQueueHd, at_ifaddr) at_ifQueueHd;
274
275 int at_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
276 int ddp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *,
277 struct mbuf *));
278 int ddp_ctloutput __P((struct socket *, struct sockopt *));
279 void ddp_init __P((void));;
280 void ddp_slowtimo __P((void));
281 #endif
282
283 /*
284 * Define AppleTalk event subclass and specific AppleTalk events.
285 */
286
287 #define KEV_ATALK_SUBCLASS 5
288
289 #define KEV_ATALK_ENABLED 1 /* AppleTalk enabled from user space - node/net set and valid */
290 #define KEV_ATALK_DISABLED 2 /* AppleTalk disabled from user space */
291 #define KEV_ATALK_ZONEUPDATED 3 /* Zone for this node set/changed */
292 #define KEV_ATALK_ROUTERUP 4 /* Seed router found with valid cable range */
293 #define KEV_ATALK_ROUTERUP_INVALID 5 /* Seed router found with invalid cable range */
294 #define KEV_ATALK_ROUTERDOWN 6 /* Seed router down */
295 #define KEV_ATALK_ZONELISTCHANGED 7 /* Zone list changed by router */
296
297 struct kev_atalk_data {
298 struct net_event_data link_data;
299 union {
300 struct at_addr address;
301 at_nvestr_t zone;
302 } node_data;
303 };
304
305 #endif /* __APPLE_API_PRIVATE */