]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Status.c
1f4158d2713140f299c982b4fbad46453016e3af
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 * From Mike Shoemaker v01.04 06/15/90 mbs
27 * Modified for MP, 1996 by Tuyen Nguyen
28 * Modified, April 9, 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>
43 #include <netat/sysglue.h>
44 #include <netat/appletalk.h>
45 #include <netat/at_pcb.h>
46 #include <netat/adsp.h>
47 #include <netat/adsp_internal.h>
55 * # of bytes avail in local send queue
57 int CalcSendQFree(sp
) /* (CCBPtr sp) */
62 bytes
= calcSendQ(sp
);
63 bytes
= sp
->sbuflen
- bytes
;
76 if (sp
->sData
) { /* There is data in buffer */
77 if (mp
= sp
->sbuf_mb
) {
79 bytes
+= gbuf_msgsize(mp
);
83 if (mp
= sp
->csbuf_mb
)
84 bytes
+= gbuf_msgsize(mp
);
93 * --> ccbRefNum refnum of connection end
96 * <-- statusCCB Pointer to the connection control block
97 * <-- sendQPending bytes waiting to be sent or acknowledged
98 * <-- sendQFree available buffer in bytes of send queue
99 * <-- recvQPending bytes waiting to be read from queue
100 * <-- recvQFree available buffer in bytes of receive queue
103 * errRefNum bad connection refnum
104 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
106 int adspStatus(sp
, pb
) /* (DSPPBPtr pb) */
108 register struct adspcmd
*pb
;
115 pb
->ioResult
= errRefNum
;
119 pb
->u
.statusParams
.ccbPtr
= (TPCCB
)sp
;
120 ATDISABLE(s
, sp
->lock
);
123 * pending bytes in send queue
126 bytes
= calcSendQ(sp
);
129 pb
->u
.statusParams
.sendQPending
= bytes
;
131 /* available buffer space in send queue */
132 pb
->u
.statusParams
.sendQFree
= CalcSendQFree(sp
);
135 * pending bytes in recv queue
138 bytes
= calcRecvQ(sp
);
141 pb
->u
.statusParams
.recvQPending
= bytes
;
143 /* available buffer space in receive queue */
144 pb
->u
.statusParams
.recvQFree
= CalcRecvWdw(sp
);
146 ATENABLE(s
, sp
->lock
);
148 adspioc_ack(0, pb
->ioc
, pb
->gref
);