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