The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | 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
 

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_start (fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx, fr_retry_config_t const *cfg)
 
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
f2ed5ea934c3b90a2151f23f65d1c8b64c382f6a

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 35 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 42 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
bool cancelled was this item cancelled?
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
fr_retry_t 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
void * uctx user-writable context

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 111 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 98 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 43 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 73 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 54 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 852 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 767 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_start()

int fr_bio_retry_entry_start ( fr_bio_t bio,
fr_bio_retry_entry_t retry_ctx,
fr_retry_config_t const *  cfg 
)

◆ 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 447 of file retry.c.

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