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