Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.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  *      @(#) $DragonFly: src/usr.sbin/atm/scspd/scsp_timer.c,v 1.2 2003/06/17 04:29:52 dillon Exp $
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 /*
60  * Process an SCSP Open timeout
61  *
62  * The open timer is set when an attempt to open a VCC to a DCS fails.
63  * This routine will be called when the timer fires and will retry
64  * the open.  Retries can continue indefinitely.
65  *
66  * Arguments:
67  *      stp     pointer to an SCSP timer block
68  *
69  * Returns:
70  *      None
71  *
72  */
73 void
74 scsp_open_timeout(stp)
75         Harp_timer      *stp;
76 {
77         Scsp_dcs        *dcsp;
78
79         /*
80          * Back off to start of DCS entry
81          */
82         dcsp = (Scsp_dcs *) ((caddr_t)stp -
83                         (int)(&((Scsp_dcs *)0)->sd_open_t));
84
85         /*
86          * Retry the connection
87          */
88         if (scsp_dcs_connect(dcsp)) {
89                 /*
90                  * Connect failed -- we hope the error was temporary
91                  * and set the timer to try again later
92                  */
93                 HARP_TIMER(&dcsp->sd_open_t, SCSP_Open_Interval,
94                                 scsp_open_timeout);
95         }
96 }
97
98
99 /*
100  * Process an SCSP Hello timeout
101  *
102  * The Hello timer fires every SCSP_HELLO_Interval seconds.  This
103  * routine will notify the Hello FSM when the timer fires.
104  *
105  * Arguments:
106  *      stp     pointer to an SCSP timer block
107  *
108  * Returns:
109  *      None
110  *
111  */
112 void
113 scsp_hello_timeout(stp)
114         Harp_timer      *stp;
115 {
116         Scsp_dcs        *dcsp;
117
118         /*
119          * Back off to start of DCS entry
120          */
121         dcsp = (Scsp_dcs *) ((caddr_t)stp -
122                         (int)(&((Scsp_dcs *)0)->sd_hello_h_t));
123
124         /*
125          * Call the Hello FSM
126          */
127         (void)scsp_hfsm(dcsp, SCSP_HFSM_HELLO_T, (Scsp_msg *)0);
128
129         return;
130 }
131
132
133 /*
134  * Process an SCSP receive timeout
135  *
136  * The receive timer is started whenever the Hello FSM receives a
137  * Hello message from its DCS.  If the timer fires, it means that no
138  * Hello messages have been received in the DCS's Hello interval.
139  *
140  * Arguments:
141  *      stp     pointer to an SCSP timer block
142  *
143  * Returns:
144  *      None
145  *
146  */
147 void
148 scsp_hello_rcv_timeout(stp)
149         Harp_timer      *stp;
150 {
151         Scsp_dcs        *dcsp;
152
153         /*
154          * Back off to start of DCS entry
155          */
156         dcsp = (Scsp_dcs *) ((caddr_t)stp -
157                         (int)(&((Scsp_dcs *)0)->sd_hello_rcv_t));
158
159         /*
160          * Call the Hello FSM
161          */
162         (void)scsp_hfsm(dcsp, SCSP_HFSM_RCV_T, (void *)0);
163
164         return;
165 }
166
167
168 /*
169  * Process an SCSP CA retransmit timeout
170  *
171  * Arguments:
172  *      stp     pointer to an SCSP timer block
173  *
174  * Returns:
175  *      None
176  *
177  */
178 void
179 scsp_ca_retran_timeout(stp)
180         Harp_timer      *stp;
181 {
182         Scsp_dcs        *dcsp;
183
184         /*
185          * Back off to start of DCS entry
186          */
187         dcsp = (Scsp_dcs *) ((caddr_t)stp -
188                         (int)(&((Scsp_dcs *)0)->sd_ca_rexmt_t));
189
190         /*
191          * Call the CA FSM
192          */
193         (void)scsp_cafsm(dcsp, SCSP_CAFSM_CA_T, (void *)0);
194
195         return;
196 }
197
198
199 /*
200  * Process an SCSP CSUS retransmit timeout
201  *
202  * Arguments:
203  *      stp     pointer to an SCSP timer block
204  *
205  * Returns:
206  *      None
207  *
208  */
209 void
210 scsp_csus_retran_timeout(stp)
211         Harp_timer      *stp;
212 {
213         Scsp_dcs        *dcsp;
214
215         /*
216          * Back off to start of DCS entry
217          */
218         dcsp = (Scsp_dcs *) ((caddr_t)stp -
219                         (int)(&((Scsp_dcs *)0)->sd_csus_rexmt_t));
220
221         /*
222          * Call the CA FSM
223          */
224         (void)scsp_cafsm(dcsp, SCSP_CAFSM_CSUS_T, (void *)0);
225
226         return;
227 }
228
229
230 /*
231  * Process an SCSP CSU Req retransmit timeout
232  *
233  * Arguments:
234  *      stp     pointer to an SCSP timer block
235  *
236  * Returns:
237  *      None
238  *
239  */
240 void
241 scsp_csu_req_retran_timeout(stp)
242         Harp_timer      *stp;
243 {
244         Scsp_csu_rexmt  *rxp;
245         Scsp_dcs        *dcsp;
246
247         /*
248          * Back off to start of CSU Request retransmission entry
249          */
250         rxp = (Scsp_csu_rexmt *) ((caddr_t)stp -
251                         (int)(&((Scsp_csu_rexmt *)0)->sr_t));
252         dcsp = rxp->sr_dcs;
253
254         /*
255          * Call the CA FSM
256          */
257         (void)scsp_cafsm(dcsp, SCSP_CAFSM_CSU_T, (void *)rxp);
258
259         return;
260 }