]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
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@ | |
1c79356b A |
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_ | |
9bccf70c | 45 | #include <sys/appleapiopts.h> |
1c79356b A |
46 | |
47 | #include <sys/types.h> | |
48 | #include <sys/uio.h> | |
49 | ||
91447636 A |
50 | #ifdef __APPLE_API_OBSOLETE |
51 | ||
1c79356b A |
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 | ||
5d5c5d0d A |
83 | /* Macros to assign unaligned fields with byte swapping */ |
84 | #define UAS_ASSIGN_HTON(x,s) *(unsigned short *) &(x[0]) = htons((unsigned short) (s)) | |
85 | #define UAS_ASSIGN_NTOH(x,s) *(unsigned short *) &(x[0]) = ntohs((unsigned short) (s)) | |
86 | #define UAS_VALUE_HTON(x) htons((*(unsigned short *) &(x[0]))) | |
87 | #define UAS_VALUE_NTOH(x) ntohs((*(unsigned short *) &(x[0]))) | |
88 | #define UAL_ASSIGN_HTON(x,l) *(unsigned long *) &(x[0]) = htonl((unsigned long) (l)) | |
89 | #define UAL_ASSIGN_NTOH(x,l) *(unsigned long *) &(x[0]) = ntohl((unsigned long) (l)) | |
90 | #define UAL_VALUE_HTON(x) htonl((*(unsigned long *) &(x[0]))) | |
91 | #define UAL_VALUE_NTOH(x) ntohl((*(unsigned long *) &(x[0]))) | |
92 | ||
1c79356b | 93 | /* Macros to manipulate at_net variables */ |
5d5c5d0d A |
94 | #define NET_ASSIGN(x,s) *(unsigned short *)&(x[0]) = htons((unsigned short)(s)) |
95 | #define NET_ASSIGN_NOSWAP(x,s) *(unsigned short *)&(x[0]) = (unsigned short)(s) | |
96 | #define NET_NET(x, y) *(unsigned short *)&(x[0]) = *(unsigned short *)&(y[0]) | |
97 | #define NET_VALUE(x) ntohs((*(unsigned short *) &(x[0]))) | |
98 | #define NET_VALUE_NOSWAP(x) (*(unsigned short *) &(x[0])) | |
1c79356b A |
99 | #define ATALK_ASSIGN(a, net, node, unused ) \ |
100 | a.atalk_unused = unused; a.atalk_node = node; NET_ASSIGN(a.atalk_net, net) | |
101 | ||
102 | #define NET_EQUAL(a, b) (NET_VALUE(a) == NET_VALUE(b)) | |
103 | #define NET_NOTEQ(a, b) (NET_VALUE(a) != NET_VALUE(b)) | |
104 | #define NET_EQUAL0(a) (NET_VALUE(a) == 0) | |
105 | #define NET_NOTEQ0(a) (NET_VALUE(a) != 0) | |
106 | ||
107 | ||
108 | /* | |
109 | AppleTalk Internet Address | |
110 | */ | |
111 | ||
112 | typedef struct at_inet { | |
113 | u_short net; /* Network Address */ | |
114 | u_char node; /* Node number */ | |
115 | u_char socket; /* Socket number */ | |
116 | } at_inet_t; | |
117 | ||
118 | /* | |
119 | DDP Address for OT | |
120 | */ | |
121 | ||
122 | typedef struct ddp_addr { | |
123 | at_inet_t inet; | |
124 | u_short ddptype; | |
125 | } ddp_addr_t; | |
126 | ||
127 | /* | |
128 | AppleTalk address | |
129 | */ | |
130 | ||
131 | struct at_addr { | |
132 | u_short s_net; /* 16-bit network address */ | |
133 | u_char s_node; /* 8-bit node # (1-0xfd) */ | |
134 | }; | |
135 | ||
136 | /* | |
137 | Appletalk sockaddr definition | |
138 | */ | |
139 | struct sockaddr_at { | |
140 | u_char sat_len; /* total length */ | |
141 | u_char sat_family; /* address family (AF_APPLETALK) */ | |
142 | u_char sat_port; /* 8-bit "socket number" */ | |
143 | struct at_addr sat_addr; /* 16-bit "net" and 8-bit "node */ | |
144 | char sat_zero[8]; /* used for netrange in netatalk */ | |
145 | }; | |
146 | ||
147 | #define ATADDR_ANYNET (u_short)0x0000 | |
148 | #define ATADDR_ANYNODE (u_char)0x00 | |
149 | #define ATADDR_ANYPORT (u_char)0x00 | |
150 | ||
151 | #define ATADDR_BCASTNODE (u_char)0xff /* There is no BCAST for NET */ | |
152 | ||
153 | /* make sure the net, node and socket numbers are in legal range : | |
154 | * | |
155 | * Net# 0 Local Net | |
156 | * 1 - 0xfffe Legal net nos | |
157 | * 0xffff Reserved by Apple for future use. | |
158 | * Node# 0 Illegal | |
159 | * 1 - 0x7f Legal (user node id's) | |
160 | * 0x80 - 0xfe Legal (server node id's; 0xfe illegal in | |
161 | * Phase II nodes) | |
162 | * 0xff Broadcast | |
163 | * Socket# 0 Illegal | |
164 | * 1 - 0xfe Legal | |
165 | * 0xff Illegal | |
166 | */ | |
167 | #define valid_at_addr(addr) \ | |
168 | ((!(addr) || (addr)->net == 0xffff || (addr)->node == 0 || \ | |
169 | (addr)->socket == 0 || (addr)->socket == 0xff)? 0: 1) | |
170 | ||
171 | /*** * ETHERTYPE_ definitions are in netinet/if_ether.h *** */ | |
172 | #define ETHERTYPE_AT 0x809B /* AppleTalk protocol */ | |
173 | #define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */ | |
174 | ||
175 | /* | |
176 | DDP protocol types | |
177 | */ | |
178 | ||
179 | #define DDP_RTMP 0x01 | |
180 | #define DDP_NBP 0x02 | |
181 | #define DDP_ATP 0x03 | |
182 | #define DDP_ECHO 0x04 | |
183 | #define DDP_RTMP_REQ 0x05 | |
184 | #define DDP_ZIP 0x06 | |
185 | #define DDP_ADSP 0x07 | |
186 | ||
187 | /* | |
188 | Protocols for the socket API | |
189 | */ | |
190 | ||
191 | #define ATPROTO_NONE 0 /* no corresponding DDP type exists */ | |
192 | ||
193 | #define ATPROTO_ATP DDP_ATP /* must match DDP type */ | |
194 | #define ATPROTO_ADSP DDP_ADSP /* must match DDP type */ | |
195 | ||
196 | #define ATPROTO_DDP 249 /* *** to be eliminated eventually *** */ | |
197 | #define ATPROTO_LAP 250 /* *** to be eliminated eventually *** */ | |
198 | ||
199 | #define ATPROTO_AURP 251 /* no corresponding DDP type exists */ | |
200 | #define ATPROTO_ASP 252 /* no corresponding DDP type exists */ | |
201 | #define ATPROTO_AFP 253 /* no corresponding DDP type exists */ | |
202 | ||
203 | #define ATPROTO_RAW 255 /* no corresponding DDP type exists */ | |
204 | ||
205 | /* | |
206 | Options for use with [gs]etsockopt at the DDP level. | |
207 | First word of comment is data type; bool is stored in int. | |
208 | */ | |
209 | #define DDP_CHKSUM_ON 1 /* int; default = FALSE; | |
210 | DDP checksums should be used */ | |
211 | #define DDP_HDRINCL 2 /* int; default = FALSE; | |
212 | header is included with data */ | |
213 | #define DDP_GETSOCKNAME 3 /* used to get ddp_addr_t */ | |
214 | #define DDP_SLFSND_ON 4 /* int; default = FALSE; | |
215 | packets sent to the cable-multicast address | |
216 | on this socket will be looped back */ | |
217 | #define DDP_STRIPHDR 5 /* int; default = FALSE; | |
218 | drop DDP header on receive (raw) */ | |
219 | ||
220 | /* | |
221 | AppleTalk protocol retry and timeout | |
222 | */ | |
223 | ||
224 | typedef struct at_retry { | |
225 | short interval; /* Retry interval in seconds */ | |
226 | short retries; /* Maximum number of retries */ | |
227 | u_char backoff; /* Retry backoff, must be 1 through 4 */ | |
228 | } at_retry_t; | |
229 | ||
230 | /* | |
231 | Basic NBP Definitions needed for AppleTalk framework | |
232 | */ | |
233 | ||
234 | #define MAX_ZONES 50 | |
235 | ||
236 | #define NBP_NVE_STR_SIZE 32 /* Maximum NBP tuple string size */ | |
237 | typedef struct at_nvestr { | |
238 | u_char len; | |
239 | u_char str[NBP_NVE_STR_SIZE]; | |
240 | } at_nvestr_t; | |
241 | ||
242 | /* Entity Name */ | |
243 | typedef struct at_entity { | |
244 | at_nvestr_t object; | |
245 | at_nvestr_t type; | |
246 | at_nvestr_t zone; | |
247 | } at_entity_t; | |
248 | ||
249 | #define NBP_TUPLE_SIZE ((3*NBP_NVE_STR_SIZE)+3) | |
250 | /* 3 for field lengths + 3*32 for three names */ | |
251 | typedef struct at_nbptuple { | |
252 | at_inet_t enu_addr; | |
253 | u_char enu_enum; | |
254 | at_entity_t enu_entity; | |
255 | } at_nbptuple_t; | |
256 | ||
257 | /* | |
258 | Basic ATP Definitions needed for LibcAT | |
259 | */ | |
260 | ||
261 | #define ATP_TRESP_MAX 8 /* Maximum number of Tresp pkts */ | |
262 | ||
263 | /* Response buffer structure for atp_sendreq() and atp_sendrsp() */ | |
264 | typedef struct at_resp { | |
265 | u_char bitmap; /* Bitmap of responses */ | |
266 | u_char filler[3]; /* Force 68K to RISC alignment */ | |
267 | struct iovec resp[ATP_TRESP_MAX]; /* Buffer for response data */ | |
268 | long userdata[ATP_TRESP_MAX]; /* Buffer for response user data */ | |
269 | } at_resp_t; | |
270 | ||
271 | /* | |
272 | Needed for ASP and ADSP | |
273 | */ | |
274 | ||
275 | typedef struct { | |
276 | int maxlen; /* max buffer length */ | |
277 | int len; /* length of data */ | |
278 | char *buf; /* pointer to buffer */ | |
279 | } strbuf_t; | |
280 | ||
281 | #define IFID_HOME 1 /* home port in ifID_table */ | |
282 | ||
283 | #define ATALK_VALUE(a) ((*(u_long *) &(a))&0x00ffffff) | |
1c79356b A |
284 | |
285 | #define VERSION_LENGTH 80 /* length of version string */ | |
286 | ||
287 | /* struture containing general information regarding the state of | |
288 | * the Appletalk networking | |
289 | */ | |
290 | typedef struct at_state { | |
291 | unsigned int flags; /* various init flags */ | |
292 | } at_state_t; | |
293 | ||
294 | /* at_state_t 'flags' defines */ | |
9bccf70c A |
295 | #define AT_ST_STARTED 0x0001 /* set if protocol is fully enabled */ |
296 | #define AT_ST_STARTING 0x0002 /* set if interfaces are configured */ | |
1c79356b A |
297 | #define AT_ST_MULTIHOME 0x0080 /* set if multihome mode */ |
298 | #define AT_ST_ROUTER 0x0100 /* set if we are a router */ | |
299 | #define AT_ST_IF_CHANGED 0x0200 /* set when state of any I/F | |
300 | changes (for SNMP) */ | |
301 | #define AT_ST_RT_CHANGED 0x0400 /* route table changed (for SNMP)*/ | |
302 | #define AT_ST_ZT_CHANGED 0x0800 /* zone table changed (for SNMP) */ | |
303 | #define AT_ST_NBP_CHANGED 0x1000 /* if nbp table changed (for SNMP)*/ | |
304 | ||
91447636 | 305 | #ifdef KERNEL_PRIVATE |
1c79356b A |
306 | extern at_state_t at_state; /* global state of AT network */ |
307 | ||
308 | #define ROUTING_MODE (at_state.flags & AT_ST_ROUTER) | |
309 | #define MULTIHOME_MODE (at_state.flags & AT_ST_MULTIHOME) | |
310 | #define MULTIPORT_MODE (ROUTING_MODE || MULTIHOME_MODE) | |
91447636 | 311 | #endif /* KERNEL_PRIVATE */ |
1c79356b A |
312 | |
313 | /* defines originally from h/at_elap.h */ | |
314 | #define AT_ADDR 0 | |
315 | #define ET_ADDR 1 | |
316 | #define AT_ADDR_NO_LOOP 2 /* disables packets from looping back */ | |
317 | ||
91447636 | 318 | #endif /* __APPLE_API_OBSOLETE */ |
1c79356b | 319 | #endif /* _NETAT_APPLETALK_H_ */ |