The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Functions | Variables
udp_queue.c File Reference
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/socket.h>
#include <freeradius-devel/util/udp_queue.h>
+ Include dependency graph for udp_queue.c:

Go to the source code of this file.

Data Structures

struct  fr_udp_queue_entry_t
 
struct  fr_udp_queue_s
 

Functions

static int _udp_queue_entry_free (fr_udp_queue_entry_t *entry)
 
static int _udp_queue_free (fr_udp_queue_t *uq)
 
 close (uq->fd)
 
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...
 
 if (fr_dlist_num_elements(&uq->queue)==0)
 
static void udp_queue_writable (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
 If the socket is writable, then flush packets until either it returns EWOULDBLOCK, or there are no more packets to write. More...
 

Variables

 return
 

Data Structure Documentation

◆ fr_udp_queue_entry_t

struct fr_udp_queue_entry_t

Definition at line 47 of file udp_queue.c.

+ Collaboration diagram for fr_udp_queue_entry_t:
Data Fields
fr_dlist_t dlist
fr_time_t expires
uint8_t packet[]
size_t packet_len
void * rctx
struct sockaddr_storage sockaddr
socklen_t socklen
fr_udp_queue_t * uq

◆ fr_udp_queue_s

struct fr_udp_queue_s

Definition at line 35 of file udp_queue.c.

+ Collaboration diagram for fr_udp_queue_s:
Data Fields
bool blocked are we blocked?
fr_udp_queue_config_t const * config configuration
fr_event_list_t * el
int fd
int port
fr_dlist_head_t queue list of queued packets to write, ordered by time
fr_udp_queue_resume_t resume

Function Documentation

◆ _udp_queue_entry_free()

static int _udp_queue_entry_free ( fr_udp_queue_entry_t entry)
static

Definition at line 73 of file udp_queue.c.

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

◆ _udp_queue_free()

static int _udp_queue_free ( fr_udp_queue_t uq)
static

Definition at line 62 of file udp_queue.c.

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

◆ close()

close ( uq->  fd)

◆ 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:

◆ if()

if ( fr_dlist_num_elements &->  queue = = 0)

Definition at line 234 of file udp_queue.c.

+ Here is the call graph for this function:

◆ udp_queue_writable()

static void udp_queue_writable ( UNUSED fr_event_list_t el,
UNUSED int  fd,
UNUSED int  flags,
void *  uctx 
)
static

If the socket is writable, then flush packets until either it returns EWOULDBLOCK, or there are no more packets to write.

Definition at line 185 of file udp_queue.c.

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

Variable Documentation

◆ return

return

Definition at line 70 of file udp_queue.c.