2 * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1998 Apple Computer, Inc.
32 #ifndef _NETAT_AT_VAR_H_
33 #define _NETAT_AT_VAR_H_
35 #include <sys/appleapiopts.h>
36 #ifdef __APPLE_API_OBSOLETE
37 #include <sys/queue.h>
41 /* at_var.h contains definitions formerly found in: at/at_lap.h & at/elap.h */
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
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
54 #define FDDI_OR_TOKENRING(i) ((i == IFT_FDDI) || (i == IFT_ISO88025))
55 #define ETHERNET_ADDR_LEN 6
57 typedef struct etalk_addr
{
58 u_char etalk_addr_octet
[ETHERNET_ADDR_LEN
];
60 typedef char if_name_t
[IFNAMESIZ
];
61 typedef struct at_ifname_list
{
62 if_name_t at_if
[IF_TOTAL_MAX
];
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 */
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 */
84 char ifr_name
[IFNAMESIZ
];
85 u_int flags
; /* misc. port flags,
86 (ELAP_CFG_xxx on input
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 */
97 at_inet_t addr
; /* net and node are ignored, except in
98 multihoming mode where "addr" is used
99 to specify the interface. */
105 char ifr_name
[IFNAMESIZ
];
106 at_nvestr_t zonename
;
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
114 at_ifnames_t zone_iflist
; /* list of interfaces for
116 char usage
[IF_TOTAL_MAX
]; /* I/F usage (set if
125 } at_router_params_t
;
128 typedef struct at_kern_err
{
129 int error
; /* kernel error # (KE_xxx) */
132 char name1
[IFNAMESIZ
];
133 char name2
[IFNAMESIZ
];
136 u_short netr1b
, netr1e
; /* net range 1 begin & end */
137 u_short netr2b
, netr2e
; /* net range 2 begin & end */
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
147 #define KE_INVAL_RANGE 7
148 #define KE_SEED_STARTUP 8
150 #define KE_RTMP_OVERFLOW 10
151 #define KE_ZIP_OVERFLOW 11
153 #ifdef KERNEL_PRIVATE
155 * Interface address, AppleTalk version. One of these structures
156 * is allocated for each AppleTalk address on an interface.
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.
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
167 TAILQ_ENTRY(at_ifaddr
) aa_link
; /* tailq macro glue */
168 int at_was_attached
; /* 1=attached, 0=detached */
170 /* from pat_unit_t */
171 unsigned char mcast
[MAX_MCASTS
];
172 char xaddr
[ETHERNET_ADDR_LEN
];
174 /* from elap_specifics_t */
175 at_elap_stats_t stats
;
177 /* The DDP sets these values: */
178 u_char ifState
; /* State of the interface LAP_* */
179 u_short ifThisCableStart
;
180 u_short ifThisCableEnd
;
181 struct at_addr ifARouter
;
182 u_char ifRouterState
;
183 u_int ifFlags
; /* Flags, see AT_IFF_* */
184 struct sockaddr_at ifNodeAddress
;
185 #define ifThisNode ifNodeAddress.sat_addr
186 /* AppleTalk node ID is ifNodeAddress.sat_addr*/
190 u_char ifGNIScheduled
; /* to keep getnetinfo from being scheduled more than once */
191 at_nvestr_t ifZoneName
;
193 /* Added for routing support */
194 int ifPort
; /* the unique ddp logical port
195 number, also index into
196 at_interfaces[] and ifID_table[] */
197 char ifName
[IFNAMESIZ
];
198 /* added to support LAP_IOC_GET_IFID */
199 u_short ifDefZone
; /* Default Zone index in ZoneTable; used
200 only in routing/multihome modes to be
201 able to answer a ZIP GetNetInfo request */
202 char ifZipNeedQueries
;
203 /* ZIP/RTMP Query flag */
204 char ifRoutingState
; /* Port (as a router) state */
206 ifStatistics
; /* statistics */
207 /* end of elap_if structure */
209 u_short flags
; /* port specific flags */
210 struct etalk_addr ZoneMcastAddr
;
211 /* zone multicast addr */
212 struct etalk_addr cable_multicast_addr
;
213 /* AppleTalk broadcast addr */
215 struct at_addr initial_addr
; /* temporary value used during startup */
216 at_nvestr_t startup_zone
;
217 int startup_error
, /* to get error code back from
218 ZIPwakeup() / AARPwakeup() */
219 startup_inprogress
; /* to decide whether it's the
220 middle of an elap_online operation */
223 #endif /* KERNEL_PRIVATE */
225 #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */
227 #define LAP_ONLINE_FOR_ZIP 2
228 #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */
230 #define NO_ROUTER 1 /* there's no router around */
231 #define ROUTER_WARNING 2 /* there's a router around that */
232 /* we are ignoring, warning has */
233 /* been issued to the user */
234 #define ROUTER_AROUND 3 /* A router is around and we've */
235 /* noted its presence */
236 #define ROUTER_UPDATED 4 /* for mh tracking of routers. Value decremented
237 with rtmp aging timer, a value of 4 allows a
238 minimum of 40 secs to laps before we decide
239 to revert to cable multicasts */
241 /* AppleTalk IOCTLs */
244 #define AIOCSTOPATALK _IOWR('a', 1, int) /* stop AppleTalk */
245 #define AIOCGETIFCFG _IOWR('a', 2, at_if_cfg_t) /* get AT interface cfg */
246 #define AIOCNBPREG _IOWR('a', 3, at_nbp_reg_t) /* NBP register */
247 #define AIOCNBPREMOVE _IOW('a', 4, at_nbp_reg_t) /* NBP remove */
248 #define AIOCGETSTATE _IOR('a', 5, at_state_t) /* get AT global state */
249 #define AIOCSETDEFZONE _IOW('a', 6, at_def_zone_t)
250 /* in single-port, router, and multihome modes, set default zone */
251 #define AIOCSETROUTER _IOW('a', 7, at_router_params_t)
252 #define AIOCGETROUTER _IOR('a', 8, at_router_params_t)
253 #define AIOCSIFADDR _IOW('a', 9, at_if_cfg_t) /* init AT interface */
254 #define AIOCSTARTROUTER _IOR('a',10, at_kern_err_t) /* start AT routing */
255 #define AIOCREGLOCALZN _IOW('a',11, at_nvestr_t)
256 /* in single-port mode, register local zone in kernel table for
257 future use in error checking NBP registration */
258 #define AIOCSETZNUSAGE _IOW('a',12, zone_usage_t)
259 /* in router mode, set up each zone for interfaces being seeded */
260 #define AIOCGETZNUSAGE _IOWR('a',13, zone_usage_t)
261 /* in router and multihome modes, given a zone index, report zone name
262 and interfaces corresponding to that zone */
264 /* values for ifFlags */
265 #define LAP_STATE_MASK 0xf /* low order bits used to report
266 IF state, by AIOCGETIFCFG */
267 #define AT_IFF_DEFAULT 0x40000
268 #define AT_IFF_AURP 0x20000
269 #define RTR_NXNET_PORT 0x10000000 /* Non Extended net port */
270 #define RTR_XNET_PORT 0x20000000 /* Extended net port */
271 #define RTR_SEED_PORT 0x40000000 /* Seed port require config net values*/
273 /* elap_cfg 'flags' defines */
274 #define ELAP_CFG_ZONELESS 0x01 /* true if we shouldn't set a zone
275 (to avoid generating a zip_getnetinfo
277 #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */
278 #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */
280 #ifdef KERNEL_PRIVATE
281 extern TAILQ_HEAD(at_ifQueueHd
, at_ifaddr
) at_ifQueueHd
;
283 int at_control(struct socket
*, u_long
, caddr_t
, struct ifnet
*);
284 int ddp_usrreq(struct socket
*, int, struct mbuf
*, struct mbuf
*,
286 int ddp_ctloutput(struct socket
*, struct sockopt
*);
288 void ddp_slowtimo(void);
289 #endif /* KERNEL_PRIVATE */
292 * Define AppleTalk event subclass and specific AppleTalk events.
295 #define KEV_ATALK_SUBCLASS 5
297 #define KEV_ATALK_ENABLED 1 /* AppleTalk enabled from user space - node/net set and valid */
298 #define KEV_ATALK_DISABLED 2 /* AppleTalk disabled from user space */
299 #define KEV_ATALK_ZONEUPDATED 3 /* Zone for this node set/changed */
300 #define KEV_ATALK_ROUTERUP 4 /* Seed router found with valid cable range */
301 #define KEV_ATALK_ROUTERUP_INVALID 5 /* Seed router found with invalid cable range */
302 #define KEV_ATALK_ROUTERDOWN 6 /* Seed router down */
303 #define KEV_ATALK_ZONELISTCHANGED 7 /* Zone list changed by router */
305 struct kev_atalk_data
{
306 struct net_event_data link_data
;
308 struct at_addr address
;
313 #ifdef KERNEL_PRIVATE
315 void atalk_post_msg(struct ifnet
*ifp
, u_long event_code
, struct at_addr
*address
, at_nvestr_t
*zone
);
316 void aarp_sched_probe(void *);
317 void atalk_lock(void);
318 void atalk_unlock(void);
319 void appletalk_hack_start(void);
320 void ddp_input(gbuf_t
*, at_ifaddr_t
*);
322 void ddp_glean(gbuf_t
*, at_ifaddr_t
*, struct etalk_addr
*);
324 int pat_output(at_ifaddr_t
*, struct mbuf
*, unsigned char *, int);
326 void ep_input(gbuf_t
*, at_ifaddr_t
*);
327 void zip_router_input(gbuf_t
*, at_ifaddr_t
*);
328 void nbp_input(gbuf_t
*, at_ifaddr_t
*);
329 void sip_input(gbuf_t
*, at_ifaddr_t
*);
331 void ioc_ack(int, gbuf_t
*, gref_t
*);
332 int ddp_adjmsg(gbuf_t
*, int );
333 gbuf_t
*ddp_growmsg(gbuf_t
*, int );
336 int atalk_openref(gref_t
*, int *, struct proc
*);
339 int atalk_closeref(struct fileglob
*, gref_t
**);
341 int _ATputmsg(int, strbuf_t
*, strbuf_t
*, int , int *, void *);
342 int _ATgetmsg(int, strbuf_t
*, strbuf_t
*, int *, int *, void *);
343 int _ATsocket(int, int *, void *);
345 void ddp_start(void);
347 typedef void (*ddp_handler_func
)(gbuf_t
*, at_ifaddr_t
*);
348 void add_ddp_handler(u_char
, ddp_handler_func
);
349 void init_ddp_handler(void);
351 int elap_wput(gref_t
*gref
, gbuf_t
*m
);
352 int at_ioctl(struct atpcb
*, u_long
, caddr_t
, int );
354 extern void at_purgeaddrs(struct ifnet
*);
356 #endif /* KERNEL_PRIVATE */
357 #endif /* __APPLE_API_OBSOLETE */
358 #endif /* _NETAT_AT_VAR_H_ */