Initial import from FreeBSD RELENG_4:
[games.git] / usr.sbin / atm / scspd / scsp_timer.c
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/usr.sbin/atm/scspd/scsp_timer.c,v 1.3 1999/08/28 01:15:34 peter Exp $
27  *
28  */
29
30 /*
31  * Server Cache Synchronization Protocol (SCSP) Support
32  * ----------------------------------------------------
33  *
34  * Timer processing
35  *
36  */
37
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/socket.h>
41 #include <net/if.h>
42 #include <netinet/in.h>
43 #include <netatm/queue.h> 
44 #include <netatm/atm.h>
45 #include <netatm/atm_if.h>
46 #include <netatm/atm_sap.h>
47 #include <netatm/atm_sys.h>
48 #include <netatm/atm_ioctl.h>
49
50 #include <errno.h>
51 #include <libatm.h>
52 #include <stdio.h>
53 #include <syslog.h>
54
55 #include "scsp_msg.h"
56 #include "scsp_if.h"
57 #include "scsp_var.h"
58
59 #ifndef lint
60 __RCSID("@(#) $FreeBSD: src/usr.sbin/atm/scspd/scsp_timer.c,v 1.3 1999/08/28 01:15:34 peter Exp $");
61 #endif
62
63
64 /*
65  * Process an SCSP Open timeout
66  *
67  * The open timer is set when an attempt to open a VCC to a DCS fails.
68  * This routine will be called when the timer fires and will retry
69  * the open.  Retries can continue indefinitely.
70  *
71  * Arguments:
72  *      stp     pointer to an SCSP timer block
73  *
74  * Returns:
75  *      None
76  *
77  */
78 void
79 scsp_open_timeout(stp)
80         Harp_timer      *stp;
81 {
82         Scsp_dcs        *dcsp;
83
84         /*
85          * Back off to start of DCS entry
86          */
87         dcsp = (Scsp_dcs *) ((caddr_t)stp -
88                         (int)(&((Scsp_dcs *)0)->sd_open_t));
89
90         /*
91          * Retry the connection
92          */
93         if (scsp_dcs_connect(dcsp)) {
94                 /*
95                  * Connect failed -- we hope the error was temporary
96                  * and set the timer to try again later
97                  */
98                 HARP_TIMER(&dcsp->sd_open_t, SCSP_Open_Interval,
99                                 scsp_open_timeout);
100         }
101 }
102
103
104 /*
105  * Process an SCSP Hello timeout
106  *
107  * The Hello timer fires every SCSP_HELLO_Interval seconds.  This
108  * routine will notify the Hello FSM when the timer fires.
109  *
110  * Arguments:
111  *      stp     pointer to an SCSP timer block
112  *
113  * Returns:
114  *      None
115  *
116  */
117 void
118 scsp_hello_timeout(stp)
119         Harp_timer      *stp;
120 {
121         Scsp_dcs        *dcsp;
122
123         /*
124          * Back off to start of DCS entry
125          */
126         dcsp = (Scsp_dcs *) ((caddr_t)stp -
127                         (int)(&((Scsp_dcs *)0)->sd_hello_h_t));
128
129         /*
130          * Call the Hello FSM
131          */
132         (void)scsp_hfsm(dcsp, SCSP_HFSM_HELLO_T, (Scsp_msg *)0);
133
134         return;
135 }
136
137
138 /*
139  * Process an SCSP receive timeout
140  *
141  * The receive timer is started whenever the Hello FSM receives a
142  * Hello message from its DCS.  If the timer fires, it means that no
143  * Hello messages have been received in the DCS's Hello interval.
144  *
145  * Arguments:
146  *      stp     pointer to an SCSP timer block
147  *
148  * Returns:
149  *      None
150  *
151  */
152 void
153 scsp_hello_rcv_timeout(stp)
154         Harp_timer      *stp;
155 {
156         Scsp_dcs        *dcsp;
157
158         /*
159          * Back off to start of DCS entry
160          */
161         dcsp = (Scsp_dcs *) ((caddr_t)stp -
162                         (int)(&((Scsp_dcs *)0)->sd_hello_rcv_t));
163
164         /*
165          * Call the Hello FSM
166          */
167         (void)scsp_hfsm(dcsp, SCSP_HFSM_RCV_T, (void *)0);
168
169         return;
170 }
171
172
173 /*
174  * Process an SCSP CA retransmit timeout
175  *
176  * Arguments:
177  *      stp     pointer to an SCSP timer block
178  *
179  * Returns:
180  *      None
181  *
182  */
183 void
184 scsp_ca_retran_timeout(stp)
185         Harp_timer      *stp;
186 {
187         Scsp_dcs        *dcsp;
188
189         /*
190          * Back off to start of DCS entry
191          */
192         dcsp = (Scsp_dcs *) ((caddr_t)stp -
193                         (int)(&((Scsp_dcs *)0)->sd_ca_rexmt_t));
194
195         /*
196          * Call the CA FSM
197          */
198         (void)scsp_cafsm(dcsp, SCSP_CAFSM_CA_T, (void *)0);
199
200         return;
201 }
202
203
204 /*
205  * Process an SCSP CSUS retransmit timeout
206  *
207  * Arguments:
208  *      stp     pointer to an SCSP timer block
209  *
210  * Returns:
211  *      None
212  *
213  */
214 void
215 scsp_csus_retran_timeout(stp)
216         Harp_timer      *stp;
217 {
218         Scsp_dcs        *dcsp;
219
220         /*
221          * Back off to start of DCS entry
222          */
223         dcsp = (Scsp_dcs *) ((caddr_t)stp -
224                         (int)(&((Scsp_dcs *)0)->sd_csus_rexmt_t));
225
226         /*
227          * Call the CA FSM
228          */
229         (void)scsp_cafsm(dcsp, SCSP_CAFSM_CSUS_T, (void *)0);
230
231         return;
232 }
233
234
235 /*
236  * Process an SCSP CSU Req retransmit timeout
237  *
238  * Arguments:
239  *      stp     pointer to an SCSP timer block
240  *
241  * Returns:
242  *      None
243  *
244  */
245 void
246 scsp_csu_req_retran_timeout(stp)
247         Harp_timer      *stp;
248 {
249         Scsp_csu_rexmt  *rxp;
250         Scsp_dcs        *dcsp;
251
252         /*
253          * Back off to start of CSU Request retransmission entry
254          */
255         rxp = (Scsp_csu_rexmt *) ((caddr_t)stp -
256                         (int)(&((Scsp_csu_rexmt *)0)->sr_t));
257         dcsp = rxp->sr_dcs;
258
259         /*
260          * Call the CA FSM
261          */
262         (void)scsp_cafsm(dcsp, SCSP_CAFSM_CSU_T, (void *)rxp);
263
264         return;
265 }