]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_attention.c
59898819396170f1fa45a9e04d1cee261820be4e
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
33 * From Mike Shoemaker v01.05 03/16/90 mbs
37 * 06/29/95 - Modified to handle flow control for writing (Tuyen Nguyen)
38 * Modified for MP, 1996 by Tuyen Nguyen
39 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
42 #include <sys/errno.h>
43 #include <sys/types.h>
44 #include <sys/param.h>
45 #include <machine/spl.h>
46 #include <sys/systm.h>
47 #include <sys/kernel.h>
49 #include <sys/filedesc.h>
50 #include <sys/fcntl.h>
52 #include <sys/socket.h>
54 #include <netat/sysglue.h>
55 #include <netat/appletalk.h>
56 #include <netat/at_pcb.h>
57 #include <netat/debug.h>
58 #include <netat/adsp.h>
59 #include <netat/adsp_internal.h>
65 * --> ccbRefNum refnum of connection end
66 * --> attnCode client attention code
67 * --> attnSize size in bytes of attention data
68 * --> attnData pointer to attention data
69 * --> attnInterval attention retransmit interval
70 * (ignored by ADSP 1.5 & up)
76 * errRefNum bad connection refnum
77 * errState connection is not open
78 * errAttention attention message too long
79 * errAborted request aborted by Remove or Close call
81 int adspAttention(register struct adspcmd
*pb
, register CCBPtr sp
)
83 register gbuf_t
*mp
, *nmp
;
87 pb
->ioResult
= errRefNum
;
91 if (sp
->state
!= sOpen
) { /* If we're not open, tell user to go away */
92 pb
->ioResult
= errState
;
95 atalk_notify(sp
->gref
, uerr
);
100 if (pb
->u
.attnParams
.attnSize
> attnBufSize
) /* If data too big, bye-bye */
102 pb
->ioResult
= errAttention
;
107 /* The 1st mbuf in the pb->mp chain (mp) is the adspcmd structure.
108 The 2nd mbuf (nmp) will be the beginning of the data. */
110 if (pb
->u
.attnParams
.attnSize
) {
112 if (gbuf_len(mp
) > sizeof(struct adspcmd
)) {
113 if ((nmp
= gbuf_dupb(mp
)) == 0) {
114 gbuf_wset(mp
, sizeof(struct adspcmd
));
118 gbuf_wset(mp
, sizeof(struct adspcmd
));
119 gbuf_rinc(nmp
, sizeof(struct adspcmd
));
120 gbuf_cont(nmp
) = gbuf_cont(mp
);
124 pb
->ioDirection
= 1; /* outgoing attention data */
125 if (sp
->sapb
) { /* Pending attentions already? */
126 qAddToEnd(&sp
->sapb
, pb
); /* Just add to end of queue */
128 sp
->sendAttnData
= 1; /* Start off this attention */
133 pb
->ioResult
= 1; /* indicate that the IO is not complete */