The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
retry.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /** Boxed value structures and functions to manipulate them
19  *
20  * @file src/lib/util/retry.h
21  *
22  * @copyright 2020 Network RADIUS SAS
23  */
24 RCSIDH(retry_h, "$Id: 0e289f41e9e69e064eff0899fb180e0ab9a534bd $")
25 
26 #include <freeradius-devel/util/time.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 typedef struct {
33  fr_time_delta_t irt; //!< Initial transmission time
34  fr_time_delta_t mrt; //!< Maximum retransmission time
35  fr_time_delta_t mrd; //!< Maximum retransmission duration
36  uint32_t mrc; //!< Maximum retransmission count
38 
39 #define RETRY_INIT { fr_time_delta_wrap(0), fr_time_delta_wrap(0), fr_time_delta_wrap(0), 0 }
40 
41 typedef struct {
42  fr_retry_config_t const *config; //!< master configuration
43  fr_time_t start; //!< when we started the retransmission
44  fr_time_t next; //!< when the next timer should be set
45  fr_time_t updated; //!< last update, really a cached "now".
46  fr_time_delta_t rt; //!< retransmit interval
47  uint32_t count; //!< number of sent packets
48  uint32_t replies; //!< number of responses received.
49 } fr_retry_t;
50 
51 /*
52  * Anything other than "CONTINUE" means "DONE". For helpfulness,
53  * we return *why* the timer is done.
54  */
55 typedef enum {
57  FR_RETRY_MRC, //!< reached maximum retransmission count
58  FR_RETRY_MRD, //!< reached maximum retransmission duration
60 
61 void fr_retry_init(fr_retry_t *r, fr_time_t now, fr_retry_config_t const *config) CC_HINT(nonnull);
63 
64 #ifdef __cplusplus
65 }
66 #endif
#define RCSIDH(h, id)
Definition: build.h:445
unsigned int uint32_t
Definition: merged_model.c:33
static const conf_parser_t config[]
Definition: base.c:188
A time delta, a difference in time measured in nanoseconds.
Definition: time.h:80
"server local" time.
Definition: time.h:69
fr_retry_state_t fr_retry_next(fr_retry_t *r, fr_time_t now)
Initialize a retransmission counter.
Definition: retry.c:84
fr_time_t start
when we started the retransmission
Definition: retry.h:43
fr_time_delta_t irt
Initial transmission time.
Definition: retry.h:33
fr_time_delta_t rt
retransmit interval
Definition: retry.h:46
uint32_t replies
number of responses received.
Definition: retry.h:48
fr_time_delta_t mrt
Maximum retransmission time.
Definition: retry.h:34
uint32_t mrc
Maximum retransmission count.
Definition: retry.h:36
void fr_retry_init(fr_retry_t *r, fr_time_t now, fr_retry_config_t const *config)
Initialize a retransmission counter.
Definition: retry.c:36
fr_retry_config_t const * config
master configuration
Definition: retry.h:42
fr_retry_state_t
Definition: retry.h:55
@ FR_RETRY_MRC
reached maximum retransmission count
Definition: retry.h:57
@ FR_RETRY_CONTINUE
Definition: retry.h:56
@ FR_RETRY_MRD
reached maximum retransmission duration
Definition: retry.h:58
uint32_t count
number of sent packets
Definition: retry.h:47
fr_time_delta_t mrd
Maximum retransmission duration.
Definition: retry.h:35
fr_time_t updated
last update, really a cached "now".
Definition: retry.h:45
fr_time_t next
when the next timer should be set
Definition: retry.h:44
int nonnull(2, 5))