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