|
|
1.1 root 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/queue.h>
27:
28: /* at_var.h */
29:
30: /* at_var.h contains definitions formerly found in: at/at_lap.h & at/elap.h */
31:
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
37:
38: #define ETHERNET_ADDR_LEN 6
39: #define IFNAMESIZ 16
40:
41: #define FDDI_OR_TOKENRING(i) ((i == IFT_FDDI) || (i == IFT_ISO88025))
42:
43: typedef struct etalk_addr {
44: u_char etalk_addr_octet[ETHERNET_ADDR_LEN];
45: } etalk_addr_t;
46:
47: typedef char if_name_t[IFNAMESIZ];
48:
49: typedef struct at_if_statstics {
50: u_long fwdBytes; /* bytes received & forwarded */
51: u_long fwdPkts; /* pkts received & forwarded */
52: u_long droppedBytes; /* bytes received & dropped */
53: u_long droppedPkts; /* pkts received & dropped */
54: u_long outBytes; /* bytes sent */
55: u_long outPkts; /* pkts sent */
56: u_long routes; /* count of routes in rtmptable */
57: } at_if_statistics_t;
58:
59: typedef struct {
60: u_int unknown_mblks; /* number of unknown streams msgs */
61: u_int rcv_bytes; /* number of data bytes received */
62: u_int rcv_packets; /* number of packets received */
63: u_int xmit_bytes; /* number of data bytes xmited */
64: u_int xmit_packets; /* number of packets xmited */
65: } at_elap_stats_t;
66:
67: typedef struct {
68: char ifr_name[IFNAMESIZ];
69: u_int flags; /* misc. port flags,
70: (ELAP_CFG_xxx on input
71: ifFlags on output) */
72: struct at_addr node; /* Our node number. */
73: struct at_addr router; /* Our router. */
74: u_short netStart; /* network start range */
75: u_short netEnd; /* network ending range */
76: at_nvestr_t zonename;
77: } at_if_cfg_t;
78:
79: typedef struct {
80: at_entity_t name;
81: at_inet_t addr; /* net and node are ignored, except in
82: multihoming mode where "addr" is used
83: to specify the interface. */
84: u_char ddptype;
85: long unique_nbp_id;
86: } at_nbp_reg_t;
87:
88: typedef struct {
89: char ifr_name[IFNAMESIZ];
90: at_nvestr_t zonename;
91: } at_def_zone_t;
92:
93: typedef struct {
94: short multihome;
95: short rtmp_table_sz;
96: short zone_table_sz;
97: short router_mix;
98: } at_router_params_t;
99:
100: typedef struct at_kern_err {
101: int error; /* kernel error # (KE_xxx) */
102: int port1;
103: int port2;
104: char name1[IFNAMESIZ];
105: char name2[IFNAMESIZ];
106: u_short net;
107: u_char node;
108: u_short netr1b, netr1e; /* net range 1 begin & end */
109: u_short netr2b, netr2e; /* net range 2 begin & end */
110: u_char rtmp_id;
111: } at_kern_err_t;
112:
113: #define KE_CONF_RANGE 1
114: #define KE_CONF_SEED_RNG 2
115: #define KE_CONF_SEED1 3
116: #define KE_CONF_SEED_NODE 4
117: #define KE_NO_ZONES_FOUND 5
118: #define KE_NO_SEED 6
119: #define KE_INVAL_RANGE 7
120: #define KE_SEED_STARTUP 8
121: #define KE_BAD_VER 9
122: #define KE_RTMP_OVERFLOW 10
123: #define KE_ZIP_OVERFLOW 11
124:
125: /*
126: * Interface address, AppleTalk version. One of these structures
127: * is allocated for each AppleTalk address on an interface.
128: *
129: * The ifaddr structure contains the protocol-independent part
130: * of the structure and is assumed to be first, as it is in
131: * "struct in_ifaddr", defined in bsd/netinet/in_var.h.
132: */
133: typedef struct at_ifaddr {
134: struct ifaddr aa_ifa;
135: #define aa_ifp aa_ifa.ifa_ifp
136: #define aa_flags aa_ifa.ifa_flags
137:
138: TAILQ_ENTRY(at_ifaddr) aa_link; /* tailq macro glue */
139:
140: u_long at_dl_tag; /* DLIL tag to be used in packet output */
141: u_long aarp_dl_tag; /* DLIL tag for Appletalk ARP */
142:
143: /* from pat_unit_t */
144: unsigned char mcast[MAX_MCASTS];
145: char xaddr[ETHERNET_ADDR_LEN];
146:
147: /* from elap_specifics_t */
148: at_elap_stats_t stats;
149:
150: /* The DDP sets these values: */
151: u_char ifState; /* State of the interface LAP_* */
152: u_short ifThisCableStart;
153: u_short ifThisCableEnd;
154: struct at_addr ifARouter;
155: u_char ifRouterState;
156: u_int ifFlags; /* Flags, see AT_IFF_* */
157: struct sockaddr_at ifNodeAddress;
158: #define ifThisNode ifNodeAddress.sat_addr
159: /* AppleTalk node ID is ifNodeAddress.sat_addr*/
160:
161: /* for use by ZIP */
162: u_char ifNumRetries;
163: at_nvestr_t ifZoneName;
164:
165: /* Added for routing support */
166: int ifPort; /* the unique ddp logical port
167: number, also index into
168: at_interfaces[] and ifID_table[] */
169: char ifName[IFNAMESIZ];
170: /* added to support LAP_IOC_GET_IFID */
171: u_short ifDefZone; /* Default Zone index in ZoneTable; used
172: only in routing/multihome modes to be
173: able to answer a ZIP GetNetInfo request */
174: char ifZipNeedQueries;
175: /* ZIP/RTMP Query flag */
176: char ifRoutingState; /* Port (as a router) state */
177: at_if_statistics_t
178: ifStatistics; /* statistics */
179: /* end of elap_if structure */
180:
181: u_short flags; /* port specific flags */
182: struct etalk_addr ZoneMcastAddr;
183: /* zone multicast addr */
184: struct etalk_addr cable_multicast_addr;
185: /* AppleTalk broadcast addr */
186:
187: struct at_addr initial_addr; /* temporary value used during startup */
188: at_nvestr_t startup_zone;
189: int startup_error, /* to get error code back from
190: ZIPwakeup() / AARPwakeup() */
191: startup_inprogress; /* to decide whether it's the
192: middle of an elap_online operation */
193:
194: } at_ifaddr_t;
195:
196: #define LAP_OFFLINE 0 /* LAP_OFFLINE MUST be 0 */
197: #define LAP_ONLINE 1
198: #define LAP_ONLINE_FOR_ZIP 2
199: #define LAP_ONLINE_ZONELESS 3 /* for non-home router ports */
200:
201: #define NO_ROUTER 1 /* there's no router around */
202: #define ROUTER_WARNING 2 /* there's a router around that */
203: /* we are ignoring, warning has */
204: /* been issued to the user */
205: #define ROUTER_AROUND 3 /* A router is around and we've */
206: /* noted its presence */
207: #define ROUTER_UPDATED 4 /* for mh tracking of routers. Value decremented
208: with rtmp aging timer, a value of 4 allows a
209: minimum of 40 secs to laps before we decide
210: to revert to cable multicasts */
211:
212: #define AIOCSTOPATALK _IOW('a', 1, int) /* stop AppleTalk */
213: #define AIOCGETIFCFG _IOWR('a', 2, at_if_cfg_t) /* get AT interface cfg */
214: #define AIOCNBPREG _IOWR('a', 3, at_nbp_reg_t) /* NBP register */
215: #define AIOCNBPREMOVE _IOW('a', 4, at_nbp_reg_t) /* NBP remove */
216: #define AIOCGETSTATE _IOR('a', 5, at_state_t) /* get AT global state */
217: #define AIOCSETDEFZONE _IOW('a', 6, at_def_zone_t) /* set default zone */
218: #define AIOCSETROUTER _IOW('a', 7, at_router_params_t)
219: #define AIOCGETROUTER _IOR('a', 8, at_router_params_t)
220: #define AIOCSIFADDR _IOW('a', 9, at_if_cfg_t) /* init AT interface */
221: #define AIOCSTARTROUTER _IOR('a',10, at_kern_err_t) /* start AT routing */
222:
223: /* values for ifFlags */
224: #define LAP_STATE_MASK 0xf /* low order bits used to report
225: IF state, by AIOCGETIFCFG */
226: #define AT_IFF_DEFAULT 0x40000
227: #define AT_IFF_AURP 0x20000
228: #define RTR_NXNET_PORT 0x10000000 /* Non Extended net port */
229: #define RTR_XNET_PORT 0x20000000 /* Extended net port */
230: #define RTR_SEED_PORT 0x40000000 /* Seed port require config net values*/
231:
232: /* elap_cfg 'flags' defines */
233: #define ELAP_CFG_ZONELESS 0x01 /* true if we shouldn't set a zone
234: (to avoid generating a zip_getnetinfo
235: when routing) */
236: #define ELAP_CFG_HOME 0x02 /* designate home port (one allowed) */
237: #define ELAP_CFG_SEED 0x08 /* set if it's a seed port */
238:
239: #ifdef KERNEL
240: extern TAILQ_HEAD(at_ifQueueHd, at_ifaddr) at_ifQueueHd;
241:
242: int at_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
243: int ddp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *,
244: struct mbuf *));
245: int ddp_ctloutput __P((struct socket *, struct sockopt *));
246: void ddp_init __P((void));;
247: void ddp_slowtimo __P((void));
248: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.