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