]>
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 * 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.05 03/16/90 mbs
30 * 06/29/95 - Modified to handle flow control for writing (Tuyen Nguyen)
31 * Modified for MP, 1996 by Tuyen Nguyen
32 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
35 #include <sys/errno.h>
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <machine/spl.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
42 #include <sys/filedesc.h>
43 #include <sys/fcntl.h>
45 #include <sys/socket.h>
47 #include <netat/sysglue.h>
48 #include <netat/appletalk.h>
49 #include <netat/at_pcb.h>
50 #include <netat/debug.h>
51 #include <netat/adsp.h>
52 #include <netat/adsp_internal.h>
58 * --> ccbRefNum refnum of connection end
59 * --> attnCode client attention code
60 * --> attnSize size in bytes of attention data
61 * --> attnData pointer to attention data
62 * --> attnInterval attention retransmit interval
63 * (ignored by ADSP 1.5 & up)
69 * errRefNum bad connection refnum
70 * errState connection is not open
71 * errAttention attention message too long
72 * errAborted request aborted by Remove or Close call
74 int adspAttention(register struct adspcmd
*pb
, register CCBPtr sp
)
77 register gbuf_t
*mp
, *nmp
;
81 pb
->ioResult
= errRefNum
;
85 if (sp
->state
!= sOpen
) { /* If we're not open, tell user to go away */
86 pb
->ioResult
= errState
;
89 atalk_notify(sp
->gref
, uerr
);
94 if (pb
->u
.attnParams
.attnSize
> attnBufSize
) /* If data too big, bye-bye */
96 pb
->ioResult
= errAttention
;
101 /* The 1st mbuf in the pb->mp chain (mp) is the adspcmd structure.
102 The 2nd mbuf (nmp) will be the beginning of the data. */
104 if (pb
->u
.attnParams
.attnSize
) {
106 if (gbuf_len(mp
) > sizeof(struct adspcmd
)) {
107 if ((nmp
= gbuf_dupb(mp
)) == 0) {
108 gbuf_wset(mp
, sizeof(struct adspcmd
));
112 gbuf_wset(mp
, sizeof(struct adspcmd
));
113 gbuf_rinc(nmp
, sizeof(struct adspcmd
));
114 gbuf_cont(nmp
) = gbuf_cont(mp
);
118 pb
->ioDirection
= 1; /* outgoing attention data */
119 ATDISABLE(s
, sp
->lock
);
120 if (sp
->sapb
) { /* Pending attentions already? */
121 qAddToEnd(&sp
->sapb
, pb
); /* Just add to end of queue */
122 ATENABLE(s
, sp
->lock
);
124 sp
->sendAttnData
= 1; /* Start off this attention */
127 ATENABLE(s
, sp
->lock
);
130 pb
->ioResult
= 1; /* indicate that the IO is not complete */