]>
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>
60 * # of bytes avail in local send queue
62 int CalcSendQFree(sp
) /* (CCBPtr sp) */
67 bytes
= calcSendQ(sp
);
68 bytes
= sp
->sbuflen
- bytes
;
81 if (sp
->sData
) { /* There is data in buffer */
82 if (mp
= sp
->sbuf_mb
) {
84 bytes
+= gbuf_msgsize(mp
);
88 if (mp
= sp
->csbuf_mb
)
89 bytes
+= gbuf_msgsize(mp
);
98 * --> ccbRefNum refnum of connection end
101 * <-- statusCCB Pointer to the connection control block
102 * <-- sendQPending bytes waiting to be sent or acknowledged
103 * <-- sendQFree available buffer in bytes of send queue
104 * <-- recvQPending bytes waiting to be read from queue
105 * <-- recvQFree available buffer in bytes of receive queue
108 * errRefNum bad connection refnum
109 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
111 int adspStatus(sp
, pb
) /* (DSPPBPtr pb) */
113 register struct adspcmd
*pb
;
119 pb
->ioResult
= errRefNum
;
123 pb
->u
.statusParams
.ccbPtr
= (TPCCB
)sp
;
126 * pending bytes in send queue
129 bytes
= calcSendQ(sp
);
132 pb
->u
.statusParams
.sendQPending
= bytes
;
134 /* available buffer space in send queue */
135 pb
->u
.statusParams
.sendQFree
= CalcSendQFree(sp
);
138 * pending bytes in recv queue
141 bytes
= calcRecvQ(sp
);
144 pb
->u
.statusParams
.recvQPending
= bytes
;
146 /* available buffer space in receive queue */
147 pb
->u
.statusParams
.recvQFree
= CalcRecvWdw(sp
);
150 adspioc_ack(0, pb
->ioc
, pb
->gref
);