]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/appletalk.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * (C) COPYRIGHT Apple Computer, Inc. 1992-1996
37 /* Miscellaneous definitions for AppleTalk used by all protocol
41 #ifndef _NETAT_APPLETALK_H_
42 #define _NETAT_APPLETALK_H_
43 #include <sys/appleapiopts.h>
45 #include <sys/types.h>
48 #ifdef __APPLE_API_OBSOLETE
51 Non-aligned types are used in packet headers.
54 /* New fundemental types: non-aligned variations of u_short and u_long */
55 typedef u_char ua_short
[2]; /* Unaligned short */
56 typedef u_char ua_long
[4]; /* Unaligned long */
58 /* Two at_net typedefs; the first is aligned the other isn't */
59 typedef u_short at_net_al
; /* Aligned AppleTalk network number */
60 typedef ua_short at_net_unal
; /* Unaligned AppleTalk network number */
62 /* Miscellaneous types */
63 typedef u_char at_node
; /* AppleTalk node number */
64 typedef u_char at_socket
; /* AppleTalk socket number */
66 typedef at_net_unal at_net
; /* Default: Unaligned AppleTalk network number */
73 /* Macros to manipulate unaligned fields */
74 #define UAS_ASSIGN(x,s) *(unsigned short *) &(x[0]) = (unsigned short) (s)
75 #define UAS_UAS(x,y) *(unsigned short *) &(x[0]) = *(unsigned short *) &(y[0])
76 #define UAS_VALUE(x) (*(unsigned short *) &(x[0]))
77 #define UAL_ASSIGN(x,l) *(unsigned long *) &(x[0]) = (unsigned long) (l)
78 #define UAL_UAL(x,y) *(unsigned long *) &(x[0]) = *(unsigned long *) &(y[0])
79 #define UAL_VALUE(x) (*(unsigned long *) &(x[0]))
81 /* Macros to manipulate at_net variables */
82 #define NET_ASSIGN(x,s) *(unsigned short *)&(x[0]) = (unsigned short)(s)
83 #define NET_NET(x, y) *(unsigned short *)&(x[0]) = *(unsigned short *)&(y[0])
84 #define NET_VALUE(x) (*(unsigned short *) &(x[0]))
85 #define ATALK_ASSIGN(a, net, node, unused ) \
86 a.atalk_unused = unused; a.atalk_node = node; NET_ASSIGN(a.atalk_net, net)
88 #define NET_EQUAL(a, b) (NET_VALUE(a) == NET_VALUE(b))
89 #define NET_NOTEQ(a, b) (NET_VALUE(a) != NET_VALUE(b))
90 #define NET_EQUAL0(a) (NET_VALUE(a) == 0)
91 #define NET_NOTEQ0(a) (NET_VALUE(a) != 0)
95 AppleTalk Internet Address
98 typedef struct at_inet
{
99 u_short net
; /* Network Address */
100 u_char node
; /* Node number */
101 u_char socket
; /* Socket number */
108 typedef struct ddp_addr
{
118 u_short s_net
; /* 16-bit network address */
119 u_char s_node
; /* 8-bit node # (1-0xfd) */
123 Appletalk sockaddr definition
126 u_char sat_len
; /* total length */
127 u_char sat_family
; /* address family (AF_APPLETALK) */
128 u_char sat_port
; /* 8-bit "socket number" */
129 struct at_addr sat_addr
; /* 16-bit "net" and 8-bit "node */
130 char sat_zero
[8]; /* used for netrange in netatalk */
133 #define ATADDR_ANYNET (u_short)0x0000
134 #define ATADDR_ANYNODE (u_char)0x00
135 #define ATADDR_ANYPORT (u_char)0x00
137 #define ATADDR_BCASTNODE (u_char)0xff /* There is no BCAST for NET */
139 /* make sure the net, node and socket numbers are in legal range :
142 * 1 - 0xfffe Legal net nos
143 * 0xffff Reserved by Apple for future use.
145 * 1 - 0x7f Legal (user node id's)
146 * 0x80 - 0xfe Legal (server node id's; 0xfe illegal in
153 #define valid_at_addr(addr) \
154 ((!(addr) || (addr)->net == 0xffff || (addr)->node == 0 || \
155 (addr)->socket == 0 || (addr)->socket == 0xff)? 0: 1)
157 /*** * ETHERTYPE_ definitions are in netinet/if_ether.h *** */
158 #define ETHERTYPE_AT 0x809B /* AppleTalk protocol */
159 #define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */
165 #define DDP_RTMP 0x01
168 #define DDP_ECHO 0x04
169 #define DDP_RTMP_REQ 0x05
171 #define DDP_ADSP 0x07
174 Protocols for the socket API
177 #define ATPROTO_NONE 0 /* no corresponding DDP type exists */
179 #define ATPROTO_ATP DDP_ATP /* must match DDP type */
180 #define ATPROTO_ADSP DDP_ADSP /* must match DDP type */
182 #define ATPROTO_DDP 249 /* *** to be eliminated eventually *** */
183 #define ATPROTO_LAP 250 /* *** to be eliminated eventually *** */
185 #define ATPROTO_AURP 251 /* no corresponding DDP type exists */
186 #define ATPROTO_ASP 252 /* no corresponding DDP type exists */
187 #define ATPROTO_AFP 253 /* no corresponding DDP type exists */
189 #define ATPROTO_RAW 255 /* no corresponding DDP type exists */
192 Options for use with [gs]etsockopt at the DDP level.
193 First word of comment is data type; bool is stored in int.
195 #define DDP_CHKSUM_ON 1 /* int; default = FALSE;
196 DDP checksums should be used */
197 #define DDP_HDRINCL 2 /* int; default = FALSE;
198 header is included with data */
199 #define DDP_GETSOCKNAME 3 /* used to get ddp_addr_t */
200 #define DDP_SLFSND_ON 4 /* int; default = FALSE;
201 packets sent to the cable-multicast address
202 on this socket will be looped back */
203 #define DDP_STRIPHDR 5 /* int; default = FALSE;
204 drop DDP header on receive (raw) */
207 AppleTalk protocol retry and timeout
210 typedef struct at_retry
{
211 short interval
; /* Retry interval in seconds */
212 short retries
; /* Maximum number of retries */
213 u_char backoff
; /* Retry backoff, must be 1 through 4 */
217 Basic NBP Definitions needed for AppleTalk framework
222 #define NBP_NVE_STR_SIZE 32 /* Maximum NBP tuple string size */
223 typedef struct at_nvestr
{
225 u_char str
[NBP_NVE_STR_SIZE
];
229 typedef struct at_entity
{
235 #define NBP_TUPLE_SIZE ((3*NBP_NVE_STR_SIZE)+3)
236 /* 3 for field lengths + 3*32 for three names */
237 typedef struct at_nbptuple
{
240 at_entity_t enu_entity
;
244 Basic ATP Definitions needed for LibcAT
247 #define ATP_TRESP_MAX 8 /* Maximum number of Tresp pkts */
249 /* Response buffer structure for atp_sendreq() and atp_sendrsp() */
250 typedef struct at_resp
{
251 u_char bitmap
; /* Bitmap of responses */
252 u_char filler
[3]; /* Force 68K to RISC alignment */
253 struct iovec resp
[ATP_TRESP_MAX
]; /* Buffer for response data */
254 long userdata
[ATP_TRESP_MAX
]; /* Buffer for response user data */
258 Needed for ASP and ADSP
262 int maxlen
; /* max buffer length */
263 int len
; /* length of data */
264 char *buf
; /* pointer to buffer */
267 #define IFID_HOME 1 /* home port in ifID_table */
269 #define ATALK_VALUE(a) ((*(u_long *) &(a))&0x00ffffff)
270 #define ATALK_EQUAL(a, b) (ATALK_VALUE(a) == ATALK_VALUE(b))
272 #define VERSION_LENGTH 80 /* length of version string */
274 /* struture containing general information regarding the state of
275 * the Appletalk networking
277 typedef struct at_state
{
278 unsigned int flags
; /* various init flags */
281 /* at_state_t 'flags' defines */
282 #define AT_ST_STARTED 0x0001 /* set if protocol is fully enabled */
283 #define AT_ST_STARTING 0x0002 /* set if interfaces are configured */
284 #define AT_ST_MULTIHOME 0x0080 /* set if multihome mode */
285 #define AT_ST_ROUTER 0x0100 /* set if we are a router */
286 #define AT_ST_IF_CHANGED 0x0200 /* set when state of any I/F
287 changes (for SNMP) */
288 #define AT_ST_RT_CHANGED 0x0400 /* route table changed (for SNMP)*/
289 #define AT_ST_ZT_CHANGED 0x0800 /* zone table changed (for SNMP) */
290 #define AT_ST_NBP_CHANGED 0x1000 /* if nbp table changed (for SNMP)*/
292 #ifdef KERNEL_PRIVATE
293 extern at_state_t at_state
; /* global state of AT network */
295 #define ROUTING_MODE (at_state.flags & AT_ST_ROUTER)
296 #define MULTIHOME_MODE (at_state.flags & AT_ST_MULTIHOME)
297 #define MULTIPORT_MODE (ROUTING_MODE || MULTIHOME_MODE)
298 #endif /* KERNEL_PRIVATE */
300 /* defines originally from h/at_elap.h */
303 #define AT_ADDR_NO_LOOP 2 /* disables packets from looping back */
305 #endif /* __APPLE_API_OBSOLETE */
306 #endif /* _NETAT_APPLETALK_H_ */