|
|
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) Computing Centre, University of British Columbia, 1984 ! 27: * Copyright (C) Computer Science Department IV, ! 28: * University of Erlangen-Nuremberg, Germany, 1990, 1992 ! 29: * Copyright (c) 1990, 1992, 1993 ! 30: * The Regents of the University of California. All rights reserved. ! 31: * ! 32: * This code is derived from software contributed to Berkeley by the ! 33: * Laboratory for Computation Vision and the Computer Science Department ! 34: * of the the University of British Columbia and the Computer Science ! 35: * Department (IV) of the University of Erlangen-Nuremberg, Germany. ! 36: * ! 37: * Redistribution and use in source and binary forms, with or without ! 38: * modification, are permitted provided that the following conditions ! 39: * are met: ! 40: * 1. Redistributions of source code must retain the above copyright ! 41: * notice, this list of conditions and the following disclaimer. ! 42: * 2. Redistributions in binary form must reproduce the above copyright ! 43: * notice, this list of conditions and the following disclaimer in the ! 44: * documentation and/or other materials provided with the distribution. ! 45: * 3. All advertising materials mentioning features or use of this software ! 46: * must display the following acknowledgement: ! 47: * This product includes software developed by the University of ! 48: * California, Berkeley and its contributors. ! 49: * 4. Neither the name of the University nor the names of its contributors ! 50: * may be used to endorse or promote products derived from this software ! 51: * without specific prior written permission. ! 52: * ! 53: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 54: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 55: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 56: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 57: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 58: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 59: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 60: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 61: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 62: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 63: * SUCH DAMAGE. ! 64: * ! 65: * @(#)pk_timer.c 8.1 (Berkeley) 6/10/93 ! 66: */ ! 67: ! 68: #include <sys/param.h> ! 69: #include <sys/systm.h> ! 70: #include <sys/mbuf.h> ! 71: #include <sys/socket.h> ! 72: #include <sys/protosw.h> ! 73: #include <sys/socketvar.h> ! 74: #include <sys/errno.h> ! 75: ! 76: #include <net/if.h> ! 77: ! 78: #include <netccitt/x25.h> ! 79: #include <netccitt/pk.h> ! 80: #include <netccitt/pk_var.h> ! 81: ! 82: /* ! 83: * Various timer values. They can be adjusted ! 84: * by patching the binary with adb if necessary. ! 85: */ ! 86: int pk_t20 = 18 * PR_SLOWHZ; /* restart timer */ ! 87: int pk_t21 = 20 * PR_SLOWHZ; /* call timer */ ! 88: /* XXX pk_t22 is never used */ ! 89: int pk_t22 = 18 * PR_SLOWHZ; /* reset timer */ ! 90: int pk_t23 = 18 * PR_SLOWHZ; /* clear timer */ ! 91: ! 92: pk_timer () ! 93: { ! 94: register struct pkcb *pkp; ! 95: register struct pklcd *lcp, **pp; ! 96: register int lcns_jammed, cant_restart; ! 97: ! 98: FOR_ALL_PKCBS(pkp) { ! 99: switch (pkp -> pk_state) { ! 100: case DTE_SENT_RESTART: ! 101: lcp = pkp -> pk_chan[0]; ! 102: /* ! 103: * If restart failures are common, a link level ! 104: * reset should be initiated here. ! 105: */ ! 106: if (lcp -> lcd_timer && --lcp -> lcd_timer == 0) { ! 107: pk_message (0, pkp -> pk_xcp, ! 108: "packet level restart failed"); ! 109: pkp -> pk_state = DTE_WAITING; ! 110: } ! 111: break; ! 112: ! 113: case DTE_READY: ! 114: lcns_jammed = cant_restart = 0; ! 115: for (pp = &pkp -> pk_chan[1]; pp <= &pkp -> pk_chan[pkp -> pk_maxlcn]; pp++) { ! 116: if ((lcp = *pp) == 0) ! 117: continue; ! 118: switch (lcp -> lcd_state) { ! 119: case SENT_CALL: ! 120: if (--lcp -> lcd_timer == 0) { ! 121: if (lcp -> lcd_so) ! 122: lcp -> lcd_so -> so_error = ETIMEDOUT; ! 123: pk_clear (lcp, 49, 1); ! 124: } ! 125: break; ! 126: ! 127: case SENT_CLEAR: ! 128: if (lcp -> lcd_retry >= 3) ! 129: lcns_jammed++; ! 130: else ! 131: if (--lcp -> lcd_timer == 0) ! 132: pk_clear (lcp, 50, 1); ! 133: break; ! 134: ! 135: case DATA_TRANSFER: /* lcn active */ ! 136: cant_restart++; ! 137: break; ! 138: ! 139: case LCN_ZOMBIE: /* zombie state */ ! 140: pk_freelcd (lcp); ! 141: break; ! 142: } ! 143: } ! 144: if (lcns_jammed > pkp -> pk_maxlcn / 2 && cant_restart == 0) { ! 145: pk_message (0, pkp -> pk_xcp, "%d lcns jammed: attempting restart", lcns_jammed); ! 146: pk_restart (pkp, 0); ! 147: } ! 148: } ! 149: } ! 150: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.