]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ | |
5 | * | |
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 | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
29 | */ | |
30 | /* | |
31 | * | |
32 | * ORIGINS: 82 | |
33 | * | |
34 | * (C) COPYRIGHT Apple Computer, Inc. 1992-1996 | |
35 | * All Rights Reserved | |
36 | * | |
37 | */ | |
38 | ||
39 | /* Miscellaneous definitions for AppleTalk used by all protocol | |
40 | * modules. | |
41 | */ | |
42 | ||
43 | #ifndef _NETAT_APPLETALK_H_ | |
44 | #define _NETAT_APPLETALK_H_ | |
45 | #include <sys/appleapiopts.h> | |
46 | ||
47 | #include <sys/types.h> | |
48 | #include <sys/uio.h> | |
49 | ||
50 | #ifdef __APPLE_API_OBSOLETE | |
51 | ||
52 | /* | |
53 | Non-aligned types are used in packet headers. | |
54 | */ | |
55 | ||
56 | /* New fundemental types: non-aligned variations of u_short and u_long */ | |
57 | typedef u_char ua_short[2]; /* Unaligned short */ | |
58 | typedef u_char ua_long[4]; /* Unaligned long */ | |
59 | ||
60 | /* Two at_net typedefs; the first is aligned the other isn't */ | |
61 | typedef u_short at_net_al; /* Aligned AppleTalk network number */ | |
62 | typedef ua_short at_net_unal; /* Unaligned AppleTalk network number */ | |
63 | ||
64 | /* Miscellaneous types */ | |
65 | typedef u_char at_node; /* AppleTalk node number */ | |
66 | typedef u_char at_socket; /* AppleTalk socket number */ | |
67 | ||
68 | typedef at_net_unal at_net; /* Default: Unaligned AppleTalk network number */ | |
69 | struct atalk_addr { | |
70 | u_char atalk_unused; | |
71 | at_net atalk_net; | |
72 | at_node atalk_node; | |
73 | }; | |
74 | ||
75 | /* Macros to manipulate unaligned fields */ | |
76 | #define UAS_ASSIGN(x,s) *(unsigned short *) &(x[0]) = (unsigned short) (s) | |
77 | #define UAS_UAS(x,y) *(unsigned short *) &(x[0]) = *(unsigned short *) &(y[0]) | |
78 | #define UAS_VALUE(x) (*(unsigned short *) &(x[0])) | |
79 | #define UAL_ASSIGN(x,l) *(unsigned long *) &(x[0]) = (unsigned long) (l) | |
80 | #define UAL_UAL(x,y) *(unsigned long *) &(x[0]) = *(unsigned long *) &(y[0]) | |
81 | #define UAL_VALUE(x) (*(unsigned long *) &(x[0])) | |
82 | ||
83 | /* Macros to manipulate at_net variables */ | |
84 | #define NET_ASSIGN(x,s) *(unsigned short *)&(x[0]) = (unsigned short)(s) | |
85 | #define NET_NET(x, y) *(unsigned short *)&(x[0]) = *(unsigned short *)&(y[0]) | |
86 | #define NET_VALUE(x) (*(unsigned short *) &(x[0])) | |
87 | #define ATALK_ASSIGN(a, net, node, unused ) \ | |
88 | a.atalk_unused = unused; a.atalk_node = node; NET_ASSIGN(a.atalk_net, net) | |
89 | ||
90 | #define NET_EQUAL(a, b) (NET_VALUE(a) == NET_VALUE(b)) | |
91 | #define NET_NOTEQ(a, b) (NET_VALUE(a) != NET_VALUE(b)) | |
92 | #define NET_EQUAL0(a) (NET_VALUE(a) == 0) | |
93 | #define NET_NOTEQ0(a) (NET_VALUE(a) != 0) | |
94 | ||
95 | ||
96 | /* | |
97 | AppleTalk Internet Address | |
98 | */ | |
99 | ||
100 | typedef struct at_inet { | |
101 | u_short net; /* Network Address */ | |
102 | u_char node; /* Node number */ | |
103 | u_char socket; /* Socket number */ | |
104 | } at_inet_t; | |
105 | ||
106 | /* | |
107 | DDP Address for OT | |
108 | */ | |
109 | ||
110 | typedef struct ddp_addr { | |
111 | at_inet_t inet; | |
112 | u_short ddptype; | |
113 | } ddp_addr_t; | |
114 | ||
115 | /* | |
116 | AppleTalk address | |
117 | */ | |
118 | ||
119 | struct at_addr { | |
120 | u_short s_net; /* 16-bit network address */ | |
121 | u_char s_node; /* 8-bit node # (1-0xfd) */ | |
122 | }; | |
123 | ||
124 | /* | |
125 | Appletalk sockaddr definition | |
126 | */ | |
127 | struct sockaddr_at { | |
128 | u_char sat_len; /* total length */ | |
129 | u_char sat_family; /* address family (AF_APPLETALK) */ | |
130 | u_char sat_port; /* 8-bit "socket number" */ | |
131 | struct at_addr sat_addr; /* 16-bit "net" and 8-bit "node */ | |
132 | char sat_zero[8]; /* used for netrange in netatalk */ | |
133 | }; | |
134 | ||
135 | #define ATADDR_ANYNET (u_short)0x0000 | |
136 | #define ATADDR_ANYNODE (u_char)0x00 | |
137 | #define ATADDR_ANYPORT (u_char)0x00 | |
138 | ||
139 | #define ATADDR_BCASTNODE (u_char)0xff /* There is no BCAST for NET */ | |
140 | ||
141 | /* make sure the net, node and socket numbers are in legal range : | |
142 | * | |
143 | * Net# 0 Local Net | |
144 | * 1 - 0xfffe Legal net nos | |
145 | * 0xffff Reserved by Apple for future use. | |
146 | * Node# 0 Illegal | |
147 | * 1 - 0x7f Legal (user node id's) | |
148 | * 0x80 - 0xfe Legal (server node id's; 0xfe illegal in | |
149 | * Phase II nodes) | |
150 | * 0xff Broadcast | |
151 | * Socket# 0 Illegal | |
152 | * 1 - 0xfe Legal | |
153 | * 0xff Illegal | |
154 | */ | |
155 | #define valid_at_addr(addr) \ | |
156 | ((!(addr) || (addr)->net == 0xffff || (addr)->node == 0 || \ | |
157 | (addr)->socket == 0 || (addr)->socket == 0xff)? 0: 1) | |
158 | ||
159 | /*** * ETHERTYPE_ definitions are in netinet/if_ether.h *** */ | |
160 | #define ETHERTYPE_AT 0x809B /* AppleTalk protocol */ | |
161 | #define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */ | |
162 | ||
163 | /* | |
164 | DDP protocol types | |
165 | */ | |
166 | ||
167 | #define DDP_RTMP 0x01 | |
168 | #define DDP_NBP 0x02 | |
169 | #define DDP_ATP 0x03 | |
170 | #define DDP_ECHO 0x04 | |
171 | #define DDP_RTMP_REQ 0x05 | |
172 | #define DDP_ZIP 0x06 | |
173 | #define DDP_ADSP 0x07 | |
174 | ||
175 | /* | |
176 | Protocols for the socket API | |
177 | */ | |
178 | ||
179 | #define ATPROTO_NONE 0 /* no corresponding DDP type exists */ | |
180 | ||
181 | #define ATPROTO_ATP DDP_ATP /* must match DDP type */ | |
182 | #define ATPROTO_ADSP DDP_ADSP /* must match DDP type */ | |
183 | ||
184 | #define ATPROTO_DDP 249 /* *** to be eliminated eventually *** */ | |
185 | #define ATPROTO_LAP 250 /* *** to be eliminated eventually *** */ | |
186 | ||
187 | #define ATPROTO_AURP 251 /* no corresponding DDP type exists */ | |
188 | #define ATPROTO_ASP 252 /* no corresponding DDP type exists */ | |
189 | #define ATPROTO_AFP 253 /* no corresponding DDP type exists */ | |
190 | ||
191 | #define ATPROTO_RAW 255 /* no corresponding DDP type exists */ | |
192 | ||
193 | /* | |
194 | Options for use with [gs]etsockopt at the DDP level. | |
195 | First word of comment is data type; bool is stored in int. | |
196 | */ | |
197 | #define DDP_CHKSUM_ON 1 /* int; default = FALSE; | |
198 | DDP checksums should be used */ | |
199 | #define DDP_HDRINCL 2 /* int; default = FALSE; | |
200 | header is included with data */ | |
201 | #define DDP_GETSOCKNAME 3 /* used to get ddp_addr_t */ | |
202 | #define DDP_SLFSND_ON 4 /* int; default = FALSE; | |
203 | packets sent to the cable-multicast address | |
204 | on this socket will be looped back */ | |
205 | #define DDP_STRIPHDR 5 /* int; default = FALSE; | |
206 | drop DDP header on receive (raw) */ | |
207 | ||
208 | /* | |
209 | AppleTalk protocol retry and timeout | |
210 | */ | |
211 | ||
212 | typedef struct at_retry { | |
213 | short interval; /* Retry interval in seconds */ | |
214 | short retries; /* Maximum number of retries */ | |
215 | u_char backoff; /* Retry backoff, must be 1 through 4 */ | |
216 | } at_retry_t; | |
217 | ||
218 | /* | |
219 | Basic NBP Definitions needed for AppleTalk framework | |
220 | */ | |
221 | ||
222 | #define MAX_ZONES 50 | |
223 | ||
224 | #define NBP_NVE_STR_SIZE 32 /* Maximum NBP tuple string size */ | |
225 | typedef struct at_nvestr { | |
226 | u_char len; | |
227 | u_char str[NBP_NVE_STR_SIZE]; | |
228 | } at_nvestr_t; | |
229 | ||
230 | /* Entity Name */ | |
231 | typedef struct at_entity { | |
232 | at_nvestr_t object; | |
233 | at_nvestr_t type; | |
234 | at_nvestr_t zone; | |
235 | } at_entity_t; | |
236 | ||
237 | #define NBP_TUPLE_SIZE ((3*NBP_NVE_STR_SIZE)+3) | |
238 | /* 3 for field lengths + 3*32 for three names */ | |
239 | typedef struct at_nbptuple { | |
240 | at_inet_t enu_addr; | |
241 | u_char enu_enum; | |
242 | at_entity_t enu_entity; | |
243 | } at_nbptuple_t; | |
244 | ||
245 | /* | |
246 | Basic ATP Definitions needed for LibcAT | |
247 | */ | |
248 | ||
249 | #define ATP_TRESP_MAX 8 /* Maximum number of Tresp pkts */ | |
250 | ||
251 | /* Response buffer structure for atp_sendreq() and atp_sendrsp() */ | |
252 | typedef struct at_resp { | |
253 | u_char bitmap; /* Bitmap of responses */ | |
254 | u_char filler[3]; /* Force 68K to RISC alignment */ | |
255 | struct iovec resp[ATP_TRESP_MAX]; /* Buffer for response data */ | |
256 | long userdata[ATP_TRESP_MAX]; /* Buffer for response user data */ | |
257 | } at_resp_t; | |
258 | ||
259 | /* | |
260 | Needed for ASP and ADSP | |
261 | */ | |
262 | ||
263 | typedef struct { | |
264 | int maxlen; /* max buffer length */ | |
265 | int len; /* length of data */ | |
266 | char *buf; /* pointer to buffer */ | |
267 | } strbuf_t; | |
268 | ||
269 | #define IFID_HOME 1 /* home port in ifID_table */ | |
270 | ||
271 | #define ATALK_VALUE(a) ((*(u_long *) &(a))&0x00ffffff) | |
272 | #define ATALK_EQUAL(a, b) (ATALK_VALUE(a) == ATALK_VALUE(b)) | |
273 | ||
274 | #define VERSION_LENGTH 80 /* length of version string */ | |
275 | ||
276 | /* struture containing general information regarding the state of | |
277 | * the Appletalk networking | |
278 | */ | |
279 | typedef struct at_state { | |
280 | unsigned int flags; /* various init flags */ | |
281 | } at_state_t; | |
282 | ||
283 | /* at_state_t 'flags' defines */ | |
284 | #define AT_ST_STARTED 0x0001 /* set if protocol is fully enabled */ | |
285 | #define AT_ST_STARTING 0x0002 /* set if interfaces are configured */ | |
286 | #define AT_ST_MULTIHOME 0x0080 /* set if multihome mode */ | |
287 | #define AT_ST_ROUTER 0x0100 /* set if we are a router */ | |
288 | #define AT_ST_IF_CHANGED 0x0200 /* set when state of any I/F | |
289 | changes (for SNMP) */ | |
290 | #define AT_ST_RT_CHANGED 0x0400 /* route table changed (for SNMP)*/ | |
291 | #define AT_ST_ZT_CHANGED 0x0800 /* zone table changed (for SNMP) */ | |
292 | #define AT_ST_NBP_CHANGED 0x1000 /* if nbp table changed (for SNMP)*/ | |
293 | ||
294 | #ifdef KERNEL_PRIVATE | |
295 | extern at_state_t at_state; /* global state of AT network */ | |
296 | ||
297 | #define ROUTING_MODE (at_state.flags & AT_ST_ROUTER) | |
298 | #define MULTIHOME_MODE (at_state.flags & AT_ST_MULTIHOME) | |
299 | #define MULTIPORT_MODE (ROUTING_MODE || MULTIHOME_MODE) | |
300 | #endif /* KERNEL_PRIVATE */ | |
301 | ||
302 | /* defines originally from h/at_elap.h */ | |
303 | #define AT_ADDR 0 | |
304 | #define ET_ADDR 1 | |
305 | #define AT_ADDR_NO_LOOP 2 /* disables packets from looping back */ | |
306 | ||
307 | #endif /* __APPLE_API_OBSOLETE */ | |
308 | #endif /* _NETAT_APPLETALK_H_ */ |