]>
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.
31 #include <sys/errno.h>
32 #include <sys/types.h>
33 #include <sys/param.h>
34 #include <machine/spl.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
38 #include <sys/filedesc.h>
39 #include <sys/fcntl.h>
41 #include <sys/socket.h>
42 #include <sys/socketvar.h>
45 #include <netat/sysglue.h>
46 #include <netat/appletalk.h>
47 #include <netat/at_var.h>
48 #include <netat/routing_tables.h>
49 #include <netat/at_pcb.h>
50 #include <netat/aurp.h>
51 #include <netat/debug.h>
54 * Not using the stream queue for data; keep this around to handle
55 * requests from the user proc (mostly setup).
62 register ioc_t
*iocbp
;
63 register gbuf_t
*mdata
;
64 register int temp
, error
;
66 switch (gbuf_type(m
)) {
69 iocbp
= (ioc_t
*)gbuf_rptr(m
);
70 switch (iocbp
->ioc_cmd
) {
71 case AUC_CFGTNL
: /* set up a tunnel, init the AURP daemon */
73 temp
= (int)(*gbuf_rptr(mdata
));
74 if (temp
!= dst_addr_cnt
) {
75 AURPiocnak(gref
, m
, ENOSPC
);
78 if ((error
= aurpd_start()) != 0) {
79 AURPiocnak(gref
, m
, error
);
83 AURPiocnak(gref
, m
, ENOMEM
);
86 ddp_AURPfuncx(AURPCODE_AURPPROTO
, 0, 0);
90 case AUC_SHTDOWN
: /* shutdown AURP operation */
94 case AUC_EXPNET
: /* configure networks to be exported */
95 case AUC_HIDENET
: /* configure networks to be hiden */
97 net_access_cnt
= (gbuf_len(mdata
))/sizeof(short);
98 if ((net_access_cnt
==0) || (net_access_cnt
>AURP_MaxNetAccess
)) {
99 AURPiocnak(gref
, m
, EINVAL
);
102 bcopy(gbuf_rptr(mdata
), net_access
,
104 if (iocbp
->ioc_cmd
== AUC_EXPNET
)
109 aurp_global
.udp_port
= *(char *)gbuf_rptr(mdata
);
113 mdata
= gbuf_cont(m
);
115 * Compute # addrs, Save for later check
116 * We cheat with a shift.
118 dst_addr_cnt
= ((gbuf_len(mdata
)) >> 2)-1;
119 bcopy(gbuf_rptr(mdata
), &aurp_global
.dst_addr
,
121 aurp_global
.src_addr
= aurp_global
.dst_addr
[0];
122 aurp_global
.dst_addr
[0] = 0;
126 AURPiocnak(gref
, m
, EINVAL
);
133 dPrintf(D_M_AURP
, D_L_WARNING
,
134 ("aurp_wput: bad msg type=%d\n", gbuf_type(m
)));
143 * Insert an appletalk packet into the appletalk stack.
144 * If it's an AURP data packet, just send it up; if it's AURP protocol,
149 at_insert(m
, type
, node
)
151 register unsigned int type
, node
;
153 register aurp_hdr_t
*hdrp
;
154 register aurp_state_t
*state
;
156 if (type
== AUD_Atalk
)
157 /* non-AURP proto packet */
158 ddp_AURPfuncx(AURPCODE_DATAPKT
, m
, node
);
160 { /* AURP proto packet */
161 state
= (aurp_state_t
*)&aurp_state
[node
];
162 state
->tickle_retry
= 0;
163 hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
165 switch (hdrp
->command_code
) {
167 AURPrcvRIUpd(state
, m
); break;
170 AURPrcvRIReq(state
, m
); break;
173 AURPrcvRIRsp(state
, m
); break;
176 AURPrcvRIAck(state
, m
); break;
179 AURPrcvZReq(state
, m
); break;
182 AURPrcvZRsp(state
, m
); break;
184 case AURPCMD_OpenReq
:
185 AURPrcvOpenReq(state
, m
); break;
187 case AURPCMD_OpenRsp
:
188 AURPrcvOpenRsp(state
, m
); break;
191 AURPrcvTickle(state
, m
); break;
193 case AURPCMD_TickleAck
:
194 AURPrcvTickleAck(state
, m
); break;
197 AURPrcvRDReq(state
, m
); break;
200 dPrintf(D_M_AURP
, D_L_WARNING
,
201 ("at_insert: bad proto cmd=%d\n",
202 hdrp
->command_code
));