]>
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_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.05 03/16/90 mbs
35 * 06/29/95 - Modified to handle flow control for writing (Tuyen Nguyen)
36 * Modified for MP, 1996 by Tuyen Nguyen
37 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
40 #include <sys/errno.h>
41 #include <sys/types.h>
42 #include <sys/param.h>
43 #include <machine/spl.h>
44 #include <sys/systm.h>
45 #include <sys/kernel.h>
47 #include <sys/filedesc.h>
48 #include <sys/fcntl.h>
50 #include <sys/socket.h>
52 #include <netat/sysglue.h>
53 #include <netat/appletalk.h>
54 #include <netat/at_pcb.h>
55 #include <netat/debug.h>
56 #include <netat/adsp.h>
57 #include <netat/adsp_internal.h>
63 * --> ccbRefNum refnum of connection end
64 * --> attnCode client attention code
65 * --> attnSize size in bytes of attention data
66 * --> attnData pointer to attention data
67 * --> attnInterval attention retransmit interval
68 * (ignored by ADSP 1.5 & up)
74 * errRefNum bad connection refnum
75 * errState connection is not open
76 * errAttention attention message too long
77 * errAborted request aborted by Remove or Close call
79 int adspAttention(register struct adspcmd
*pb
, register CCBPtr sp
)
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 if (sp
->sapb
) { /* Pending attentions already? */
124 qAddToEnd((struct qlink
**)&sp
->sapb
, (struct qlink
*)pb
); /* Just add to end of queue */
126 sp
->sendAttnData
= 1; /* Start off this attention */
131 pb
->ioResult
= 1; /* indicate that the IO is not complete */