]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Init.c
57e4b85f8137beb3e03aab47d8463b1114a55bf3
2 * Copyright (c) 2006 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@
31 * Copyright (c) 1990, 1996-1998 Apple Computer, Inc.
32 * All Rights Reserved.
37 * From Mike Shoemaker v01.20 06/29/90 mbs
38 * Modified for MP, 1996 by Tuyen Nguyen
39 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
41 #include <sys/errno.h>
42 #include <sys/types.h>
43 #include <sys/param.h>
44 #include <machine/spl.h>
45 #include <sys/systm.h>
46 #include <sys/kernel.h>
48 #include <sys/filedesc.h>
49 #include <sys/fcntl.h>
51 #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>
61 extern atlock_t adspgen_lock
;
66 * Handle 2nd half of code for dsp init. We could be called directly by
67 * the dsp Init routine, or if a socket has to be opened, we get called
68 * by the completion routine of the dsp open socket.
71 * sp The stream we're initing (not yet on list of streams)
72 * pb The user's dsp Init param block
73 * soc The socket we're going to use
77 static void InitContinue(sp
, pb
) /* (CCBPtr sp, DSPPBPtr pb, int soc) */
83 /* Save connection's socket # in CCB */
84 sp
->localSocket
= pb
->socket
;
87 * Link the new ccb onto queue. Must be done with interrupts off.
89 ATDISABLE(s
, adspgen_lock
);
90 qAddToEnd(AT_ADSP_STREAMS
, sp
); /* Put on linked list of connections */
91 ATENABLE(s
, adspgen_lock
);
98 * Create and initialize a connection end. return ccbRefNum so that client can
99 * reference this ccb in later calls. The caller provides a pointer to
100 * ccb which belongs to adsp until the connection end is removed.
102 * If we have to open a socket, we'll have to do an async open socket, and
103 * finish up in the completion routine
106 * --> ccbPtr Pointer to connection control block
107 * --> adspcmdPtr Pointer to user request block
110 * <-- ccbRefNum refnum assigned to this connection.
115 int adspInit(sp
, ap
) /* (DSPPBPtr pb) */
120 * Set connection end defaults
122 sp
->badSeqMax
= 3; /* # of out-of-sequence packets received */
123 /* until a retransmit advice packet is sent */
124 sp
->probeInterval
= 6 * 30; /* 30 second probe interval */
125 sp
->rtmtInterval
= 6 * 5; /* Just a guess --- 5 seconds */
126 sp
->sendBlocking
= 16;
127 sp
->sendInterval
= 6;
128 sp
->badSeqMax
= 3; /* This is the default */
130 sp
->ProbeTimer
.type
= kProbeTimerType
;
131 sp
->FlushTimer
.type
= kFlushTimerType
;
132 sp
->RetryTimer
.type
= kRetryTimerType
;
133 sp
->AttnTimer
.type
= kAttnTimerType
;
134 sp
->ResetTimer
.type
= kResetTimerType
;
136 if (ap
->csCode
== dspInit
) { /* Only do this if not connection Listener */
138 * Initialize send and receive queue. Make sure they are the
141 sp
->rbuflen
= RecvQSize
;
143 sp
->sbuflen
= SendQSize
;
148 * Initialize send and receive defaults
152 sp
->state
= sClosed
; /* Set state for connection end */
157 sp
->state
= sListening
; /* Set state for conn end */
158 } /* end dspCLInit */
160 * User opens the socket, so continue with the init stuff
162 InitContinue(sp
, ap
);
172 * --> ap Parameter block
175 int AdspBad(ap
) /* (DSPPBPtr pb) */
178 dPrintf(D_M_ADSP
, D_L_ERROR
,
179 ("Hey! Do you have the right AuthToolbox?"));
180 ap
->ioResult
= controlErr
; /* Unknown csCode in the param block */