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

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

#include <freeradius-devel/util/event.h>
+ Include dependency graph for dedup.h:

Go to the source code of this file.

Data Structures

struct  fr_bio_dedup_config_t
 
struct  fr_bio_dedup_entry_s
 

Typedefs

typedef struct fr_bio_dedup_entry_s fr_bio_dedup_entry_t
 
typedef fr_bio_dedup_entry_t *(* fr_bio_dedup_get_item_t) (fr_bio_t *bio, void *packet_ctx)
 
typedef bool(* fr_bio_dedup_receive_t) (fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, void *packet_ctx, const void *buffer, size_t size)
 Callback on read to see if we should receive the packet. More...
 
typedef void(* fr_bio_dedup_release_t) (fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, fr_bio_dedup_release_reason_t reason)
 Callback on release the packet (timeout, or cancelled by the application) More...
 

Enumerations

enum  fr_bio_dedup_release_reason_t {
  FR_BIO_DEDUP_EXPIRED = 0 ,
  FR_BIO_DEDUP_CANCELLED ,
  FR_BIO_DEDUP_WRITE_ERROR ,
  FR_BIO_DEDUP_INTERNAL_ERROR
}
 

Functions

fr_bio_tfr_bio_dedup_alloc (TALLOC_CTX *ctx, size_t max_saved, fr_bio_dedup_receive_t receive, fr_bio_dedup_release_t release, fr_bio_dedup_get_item_t get_item, fr_bio_dedup_config_t const *cfg, fr_bio_t *next))
 Allocate a fr_bio_dedup_t. More...
 
void fr_bio_dedup_entry_cancel (fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx)
 Cancel one item. More...
 
int fr_bio_dedup_entry_extend (fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, fr_time_t expires)
 Extend the expiry time for an entry. More...
 
ssize_t fr_bio_dedup_respond (fr_bio_t *bio, fr_bio_dedup_entry_t *item)
 Resend a reply when we receive a duplicate request. More...
 

Detailed Description

Binary IO abstractions for deduping of raw packets.

Id
1860730646f4a58ce740b49c08a9f5e7b93f5c89

Read packets from a dedup bio. Once a packet is read, it is checked against a dedup tree. Duplicate packets are suppressed.

The caller has to manage the actual dedup tree and comparisons. Each protocol has its own requirements for dedup, and it is too awkward to make a generic method which works everywhere.

Definition in file dedup.h.


Data Structure Documentation

◆ fr_bio_dedup_config_t

struct fr_bio_dedup_config_t

Definition at line 36 of file dedup.h.

+ Collaboration diagram for fr_bio_dedup_config_t:
Data Fields
fr_event_list_t * el event list
fr_time_delta_t lifetime default lifetime of dedup entry

◆ fr_bio_dedup_entry_s

struct fr_bio_dedup_entry_s

Definition at line 57 of file dedup.c.

+ Collaboration diagram for fr_bio_dedup_entry_s:
Data Fields
union fr_bio_dedup_entry_s __unnamed__
fr_time_t expires when this entry expires
fr_bio_dedup_t * my so we can get to it from the event timer callback
uint8_t * packet cached packet data for finding duplicates

cached packet data.

void * packet_ctx packet_ctx for dedup purposes
size_t packet_size size of the cached packet data
uint8_t * reply reply cached by the application
void * reply_ctx reply ctx
size_t reply_size size of the cached reply
fr_bio_dedup_state_t state which tree or list this item is in
void * uctx user-writable context

Typedef Documentation

◆ fr_bio_dedup_entry_t

Definition at line 1 of file dedup.h.

◆ fr_bio_dedup_get_item_t

typedef fr_bio_dedup_entry_t*(* fr_bio_dedup_get_item_t) (fr_bio_t *bio, void *packet_ctx)

Definition at line 93 of file dedup.h.

◆ fr_bio_dedup_receive_t

typedef bool(* fr_bio_dedup_receive_t) (fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, void *packet_ctx, const void *buffer, size_t size)

Callback on read to see if we should receive the packet.

The caller should cache dedup_ctx, unless it's a duplicate request.

If it's a duplicate request, the caller should call fr_bio_dedup_respond() to write out the reply.

Parameters
biothe binary IO handler
dedup_ctxnew dedup_ctx assigned to this potential packet
packet_ctxper-packet context for the response
bufferraw data for the request
sizesize of the raw request data
Returns
  • false - discard the packet
  • true - create a new entry for the packet

Definition at line 78 of file dedup.h.

◆ fr_bio_dedup_release_t

typedef void(* fr_bio_dedup_release_t) (fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, fr_bio_dedup_release_reason_t reason)

Callback on release the packet (timeout, or cancelled by the application)

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
dedup_ctxthe dedup ctx to release
reasonwhy this packet is being released

Definition at line 91 of file dedup.h.

Enumeration Type Documentation

◆ fr_bio_dedup_release_reason_t

Enumerator
FR_BIO_DEDUP_EXPIRED 
FR_BIO_DEDUP_CANCELLED 
FR_BIO_DEDUP_WRITE_ERROR 
FR_BIO_DEDUP_INTERNAL_ERROR 

Definition at line 56 of file dedup.h.

Function Documentation

◆ fr_bio_dedup_alloc()

fr_bio_t* fr_bio_dedup_alloc ( TALLOC_CTX *  ctx,
size_t  max_saved,
fr_bio_dedup_receive_t  receive,
fr_bio_dedup_release_t  release,
fr_bio_dedup_get_item_t  get_item,
fr_bio_dedup_config_t const *  cfg,
fr_bio_t next 
)

Allocate a fr_bio_dedup_t.

Definition at line 987 of file dedup.c.

+ Here is the call graph for this function:

◆ fr_bio_dedup_entry_cancel()

void fr_bio_dedup_entry_cancel ( fr_bio_t bio,
fr_bio_dedup_entry_t item 
)

Cancel one item.

Parameters
biothe binary IO handler
itemthe dedup context from #fr_bio_dedup_respond_t

Definition at line 887 of file dedup.c.

+ Here is the call graph for this function:

◆ fr_bio_dedup_entry_extend()

int fr_bio_dedup_entry_extend ( fr_bio_t bio,
fr_bio_dedup_entry_t item,
fr_time_t  expires 
)

Extend the expiry time for an entry.

Parameters
biothe binary IO handler
itemthe dedup context from #fr_bio_dedup_respond_t
expiresthe new expiry time
Returns
  • <0 error
  • 0 success

Definition at line 905 of file dedup.c.

+ Here is the call graph for this function:

◆ fr_bio_dedup_respond()

ssize_t fr_bio_dedup_respond ( fr_bio_t bio,
fr_bio_dedup_entry_t item 
)

Resend a reply when we receive a duplicate request.

This function should be called by the respond() callback to re-send a duplicate reply.

It can also be called by the application when it first has a response to the request.

Parameters
biothe binary IO handler
itemthe dedup context from #fr_bio_dedup_sent_t
Returns
  • <0 on error
  • 0 for "wrote no data"
  • >0 for "wrote data".

Definition at line 173 of file dedup.c.

+ Here is the call graph for this function: