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