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

Handle queues of outgoing UDP packets. More...

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

Go to the source code of this file.

Data Structures

struct  fr_udp_queue_config_t
 

Typedefs

typedef void(* fr_udp_queue_resume_t) (bool written, void *rctx)
 
typedef struct fr_udp_queue_s fr_udp_queue_t
 

Functions

fr_udp_queue_tfr_udp_queue_alloc (TALLOC_CTX *ctx, fr_udp_queue_config_t const *config, fr_event_list_t *el, fr_udp_queue_resume_t resume))
 Allocate an outbound UDP queue. More...
 
int fr_udp_queue_write (TALLOC_CTX *ctx, fr_udp_queue_t *uq, uint8_t const *packet, size_t packet_len, fr_ipaddr_t const *ipaddr, int port, void *rctx))
 Write packet to socket, OR enqueue it if we get EAGAIN. More...
 

Detailed Description

Handle queues of outgoing UDP packets.

Id
24fda9b6eb6eb81d7c489c544db1f5441b764f73

Definition in file udp_queue.h.


Data Structure Documentation

◆ fr_udp_queue_config_t

struct fr_udp_queue_config_t

Definition at line 36 of file udp_queue.h.

+ Collaboration diagram for fr_udp_queue_config_t:
Data Fields
char const * interface Interface to bind to.
fr_ipaddr_t ipaddr socket IP address
uint32_t max_queued_packets maximum queued packets
fr_time_delta_t max_queued_time maximum time a packet can be queued
uint16_t port socket port
uint32_t send_buff How big the kernel's send buffer should be.
bool send_buff_is_set Whether we were provided with a send_buf.

Typedef Documentation

◆ fr_udp_queue_resume_t

typedef void(* fr_udp_queue_resume_t) (bool written, void *rctx)

Definition at line 53 of file udp_queue.h.

◆ fr_udp_queue_t

Definition at line 1 of file udp_queue.h.

Function Documentation

◆ fr_udp_queue_alloc()

fr_udp_queue_t* fr_udp_queue_alloc ( TALLOC_CTX *  ctx,
fr_udp_queue_config_t const *  config,
fr_event_list_t el,
fr_udp_queue_resume_t  resume 
)

Allocate an outbound UDP queue.

Parameters
ctxwhere the structure will be allocated.
configcontaining the IPs, ports, etc
elthe event list for adding events to see if the socket is writable
resumethe function to call after a delayed packet has been written
Returns
  • NULL on error
  • !NULL on success

Definition at line 95 of file udp_queue.c.

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

◆ fr_udp_queue_write()

int fr_udp_queue_write ( TALLOC_CTX *  ctx,
fr_udp_queue_t uq,
uint8_t const *  packet,
size_t  packet_len,
fr_ipaddr_t const *  ipaddr,
int  port,
void *  rctx 
)

Write packet to socket, OR enqueue it if we get EAGAIN.

In most cases, the packet will get written to the socket immediately.

However, if the socket is blocked, then the packet is added to an outbound queue. When the socket becomes unblocked, the packets will be sent.

Parameters
ctxthe talloc context for this packet to be saved in, usually request_t
uqthe local queue to write it to
packetthe packet to write
packet_lenhow long the packet is
ipaddrthe IP address we're sending the packet to
portthe port we're sending the packet to
rctxfor resumption, usually request_t, or a structure which holds a request_t
Returns
  • <0 for error
  • 0 for "didn't write it to socket, but added it to the queue, and the caller should yield"
  • 1 for "wrote it to the socket, you're good to go".

Definition at line 260 of file udp_queue.c.

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