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