]> git.saurik.com Git - apple/xnu.git/blame - bsd/netat/adsp_CLListen.c
xnu-517.3.15.tar.gz
[apple/xnu.git] / bsd / netat / adsp_CLListen.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
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
13 * file.
14 *
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
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.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/* dspCLListen.c
26 *
27 * From Mike Shoemaker v01.02 04/19/90 mbs
28 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
29 */
30
31#include <sys/errno.h>
32#include <sys/types.h>
33#include <sys/param.h>
34#include <machine/spl.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/proc.h>
38#include <sys/filedesc.h>
39#include <sys/fcntl.h>
40#include <sys/mbuf.h>
41#include <sys/socket.h>
42
43#include <netat/sysglue.h>
44#include <netat/appletalk.h>
45#include <netat/at_pcb.h>
46#include <netat/debug.h>
47#include <netat/adsp.h>
48#include <netat/adsp_internal.h>
49
50/*
51 * dspCLListen
52 *
53 * INPUTS:
54 * --> ccbRefNum refnum of connection end
55 * --> filterAddress filter for incoming open connection requests
56 *
57 * OUTPUTS:
58 * <-- remoteCID connection identifier of remote connection end
59 * <-- remoteAddress internet address of remote connection end
60 * <-- sendSeq initial send sequence number to use
61 * <-- sendWindow initial size of remote end's receive buffer
62 * <-- attnSendSeq initial attention send sequence number to use
63 *
64 * ERRORS:
65 * errRefNum bad connection refnum
66 * errState not a connection listener
67 * errAborted request aborted by a Remove call
68 */
69int adspCLListen(sp, pb) /* (DSPPBPtr pb) */
70 register CCBPtr sp;
71 register struct adspcmd *pb;
72{
73 register struct adspcmd *clpb;
74 gbuf_t *mp;
75 int s;
76
77 if (sp == 0) {
78 pb->ioResult = errRefNum;
79 return EINVAL;
80 }
81
82 if (sp->state != sListening) { /* But this isn't a connection listener! */
83 pb->ioResult = errState;
84 return EALREADY;
85 }
86
87 if (mp = gbuf_copym(pb->mp)) { /* keep a copy of the parameter block */
88 pb->ioResult = 1; /* not done */
89 adspioc_ack(0, pb->ioc, pb->gref); /* release user ioctl block */
90 clpb = (struct adspcmd *)gbuf_rptr(mp);
91 clpb->ioc = 0;
92 clpb->mp = mp;
93 ATDISABLE(s, sp->lock);
94 if (qAddToEnd(&sp->opb, clpb)){ /* Add to list of listeners */
95 ATENABLE(s, sp->lock);
96 return EFAULT; /* bogus, but discriminate from other errors */
97 }
98 ATENABLE(s, sp->lock);
99 } else {
100 pb->ioResult = errDSPQueueSize;
101 return ENOBUFS;
102 }
103 return 0;
104
105}