]> git.saurik.com Git - apple/xnu.git/blame - bsd/netat/aurp.h
xnu-1228.15.4.tar.gz
[apple/xnu.git] / bsd / netat / aurp.h
CommitLineData
1c79356b 1/*
5d5c5d0d
A
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
8f6c56a5 25 *
2d21ac55 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
0c530ab8
A
36#ifdef AURP_SUPPORT
37
1c79356b
A
38#ifndef _NETAT_AURP_H_
39#define _NETAT_AURP_H_
9bccf70c 40#include <sys/appleapiopts.h>
1c79356b 41
91447636
A
42#ifdef __APPLE_API_OBSOLETE
43
1c79356b
A
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
91447636 62#ifdef KERNEL_PRIVATE
1c79356b
A
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 */
145typedef 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 */
170typedef 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
1c79356b
A
177extern gref_t *aurp_gref;
178extern unsigned char dst_addr_cnt;
179extern unsigned char net_access_cnt;
180extern unsigned char net_export;
181extern unsigned short rcv_connection_id;
182extern int net_port;
183extern int update_tmo;
184extern aurp_state_t aurp_state[];
185extern unsigned short net_access[];
1c79356b
A
186
187struct myq
188{ struct mbuf *q_head;
189 struct mbuf *q_tail;
190 int q_cnt;
191};
192
1c79356b 193
91447636
A
194#include <sys/uio_internal.h>
195
1c79356b
A
196/*
197 * Quandry: if we use a single socket, we have to rebind on each call.
198 * If we use separate sockets per tunnel endpoint, we have to examine
199 * each one on wakeup. What to do; what to do?
200 */
201struct aurp_global_t
202{ int src_addr; /* What's our IP address? */
203 int udp_port; /* Local UDP port */
204 unsigned short net_access[AURP_MAXNETACCESS];
205 long dst_addr[256]; /* Tunnel 'other ends', passed in from user */
206 int pid; /* Who are we? */
207 struct socket *tunnel; /* IP socket for all IP endpoints */
208 int event; /* Sleep queue anchor */
209 int event_anchor; /* Sleep queue anchor */
210 atlock_t glock; /* aurp_global lock */
211 struct uio auio; /* Dummy uio struct for soreceive() */
212 /* Statistics */
213 unsigned int toosmall; /* size less than domain header, from UDP */
214 unsigned int no_mbufs; /* gbuf_to_mbuf failed */
215 unsigned int no_gbufs; /* mbuf_to_gbuf failed */
216 unsigned int shutdown; /* shutdown flag */
217 unsigned int running; /* running flag */
218};
219
220#define AE_ATALK 0x01 /* A/talk input event */
221#define AE_UDPIP 0x02 /* UDP/IP input event */
222#define AE_SHUTDOWN 0x04 /* Shutdown AURP process */
223
91447636
A
224void aurp_wakeup(struct socket *, caddr_t, int);
225struct mbuf *at_gbuf_to_mbuf(gbuf_t *);
226gbuf_t *at_mbuf_to_gbuf(struct mbuf *, int);
227int at_insert(gbuf_t *m, unsigned int type, unsigned int node);
228int ddp_AURPfuncx(int code, void *param, unsigned char node);
229int AURPinit(void);
230int aurpd_start(void);
231void atalk_to_ip(gbuf_t *m);
232void AURPaccess(void);
233void AURPshutdown(void);
234void AURPiocack(gref_t *gref, gbuf_t *m);
235void AURPiocnak(gref_t *gref, gbuf_t *m, int error);
236void AURPsndZReq(aurp_state_t *state);
237void AURPsndZRsp(aurp_state_t *state, gbuf_t *dat_m, int flag);
238void AURPsndRIUpd(aurp_state_t *state);
239void AURPsndRIReq(aurp_state_t *state);
240void AURPsndRIAck(aurp_state_t *state, gbuf_t *m, unsigned short flags);
241void AURPsndOpenReq(aurp_state_t *state);
242void AURPsndRDReq(aurp_state_t *state);
243void AURPrcvZReq(aurp_state_t *state, gbuf_t *m);
244void AURPrcvZRsp(aurp_state_t *state, gbuf_t *m);
245void AURPrcvRIUpd(aurp_state_t *state, gbuf_t *m);
246void AURPrcvRIReq(aurp_state_t *state, gbuf_t *m);
247void AURPrcvRIAck(aurp_state_t *state, gbuf_t *m);
248void AURPrcvRIRsp(aurp_state_t *state, gbuf_t *m);
249void AURPrcvOpenReq(aurp_state_t *state, gbuf_t *m);
250void AURPrcvOpenRsp(aurp_state_t *state, gbuf_t *m);
251void AURPrcvTickle(aurp_state_t *state, gbuf_t *m);
252void AURPrcvTickleAck(aurp_state_t *state, gbuf_t *m);
253void AURPrcvRDReq(aurp_state_t *state, gbuf_t *m);
254void AURPfreemsg(gbuf_t *m);
255void AURPrtupdate(RT_entry *entry, unsigned char ev);
256void AURPsend(gbuf_t *mdata, int type, int node);
257void AURPcleanup(aurp_state_t *state);
258void AURPpurgeri(unsigned char node);
259int AURPgetri(short next_entry, unsigned char *buf, short *len);
260int AURPsetri(unsigned char node, gbuf_t *m);
261int AURPupdateri(unsigned char node, gbuf_t *m);
1c79356b 262
1c79356b
A
263/* AURP header for IP tunneling */
264typedef struct aurp_domain
265{ char dst_length;
266 char dst_authority;
267 short dst_distinguisher;
268 long dst_address;
269 char src_length;
270 char src_authority;
271 short src_distinguisher;
272 long src_address;
273 short version;
274 short reserved;
275 short type;
276} aurp_domain_t;
277
278/* AURP/domain header constants */
279#define AUD_Version 0x1
280#define AUD_Atalk 0x2
281#define AUD_AURP 0x3
282
283/* IP domain identifier constants */
284#define IP_LENGTH 7
285#define IP_AUTHORITY 1
286#define IP_DISTINGUISHER 0
287/* Need this because the )(*&^%$#@ compiler rounds up the size */
288#define IP_DOMAINSIZE 22
289
290/****### LD 9/26/97*/
291extern struct aurp_global_t aurp_global;
91447636
A
292#endif /* KERNEL_PRIVATE */
293#endif /* __APPLE_API_OBSOLETE */
1c79356b 294#endif /* _NETAT_AURP_H_ */
0c530ab8 295
2d21ac55 296#endif /* AURP_SUPPORT */