]>
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_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1996 Apple Computer, Inc.
28 * Created April 8, 1996 by Tuyen Nguyen
29 * Modified for Kernel execution, May, 1996, Justin C. Walker
30 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
34 #include <sys/errno.h>
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <machine/spl.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
41 #include <sys/filedesc.h>
42 #include <sys/fcntl.h>
44 #include <sys/socket.h>
45 #include <sys/socketvar.h>
48 #include <netat/sysglue.h>
49 #include <netat/appletalk.h>
50 #include <netat/at_var.h>
51 #include <netat/routing_tables.h>
52 #include <netat/at_pcb.h>
53 #include <netat/aurp.h>
54 #include <netat/debug.h>
57 * Not using the stream queue for data; keep this around to handle
58 * requests from the user proc (mostly setup).
65 register ioc_t
*iocbp
;
66 register gbuf_t
*mdata
;
67 register int temp
, error
;
69 switch (gbuf_type(m
)) {
72 iocbp
= (ioc_t
*)gbuf_rptr(m
);
73 switch (iocbp
->ioc_cmd
) {
74 case AUC_CFGTNL
: /* set up a tunnel, init the AURP daemon */
76 temp
= (int)(*gbuf_rptr(mdata
));
77 if (temp
!= dst_addr_cnt
) {
78 AURPiocnak(gref
, m
, ENOSPC
);
81 if ((error
= aurpd_start()) != 0) {
82 AURPiocnak(gref
, m
, error
);
86 AURPiocnak(gref
, m
, ENOMEM
);
89 ddp_AURPfuncx(AURPCODE_AURPPROTO
, 0, 0);
93 case AUC_SHTDOWN
: /* shutdown AURP operation */
97 case AUC_EXPNET
: /* configure networks to be exported */
98 case AUC_HIDENET
: /* configure networks to be hiden */
100 net_access_cnt
= (gbuf_len(mdata
))/sizeof(short);
101 if ((net_access_cnt
==0) || (net_access_cnt
>AURP_MaxNetAccess
)) {
102 AURPiocnak(gref
, m
, EINVAL
);
105 bcopy(gbuf_rptr(mdata
), net_access
,
107 if (iocbp
->ioc_cmd
== AUC_EXPNET
)
112 aurp_global
.udp_port
= *(char *)gbuf_rptr(mdata
);
116 mdata
= gbuf_cont(m
);
118 * Compute # addrs, Save for later check
119 * We cheat with a shift.
121 dst_addr_cnt
= ((gbuf_len(mdata
)) >> 2)-1;
122 bcopy(gbuf_rptr(mdata
), &aurp_global
.dst_addr
,
124 aurp_global
.src_addr
= aurp_global
.dst_addr
[0];
125 aurp_global
.dst_addr
[0] = 0;
129 AURPiocnak(gref
, m
, EINVAL
);
136 dPrintf(D_M_AURP
, D_L_WARNING
,
137 ("aurp_wput: bad msg type=%d\n", gbuf_type(m
)));
146 * Insert an appletalk packet into the appletalk stack.
147 * If it's an AURP data packet, just send it up; if it's AURP protocol,
152 at_insert(m
, type
, node
)
154 register unsigned int type
, node
;
156 register aurp_hdr_t
*hdrp
;
157 register aurp_state_t
*state
;
159 if (type
== AUD_Atalk
)
160 /* non-AURP proto packet */
161 ddp_AURPfuncx(AURPCODE_DATAPKT
, m
, node
);
163 { /* AURP proto packet */
164 state
= (aurp_state_t
*)&aurp_state
[node
];
165 state
->tickle_retry
= 0;
166 hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
168 switch (hdrp
->command_code
) {
170 AURPrcvRIUpd(state
, m
); break;
173 AURPrcvRIReq(state
, m
); break;
176 AURPrcvRIRsp(state
, m
); break;
179 AURPrcvRIAck(state
, m
); break;
182 AURPrcvZReq(state
, m
); break;
185 AURPrcvZRsp(state
, m
); break;
187 case AURPCMD_OpenReq
:
188 AURPrcvOpenReq(state
, m
); break;
190 case AURPCMD_OpenRsp
:
191 AURPrcvOpenRsp(state
, m
); break;
194 AURPrcvTickle(state
, m
); break;
196 case AURPCMD_TickleAck
:
197 AURPrcvTickleAck(state
, m
); break;
200 AURPrcvRDReq(state
, m
); break;
203 dPrintf(D_M_AURP
, D_L_WARNING
,
204 ("at_insert: bad proto cmd=%d\n",
205 hdrp
->command_code
));