]>
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_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@
28 * From Mike Shoemaker v01.04 06/15/90 mbs
29 * Modified for MP, 1996 by Tuyen Nguyen
30 * Modified, April 9, 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>
45 #include <netat/sysglue.h>
46 #include <netat/appletalk.h>
47 #include <netat/at_pcb.h>
48 #include <netat/adsp.h>
49 #include <netat/adsp_internal.h>
57 * # of bytes avail in local send queue
59 int CalcSendQFree(sp
) /* (CCBPtr sp) */
64 bytes
= calcSendQ(sp
);
65 bytes
= sp
->sbuflen
- bytes
;
78 if (sp
->sData
) { /* There is data in buffer */
79 if (mp
= sp
->sbuf_mb
) {
81 bytes
+= gbuf_msgsize(mp
);
85 if (mp
= sp
->csbuf_mb
)
86 bytes
+= gbuf_msgsize(mp
);
95 * --> ccbRefNum refnum of connection end
98 * <-- statusCCB Pointer to the connection control block
99 * <-- sendQPending bytes waiting to be sent or acknowledged
100 * <-- sendQFree available buffer in bytes of send queue
101 * <-- recvQPending bytes waiting to be read from queue
102 * <-- recvQFree available buffer in bytes of receive queue
105 * errRefNum bad connection refnum
106 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
108 int adspStatus(sp
, pb
) /* (DSPPBPtr pb) */
110 register struct adspcmd
*pb
;
117 pb
->ioResult
= errRefNum
;
121 pb
->u
.statusParams
.ccbPtr
= (TPCCB
)sp
;
122 ATDISABLE(s
, sp
->lock
);
125 * pending bytes in send queue
128 bytes
= calcSendQ(sp
);
131 pb
->u
.statusParams
.sendQPending
= bytes
;
133 /* available buffer space in send queue */
134 pb
->u
.statusParams
.sendQFree
= CalcSendQFree(sp
);
137 * pending bytes in recv queue
140 bytes
= calcRecvQ(sp
);
143 pb
->u
.statusParams
.recvQPending
= bytes
;
145 /* available buffer space in receive queue */
146 pb
->u
.statusParams
.recvQFree
= CalcRecvWdw(sp
);
148 ATENABLE(s
, sp
->lock
);
150 adspioc_ack(0, pb
->ioc
, pb
->gref
);