The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
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 <freeradius-devel/util/rb.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)
 Callback on read to see if we should receive the packet.
 
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)
 

Enumerations

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

Functions

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.
 
void fr_bio_dedup_entry_cancel (fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx)
 Cancel one item.
 
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.
 
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.
 

Detailed Description

Binary IO abstractions for deduping of raw packets.

Id
13eeb3d7db27b7606905a51aa9bc4343bd9d9120

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 37 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 94 of file dedup.c.

+ Collaboration diagram for fr_bio_dedup_entry_s:
Data Fields
union fr_bio_dedup_entry_s.__unnamed20__ __unnamed__
fr_rb_node_t dedup user managed dedup node
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 43 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 94 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)

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
Returns
  • false - discard the packet
  • true - create a new entry for the packet

Definition at line 79 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 92 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 59 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 1117 of file dedup.c.

+ Here is the call graph for this function:
+ Here is the caller 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 1013 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 1031 of file dedup.c.

+ Here is the call graph for this function:
+ Here is the caller 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 212 of file dedup.c.

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