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