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