]> git.saurik.com Git - apple/xnu.git/blame - bsd/netat/aurp.h
xnu-344.49.tar.gz
[apple/xnu.git] / bsd / netat / aurp.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * Copyright (c) 1996 Apple Computer, Inc.
27 *
28 * Created April 23, 1996, by Justin C. Walker
29 *
30 * File: aurp.h
31 */
32
33#ifndef _NETAT_AURP_H_
34#define _NETAT_AURP_H_
9bccf70c 35#include <sys/appleapiopts.h>
1c79356b
A
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
9bccf70c 56#ifdef __APPLE_API_PRIVATE
1c79356b
A
57
58#define AURPCODE_REG 0
59#define AURPCODE_RTMPPKT 1
60#define AURPCODE_DATAPKT 2
61#define AURPCODE_AURPPROTO 3
62#define AURPCODE_DEBUGINFO 10
63#ifdef NOT_USED
64#define AURPCODE_RTINFO 11 /* was used to set up pointers to the
65 routing table, the zone table, and
66 several functions */
67#endif
68#define AURPCODE_RTUPDATE 12
69
70#define AURPSTATE_Unconnected 0
71#define AURPSTATE_Connected 1
72#define AURPSTATE_WaitingForOpenRsp 2
73#define AURPSTATE_WaitingForRIRsp 3
74#define AURPSTATE_WaitingForTickleAck 4
75#define AURPSTATE_WaitingForRIAck1 5
76#define AURPSTATE_WaitingForRIAck2 6
77#define AURPSTATE_WaitingForRIAck3 7
78
79#define AURPCMD_RIReq 1
80#define AURPCMD_RIRsp 2
81#define AURPCMD_RIAck 3
82#define AURPCMD_RIUpd 4
83#define AURPCMD_RDReq 5
84#define AURPCMD_ZReq 6
85#define AURPCMD_ZRsp 7
86#define AURPCMD_OpenReq 8
87#define AURPCMD_OpenRsp 9
88#define AURPCMD_Tickle 14
89#define AURPCMD_TickleAck 15
90
91#define AURPSUBCODE_ZoneInfo1 1
92#define AURPSUBCODE_ZoneInfo2 2
93#define AURPSUBCODE_GetZoneNets 3
94#define AURPSUBCODE_GetDomainZoneList 4
95
96#define AURPEV_Null 0
97#define AURPEV_NetAdded 1
98#define AURPEV_NetDeleted 2
99#define AURPEV_NetRouteChange 3
100#define AURPEV_NetDistChange 4
101#define AURPEV_NetZoneChange 5
102
103#define AURP_Version 1
104#define AURP_ProbeRetryInterval 300
105#define AURP_MaxTickleRetry 4
106#define AURP_TickleRetryInterval 30
107#define AURP_MaxRetry 10
108#define AURP_RetryInterval 3
109#define AURP_UpdateRate 1
110#define AURP_UDType 0
111#define AURP_UDNode 1
112#define AURP_UDSize 2
113#define AURP_FirstSeqNum 1
114#define AURP_LastSeqNum 65535
115#define AURP_MaxPktSize 1400
116#define AURP_MaxNetAccess 64
117#define AURP_NetHiden 0x01
118
119#define AURPERR_NormalConnectionClose -1
120#define AURPERR_RoutingLoopDetected -2
121#define AURPERR_ConnectionOutOfSync -3
122#define AURPERR_OptionNegotiationError -4
123#define AURPERR_InvalidVersionNumber -5
124#define AURPERR_InsufficientResources -6
125#define AURPERR_AuthenticationError -7
126
127#define AURPFLG_NA 0x4000
128#define AURPFLG_ND 0x2000
129#define AURPFLG_NDC 0x1000
130#define AURPFLG_ZC 0x0800
131#define AURPFLG_RMA 0x4000
132#define AURPFLG_HCRA 0x2000
133#define AURPFLG_SZI 0x4000
134#define AURPFLG_LAST 0x8000
135
136/*
137 * AURP state block
138 */
139typedef struct {
140 unsigned char get_zi; /* get zone info flag */
141 unsigned char rem_node; /* node id of a tunnel peer */
142 unsigned char tickle_retry; /* tickle retry count */
143 unsigned char rcv_retry; /* data receiver retry count */
144 unsigned char snd_state; /* data sender state */
145 unsigned char rcv_state; /* data receiver state */
146 unsigned char filler[2];
147 unsigned short rcv_update_rate;
148 unsigned short snd_next_entry; /* next entry in RT */
149 unsigned short rcv_env;
150 unsigned short snd_sui;
151 unsigned short rcv_connection_id; /* data receiver connection id */
152 unsigned short snd_connection_id; /* data sender connection id */
153 unsigned short rcv_sequence_number; /* data receiver sequence number */
154 unsigned short snd_sequence_number; /* data sender sequence number */
155 int rcv_tmo;
156 int snd_tmo;
157 gbuf_t *rsp_m;
158 gbuf_t *upd_m;
159} aurp_state_t;
160
161/*
162 * AURP protocol header
163 */
164typedef struct {
165 unsigned short connection_id;
166 unsigned short sequence_number;
167 unsigned short command_code;
168 unsigned short flags;
169} aurp_hdr_t;
170
1c79356b
A
171#ifdef AURP_SUPPORT
172
173extern atlock_t aurpgen_lock;
174extern gref_t *aurp_gref;
175extern unsigned char dst_addr_cnt;
176extern unsigned char net_access_cnt;
177extern unsigned char net_export;
178extern unsigned short rcv_connection_id;
179extern int net_port;
180extern int update_tmo;
181extern aurp_state_t aurp_state[];
182extern unsigned short net_access[];
183#endif
184
185struct myq
186{ struct mbuf *q_head;
187 struct mbuf *q_tail;
188 int q_cnt;
189};
190
191#define LOCK_DECL(x) atlock_t x
192
193/*
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?
197 */
198struct aurp_global_t
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() */
209 /* Statistics */
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 */
215};
216
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 */
220
221void aurp_wakeup __P((struct socket *, caddr_t, int));
222struct mbuf *at_gbuf_to_mbuf __P((gbuf_t *));
223gbuf_t *at_mbuf_to_gbuf __P((struct mbuf *, int));
224int at_insert __P((gbuf_t *m, unsigned int type, unsigned int node));
225int ddp_AURPfuncx __P((int code, void *param, unsigned char node));
226int AURPinit __P((void));
227int aurpd_start __P((void));
228void atalk_to_ip __P((gbuf_t *m));
229void AURPaccess __P((void));
230void AURPshutdown __P((void));
231void AURPiocack __P((gref_t *gref, gbuf_t *m));
232void AURPiocnak __P((gref_t *gref, gbuf_t *m, int error));
233void AURPsndZReq __P((aurp_state_t *state));
234void AURPsndZRsp __P((aurp_state_t *state, gbuf_t *dat_m, int flag));
235void AURPsndRIUpd __P((aurp_state_t *state));
236void AURPsndRIReq __P((aurp_state_t *state));
237void AURPsndRIAck __P((aurp_state_t *state, gbuf_t *m, unsigned short flags));
238void AURPsndOpenReq __P((aurp_state_t *state));
239void AURPsndRDReq __P((aurp_state_t *state));
240void AURPrcvZReq __P((aurp_state_t *state, gbuf_t *m));
241void AURPrcvZRsp __P((aurp_state_t *state, gbuf_t *m));
242void AURPrcvRIUpd __P((aurp_state_t *state, gbuf_t *m));
243void AURPrcvRIReq __P((aurp_state_t *state, gbuf_t *m));
244void AURPrcvRIAck __P((aurp_state_t *state, gbuf_t *m));
245void AURPrcvRIRsp __P((aurp_state_t *state, gbuf_t *m));
246void AURPrcvOpenReq __P((aurp_state_t *state, gbuf_t *m));
247void AURPrcvOpenRsp __P((aurp_state_t *state, gbuf_t *m));
248void AURPrcvTickle __P((aurp_state_t *state, gbuf_t *m));
249void AURPrcvTickleAck __P((aurp_state_t *state, gbuf_t *m));
250void AURPrcvRDReq __P((aurp_state_t *state, gbuf_t *m));
251void AURPfreemsg __P((gbuf_t *m));
252void AURPrtupdate __P((RT_entry *entry, unsigned char ev));
253void AURPsend __P((gbuf_t *mdata, int type, int node));
254void AURPcleanup __P((aurp_state_t *state));
255void AURPpurgeri __P((unsigned char node));
256int AURPgetri __P((short next_entry, unsigned char *buf, short *len));
257int AURPsetri __P((unsigned char node, gbuf_t *m));
258int AURPupdateri __P((unsigned char node, gbuf_t *m));
259
1c79356b
A
260/* AURP header for IP tunneling */
261typedef struct aurp_domain
262{ char dst_length;
263 char dst_authority;
264 short dst_distinguisher;
265 long dst_address;
266 char src_length;
267 char src_authority;
268 short src_distinguisher;
269 long src_address;
270 short version;
271 short reserved;
272 short type;
273} aurp_domain_t;
274
275/* AURP/domain header constants */
276#define AUD_Version 0x1
277#define AUD_Atalk 0x2
278#define AUD_AURP 0x3
279
280/* IP domain identifier constants */
281#define IP_LENGTH 7
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
286
287/****### LD 9/26/97*/
288extern struct aurp_global_t aurp_global;
9bccf70c 289#endif /* __APPLE_API_PRIVATE */
1c79356b
A
290#endif /* KERNEL */
291#endif /* _NETAT_AURP_H_ */