]> git.saurik.com Git - apple/xnu.git/blame - bsd/netat/adsp_CLListen.c
xnu-792.22.5.tar.gz
[apple/xnu.git] / bsd / netat / adsp_CLListen.c
CommitLineData
1c79356b 1/*
5d5c5d0d
A
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
8f6c56a5 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
8f6c56a5
A
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
8ad349bb 24 * limitations under the License.
8f6c56a5
A
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/* dspCLListen.c
29 *
30 * From Mike Shoemaker v01.02 04/19/90 mbs
31 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
32 */
33
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>
40#include <sys/proc.h>
41#include <sys/filedesc.h>
42#include <sys/fcntl.h>
43#include <sys/mbuf.h>
44#include <sys/socket.h>
45
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>
52
53/*
54 * dspCLListen
55 *
56 * INPUTS:
57 * --> ccbRefNum refnum of connection end
58 * --> filterAddress filter for incoming open connection requests
59 *
60 * OUTPUTS:
61 * <-- remoteCID connection identifier of remote connection end
62 * <-- remoteAddress internet address of remote connection end
63 * <-- sendSeq initial send sequence number to use
64 * <-- sendWindow initial size of remote end's receive buffer
65 * <-- attnSendSeq initial attention send sequence number to use
66 *
67 * ERRORS:
68 * errRefNum bad connection refnum
69 * errState not a connection listener
70 * errAborted request aborted by a Remove call
71 */
72int adspCLListen(sp, pb) /* (DSPPBPtr pb) */
73 register CCBPtr sp;
74 register struct adspcmd *pb;
75{
76 register struct adspcmd *clpb;
77 gbuf_t *mp;
1c79356b
A
78
79 if (sp == 0) {
80 pb->ioResult = errRefNum;
81 return EINVAL;
82 }
83
84 if (sp->state != sListening) { /* But this isn't a connection listener! */
85 pb->ioResult = errState;
86 return EALREADY;
87 }
88
89 if (mp = gbuf_copym(pb->mp)) { /* keep a copy of the parameter block */
90 pb->ioResult = 1; /* not done */
91 adspioc_ack(0, pb->ioc, pb->gref); /* release user ioctl block */
92 clpb = (struct adspcmd *)gbuf_rptr(mp);
93 clpb->ioc = 0;
94 clpb->mp = mp;
4452a7af
A
95 if (qAddToEnd(&sp->opb, clpb)) /* Add to list of listeners */
96 return EFAULT; /* bogus, but discriminate from other errors */
1c79356b
A
97 } else {
98 pb->ioResult = errDSPQueueSize;
99 return ENOBUFS;
100 }
101 return 0;
102
103}