]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Copyright (c) 1990, 1996-1998 Apple Computer, Inc. | |
27 | * All Rights Reserved. | |
28 | */ | |
29 | ||
30 | /* dspInit.c | |
31 | * | |
32 | * From Mike Shoemaker v01.20 06/29/90 mbs | |
33 | * Modified for MP, 1996 by Tuyen Nguyen | |
34 | * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX. | |
35 | */ | |
36 | #include <sys/errno.h> | |
37 | #include <sys/types.h> | |
38 | #include <sys/param.h> | |
39 | #include <machine/spl.h> | |
40 | #include <sys/systm.h> | |
41 | #include <sys/kernel.h> | |
42 | #include <sys/proc.h> | |
43 | #include <sys/filedesc.h> | |
44 | #include <sys/fcntl.h> | |
45 | #include <sys/mbuf.h> | |
46 | #include <sys/socket.h> | |
47 | #include <sys/time.h> | |
48 | ||
49 | #include <netat/sysglue.h> | |
50 | #include <netat/appletalk.h> | |
51 | #include <netat/at_pcb.h> | |
52 | #include <netat/debug.h> | |
53 | #include <netat/adsp.h> | |
54 | #include <netat/adsp_internal.h> | |
55 | ||
56 | extern atlock_t adspgen_lock; | |
57 | ||
58 | /* | |
59 | * InitContinue | |
60 | * | |
61 | * Handle 2nd half of code for dsp init. We could be called directly by | |
62 | * the dsp Init routine, or if a socket has to be opened, we get called | |
63 | * by the completion routine of the dsp open socket. | |
64 | * | |
65 | * INPUTS: | |
66 | * sp The stream we're initing (not yet on list of streams) | |
67 | * pb The user's dsp Init param block | |
68 | * soc The socket we're going to use | |
69 | * OUTPUTS: | |
70 | * none | |
71 | */ | |
72 | static void InitContinue(sp, pb) /* (CCBPtr sp, DSPPBPtr pb, int soc) */ | |
73 | CCBPtr sp; | |
74 | struct adspcmd *pb; | |
75 | { | |
76 | int s; | |
77 | ||
78 | /* Save connection's socket # in CCB */ | |
79 | sp->localSocket = pb->socket; | |
80 | ||
81 | /* | |
82 | * Link the new ccb onto queue. Must be done with interrupts off. | |
83 | */ | |
84 | ATDISABLE(s, adspgen_lock); | |
85 | qAddToEnd(AT_ADSP_STREAMS, sp); /* Put on linked list of connections */ | |
86 | ATENABLE(s, adspgen_lock); | |
87 | return; | |
88 | } | |
89 | ||
90 | /* | |
91 | * dspInit | |
92 | * | |
93 | * Create and initialize a connection end. return ccbRefNum so that client can | |
94 | * reference this ccb in later calls. The caller provides a pointer to | |
95 | * ccb which belongs to adsp until the connection end is removed. | |
96 | * | |
97 | * If we have to open a socket, we'll have to do an async open socket, and | |
98 | * finish up in the completion routine | |
99 | * | |
100 | * INPUTS: | |
101 | * --> ccbPtr Pointer to connection control block | |
102 | * --> adspcmdPtr Pointer to user request block | |
103 | * | |
104 | * OUTPUTS: | |
105 | * <-- ccbRefNum refnum assigned to this connection. | |
106 | * | |
107 | * ERRORS: | |
108 | * EADDRINUSE or 0 | |
109 | */ | |
110 | int adspInit(sp, ap) /* (DSPPBPtr pb) */ | |
111 | CCBPtr sp; | |
112 | struct adspcmd *ap; | |
113 | { | |
114 | /* | |
115 | * Set connection end defaults | |
116 | */ | |
117 | sp->badSeqMax = 3; /* # of out-of-sequence packets received */ | |
118 | /* until a retransmit advice packet is sent */ | |
119 | sp->probeInterval = 6 * 30; /* 30 second probe interval */ | |
120 | sp->rtmtInterval = 6 * 5; /* Just a guess --- 5 seconds */ | |
121 | sp->sendBlocking = 16; | |
122 | sp->sendInterval = 6; | |
123 | sp->badSeqMax = 3; /* This is the default */ | |
124 | ||
125 | sp->ProbeTimer.type = kProbeTimerType; | |
126 | sp->FlushTimer.type = kFlushTimerType; | |
127 | sp->RetryTimer.type = kRetryTimerType; | |
128 | sp->AttnTimer.type = kAttnTimerType; | |
129 | sp->ResetTimer.type = kResetTimerType; | |
130 | ||
131 | if (ap->csCode == dspInit) { /* Only do this if not connection Listener */ | |
132 | /* | |
133 | * Initialize send and receive queue. Make sure they are the | |
134 | * right size | |
135 | */ | |
136 | sp->rbuflen = RecvQSize; | |
137 | sp->rbuf_mb = 0; | |
138 | sp->sbuflen = SendQSize; | |
139 | sp->sbuf_mb = 0; | |
140 | sp->csbuf_mb = 0; | |
141 | ||
142 | /* | |
143 | * Initialize send and receive defaults | |
144 | */ | |
145 | ||
146 | sp->attn_mb = 0; | |
147 | sp->state = sClosed; /* Set state for connection end */ | |
148 | /* end dspInit */ | |
149 | } else { | |
150 | ||
151 | /* dspCLInit */ | |
152 | sp->state = sListening; /* Set state for conn end */ | |
153 | } /* end dspCLInit */ | |
154 | /* | |
155 | * User opens the socket, so continue with the init stuff | |
156 | */ | |
157 | InitContinue(sp, ap); | |
158 | return(0); | |
159 | } | |
160 | ||
161 | ||
162 | /* | |
163 | * AdspBad | |
164 | * | |
165 | * | |
166 | * INPUTS: | |
167 | * --> ap Parameter block | |
168 | * | |
169 | */ | |
170 | int AdspBad(ap) /* (DSPPBPtr pb) */ | |
171 | struct adspcmd *ap; | |
172 | { | |
173 | dPrintf(D_M_ADSP, D_L_ERROR, | |
174 | ("Hey! Do you have the right AuthToolbox?")); | |
175 | ap->ioResult = controlErr; /* Unknown csCode in the param block */ | |
176 | return EINVAL; | |
177 | } |