]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Init.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1990, 1996-1998 Apple Computer, Inc.
24 * All Rights Reserved.
29 * From Mike Shoemaker v01.20 06/29/90 mbs
30 * Modified for MP, 1996 by Tuyen Nguyen
31 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
33 #include <sys/errno.h>
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <machine/spl.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
40 #include <sys/filedesc.h>
41 #include <sys/fcntl.h>
43 #include <sys/socket.h>
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>
53 extern atlock_t adspgen_lock
;
58 * Handle 2nd half of code for dsp init. We could be called directly by
59 * the dsp Init routine, or if a socket has to be opened, we get called
60 * by the completion routine of the dsp open socket.
63 * sp The stream we're initing (not yet on list of streams)
64 * pb The user's dsp Init param block
65 * soc The socket we're going to use
69 static void InitContinue(sp
, pb
) /* (CCBPtr sp, DSPPBPtr pb, int soc) */
75 /* Save connection's socket # in CCB */
76 sp
->localSocket
= pb
->socket
;
79 * Link the new ccb onto queue. Must be done with interrupts off.
81 ATDISABLE(s
, adspgen_lock
);
82 qAddToEnd(AT_ADSP_STREAMS
, sp
); /* Put on linked list of connections */
83 ATENABLE(s
, adspgen_lock
);
90 * Create and initialize a connection end. return ccbRefNum so that client can
91 * reference this ccb in later calls. The caller provides a pointer to
92 * ccb which belongs to adsp until the connection end is removed.
94 * If we have to open a socket, we'll have to do an async open socket, and
95 * finish up in the completion routine
98 * --> ccbPtr Pointer to connection control block
99 * --> adspcmdPtr Pointer to user request block
102 * <-- ccbRefNum refnum assigned to this connection.
107 int adspInit(sp
, ap
) /* (DSPPBPtr pb) */
112 * Set connection end defaults
114 sp
->badSeqMax
= 3; /* # of out-of-sequence packets received */
115 /* until a retransmit advice packet is sent */
116 sp
->probeInterval
= 6 * 30; /* 30 second probe interval */
117 sp
->rtmtInterval
= 6 * 5; /* Just a guess --- 5 seconds */
118 sp
->sendBlocking
= 16;
119 sp
->sendInterval
= 6;
120 sp
->badSeqMax
= 3; /* This is the default */
122 sp
->ProbeTimer
.type
= kProbeTimerType
;
123 sp
->FlushTimer
.type
= kFlushTimerType
;
124 sp
->RetryTimer
.type
= kRetryTimerType
;
125 sp
->AttnTimer
.type
= kAttnTimerType
;
126 sp
->ResetTimer
.type
= kResetTimerType
;
128 if (ap
->csCode
== dspInit
) { /* Only do this if not connection Listener */
130 * Initialize send and receive queue. Make sure they are the
133 sp
->rbuflen
= RecvQSize
;
135 sp
->sbuflen
= SendQSize
;
140 * Initialize send and receive defaults
144 sp
->state
= sClosed
; /* Set state for connection end */
149 sp
->state
= sListening
; /* Set state for conn end */
150 } /* end dspCLInit */
152 * User opens the socket, so continue with the init stuff
154 InitContinue(sp
, ap
);
164 * --> ap Parameter block
167 int AdspBad(ap
) /* (DSPPBPtr pb) */
170 dPrintf(D_M_ADSP
, D_L_ERROR
,
171 ("Hey! Do you have the right AuthToolbox?"));
172 ap
->ioResult
= controlErr
; /* Unknown csCode in the param block */