]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Init.c
420c8e3f3aade8de4f4624a375940d268a3784f5
2 * Copyright (c) 2000 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>
65 * Handle 2nd half of code for dsp init. We could be called directly by
66 * the dsp Init routine, or if a socket has to be opened, we get called
67 * by the completion routine of the dsp open socket.
70 * sp The stream we're initing (not yet on list of streams)
71 * pb The user's dsp Init param block
72 * soc The socket we're going to use
76 static void InitContinue(sp
, pb
) /* (CCBPtr sp, DSPPBPtr pb, int soc) */
81 /* Save connection's socket # in CCB */
82 sp
->localSocket
= pb
->socket
;
85 * Link the new ccb onto queue. Must be done with interrupts off.
87 qAddToEnd(AT_ADSP_STREAMS
, sp
); /* Put on linked list of connections */
94 * Create and initialize a connection end. return ccbRefNum so that client can
95 * reference this ccb in later calls. The caller provides a pointer to
96 * ccb which belongs to adsp until the connection end is removed.
98 * If we have to open a socket, we'll have to do an async open socket, and
99 * finish up in the completion routine
102 * --> ccbPtr Pointer to connection control block
103 * --> adspcmdPtr Pointer to user request block
106 * <-- ccbRefNum refnum assigned to this connection.
111 int adspInit(sp
, ap
) /* (DSPPBPtr pb) */
116 * Set connection end defaults
118 sp
->badSeqMax
= 3; /* # of out-of-sequence packets received */
119 /* until a retransmit advice packet is sent */
120 sp
->probeInterval
= 6 * 30; /* 30 second probe interval */
121 sp
->rtmtInterval
= 6 * 5; /* Just a guess --- 5 seconds */
122 sp
->sendBlocking
= 16;
123 sp
->sendInterval
= 6;
124 sp
->badSeqMax
= 3; /* This is the default */
126 sp
->ProbeTimer
.type
= kProbeTimerType
;
127 sp
->FlushTimer
.type
= kFlushTimerType
;
128 sp
->RetryTimer
.type
= kRetryTimerType
;
129 sp
->AttnTimer
.type
= kAttnTimerType
;
130 sp
->ResetTimer
.type
= kResetTimerType
;
132 if (ap
->csCode
== dspInit
) { /* Only do this if not connection Listener */
134 * Initialize send and receive queue. Make sure they are the
137 sp
->rbuflen
= RecvQSize
;
139 sp
->sbuflen
= SendQSize
;
144 * Initialize send and receive defaults
148 sp
->state
= sClosed
; /* Set state for connection end */
153 sp
->state
= sListening
; /* Set state for conn end */
154 } /* end dspCLInit */
156 * User opens the socket, so continue with the init stuff
158 InitContinue(sp
, ap
);
168 * --> ap Parameter block
171 int AdspBad(ap
) /* (DSPPBPtr pb) */
174 dPrintf(D_M_ADSP
, D_L_ERROR
,
175 ("Hey! Do you have the right AuthToolbox?"));
176 ap
->ioResult
= controlErr
; /* Unknown csCode in the param block */