]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Init.c
8400cd06118f4c6b7d605fee712879f5dea03710
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>
57 * Handle 2nd half of code for dsp init. We could be called directly by
58 * the dsp Init routine, or if a socket has to be opened, we get called
59 * by the completion routine of the dsp open socket.
62 * sp The stream we're initing (not yet on list of streams)
63 * pb The user's dsp Init param block
64 * soc The socket we're going to use
68 static void InitContinue(sp
, pb
) /* (CCBPtr sp, DSPPBPtr pb, int soc) */
73 /* Save connection's socket # in CCB */
74 sp
->localSocket
= pb
->socket
;
77 * Link the new ccb onto queue. Must be done with interrupts off.
79 qAddToEnd(AT_ADSP_STREAMS
, sp
); /* Put on linked list of connections */
86 * Create and initialize a connection end. return ccbRefNum so that client can
87 * reference this ccb in later calls. The caller provides a pointer to
88 * ccb which belongs to adsp until the connection end is removed.
90 * If we have to open a socket, we'll have to do an async open socket, and
91 * finish up in the completion routine
94 * --> ccbPtr Pointer to connection control block
95 * --> adspcmdPtr Pointer to user request block
98 * <-- ccbRefNum refnum assigned to this connection.
103 int adspInit(sp
, ap
) /* (DSPPBPtr pb) */
108 * Set connection end defaults
110 sp
->badSeqMax
= 3; /* # of out-of-sequence packets received */
111 /* until a retransmit advice packet is sent */
112 sp
->probeInterval
= 6 * 30; /* 30 second probe interval */
113 sp
->rtmtInterval
= 6 * 5; /* Just a guess --- 5 seconds */
114 sp
->sendBlocking
= 16;
115 sp
->sendInterval
= 6;
116 sp
->badSeqMax
= 3; /* This is the default */
118 sp
->ProbeTimer
.type
= kProbeTimerType
;
119 sp
->FlushTimer
.type
= kFlushTimerType
;
120 sp
->RetryTimer
.type
= kRetryTimerType
;
121 sp
->AttnTimer
.type
= kAttnTimerType
;
122 sp
->ResetTimer
.type
= kResetTimerType
;
124 if (ap
->csCode
== dspInit
) { /* Only do this if not connection Listener */
126 * Initialize send and receive queue. Make sure they are the
129 sp
->rbuflen
= RecvQSize
;
131 sp
->sbuflen
= SendQSize
;
136 * Initialize send and receive defaults
140 sp
->state
= sClosed
; /* Set state for connection end */
145 sp
->state
= sListening
; /* Set state for conn end */
146 } /* end dspCLInit */
148 * User opens the socket, so continue with the init stuff
150 InitContinue(sp
, ap
);
160 * --> ap Parameter block
163 int AdspBad(ap
) /* (DSPPBPtr pb) */
166 dPrintf(D_M_ADSP
, D_L_ERROR
,
167 ("Hey! Do you have the right AuthToolbox?"));
168 ap
->ioResult
= controlErr
; /* Unknown csCode in the param block */