The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Enumerations | Functions
retry.h File Reference

Binary IO abstractions for retrying of raw packets. More...

#include <freeradius-devel/util/retry.h>
#include <freeradius-devel/util/event.h>
+ Include dependency graph for retry.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_tfr_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_tfr_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_tfr_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...
 

Detailed Description

Binary IO abstractions for retrying of raw packets.

Id
83bf057f99ae0d3f056ee99360c08e0ea3feafff

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.


Data Structure Documentation

◆ fr_bio_retry_config_t

struct fr_bio_retry_config_t

Definition at line 44 of file retry.h.

+ Collaboration diagram for fr_bio_retry_config_t:
Data Fields
fr_event_list_t * el event list
fr_retry_config_t retry_config base retry config

◆ fr_bio_retry_entry_s

struct fr_bio_retry_entry_s

Definition at line 64 of file retry.c.

+ Collaboration diagram for 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

◆ fr_bio_retry_info_t

struct fr_bio_retry_info_t

Definition at line 50 of file retry.h.

+ Collaboration diagram for 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?

Macro Definition Documentation

◆ _CONST

#define _CONST   const

Definition at line 39 of file retry.h.

Typedef Documentation

◆ fr_bio_retry_entry_t

Definition at line 1 of file retry.h.

◆ fr_bio_retry_release_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.

Parameters
biothe binary IO handler
retry_ctxthe retry ctx to release
reasonwhy this packet is being released

Definition at line 136 of file retry.h.

◆ fr_bio_retry_response_t

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.

Parameters
biothe binary IO handler
[out]item_pitem pointer for request, from #fr_bio_retry_saved_t
packet_ctxper-packet context for the response
bufferraw data for the response
sizesize of the raw response data
Returns
  • false - do not pass the packet to the reader
  • true - pass the packet through to the reader

Definition at line 123 of file retry.h.

◆ fr_bio_retry_rewrite_t

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)

Definition at line 66 of file retry.h.

◆ fr_bio_retry_sent_t

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.

Parameters
biothe binary IO handler
packet_ctxper-packet context
bufferraw data for the packet
sizesize of the raw data
retry_ctxpointer to save for use with later cancellation

Definition at line 98 of file retry.h.

Enumeration Type Documentation

◆ fr_bio_retry_release_reason_t

Enumerator
FR_BIO_RETRY_DONE 
FR_BIO_RETRY_NO_REPLY 
FR_BIO_RETRY_CANCELLED 
FR_BIO_RETRY_WRITE_ERROR 
FR_BIO_RETRY_FATAL_ERROR 

Definition at line 79 of file retry.h.

Function Documentation

◆ fr_bio_retry_alloc()

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.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_bio_retry_entry_cancel()

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.

Parameters
biothe binary IO handler
itemthe retry context from fr_bio_retry_sent_t
Returns
  • <0 error
  • 0 - didn't cancel
  • 1 - did cancel

Definition at line 993 of file retry.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_bio_retry_entry_info()

const fr_retry_t* fr_bio_retry_entry_info ( fr_bio_t bio,
fr_bio_retry_entry_t retry_ctx 
)

◆ fr_bio_retry_entry_init()

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()

fr_bio_retry_info_t const* fr_bio_retry_info ( fr_bio_t bio)

Definition at line 1158 of file retry.c.

+ Here is the caller graph for this function:

◆ fr_bio_retry_item_reserve()

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.

+ Here is the call graph for this function:

◆ fr_bio_retry_outstanding()

size_t fr_bio_retry_outstanding ( fr_bio_t bio)

Definition at line 1165 of file retry.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_bio_retry_rewrite()

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.

Parameters
biothe binary IO handler
itemthe retry context from fr_bio_retry_sent_t
bufferraw data for the packet. May be NULL, in which case the previous packet is retried
sizesize of the raw data
Returns
  • <0 on error
  • 0 for "wrote no data"
  • >0 for "wrote data".

Definition at line 554 of file retry.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: