2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1996 Apple Computer, Inc.
33 * Created April 23, 1996, by Justin C. Walker
40 #ifndef _NETAT_AURP_H_
41 #define _NETAT_AURP_H_
42 #include <sys/appleapiopts.h>
44 #ifdef __APPLE_API_OBSOLETE
47 * AURP device ioctl (I_STR) 'subcommands'
49 #define AUC_CFGTNL 0 /* Configure Tunnels */
50 #define AUC_SHTDOWN 1 /* Shutdown AURP */
51 #define AUC_EXPNET 2 /* Configure exported networks */
52 #define AUC_HIDENET 3 /* Configure hidden netowrks */
53 #define AUC_UDPPORT 4 /* UPD Port number */
54 #define AUC_NETLIST 5 /* List of remote endpoints */
55 #define AUC_TIMER 6 /* Configured update interval timer */
56 #define AUC_ADDNET 7 /* Add remote endpoints */
57 #define AUC_ACCEPTALL 8 /* Accept all nets */
58 #define AUC_MAX 9 /* Maximun numbers of access nets */
60 /* Default AURP-over-UDP port */
61 #define AURP_SOCKNUM 387
62 #define AURP_MAXNETACCESS 64
66 #define AURPCODE_REG 0
67 #define AURPCODE_RTMPPKT 1
68 #define AURPCODE_DATAPKT 2
69 #define AURPCODE_AURPPROTO 3
70 #define AURPCODE_DEBUGINFO 10
72 #define AURPCODE_RTINFO 11 /* was used to set up pointers to the
73 routing table, the zone table, and
76 #define AURPCODE_RTUPDATE 12
78 #define AURPSTATE_Unconnected 0
79 #define AURPSTATE_Connected 1
80 #define AURPSTATE_WaitingForOpenRsp 2
81 #define AURPSTATE_WaitingForRIRsp 3
82 #define AURPSTATE_WaitingForTickleAck 4
83 #define AURPSTATE_WaitingForRIAck1 5
84 #define AURPSTATE_WaitingForRIAck2 6
85 #define AURPSTATE_WaitingForRIAck3 7
87 #define AURPCMD_RIReq 1
88 #define AURPCMD_RIRsp 2
89 #define AURPCMD_RIAck 3
90 #define AURPCMD_RIUpd 4
91 #define AURPCMD_RDReq 5
92 #define AURPCMD_ZReq 6
93 #define AURPCMD_ZRsp 7
94 #define AURPCMD_OpenReq 8
95 #define AURPCMD_OpenRsp 9
96 #define AURPCMD_Tickle 14
97 #define AURPCMD_TickleAck 15
99 #define AURPSUBCODE_ZoneInfo1 1
100 #define AURPSUBCODE_ZoneInfo2 2
101 #define AURPSUBCODE_GetZoneNets 3
102 #define AURPSUBCODE_GetDomainZoneList 4
104 #define AURPEV_Null 0
105 #define AURPEV_NetAdded 1
106 #define AURPEV_NetDeleted 2
107 #define AURPEV_NetRouteChange 3
108 #define AURPEV_NetDistChange 4
109 #define AURPEV_NetZoneChange 5
111 #define AURP_Version 1
112 #define AURP_ProbeRetryInterval 300
113 #define AURP_MaxTickleRetry 4
114 #define AURP_TickleRetryInterval 30
115 #define AURP_MaxRetry 10
116 #define AURP_RetryInterval 3
117 #define AURP_UpdateRate 1
118 #define AURP_UDType 0
119 #define AURP_UDNode 1
120 #define AURP_UDSize 2
121 #define AURP_FirstSeqNum 1
122 #define AURP_LastSeqNum 65535
123 #define AURP_MaxPktSize 1400
124 #define AURP_MaxNetAccess 64
125 #define AURP_NetHiden 0x01
127 #define AURPERR_NormalConnectionClose -1
128 #define AURPERR_RoutingLoopDetected -2
129 #define AURPERR_ConnectionOutOfSync -3
130 #define AURPERR_OptionNegotiationError -4
131 #define AURPERR_InvalidVersionNumber -5
132 #define AURPERR_InsufficientResources -6
133 #define AURPERR_AuthenticationError -7
135 #define AURPFLG_NA 0x4000
136 #define AURPFLG_ND 0x2000
137 #define AURPFLG_NDC 0x1000
138 #define AURPFLG_ZC 0x0800
139 #define AURPFLG_RMA 0x4000
140 #define AURPFLG_HCRA 0x2000
141 #define AURPFLG_SZI 0x4000
142 #define AURPFLG_LAST 0x8000
148 unsigned char get_zi
; /* get zone info flag */
149 unsigned char rem_node
; /* node id of a tunnel peer */
150 unsigned char tickle_retry
; /* tickle retry count */
151 unsigned char rcv_retry
; /* data receiver retry count */
152 unsigned char snd_state
; /* data sender state */
153 unsigned char rcv_state
; /* data receiver state */
154 unsigned char filler
[2];
155 unsigned short rcv_update_rate
;
156 unsigned short snd_next_entry
; /* next entry in RT */
157 unsigned short rcv_env
;
158 unsigned short snd_sui
;
159 unsigned short rcv_connection_id
; /* data receiver connection id */
160 unsigned short snd_connection_id
; /* data sender connection id */
161 unsigned short rcv_sequence_number
; /* data receiver sequence number */
162 unsigned short snd_sequence_number
; /* data sender sequence number */
170 * AURP protocol header
173 unsigned short connection_id
;
174 unsigned short sequence_number
;
175 unsigned short command_code
;
176 unsigned short flags
;
179 extern gref_t
*aurp_gref
;
180 extern unsigned char dst_addr_cnt
;
181 extern unsigned char net_access_cnt
;
182 extern unsigned char net_export
;
183 extern unsigned short rcv_connection_id
;
185 extern int update_tmo
;
186 extern aurp_state_t aurp_state
[];
187 extern unsigned short net_access
[];
190 { struct mbuf
*q_head
;
196 #include <sys/uio_internal.h>
199 * Quandry: if we use a single socket, we have to rebind on each call.
200 * If we use separate sockets per tunnel endpoint, we have to examine
201 * each one on wakeup. What to do; what to do?
204 { int src_addr
; /* What's our IP address? */
205 int udp_port
; /* Local UDP port */
206 unsigned short net_access
[AURP_MAXNETACCESS
];
207 long dst_addr
[256]; /* Tunnel 'other ends', passed in from user */
208 int pid
; /* Who are we? */
209 struct socket
*tunnel
; /* IP socket for all IP endpoints */
210 int event
; /* Sleep queue anchor */
211 int event_anchor
; /* Sleep queue anchor */
212 atlock_t glock
; /* aurp_global lock */
213 struct uio auio
; /* Dummy uio struct for soreceive() */
215 unsigned int toosmall
; /* size less than domain header, from UDP */
216 unsigned int no_mbufs
; /* gbuf_to_mbuf failed */
217 unsigned int no_gbufs
; /* mbuf_to_gbuf failed */
218 unsigned int shutdown
; /* shutdown flag */
219 unsigned int running
; /* running flag */
222 #define AE_ATALK 0x01 /* A/talk input event */
223 #define AE_UDPIP 0x02 /* UDP/IP input event */
224 #define AE_SHUTDOWN 0x04 /* Shutdown AURP process */
226 void aurp_wakeup(struct socket
*, caddr_t
, int);
227 struct mbuf
*at_gbuf_to_mbuf(gbuf_t
*);
228 gbuf_t
*at_mbuf_to_gbuf(struct mbuf
*, int);
229 int at_insert(gbuf_t
*m
, unsigned int type
, unsigned int node
);
230 int ddp_AURPfuncx(int code
, void *param
, unsigned char node
);
232 int aurpd_start(void);
233 void atalk_to_ip(gbuf_t
*m
);
234 void AURPaccess(void);
235 void AURPshutdown(void);
236 void AURPiocack(gref_t
*gref
, gbuf_t
*m
);
237 void AURPiocnak(gref_t
*gref
, gbuf_t
*m
, int error
);
238 void AURPsndZReq(aurp_state_t
*state
);
239 void AURPsndZRsp(aurp_state_t
*state
, gbuf_t
*dat_m
, int flag
);
240 void AURPsndRIUpd(aurp_state_t
*state
);
241 void AURPsndRIReq(aurp_state_t
*state
);
242 void AURPsndRIAck(aurp_state_t
*state
, gbuf_t
*m
, unsigned short flags
);
243 void AURPsndOpenReq(aurp_state_t
*state
);
244 void AURPsndRDReq(aurp_state_t
*state
);
245 void AURPrcvZReq(aurp_state_t
*state
, gbuf_t
*m
);
246 void AURPrcvZRsp(aurp_state_t
*state
, gbuf_t
*m
);
247 void AURPrcvRIUpd(aurp_state_t
*state
, gbuf_t
*m
);
248 void AURPrcvRIReq(aurp_state_t
*state
, gbuf_t
*m
);
249 void AURPrcvRIAck(aurp_state_t
*state
, gbuf_t
*m
);
250 void AURPrcvRIRsp(aurp_state_t
*state
, gbuf_t
*m
);
251 void AURPrcvOpenReq(aurp_state_t
*state
, gbuf_t
*m
);
252 void AURPrcvOpenRsp(aurp_state_t
*state
, gbuf_t
*m
);
253 void AURPrcvTickle(aurp_state_t
*state
, gbuf_t
*m
);
254 void AURPrcvTickleAck(aurp_state_t
*state
, gbuf_t
*m
);
255 void AURPrcvRDReq(aurp_state_t
*state
, gbuf_t
*m
);
256 void AURPfreemsg(gbuf_t
*m
);
257 void AURPrtupdate(RT_entry
*entry
, unsigned char ev
);
258 void AURPsend(gbuf_t
*mdata
, int type
, int node
);
259 void AURPcleanup(aurp_state_t
*state
);
260 void AURPpurgeri(unsigned char node
);
261 int AURPgetri(short next_entry
, unsigned char *buf
, short *len
);
262 int AURPsetri(unsigned char node
, gbuf_t
*m
);
263 int AURPupdateri(unsigned char node
, gbuf_t
*m
);
265 /* AURP header for IP tunneling */
266 typedef struct aurp_domain
269 short dst_distinguisher
;
273 short src_distinguisher
;
280 /* AURP/domain header constants */
281 #define AUD_Version 0x1
282 #define AUD_Atalk 0x2
285 /* IP domain identifier constants */
287 #define IP_AUTHORITY 1
288 #define IP_DISTINGUISHER 0
289 /* Need this because the )(*&^%$#@ compiler rounds up the size */
290 #define IP_DOMAINSIZE 22
292 /****### LD 9/26/97*/
293 extern struct aurp_global_t aurp_global
;
294 #endif /* KERNEL_PRIVATE */
295 #endif /* __APPLE_API_OBSOLETE */
296 #endif /* _NETAT_AURP_H_ */
298 #endif /* AURP_SUPPORT */