]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
8f6c56a5 | 11 | * |
6601e61a A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
21 | */ |
22 | /* | |
23 | * Copyright (c) 1996 Apple Computer, Inc. | |
24 | * | |
25 | * Created April 8, 1996 by Tuyen Nguyen | |
26 | * Modified for Kernel execution, May, 1996, Justin C. Walker | |
27 | * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX. | |
28 | * | |
29 | * File: rx.c | |
30 | */ | |
31 | #include <sys/errno.h> | |
32 | #include <sys/types.h> | |
33 | #include <sys/param.h> | |
34 | #include <machine/spl.h> | |
35 | #include <sys/systm.h> | |
36 | #include <sys/kernel.h> | |
37 | #include <sys/proc.h> | |
38 | #include <sys/filedesc.h> | |
39 | #include <sys/fcntl.h> | |
40 | #include <sys/mbuf.h> | |
41 | #include <sys/socket.h> | |
42 | #include <sys/socketvar.h> | |
43 | #include <net/if.h> | |
44 | ||
45 | #include <netat/sysglue.h> | |
46 | #include <netat/appletalk.h> | |
47 | #include <netat/at_var.h> | |
48 | #include <netat/routing_tables.h> | |
49 | #include <netat/at_pcb.h> | |
50 | #include <netat/aurp.h> | |
51 | #include <netat/debug.h> | |
52 | ||
53 | /* | |
54 | * Not using the stream queue for data; keep this around to handle | |
55 | * requests from the user proc (mostly setup). | |
56 | */ | |
57 | int | |
58 | aurp_wput(gref, m) | |
59 | gref_t *gref; | |
60 | gbuf_t *m; | |
61 | { | |
62 | register ioc_t *iocbp; | |
63 | register gbuf_t *mdata; | |
64 | register int temp, error; | |
65 | ||
66 | switch (gbuf_type(m)) { | |
67 | ||
68 | case MSG_IOCTL: | |
69 | iocbp = (ioc_t *)gbuf_rptr(m); | |
70 | switch (iocbp->ioc_cmd) { | |
71 | case AUC_CFGTNL: /* set up a tunnel, init the AURP daemon */ | |
72 | mdata = gbuf_cont(m); | |
73 | temp = (int)(*gbuf_rptr(mdata)); | |
74 | if (temp != dst_addr_cnt) { | |
75 | AURPiocnak(gref, m, ENOSPC); | |
76 | return 0; | |
77 | } | |
78 | if ((error = aurpd_start()) != 0) { | |
79 | AURPiocnak(gref, m, error); | |
80 | return 0; | |
81 | } | |
82 | if (AURPinit()) { | |
83 | AURPiocnak(gref, m, ENOMEM); | |
84 | return 0; | |
85 | } | |
86 | ddp_AURPfuncx(AURPCODE_AURPPROTO, 0, 0); | |
87 | AURPaccess(); | |
88 | break; | |
89 | ||
90 | case AUC_SHTDOWN: /* shutdown AURP operation */ | |
91 | AURPshutdown(); | |
92 | break; | |
93 | ||
94 | case AUC_EXPNET: /* configure networks to be exported */ | |
95 | case AUC_HIDENET: /* configure networks to be hiden */ | |
96 | mdata = gbuf_cont(m); | |
97 | net_access_cnt = (gbuf_len(mdata))/sizeof(short); | |
98 | if ((net_access_cnt==0) || (net_access_cnt>AURP_MaxNetAccess)) { | |
99 | AURPiocnak(gref, m, EINVAL); | |
100 | return 0; | |
101 | } | |
102 | bcopy(gbuf_rptr(mdata), net_access, | |
103 | gbuf_len(mdata)); | |
104 | if (iocbp->ioc_cmd == AUC_EXPNET) | |
105 | net_export = 1; | |
106 | break; | |
107 | ||
108 | case AUC_UDPPORT: | |
91447636 | 109 | mdata = gbuf_cont(m); |
1c79356b A |
110 | aurp_global.udp_port = *(char *)gbuf_rptr(mdata); |
111 | break; | |
112 | ||
113 | case AUC_NETLIST: | |
114 | mdata = gbuf_cont(m); | |
115 | /* | |
116 | * Compute # addrs, Save for later check | |
117 | * We cheat with a shift. | |
118 | */ | |
119 | dst_addr_cnt = ((gbuf_len(mdata)) >> 2)-1; | |
120 | bcopy(gbuf_rptr(mdata), &aurp_global.dst_addr, | |
121 | gbuf_len(mdata)); | |
122 | aurp_global.src_addr = aurp_global.dst_addr[0]; | |
123 | aurp_global.dst_addr[0] = 0; | |
124 | break; | |
125 | ||
126 | default: | |
127 | AURPiocnak(gref, m, EINVAL); | |
128 | return 0; | |
129 | } | |
130 | AURPiocack(gref, m); | |
131 | break; | |
132 | ||
133 | default: | |
134 | dPrintf(D_M_AURP, D_L_WARNING, | |
135 | ("aurp_wput: bad msg type=%d\n", gbuf_type(m))); | |
136 | gbuf_freem(m); | |
137 | break; | |
138 | } | |
139 | ||
140 | return 0; | |
141 | } | |
142 | ||
143 | /* | |
144 | * Insert an appletalk packet into the appletalk stack. | |
145 | * If it's an AURP data packet, just send it up; if it's AURP protocol, | |
146 | * switch out here. | |
147 | */ | |
148 | ||
149 | int | |
150 | at_insert(m, type, node) | |
151 | register gbuf_t *m; | |
152 | register unsigned int type, node; | |
153 | { | |
154 | register aurp_hdr_t *hdrp; | |
155 | register aurp_state_t *state; | |
156 | ||
157 | if (type == AUD_Atalk) | |
158 | /* non-AURP proto packet */ | |
159 | ddp_AURPfuncx(AURPCODE_DATAPKT, m, node); | |
160 | else | |
161 | { /* AURP proto packet */ | |
162 | state = (aurp_state_t *)&aurp_state[node]; | |
163 | state->tickle_retry = 0; | |
164 | hdrp = (aurp_hdr_t *)gbuf_rptr(m); | |
165 | ||
166 | switch (hdrp->command_code) { | |
167 | case AURPCMD_RIUpd: | |
168 | AURPrcvRIUpd(state, m); break; | |
169 | ||
170 | case AURPCMD_RIReq: | |
171 | AURPrcvRIReq(state, m); break; | |
172 | ||
173 | case AURPCMD_RIRsp: | |
174 | AURPrcvRIRsp(state, m); break; | |
175 | ||
176 | case AURPCMD_RIAck: | |
177 | AURPrcvRIAck(state, m); break; | |
178 | ||
179 | case AURPCMD_ZReq: | |
180 | AURPrcvZReq(state, m); break; | |
181 | ||
182 | case AURPCMD_ZRsp: | |
183 | AURPrcvZRsp(state, m); break; | |
184 | ||
185 | case AURPCMD_OpenReq: | |
186 | AURPrcvOpenReq(state, m); break; | |
187 | ||
188 | case AURPCMD_OpenRsp: | |
189 | AURPrcvOpenRsp(state, m); break; | |
190 | ||
191 | case AURPCMD_Tickle: | |
192 | AURPrcvTickle(state, m); break; | |
193 | ||
194 | case AURPCMD_TickleAck: | |
195 | AURPrcvTickleAck(state, m); break; | |
196 | ||
197 | case AURPCMD_RDReq: | |
198 | AURPrcvRDReq(state, m); break; | |
199 | ||
200 | default: | |
201 | dPrintf(D_M_AURP, D_L_WARNING, | |
202 | ("at_insert: bad proto cmd=%d\n", | |
203 | hdrp->command_code)); | |
204 | gbuf_freem(m); | |
205 | } | |
206 | } | |
207 | ||
208 | return 0; | |
209 | } |