2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1998 Apple Computer, Inc.
29 #include <sys/appleapiopts.h>
30 #ifdef __APPLE_API_PRIVATE
31 #include <sys/queue.h>
35 /* at_var.h contains definitions formerly found in: at/at_lap.h & at/elap.h */
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
43 #define ETHERNET_ADDR_LEN 6
46 /* maximum number of I/F's allowed */
47 #define IF_TOTAL_MAX 17 /* max count of any combination of I/F's */
48 /* 17 == (1+(4*4)); 9 and 13 would also be
51 #define FDDI_OR_TOKENRING(i) ((i == IFT_FDDI) || (i == IFT_ISO88025))
53 typedef struct etalk_addr
{
54 u_char etalk_addr_octet
[ETHERNET_ADDR_LEN
];
57 typedef char if_name_t
[IFNAMESIZ
];
58 typedef struct at_ifname_list
{
59 if_name_t at_if
[IF_TOTAL_MAX
];
62 typedef struct at_if_statstics
{
63 u_long fwdBytes
; /* bytes received & forwarded */
64 u_long fwdPkts
; /* pkts received & forwarded */
65 u_long droppedBytes
; /* bytes received & dropped */
66 u_long droppedPkts
; /* pkts received & dropped */
67 u_long outBytes
; /* bytes sent */
68 u_long outPkts
; /* pkts sent */
69 u_long routes
; /* count of routes in rtmptable */
73 u_int unknown_mblks
; /* number of unknown streams msgs */
74 u_int rcv_bytes
; /* number of data bytes received */
75 u_int rcv_packets
; /* number of packets received */
76 u_int xmit_bytes
; /* number of data bytes xmited */
77 u_int xmit_packets
; /* number of packets xmited */
81 char ifr_name
[IFNAMESIZ
];
82 u_int flags
; /* misc. port flags,
83 (ELAP_CFG_xxx on input
85 struct at_addr node
; /* Our node number. */
86 struct at_addr router
; /* Our router. */
87 u_short netStart
; /* network start range */
88 u_short netEnd
; /* network ending range */
94 at_inet_t addr
; /* net and node are ignored, except in
95 multihoming mode where "addr" is used
96 to specify the interface. */
102 char ifr_name
[IFNAMESIZ
];
103 at_nvestr_t zonename
;
106 typedef struct zone_usage
{
107 int zone_index
; /* index in local_zones */
108 at_nvestr_t zone_name
; /* the zone name & len */
109 int zone_home
; /* used only to set zones in
111 at_ifnames_t zone_iflist
; /* list of interfaces for
113 char usage
[IF_TOTAL_MAX
]; /* I/F usage (set if
122 } at_router_params_t
;
124 typedef struct at_kern_err
{
125 int error
; /* kernel error # (KE_xxx) */
128 char name1
[IFNAMESIZ
];
129 char name2
[IFNAMESIZ
];
132 u_short netr1b
, netr1e
; /* net range 1 begin & end */
133 u_short netr2b
, netr2e
; /* net range 2 begin & end */
137 #define KE_CONF_RANGE 1
138 #define KE_CONF_SEED_RNG 2
139 #define KE_CONF_SEED1 3
140 #define KE_CONF_SEED_NODE 4
141 #define KE_NO_ZONES_FOUND 5
143 #define KE_INVAL_RANGE 7
144 #define KE_SEED_STARTUP 8
146 #define KE_RTMP_OVERFLOW 10
147 #define KE_ZIP_OVERFLOW 11
150 * Interface address, AppleTalk version. One of these structures
151 * is allocated for each AppleTalk address on an interface.
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.
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
162 TAILQ_ENTRY(at_ifaddr
) aa_link
; /* tailq macro glue */
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 */
167 /* from pat_unit_t */
168 unsigned char mcast
[MAX_MCASTS
];
169 char xaddr
[ETHERNET_ADDR_LEN
];
171 /* from elap_specifics_t */
172 at_elap_stats_t stats
;
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*/
187 at_nvestr_t ifZoneName
;
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 */
202 ifStatistics
; /* statistics */
203 /* end of elap_if structure */
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 */
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 */
220 #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */
222 #define LAP_ONLINE_FOR_ZIP 2
223 #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */
225 #define NO_ROUTER 1 /* there's no router around */
226 #define ROUTER_WARNING 2 /* there's a router around that */
227 /* we are ignoring, warning has */
228 /* been issued to the user */
229 #define ROUTER_AROUND 3 /* A router is around and we've */
230 /* noted its presence */
231 #define ROUTER_UPDATED 4 /* for mh tracking of routers. Value decremented
232 with rtmp aging timer, a value of 4 allows a
233 minimum of 40 secs to laps before we decide
234 to revert to cable multicasts */
236 /* AppleTalk IOCTLs */
239 #define AIOCSTOPATALK _IOWR('a', 1, int) /* stop AppleTalk */
240 #define AIOCGETIFCFG _IOWR('a', 2, at_if_cfg_t) /* get AT interface cfg */
241 #define AIOCNBPREG _IOWR('a', 3, at_nbp_reg_t) /* NBP register */
242 #define AIOCNBPREMOVE _IOW('a', 4, at_nbp_reg_t) /* NBP remove */
243 #define AIOCGETSTATE _IOR('a', 5, at_state_t) /* get AT global state */
244 #define AIOCSETDEFZONE _IOW('a', 6, at_def_zone_t)
245 /* in single-port, router, and multihome modes, set default zone */
246 #define AIOCSETROUTER _IOW('a', 7, at_router_params_t)
247 #define AIOCGETROUTER _IOR('a', 8, at_router_params_t)
248 #define AIOCSIFADDR _IOW('a', 9, at_if_cfg_t) /* init AT interface */
249 #define AIOCSTARTROUTER _IOR('a',10, at_kern_err_t) /* start AT routing */
250 #define AIOCREGLOCALZN _IOW('a',11, at_nvestr_t)
251 /* in single-port mode, register local zone in kernel table for
252 future use in error checking NBP registration */
253 #define AIOCSETZNUSAGE _IOW('a',12, zone_usage_t)
254 /* in router mode, set up each zone for interfaces being seeded */
255 #define AIOCGETZNUSAGE _IOWR('a',13, zone_usage_t)
256 /* in router and multihome modes, given a zone index, report zone name
257 and interfaces corresponding to that zone */
259 /* values for ifFlags */
260 #define LAP_STATE_MASK 0xf /* low order bits used to report
261 IF state, by AIOCGETIFCFG */
262 #define AT_IFF_DEFAULT 0x40000
263 #define AT_IFF_AURP 0x20000
264 #define RTR_NXNET_PORT 0x10000000 /* Non Extended net port */
265 #define RTR_XNET_PORT 0x20000000 /* Extended net port */
266 #define RTR_SEED_PORT 0x40000000 /* Seed port require config net values*/
268 /* elap_cfg 'flags' defines */
269 #define ELAP_CFG_ZONELESS 0x01 /* true if we shouldn't set a zone
270 (to avoid generating a zip_getnetinfo
272 #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */
273 #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */
276 extern TAILQ_HEAD(at_ifQueueHd
, at_ifaddr
) at_ifQueueHd
;
278 int at_control
__P((struct socket
*, u_long
, caddr_t
, struct ifnet
*));
279 int ddp_usrreq
__P((struct socket
*, int, struct mbuf
*, struct mbuf
*,
281 int ddp_ctloutput
__P((struct socket
*, struct sockopt
*));
282 void ddp_init
__P((void));;
283 void ddp_slowtimo
__P((void));
287 * Define AppleTalk event subclass and specific AppleTalk events.
290 #define KEV_ATALK_SUBCLASS 5
292 #define KEV_ATALK_ENABLED 1 /* AppleTalk enabled from user space - node/net set and valid */
293 #define KEV_ATALK_DISABLED 2 /* AppleTalk disabled from user space */
294 #define KEV_ATALK_ZONEUPDATED 3 /* Zone for this node set/changed */
295 #define KEV_ATALK_ROUTERUP 4 /* Seed router found with valid cable range */
296 #define KEV_ATALK_ROUTERUP_INVALID 5 /* Seed router found with invalid cable range */
297 #define KEV_ATALK_ROUTERDOWN 6 /* Seed router down */
298 #define KEV_ATALK_ZONELISTCHANGED 7 /* Zone list changed by router */
300 struct kev_atalk_data
{
301 struct net_event_data link_data
;
303 struct at_addr address
;
308 #endif /* __APPLE_API_PRIVATE */