]>
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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
25 * From Mike Shoemaker v01.05 03/16/90 mbs
29 * 06/29/95 - Modified to handle flow control for writing (Tuyen Nguyen)
30 * Modified for MP, 1996 by Tuyen Nguyen
31 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
34 #include <sys/errno.h>
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <machine/spl.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
41 #include <sys/filedesc.h>
42 #include <sys/fcntl.h>
44 #include <sys/socket.h>
46 #include <netat/sysglue.h>
47 #include <netat/appletalk.h>
48 #include <netat/at_pcb.h>
49 #include <netat/debug.h>
50 #include <netat/adsp.h>
51 #include <netat/adsp_internal.h>
57 * --> ccbRefNum refnum of connection end
58 * --> attnCode client attention code
59 * --> attnSize size in bytes of attention data
60 * --> attnData pointer to attention data
61 * --> attnInterval attention retransmit interval
62 * (ignored by ADSP 1.5 & up)
68 * errRefNum bad connection refnum
69 * errState connection is not open
70 * errAttention attention message too long
71 * errAborted request aborted by Remove or Close call
73 int adspAttention(register struct adspcmd
*pb
, register CCBPtr sp
)
75 register gbuf_t
*mp
, *nmp
;
79 pb
->ioResult
= errRefNum
;
83 if (sp
->state
!= sOpen
) { /* If we're not open, tell user to go away */
84 pb
->ioResult
= errState
;
87 atalk_notify(sp
->gref
, uerr
);
92 if (pb
->u
.attnParams
.attnSize
> attnBufSize
) /* If data too big, bye-bye */
94 pb
->ioResult
= errAttention
;
99 /* The 1st mbuf in the pb->mp chain (mp) is the adspcmd structure.
100 The 2nd mbuf (nmp) will be the beginning of the data. */
102 if (pb
->u
.attnParams
.attnSize
) {
104 if (gbuf_len(mp
) > sizeof(struct adspcmd
)) {
105 if ((nmp
= gbuf_dupb(mp
)) == 0) {
106 gbuf_wset(mp
, sizeof(struct adspcmd
));
110 gbuf_wset(mp
, sizeof(struct adspcmd
));
111 gbuf_rinc(nmp
, sizeof(struct adspcmd
));
112 gbuf_cont(nmp
) = gbuf_cont(mp
);
116 pb
->ioDirection
= 1; /* outgoing attention data */
117 if (sp
->sapb
) { /* Pending attentions already? */
118 qAddToEnd(&sp
->sapb
, pb
); /* Just add to end of queue */
120 sp
->sendAttnData
= 1; /* Start off this attention */
125 pb
->ioResult
= 1; /* indicate that the IO is not complete */