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: 752ffb33a02b91ba1694ccfc6a370e32dc99828d $")
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 /*
42  * Anything other than "CONTINUE" means "DONE". For helpfulness,
43  * we return *why* the timer is done.
44  */
45 typedef enum {
47  FR_RETRY_MRC, //!< reached maximum retransmission count
48  FR_RETRY_MRD, //!< reached maximum retransmission duration
50 
51 typedef struct {
52  fr_retry_config_t const *config; //!< master configuration
53  fr_time_t start; //!< when we started the retransmission
54  fr_time_t end; //!< when we will end the retransmissions
55  fr_time_t next; //!< when the next timer should be set
56  fr_time_t updated; //!< last update, really a cached "now".
57  fr_time_delta_t rt; //!< retransmit interval
58  uint32_t count; //!< number of sent packets
59  uint32_t replies; //!< number of responses received.
60  fr_retry_state_t state; //!< so callers can see what state it's in.
61 } fr_retry_t;
62 
63 void fr_retry_init(fr_retry_t *r, fr_time_t now, fr_retry_config_t const *config) CC_HINT(nonnull);
65 
66 #ifdef __cplusplus
67 }
68 #endif
#define RCSIDH(h, id)
Definition: build.h:482
unsigned int uint32_t
Definition: merged_model.c:33
static const conf_parser_t config[]
Definition: base.c:183
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:108
fr_time_t start
when we started the retransmission
Definition: retry.h:53
fr_time_delta_t irt
Initial transmission time.
Definition: retry.h:33
fr_time_delta_t rt
retransmit interval
Definition: retry.h:57
uint32_t replies
number of responses received.
Definition: retry.h:59
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:52
fr_retry_state_t state
so callers can see what state it's in.
Definition: retry.h:60
fr_retry_state_t
Definition: retry.h:45
@ FR_RETRY_MRC
reached maximum retransmission count
Definition: retry.h:47
@ FR_RETRY_CONTINUE
Definition: retry.h:46
@ FR_RETRY_MRD
reached maximum retransmission duration
Definition: retry.h:48
uint32_t count
number of sent packets
Definition: retry.h:58
fr_time_t end
when we will end the retransmissions
Definition: retry.h:54
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:56
fr_time_t next
when the next timer should be set
Definition: retry.h:55
int nonnull(2, 5))