]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/aurp_rx.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1996 Apple Computer, Inc.
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.
37 #include <sys/errno.h>
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <machine/spl.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
44 #include <sys/filedesc.h>
45 #include <sys/fcntl.h>
47 #include <sys/socket.h>
48 #include <sys/socketvar.h>
51 #include <netat/sysglue.h>
52 #include <netat/appletalk.h>
53 #include <netat/at_var.h>
54 #include <netat/routing_tables.h>
55 #include <netat/at_pcb.h>
56 #include <netat/aurp.h>
57 #include <netat/debug.h>
60 * Not using the stream queue for data; keep this around to handle
61 * requests from the user proc (mostly setup).
68 register ioc_t
*iocbp
;
69 register gbuf_t
*mdata
;
70 register int temp
, error
;
72 switch (gbuf_type(m
)) {
75 iocbp
= (ioc_t
*)gbuf_rptr(m
);
76 switch (iocbp
->ioc_cmd
) {
77 case AUC_CFGTNL
: /* set up a tunnel, init the AURP daemon */
79 temp
= (int)(*gbuf_rptr(mdata
));
80 if (temp
!= dst_addr_cnt
) {
81 AURPiocnak(gref
, m
, ENOSPC
);
84 if ((error
= aurpd_start()) != 0) {
85 AURPiocnak(gref
, m
, error
);
89 AURPiocnak(gref
, m
, ENOMEM
);
92 ddp_AURPfuncx(AURPCODE_AURPPROTO
, 0, 0);
96 case AUC_SHTDOWN
: /* shutdown AURP operation */
100 case AUC_EXPNET
: /* configure networks to be exported */
101 case AUC_HIDENET
: /* configure networks to be hiden */
102 mdata
= gbuf_cont(m
);
103 net_access_cnt
= (gbuf_len(mdata
))/sizeof(short);
104 if ((net_access_cnt
==0) || (net_access_cnt
>AURP_MaxNetAccess
)) {
105 AURPiocnak(gref
, m
, EINVAL
);
108 bcopy(gbuf_rptr(mdata
), net_access
,
110 if (iocbp
->ioc_cmd
== AUC_EXPNET
)
115 mdata
= gbuf_cont(m
);
116 aurp_global
.udp_port
= *(char *)gbuf_rptr(mdata
);
120 mdata
= gbuf_cont(m
);
122 * Compute # addrs, Save for later check
123 * We cheat with a shift.
125 dst_addr_cnt
= ((gbuf_len(mdata
)) >> 2)-1;
126 bcopy(gbuf_rptr(mdata
), &aurp_global
.dst_addr
,
128 aurp_global
.src_addr
= aurp_global
.dst_addr
[0];
129 aurp_global
.dst_addr
[0] = 0;
133 AURPiocnak(gref
, m
, EINVAL
);
140 dPrintf(D_M_AURP
, D_L_WARNING
,
141 ("aurp_wput: bad msg type=%d\n", gbuf_type(m
)));
150 * Insert an appletalk packet into the appletalk stack.
151 * If it's an AURP data packet, just send it up; if it's AURP protocol,
156 at_insert(m
, type
, node
)
158 register unsigned int type
, node
;
160 register aurp_hdr_t
*hdrp
;
161 register aurp_state_t
*state
;
163 if (type
== AUD_Atalk
)
164 /* non-AURP proto packet */
165 ddp_AURPfuncx(AURPCODE_DATAPKT
, m
, node
);
167 { /* AURP proto packet */
168 state
= (aurp_state_t
*)&aurp_state
[node
];
169 state
->tickle_retry
= 0;
170 hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
172 switch (hdrp
->command_code
) {
174 AURPrcvRIUpd(state
, m
); break;
177 AURPrcvRIReq(state
, m
); break;
180 AURPrcvRIRsp(state
, m
); break;
183 AURPrcvRIAck(state
, m
); break;
186 AURPrcvZReq(state
, m
); break;
189 AURPrcvZRsp(state
, m
); break;
191 case AURPCMD_OpenReq
:
192 AURPrcvOpenReq(state
, m
); break;
194 case AURPCMD_OpenRsp
:
195 AURPrcvOpenRsp(state
, m
); break;
198 AURPrcvTickle(state
, m
); break;
200 case AURPCMD_TickleAck
:
201 AURPrcvTickleAck(state
, m
); break;
204 AURPrcvRDReq(state
, m
); break;
207 dPrintf(D_M_AURP
, D_L_WARNING
,
208 ("at_insert: bad proto cmd=%d\n",
209 hdrp
->command_code
));