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