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