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/queue.h>
30 /* at_var.h contains definitions formerly found in: at/at_lap.h & at/elap.h */
32 /* multicast tracking */
33 #define MAX_MCASTS 25 /* #multicast addrs tracked per i/f */
34 #define MCAST_TRACK_ADD 1
35 #define MCAST_TRACK_DELETE 2
36 #define MCAST_TRACK_CHECK 3
38 #define ETHERNET_ADDR_LEN 6
41 /* maximum number of I/F's allowed */
42 #define IF_TOTAL_MAX 17 /* max count of any combination of I/F's */
43 /* 17 == (1+(4*4)); 9 and 13 would also be
46 #define FDDI_OR_TOKENRING(i) ((i == IFT_FDDI) || (i == IFT_ISO88025))
48 typedef struct etalk_addr
{
49 u_char etalk_addr_octet
[ETHERNET_ADDR_LEN
];
52 typedef char if_name_t
[IFNAMESIZ
];
53 typedef struct at_ifname_list
{
54 if_name_t at_if
[IF_TOTAL_MAX
];
57 typedef struct at_if_statstics
{
58 u_long fwdBytes
; /* bytes received & forwarded */
59 u_long fwdPkts
; /* pkts received & forwarded */
60 u_long droppedBytes
; /* bytes received & dropped */
61 u_long droppedPkts
; /* pkts received & dropped */
62 u_long outBytes
; /* bytes sent */
63 u_long outPkts
; /* pkts sent */
64 u_long routes
; /* count of routes in rtmptable */
68 u_int unknown_mblks
; /* number of unknown streams msgs */
69 u_int rcv_bytes
; /* number of data bytes received */
70 u_int rcv_packets
; /* number of packets received */
71 u_int xmit_bytes
; /* number of data bytes xmited */
72 u_int xmit_packets
; /* number of packets xmited */
76 char ifr_name
[IFNAMESIZ
];
77 u_int flags
; /* misc. port flags,
78 (ELAP_CFG_xxx on input
80 struct at_addr node
; /* Our node number. */
81 struct at_addr router
; /* Our router. */
82 u_short netStart
; /* network start range */
83 u_short netEnd
; /* network ending range */
89 at_inet_t addr
; /* net and node are ignored, except in
90 multihoming mode where "addr" is used
91 to specify the interface. */
97 char ifr_name
[IFNAMESIZ
];
101 typedef struct zone_usage
{
102 int zone_index
; /* index in local_zones */
103 at_nvestr_t zone_name
; /* the zone name & len */
104 int zone_home
; /* used only to set zones in
106 at_ifnames_t zone_iflist
; /* list of interfaces for
108 char usage
[IF_TOTAL_MAX
]; /* I/F usage (set if
117 } at_router_params_t
;
119 typedef struct at_kern_err
{
120 int error
; /* kernel error # (KE_xxx) */
123 char name1
[IFNAMESIZ
];
124 char name2
[IFNAMESIZ
];
127 u_short netr1b
, netr1e
; /* net range 1 begin & end */
128 u_short netr2b
, netr2e
; /* net range 2 begin & end */
132 #define KE_CONF_RANGE 1
133 #define KE_CONF_SEED_RNG 2
134 #define KE_CONF_SEED1 3
135 #define KE_CONF_SEED_NODE 4
136 #define KE_NO_ZONES_FOUND 5
138 #define KE_INVAL_RANGE 7
139 #define KE_SEED_STARTUP 8
141 #define KE_RTMP_OVERFLOW 10
142 #define KE_ZIP_OVERFLOW 11
145 * Interface address, AppleTalk version. One of these structures
146 * is allocated for each AppleTalk address on an interface.
148 * The ifaddr structure contains the protocol-independent part
149 * of the structure and is assumed to be first, as it is in
150 * "struct in_ifaddr", defined in bsd/netinet/in_var.h.
152 typedef struct at_ifaddr
{
153 struct ifaddr aa_ifa
;
154 #define aa_ifp aa_ifa.ifa_ifp
155 #define aa_flags aa_ifa.ifa_flags
157 TAILQ_ENTRY(at_ifaddr
) aa_link
; /* tailq macro glue */
159 u_long at_dl_tag
; /* DLIL tag to be used in packet output */
160 u_long aarp_dl_tag
; /* DLIL tag for Appletalk ARP */
162 /* from pat_unit_t */
163 unsigned char mcast
[MAX_MCASTS
];
164 char xaddr
[ETHERNET_ADDR_LEN
];
166 /* from elap_specifics_t */
167 at_elap_stats_t stats
;
169 /* The DDP sets these values: */
170 u_char ifState
; /* State of the interface LAP_* */
171 u_short ifThisCableStart
;
172 u_short ifThisCableEnd
;
173 struct at_addr ifARouter
;
174 u_char ifRouterState
;
175 u_int ifFlags
; /* Flags, see AT_IFF_* */
176 struct sockaddr_at ifNodeAddress
;
177 #define ifThisNode ifNodeAddress.sat_addr
178 /* AppleTalk node ID is ifNodeAddress.sat_addr*/
182 at_nvestr_t ifZoneName
;
184 /* Added for routing support */
185 int ifPort
; /* the unique ddp logical port
186 number, also index into
187 at_interfaces[] and ifID_table[] */
188 char ifName
[IFNAMESIZ
];
189 /* added to support LAP_IOC_GET_IFID */
190 u_short ifDefZone
; /* Default Zone index in ZoneTable; used
191 only in routing/multihome modes to be
192 able to answer a ZIP GetNetInfo request */
193 char ifZipNeedQueries
;
194 /* ZIP/RTMP Query flag */
195 char ifRoutingState
; /* Port (as a router) state */
197 ifStatistics
; /* statistics */
198 /* end of elap_if structure */
200 u_short flags
; /* port specific flags */
201 struct etalk_addr ZoneMcastAddr
;
202 /* zone multicast addr */
203 struct etalk_addr cable_multicast_addr
;
204 /* AppleTalk broadcast addr */
206 struct at_addr initial_addr
; /* temporary value used during startup */
207 at_nvestr_t startup_zone
;
208 int startup_error
, /* to get error code back from
209 ZIPwakeup() / AARPwakeup() */
210 startup_inprogress
; /* to decide whether it's the
211 middle of an elap_online operation */
215 #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */
217 #define LAP_ONLINE_FOR_ZIP 2
218 #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */
220 #define NO_ROUTER 1 /* there's no router around */
221 #define ROUTER_WARNING 2 /* there's a router around that */
222 /* we are ignoring, warning has */
223 /* been issued to the user */
224 #define ROUTER_AROUND 3 /* A router is around and we've */
225 /* noted its presence */
226 #define ROUTER_UPDATED 4 /* for mh tracking of routers. Value decremented
227 with rtmp aging timer, a value of 4 allows a
228 minimum of 40 secs to laps before we decide
229 to revert to cable multicasts */
231 /* AppleTalk IOCTLs */
234 #define AIOCSTOPATALK _IOWR('a', 1, int) /* stop AppleTalk */
235 #define AIOCGETIFCFG _IOWR('a', 2, at_if_cfg_t) /* get AT interface cfg */
236 #define AIOCNBPREG _IOWR('a', 3, at_nbp_reg_t) /* NBP register */
237 #define AIOCNBPREMOVE _IOW('a', 4, at_nbp_reg_t) /* NBP remove */
238 #define AIOCGETSTATE _IOR('a', 5, at_state_t) /* get AT global state */
239 #define AIOCSETDEFZONE _IOW('a', 6, at_def_zone_t)
240 /* in single-port, router, and multihome modes, set default zone */
241 #define AIOCSETROUTER _IOW('a', 7, at_router_params_t)
242 #define AIOCGETROUTER _IOR('a', 8, at_router_params_t)
243 #define AIOCSIFADDR _IOW('a', 9, at_if_cfg_t) /* init AT interface */
244 #define AIOCSTARTROUTER _IOR('a',10, at_kern_err_t) /* start AT routing */
245 #define AIOCREGLOCALZN _IOW('a',11, at_nvestr_t)
246 /* in single-port mode, register local zone in kernel table for
247 future use in error checking NBP registration */
248 #define AIOCSETZNUSAGE _IOW('a',12, zone_usage_t)
249 /* in router mode, set up each zone for interfaces being seeded */
250 #define AIOCGETZNUSAGE _IOWR('a',13, zone_usage_t)
251 /* in router and multihome modes, given a zone index, report zone name
252 and interfaces corresponding to that zone */
254 /* values for ifFlags */
255 #define LAP_STATE_MASK 0xf /* low order bits used to report
256 IF state, by AIOCGETIFCFG */
257 #define AT_IFF_DEFAULT 0x40000
258 #define AT_IFF_AURP 0x20000
259 #define RTR_NXNET_PORT 0x10000000 /* Non Extended net port */
260 #define RTR_XNET_PORT 0x20000000 /* Extended net port */
261 #define RTR_SEED_PORT 0x40000000 /* Seed port require config net values*/
263 /* elap_cfg 'flags' defines */
264 #define ELAP_CFG_ZONELESS 0x01 /* true if we shouldn't set a zone
265 (to avoid generating a zip_getnetinfo
267 #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */
268 #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */
271 extern TAILQ_HEAD(at_ifQueueHd
, at_ifaddr
) at_ifQueueHd
;
273 int at_control
__P((struct socket
*, u_long
, caddr_t
, struct ifnet
*));
274 int ddp_usrreq
__P((struct socket
*, int, struct mbuf
*, struct mbuf
*,
276 int ddp_ctloutput
__P((struct socket
*, struct sockopt
*));
277 void ddp_init
__P((void));;
278 void ddp_slowtimo
__P((void));