]>
Commit | Line | Data |
---|---|---|
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 8, 1996 by Tuyen Nguyen | |
32 | * Modified for Kernel execution, May, 1996, Justin C. Walker | |
33 | * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX. | |
34 | * | |
35 | * File: rx.c | |
36 | */ | |
0c530ab8 A |
37 | #ifdef AURP_SUPPORT |
38 | ||
1c79356b A |
39 | #include <sys/errno.h> |
40 | #include <sys/types.h> | |
41 | #include <sys/param.h> | |
42 | #include <machine/spl.h> | |
43 | #include <sys/systm.h> | |
44 | #include <sys/kernel.h> | |
45 | #include <sys/proc.h> | |
46 | #include <sys/filedesc.h> | |
47 | #include <sys/fcntl.h> | |
48 | #include <sys/mbuf.h> | |
49 | #include <sys/socket.h> | |
50 | #include <sys/socketvar.h> | |
51 | #include <net/if.h> | |
52 | ||
53 | #include <netat/sysglue.h> | |
54 | #include <netat/appletalk.h> | |
2d21ac55 | 55 | #include <netat/at_pcb.h> |
1c79356b A |
56 | #include <netat/at_var.h> |
57 | #include <netat/routing_tables.h> | |
1c79356b A |
58 | #include <netat/aurp.h> |
59 | #include <netat/debug.h> | |
60 | ||
61 | /* | |
62 | * Not using the stream queue for data; keep this around to handle | |
63 | * requests from the user proc (mostly setup). | |
64 | */ | |
65 | int | |
66 | aurp_wput(gref, m) | |
67 | gref_t *gref; | |
68 | gbuf_t *m; | |
69 | { | |
70 | register ioc_t *iocbp; | |
71 | register gbuf_t *mdata; | |
72 | register int temp, error; | |
73 | ||
74 | switch (gbuf_type(m)) { | |
75 | ||
76 | case MSG_IOCTL: | |
77 | iocbp = (ioc_t *)gbuf_rptr(m); | |
78 | switch (iocbp->ioc_cmd) { | |
79 | case AUC_CFGTNL: /* set up a tunnel, init the AURP daemon */ | |
80 | mdata = gbuf_cont(m); | |
81 | temp = (int)(*gbuf_rptr(mdata)); | |
82 | if (temp != dst_addr_cnt) { | |
83 | AURPiocnak(gref, m, ENOSPC); | |
84 | return 0; | |
85 | } | |
86 | if ((error = aurpd_start()) != 0) { | |
87 | AURPiocnak(gref, m, error); | |
88 | return 0; | |
89 | } | |
90 | if (AURPinit()) { | |
91 | AURPiocnak(gref, m, ENOMEM); | |
92 | return 0; | |
93 | } | |
94 | ddp_AURPfuncx(AURPCODE_AURPPROTO, 0, 0); | |
95 | AURPaccess(); | |
96 | break; | |
97 | ||
98 | case AUC_SHTDOWN: /* shutdown AURP operation */ | |
99 | AURPshutdown(); | |
100 | break; | |
101 | ||
102 | case AUC_EXPNET: /* configure networks to be exported */ | |
103 | case AUC_HIDENET: /* configure networks to be hiden */ | |
104 | mdata = gbuf_cont(m); | |
105 | net_access_cnt = (gbuf_len(mdata))/sizeof(short); | |
106 | if ((net_access_cnt==0) || (net_access_cnt>AURP_MaxNetAccess)) { | |
107 | AURPiocnak(gref, m, EINVAL); | |
108 | return 0; | |
109 | } | |
110 | bcopy(gbuf_rptr(mdata), net_access, | |
111 | gbuf_len(mdata)); | |
112 | if (iocbp->ioc_cmd == AUC_EXPNET) | |
113 | net_export = 1; | |
114 | break; | |
115 | ||
116 | case AUC_UDPPORT: | |
91447636 | 117 | mdata = gbuf_cont(m); |
1c79356b A |
118 | aurp_global.udp_port = *(char *)gbuf_rptr(mdata); |
119 | break; | |
120 | ||
121 | case AUC_NETLIST: | |
122 | mdata = gbuf_cont(m); | |
123 | /* | |
124 | * Compute # addrs, Save for later check | |
125 | * We cheat with a shift. | |
126 | */ | |
127 | dst_addr_cnt = ((gbuf_len(mdata)) >> 2)-1; | |
128 | bcopy(gbuf_rptr(mdata), &aurp_global.dst_addr, | |
129 | gbuf_len(mdata)); | |
130 | aurp_global.src_addr = aurp_global.dst_addr[0]; | |
131 | aurp_global.dst_addr[0] = 0; | |
132 | break; | |
133 | ||
134 | default: | |
135 | AURPiocnak(gref, m, EINVAL); | |
136 | return 0; | |
137 | } | |
138 | AURPiocack(gref, m); | |
139 | break; | |
140 | ||
141 | default: | |
142 | dPrintf(D_M_AURP, D_L_WARNING, | |
143 | ("aurp_wput: bad msg type=%d\n", gbuf_type(m))); | |
144 | gbuf_freem(m); | |
145 | break; | |
146 | } | |
147 | ||
148 | return 0; | |
149 | } | |
150 | ||
151 | /* | |
152 | * Insert an appletalk packet into the appletalk stack. | |
153 | * If it's an AURP data packet, just send it up; if it's AURP protocol, | |
154 | * switch out here. | |
155 | */ | |
156 | ||
157 | int | |
158 | at_insert(m, type, node) | |
159 | register gbuf_t *m; | |
160 | register unsigned int type, node; | |
161 | { | |
162 | register aurp_hdr_t *hdrp; | |
163 | register aurp_state_t *state; | |
164 | ||
165 | if (type == AUD_Atalk) | |
166 | /* non-AURP proto packet */ | |
167 | ddp_AURPfuncx(AURPCODE_DATAPKT, m, node); | |
168 | else | |
169 | { /* AURP proto packet */ | |
170 | state = (aurp_state_t *)&aurp_state[node]; | |
171 | state->tickle_retry = 0; | |
172 | hdrp = (aurp_hdr_t *)gbuf_rptr(m); | |
173 | ||
174 | switch (hdrp->command_code) { | |
175 | case AURPCMD_RIUpd: | |
176 | AURPrcvRIUpd(state, m); break; | |
177 | ||
178 | case AURPCMD_RIReq: | |
179 | AURPrcvRIReq(state, m); break; | |
180 | ||
181 | case AURPCMD_RIRsp: | |
182 | AURPrcvRIRsp(state, m); break; | |
183 | ||
184 | case AURPCMD_RIAck: | |
185 | AURPrcvRIAck(state, m); break; | |
186 | ||
187 | case AURPCMD_ZReq: | |
188 | AURPrcvZReq(state, m); break; | |
189 | ||
190 | case AURPCMD_ZRsp: | |
191 | AURPrcvZRsp(state, m); break; | |
192 | ||
193 | case AURPCMD_OpenReq: | |
194 | AURPrcvOpenReq(state, m); break; | |
195 | ||
196 | case AURPCMD_OpenRsp: | |
197 | AURPrcvOpenRsp(state, m); break; | |
198 | ||
199 | case AURPCMD_Tickle: | |
200 | AURPrcvTickle(state, m); break; | |
201 | ||
202 | case AURPCMD_TickleAck: | |
203 | AURPrcvTickleAck(state, m); break; | |
204 | ||
205 | case AURPCMD_RDReq: | |
206 | AURPrcvRDReq(state, m); break; | |
207 | ||
208 | default: | |
209 | dPrintf(D_M_AURP, D_L_WARNING, | |
210 | ("at_insert: bad proto cmd=%d\n", | |
211 | hdrp->command_code)); | |
212 | gbuf_freem(m); | |
213 | } | |
214 | } | |
215 | ||
216 | return 0; | |
217 | } | |
0c530ab8 | 218 | |
2d21ac55 | 219 | #endif /* AURP_SUPPORT */ |