2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1998 Apple Computer, Inc.
26 #include <sys/appleapiopts.h>
27 #ifdef __APPLE_API_PRIVATE
28 #include <sys/queue.h>
32 /* at_var.h contains definitions formerly found in: at/at_lap.h & at/elap.h */
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
40 #define ETHERNET_ADDR_LEN 6
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
48 #define FDDI_OR_TOKENRING(i) ((i == IFT_FDDI) || (i == IFT_ISO88025))
50 typedef struct etalk_addr
{
51 u_char etalk_addr_octet
[ETHERNET_ADDR_LEN
];
54 typedef char if_name_t
[IFNAMESIZ
];
55 typedef struct at_ifname_list
{
56 if_name_t at_if
[IF_TOTAL_MAX
];
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 */
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 */
78 char ifr_name
[IFNAMESIZ
];
79 u_int flags
; /* misc. port flags,
80 (ELAP_CFG_xxx on input
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 */
91 at_inet_t addr
; /* net and node are ignored, except in
92 multihoming mode where "addr" is used
93 to specify the interface. */
99 char ifr_name
[IFNAMESIZ
];
100 at_nvestr_t zonename
;
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
108 at_ifnames_t zone_iflist
; /* list of interfaces for
110 char usage
[IF_TOTAL_MAX
]; /* I/F usage (set if
119 } at_router_params_t
;
121 typedef struct at_kern_err
{
122 int error
; /* kernel error # (KE_xxx) */
125 char name1
[IFNAMESIZ
];
126 char name2
[IFNAMESIZ
];
129 u_short netr1b
, netr1e
; /* net range 1 begin & end */
130 u_short netr2b
, netr2e
; /* net range 2 begin & end */
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
140 #define KE_INVAL_RANGE 7
141 #define KE_SEED_STARTUP 8
143 #define KE_RTMP_OVERFLOW 10
144 #define KE_ZIP_OVERFLOW 11
147 * Interface address, AppleTalk version. One of these structures
148 * is allocated for each AppleTalk address on an interface.
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.
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
159 TAILQ_ENTRY(at_ifaddr
) aa_link
; /* tailq macro glue */
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 */
164 /* from pat_unit_t */
165 unsigned char mcast
[MAX_MCASTS
];
166 char xaddr
[ETHERNET_ADDR_LEN
];
168 /* from elap_specifics_t */
169 at_elap_stats_t stats
;
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*/
184 at_nvestr_t ifZoneName
;
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 */
199 ifStatistics
; /* statistics */
200 /* end of elap_if structure */
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 */
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 */
217 #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */
219 #define LAP_ONLINE_FOR_ZIP 2
220 #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */
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 */
233 /* AppleTalk IOCTLs */
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 */
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*/
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
269 #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */
270 #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */
273 extern TAILQ_HEAD(at_ifQueueHd
, at_ifaddr
) at_ifQueueHd
;
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
*,
278 int ddp_ctloutput
__P((struct socket
*, struct sockopt
*));
279 void ddp_init
__P((void));;
280 void ddp_slowtimo
__P((void));
284 * Define AppleTalk event subclass and specific AppleTalk events.
287 #define KEV_ATALK_SUBCLASS 5
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 */
297 struct kev_atalk_data
{
298 struct net_event_data link_data
;
300 struct at_addr address
;
305 #endif /* __APPLE_API_PRIVATE */