]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/aurp_rx.c
601b6c02e88457442948019d7fb43954450cb881
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * Copyright (c) 1996 Apple Computer, Inc.
26 * Created April 8, 1996 by Tuyen Nguyen
27 * Modified for Kernel execution, May, 1996, Justin C. Walker
28 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
32 #include <sys/errno.h>
33 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <machine/spl.h>
36 #include <sys/systm.h>
37 #include <sys/kernel.h>
39 #include <sys/filedesc.h>
40 #include <sys/fcntl.h>
42 #include <sys/socket.h>
43 #include <sys/socketvar.h>
46 #include <netat/sysglue.h>
47 #include <netat/appletalk.h>
48 #include <netat/at_var.h>
49 #include <netat/routing_tables.h>
50 #include <netat/at_pcb.h>
51 #include <netat/aurp.h>
52 #include <netat/debug.h>
55 * Not using the stream queue for data; keep this around to handle
56 * requests from the user proc (mostly setup).
63 register ioc_t
*iocbp
;
64 register gbuf_t
*mdata
;
65 register int temp
, error
;
67 switch (gbuf_type(m
)) {
70 iocbp
= (ioc_t
*)gbuf_rptr(m
);
71 switch (iocbp
->ioc_cmd
) {
72 case AUC_CFGTNL
: /* set up a tunnel, init the AURP daemon */
74 temp
= (int)(*gbuf_rptr(mdata
));
75 if (temp
!= dst_addr_cnt
) {
76 AURPiocnak(gref
, m
, ENOSPC
);
79 if ((error
= aurpd_start()) != 0) {
80 AURPiocnak(gref
, m
, error
);
84 AURPiocnak(gref
, m
, ENOMEM
);
87 ddp_AURPfuncx(AURPCODE_AURPPROTO
, 0, 0);
91 case AUC_SHTDOWN
: /* shutdown AURP operation */
95 case AUC_EXPNET
: /* configure networks to be exported */
96 case AUC_HIDENET
: /* configure networks to be hiden */
98 net_access_cnt
= (gbuf_len(mdata
))/sizeof(short);
99 if ((net_access_cnt
==0) || (net_access_cnt
>AURP_MaxNetAccess
)) {
100 AURPiocnak(gref
, m
, EINVAL
);
103 bcopy(gbuf_rptr(mdata
), net_access
,
105 if (iocbp
->ioc_cmd
== AUC_EXPNET
)
110 mdata
= gbuf_cont(m
);
111 aurp_global
.udp_port
= *(char *)gbuf_rptr(mdata
);
115 mdata
= gbuf_cont(m
);
117 * Compute # addrs, Save for later check
118 * We cheat with a shift.
120 dst_addr_cnt
= ((gbuf_len(mdata
)) >> 2)-1;
121 bcopy(gbuf_rptr(mdata
), &aurp_global
.dst_addr
,
123 aurp_global
.src_addr
= aurp_global
.dst_addr
[0];
124 aurp_global
.dst_addr
[0] = 0;
128 AURPiocnak(gref
, m
, EINVAL
);
135 dPrintf(D_M_AURP
, D_L_WARNING
,
136 ("aurp_wput: bad msg type=%d\n", gbuf_type(m
)));
145 * Insert an appletalk packet into the appletalk stack.
146 * If it's an AURP data packet, just send it up; if it's AURP protocol,
151 at_insert(m
, type
, node
)
153 register unsigned int type
, node
;
155 register aurp_hdr_t
*hdrp
;
156 register aurp_state_t
*state
;
158 if (type
== AUD_Atalk
)
159 /* non-AURP proto packet */
160 ddp_AURPfuncx(AURPCODE_DATAPKT
, m
, node
);
162 { /* AURP proto packet */
163 state
= (aurp_state_t
*)&aurp_state
[node
];
164 state
->tickle_retry
= 0;
165 hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
167 switch (hdrp
->command_code
) {
169 AURPrcvRIUpd(state
, m
); break;
172 AURPrcvRIReq(state
, m
); break;
175 AURPrcvRIRsp(state
, m
); break;
178 AURPrcvRIAck(state
, m
); break;
181 AURPrcvZReq(state
, m
); break;
184 AURPrcvZRsp(state
, m
); break;
186 case AURPCMD_OpenReq
:
187 AURPrcvOpenReq(state
, m
); break;
189 case AURPCMD_OpenRsp
:
190 AURPrcvOpenRsp(state
, m
); break;
193 AURPrcvTickle(state
, m
); break;
195 case AURPCMD_TickleAck
:
196 AURPrcvTickleAck(state
, m
); break;
199 AURPrcvRDReq(state
, m
); break;
202 dPrintf(D_M_AURP
, D_L_WARNING
,
203 ("at_insert: bad proto cmd=%d\n",
204 hdrp
->command_code
));