]>
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 * 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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1996 Apple Computer, Inc.
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.
33 #include <sys/errno.h>
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <machine/spl.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
40 #include <sys/filedesc.h>
41 #include <sys/fcntl.h>
43 #include <sys/socket.h>
44 #include <sys/socketvar.h>
47 #include <netat/sysglue.h>
48 #include <netat/appletalk.h>
49 #include <netat/at_var.h>
50 #include <netat/routing_tables.h>
51 #include <netat/at_pcb.h>
52 #include <netat/aurp.h>
53 #include <netat/debug.h>
56 * Not using the stream queue for data; keep this around to handle
57 * requests from the user proc (mostly setup).
64 register ioc_t
*iocbp
;
65 register gbuf_t
*mdata
;
66 register int temp
, error
;
68 switch (gbuf_type(m
)) {
71 iocbp
= (ioc_t
*)gbuf_rptr(m
);
72 switch (iocbp
->ioc_cmd
) {
73 case AUC_CFGTNL
: /* set up a tunnel, init the AURP daemon */
75 temp
= (int)(*gbuf_rptr(mdata
));
76 if (temp
!= dst_addr_cnt
) {
77 AURPiocnak(gref
, m
, ENOSPC
);
80 if ((error
= aurpd_start()) != 0) {
81 AURPiocnak(gref
, m
, error
);
85 AURPiocnak(gref
, m
, ENOMEM
);
88 ddp_AURPfuncx(AURPCODE_AURPPROTO
, 0, 0);
92 case AUC_SHTDOWN
: /* shutdown AURP operation */
96 case AUC_EXPNET
: /* configure networks to be exported */
97 case AUC_HIDENET
: /* configure networks to be hiden */
99 net_access_cnt
= (gbuf_len(mdata
))/sizeof(short);
100 if ((net_access_cnt
==0) || (net_access_cnt
>AURP_MaxNetAccess
)) {
101 AURPiocnak(gref
, m
, EINVAL
);
104 bcopy(gbuf_rptr(mdata
), net_access
,
106 if (iocbp
->ioc_cmd
== AUC_EXPNET
)
111 mdata
= gbuf_cont(m
);
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
));
213 #endif /* AURP_SUPPORT */