The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Binary IO abstractions for retrying of raw packets. More...
#include <freeradius-devel/util/retry.h>
#include <freeradius-devel/util/event.h>
Go to the source code of this file.
Data Structures | |
struct | fr_bio_retry_config_t |
struct | fr_bio_retry_entry_s |
struct | fr_bio_retry_info_t |
Macros | |
#define | _CONST const |
Typedefs | |
typedef struct fr_bio_retry_entry_s | fr_bio_retry_entry_t |
typedef void(* | fr_bio_retry_release_t) (fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx, fr_bio_retry_release_reason_t reason) |
Callback on release the packet (timeout or have all replies) More... | |
typedef bool(* | fr_bio_retry_response_t) (fr_bio_t *bio, fr_bio_retry_entry_t **item_p, void *packet_ctx, const void *buffer, size_t size) |
Callback on read to see if a packet is a response. More... | |
typedef ssize_t(* | fr_bio_retry_rewrite_t) (fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx, const void *buffer, size_t size) |
typedef void(* | fr_bio_retry_sent_t) (fr_bio_t *bio, void *packet_ctx, const void *buffer, size_t size, fr_bio_retry_entry_t *retry_ctx) |
Callback for when a packet is sent. More... | |
Enumerations | |
enum | fr_bio_retry_release_reason_t { FR_BIO_RETRY_DONE = 0 , FR_BIO_RETRY_NO_REPLY , FR_BIO_RETRY_CANCELLED , FR_BIO_RETRY_WRITE_ERROR , FR_BIO_RETRY_FATAL_ERROR } |
Functions | |
fr_bio_t * | fr_bio_retry_alloc (TALLOC_CTX *ctx, size_t max_saved, fr_bio_retry_sent_t sent, fr_bio_retry_response_t response, fr_bio_retry_rewrite_t rewrite, fr_bio_retry_release_t release, fr_bio_retry_config_t const *cfg, fr_bio_t *next)) |
Allocate a fr_bio_retry_t. More... | |
int | fr_bio_retry_entry_cancel (fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx)) |
Cancel one item. More... | |
const fr_retry_t * | fr_bio_retry_entry_info (fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx) |
int | fr_bio_retry_entry_init (fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx, fr_retry_config_t const *cfg) |
fr_bio_retry_info_t const * | fr_bio_retry_info (fr_bio_t *bio) |
fr_bio_retry_entry_t * | fr_bio_retry_item_reserve (fr_bio_t *bio) |
Reserve an entry for later use with fr_bio_retry_rewrite() More... | |
size_t | fr_bio_retry_outstanding (fr_bio_t *bio) |
ssize_t | fr_bio_retry_rewrite (fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx, const void *buffer, size_t size)) |
Resend a packet. More... | |
Binary IO abstractions for retrying of raw packets.
Write packets of data to bios. Once a packet is written, it is retried until a response is returned. Note that this ONLY works for datagram bios, where the packets can be retransmitted identically without any changes.
Definition in file retry.h.
struct fr_bio_retry_config_t |
Data Fields | ||
---|---|---|
fr_event_list_t * | el | event list |
fr_retry_config_t | retry_config | base retry config |
struct fr_bio_retry_entry_s |
Data Fields | ||
---|---|---|
union fr_bio_retry_entry_s | __unnamed__ | |
uint8_t const * | buffer | cached copy of the packet to send |
bool | cancelled | was this item cancelled? |
fr_rb_node_t | expiry_node | for expiries |
fr_bio_retry_t * | my | so we can get to it from the event timer callback |
void * | packet_ctx | packet_ctx from the write() call |
bool | reserved | for application-layer watchdog |
fr_retry_t | retry | retry timers and counters |
fr_retry_t _CONST | retry | retry timers and counters |
fr_bio_retry_rewrite_t | rewrite | per-packet rewrite callback |
void * | rewrite_ctx | context specifically for rewriting this packet |
size_t | size | size of the cached packet |
void * | uctx | user-writable context |
struct fr_bio_retry_info_t |
Data Fields | ||
---|---|---|
fr_bio_retry_config_t const * | cfg | so we know what was asked |
fr_event_list_t * | el | event list |
fr_time_t | first_sent | first time we sent a packet since going idle |
fr_time_t | last_idle | last time we had nothing to do |
fr_time_t | last_reply | When we last received a reply. |
fr_time_t | last_sent | last time we sent a packet. |
fr_time_t | mrs_time | Most recent sent time which had a reply. |
bool | write_blocked | are writes blocked? |
typedef struct fr_bio_retry_entry_s fr_bio_retry_entry_t |
typedef void(* fr_bio_retry_release_t) (fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx, fr_bio_retry_release_reason_t reason) |
Callback on release the packet (timeout or have all replies)
The callback function should clean up any resources associated with the packet. The resources MUST NOT be released until the data is either "released" or "cancelled".
The packet will be cancelled after this call returns. The cancellation callback will NOT be run.
bio | the binary IO handler |
retry_ctx | the retry ctx to release |
reason | why this packet is being released |
typedef bool(* fr_bio_retry_response_t) (fr_bio_t *bio, fr_bio_retry_entry_t **item_p, void *packet_ctx, const void *buffer, size_t size) |
Callback on read to see if a packet is a response.
The callback should manually associate the response with a request, but allow the packet to be returned to the application.
The callback should also set item_p, even if the response is duplicate. That way the retry bio can properly track multiple requests and responses.
If there is a fatal error reading the response, the callback should set a flag (in the bio)? and return. It should NOT call any bio shutdown routine.
bio | the binary IO handler | |
[out] | item_p | item pointer for request, from #fr_bio_retry_saved_t |
packet_ctx | per-packet context for the response | |
buffer | raw data for the response | |
size | size of the raw response data |
typedef ssize_t(* fr_bio_retry_rewrite_t)(fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx, const void *buffer, size_t size) |
typedef void(* fr_bio_retry_sent_t) (fr_bio_t *bio, void *packet_ctx, const void *buffer, size_t size, fr_bio_retry_entry_t *retry_ctx) |
Callback for when a packet is sent.
The purpose of the callback is for the application to save the retry_ctx, in case the packet needs to be cancelled at a later point in time.
bio | the binary IO handler |
packet_ctx | per-packet context |
buffer | raw data for the packet |
size | size of the raw data |
retry_ctx | pointer to save for use with later cancellation |
fr_bio_t* fr_bio_retry_alloc | ( | TALLOC_CTX * | ctx, |
size_t | max_saved, | ||
fr_bio_retry_sent_t | sent, | ||
fr_bio_retry_response_t | response, | ||
fr_bio_retry_rewrite_t | rewrite, | ||
fr_bio_retry_release_t | release, | ||
fr_bio_retry_config_t const * | cfg, | ||
fr_bio_t * | next | ||
) |
Allocate a fr_bio_retry_t.
Definition at line 1087 of file retry.c.
int fr_bio_retry_entry_cancel | ( | fr_bio_t * | bio, |
fr_bio_retry_entry_t * | item | ||
) |
Cancel one item.
If "item" is NULL, the last entry in the timer tree is cancelled.
bio | the binary IO handler |
item | the retry context from fr_bio_retry_sent_t |
Definition at line 993 of file retry.c.
const fr_retry_t* fr_bio_retry_entry_info | ( | fr_bio_t * | bio, |
fr_bio_retry_entry_t * | retry_ctx | ||
) |
int fr_bio_retry_entry_init | ( | fr_bio_t * | bio, |
fr_bio_retry_entry_t * | retry_ctx, | ||
fr_retry_config_t const * | cfg | ||
) |
fr_bio_retry_info_t const* fr_bio_retry_info | ( | fr_bio_t * | bio | ) |
fr_bio_retry_entry_t* fr_bio_retry_item_reserve | ( | fr_bio_t * | bio | ) |
Reserve an entry for later use with fr_bio_retry_rewrite()
So that application-layer watchdogs can bypass the normal write / retry routines.
Definition at line 1184 of file retry.c.
ssize_t fr_bio_retry_rewrite | ( | fr_bio_t * | bio, |
fr_bio_retry_entry_t * | item, | ||
const void * | buffer, | ||
size_t | size | ||
) |
Resend a packet.
This function should be called by the rewrite() callback, after (possibly) re-encoding the packet.
bio | the binary IO handler |
item | the retry context from fr_bio_retry_sent_t |
buffer | raw data for the packet. May be NULL, in which case the previous packet is retried |
size | size of the raw data |
Definition at line 554 of file retry.c.