Annotation of kernel/bsd/netat/adsp_Init.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.