Commit | Line | Data |
---|---|---|
51386eb2 KS |
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 | * %sccs.include.redist.c% | |
11 | * | |
4507dea2 | 12 | * @(#)pk_timer.c 7.3 (Berkeley) %G% |
51386eb2 | 13 | */ |
758293b0 | 14 | |
4507dea2 KS |
15 | #include "param.h" |
16 | #include "systm.h" | |
17 | #include "mbuf.h" | |
18 | #include "socket.h" | |
19 | #include "protosw.h" | |
20 | #include "socketvar.h" | |
21 | #include "errno.h" | |
758293b0 KS |
22 | |
23 | #include "../net/if.h" | |
24 | ||
4507dea2 KS |
25 | #include "x25.h" |
26 | #include "pk.h" | |
27 | #include "pk_var.h" | |
758293b0 KS |
28 | |
29 | /* | |
30 | * Various timer values. They can be adjusted | |
31 | * by patching the binary with adb if necessary. | |
32 | */ | |
33 | int pk_t20 = 18 * PR_SLOWHZ; /* restart timer */ | |
34 | int pk_t21 = 20 * PR_SLOWHZ; /* call timer */ | |
35 | /* XXX pk_t22 is never used */ | |
36 | int pk_t22 = 18 * PR_SLOWHZ; /* reset timer */ | |
37 | int pk_t23 = 18 * PR_SLOWHZ; /* clear timer */ | |
38 | ||
39 | pk_timer () | |
40 | { | |
41 | register struct pkcb *pkp; | |
42 | register struct pklcd *lcp, **pp; | |
43 | register int lcns_jammed, cant_restart; | |
44 | ||
45 | for (pkp = pkcbhead; pkp; pkp = pkp->pk_next) { | |
46 | switch (pkp -> pk_state) { | |
47 | case DTE_SENT_RESTART: | |
48 | lcp = pkp -> pk_chan[0]; | |
49 | /* | |
50 | * If restart failures are common, a link level | |
51 | * reset should be initiated here. | |
52 | */ | |
53 | if (lcp -> lcd_timer && --lcp -> lcd_timer == 0) | |
54 | pk_message (0, pkp -> pk_xcp, | |
55 | "packet level restart failed"); | |
56 | break; | |
57 | ||
58 | case DTE_READY: | |
59 | lcns_jammed = cant_restart = 0; | |
60 | for (pp = &pkp -> pk_chan[1]; pp <= &pkp -> pk_chan[pkp -> pk_maxlcn]; pp++) { | |
61 | if ((lcp = *pp) == 0) | |
62 | continue; | |
63 | switch (lcp -> lcd_state) { | |
64 | case SENT_CALL: | |
65 | if (--lcp -> lcd_timer == 0) { | |
66 | lcp -> lcd_so -> so_error = ETIMEDOUT; | |
67 | pk_clear (lcp); | |
68 | } | |
69 | break; | |
70 | ||
71 | case SENT_CLEAR: | |
72 | if (lcp -> lcd_retry >= 3) | |
73 | lcns_jammed++; | |
74 | else | |
75 | if (--lcp -> lcd_timer == 0) | |
76 | pk_clear (lcp); | |
77 | break; | |
78 | ||
79 | case DATA_TRANSFER: /* lcn active */ | |
80 | cant_restart++; | |
81 | break; | |
82 | } | |
83 | } | |
84 | if (lcns_jammed > pkp -> pk_maxlcn / 2 && cant_restart == 0) { | |
85 | pk_message (0, pkp -> pk_xcp, "%d lcns jammed: attempting restart", lcns_jammed); | |
86 | pk_restart (pkp, 0); | |
87 | } | |
88 | } | |
89 | } | |
90 | } |