]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Status.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@
31 * From Mike Shoemaker v01.04 06/15/90 mbs
32 * Modified for MP, 1996 by Tuyen Nguyen
33 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
36 #include <sys/errno.h>
37 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <machine/spl.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
43 #include <sys/filedesc.h>
44 #include <sys/fcntl.h>
46 #include <sys/socket.h>
48 #include <netat/sysglue.h>
49 #include <netat/appletalk.h>
50 #include <netat/at_pcb.h>
51 #include <netat/adsp.h>
52 #include <netat/adsp_internal.h>
54 int calcSendQ(CCBPtr
);
62 * # of bytes avail in local send queue
64 int CalcSendQFree(sp
) /* (CCBPtr sp) */
69 bytes
= calcSendQ(sp
);
70 bytes
= sp
->sbuflen
- bytes
;
84 if (sp
->sData
) { /* There is data in buffer */
85 if ((mp
= sp
->sbuf_mb
)) {
87 bytes
+= gbuf_msgsize(mp
);
91 if ((mp
= sp
->csbuf_mb
))
92 bytes
+= gbuf_msgsize(mp
);
101 * --> ccbRefNum refnum of connection end
104 * <-- statusCCB Pointer to the connection control block
105 * <-- sendQPending bytes waiting to be sent or acknowledged
106 * <-- sendQFree available buffer in bytes of send queue
107 * <-- recvQPending bytes waiting to be read from queue
108 * <-- recvQFree available buffer in bytes of receive queue
111 * errRefNum bad connection refnum
112 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
114 int adspStatus(sp
, pb
) /* (DSPPBPtr pb) */
116 register struct adspcmd
*pb
;
121 pb
->ioResult
= errRefNum
;
125 pb
->u
.statusParams
.ccbPtr
= (TPCCB
)sp
;
128 * pending bytes in send queue
131 bytes
= calcSendQ(sp
);
134 pb
->u
.statusParams
.sendQPending
= bytes
;
136 /* available buffer space in send queue */
137 pb
->u
.statusParams
.sendQFree
= CalcSendQFree(sp
);
140 * pending bytes in recv queue
143 bytes
= calcRecvQ(sp
);
146 pb
->u
.statusParams
.recvQPending
= bytes
;
148 /* available buffer space in receive queue */
149 pb
->u
.statusParams
.recvQFree
= CalcRecvWdw(sp
);
152 adspioc_ack(0, (gbuf_t
*)pb
->ioc
, pb
->gref
);