]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a A |
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. | |
8f6c56a5 | 11 | * |
6601e61a A |
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 | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
21 | */ |
22 | /* | |
23 | * Copyright (c) 1990, 1996-1998 Apple Computer, Inc. | |
24 | * All Rights Reserved. | |
25 | */ | |
26 | ||
27 | /* dspInit.c | |
28 | * | |
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. | |
32 | */ | |
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> | |
39 | #include <sys/proc.h> | |
40 | #include <sys/filedesc.h> | |
41 | #include <sys/fcntl.h> | |
42 | #include <sys/mbuf.h> | |
43 | #include <sys/socket.h> | |
44 | #include <sys/time.h> | |
45 | ||
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> | |
52 | ||
1c79356b A |
53 | |
54 | /* | |
55 | * InitContinue | |
56 | * | |
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. | |
60 | * | |
61 | * INPUTS: | |
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 | |
65 | * OUTPUTS: | |
66 | * none | |
67 | */ | |
68 | static void InitContinue(sp, pb) /* (CCBPtr sp, DSPPBPtr pb, int soc) */ | |
69 | CCBPtr sp; | |
70 | struct adspcmd *pb; | |
71 | { | |
1c79356b A |
72 | |
73 | /* Save connection's socket # in CCB */ | |
74 | sp->localSocket = pb->socket; | |
75 | ||
76 | /* | |
77 | * Link the new ccb onto queue. Must be done with interrupts off. | |
78 | */ | |
1c79356b | 79 | qAddToEnd(AT_ADSP_STREAMS, sp); /* Put on linked list of connections */ |
1c79356b A |
80 | return; |
81 | } | |
82 | ||
83 | /* | |
84 | * dspInit | |
85 | * | |
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. | |
89 | * | |
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 | |
92 | * | |
93 | * INPUTS: | |
94 | * --> ccbPtr Pointer to connection control block | |
95 | * --> adspcmdPtr Pointer to user request block | |
96 | * | |
97 | * OUTPUTS: | |
98 | * <-- ccbRefNum refnum assigned to this connection. | |
99 | * | |
100 | * ERRORS: | |
101 | * EADDRINUSE or 0 | |
102 | */ | |
103 | int adspInit(sp, ap) /* (DSPPBPtr pb) */ | |
104 | CCBPtr sp; | |
105 | struct adspcmd *ap; | |
106 | { | |
107 | /* | |
108 | * Set connection end defaults | |
109 | */ | |
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 */ | |
117 | ||
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; | |
123 | ||
124 | if (ap->csCode == dspInit) { /* Only do this if not connection Listener */ | |
125 | /* | |
126 | * Initialize send and receive queue. Make sure they are the | |
127 | * right size | |
128 | */ | |
129 | sp->rbuflen = RecvQSize; | |
130 | sp->rbuf_mb = 0; | |
131 | sp->sbuflen = SendQSize; | |
132 | sp->sbuf_mb = 0; | |
133 | sp->csbuf_mb = 0; | |
134 | ||
135 | /* | |
136 | * Initialize send and receive defaults | |
137 | */ | |
138 | ||
139 | sp->attn_mb = 0; | |
140 | sp->state = sClosed; /* Set state for connection end */ | |
141 | /* end dspInit */ | |
142 | } else { | |
143 | ||
144 | /* dspCLInit */ | |
145 | sp->state = sListening; /* Set state for conn end */ | |
146 | } /* end dspCLInit */ | |
147 | /* | |
148 | * User opens the socket, so continue with the init stuff | |
149 | */ | |
150 | InitContinue(sp, ap); | |
151 | return(0); | |
152 | } | |
153 | ||
154 | ||
155 | /* | |
156 | * AdspBad | |
157 | * | |
158 | * | |
159 | * INPUTS: | |
160 | * --> ap Parameter block | |
161 | * | |
162 | */ | |
163 | int AdspBad(ap) /* (DSPPBPtr pb) */ | |
164 | struct adspcmd *ap; | |
165 | { | |
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 */ | |
169 | return EINVAL; | |
170 | } |