]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_attention.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.05 03/16/90 mbs
32 * 06/29/95 - Modified to handle flow control for writing (Tuyen Nguyen)
33 * Modified for MP, 1996 by Tuyen Nguyen
34 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
37 #include <sys/errno.h>
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <machine/spl.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
44 #include <sys/filedesc.h>
45 #include <sys/fcntl.h>
47 #include <sys/socket.h>
49 #include <netat/sysglue.h>
50 #include <netat/appletalk.h>
51 #include <netat/at_pcb.h>
52 #include <netat/debug.h>
53 #include <netat/adsp.h>
54 #include <netat/adsp_internal.h>
60 * --> ccbRefNum refnum of connection end
61 * --> attnCode client attention code
62 * --> attnSize size in bytes of attention data
63 * --> attnData pointer to attention data
64 * --> attnInterval attention retransmit interval
65 * (ignored by ADSP 1.5 & up)
71 * errRefNum bad connection refnum
72 * errState connection is not open
73 * errAttention attention message too long
74 * errAborted request aborted by Remove or Close call
76 int adspAttention(sp
, pb
) /* (DSPPBPtr pb) */
77 register struct adspcmd
*pb
;
81 register gbuf_t
*mp
, *nmp
;
85 pb
->ioResult
= errRefNum
;
89 if (sp
->state
!= sOpen
) { /* If we're not open, tell user to go away */
90 pb
->ioResult
= errState
;
93 atalk_notify(sp
->gref
, uerr
);
98 if (pb
->u
.attnParams
.attnSize
> attnBufSize
) /* If data too big, bye-bye */
100 pb
->ioResult
= errAttention
;
105 /* The 1st mbuf in the pb->mp chain (mp) is the adspcmd structure.
106 The 2nd mbuf (nmp) will be the beginning of the data. */
108 if (pb
->u
.attnParams
.attnSize
) {
110 if (gbuf_len(mp
) > sizeof(struct adspcmd
)) {
111 if ((nmp
= gbuf_dupb(mp
)) == 0) {
112 gbuf_wset(mp
, sizeof(struct adspcmd
));
116 gbuf_wset(mp
, sizeof(struct adspcmd
));
117 gbuf_rinc(nmp
, sizeof(struct adspcmd
));
118 gbuf_cont(nmp
) = gbuf_cont(mp
);
122 pb
->ioDirection
= 1; /* outgoing attention data */
123 ATDISABLE(s
, sp
->lock
);
124 if (sp
->sapb
) { /* Pending attentions already? */
125 qAddToEnd(&sp
->sapb
, pb
); /* Just add to end of queue */
126 ATENABLE(s
, sp
->lock
);
128 sp
->sendAttnData
= 1; /* Start off this attention */
131 ATENABLE(s
, sp
->lock
);
134 pb
->ioResult
= 1; /* indicate that the IO is not complete */