The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Enumerations | Functions
control.c File Reference

Control-plane signaling. More...

#include <freeradius-devel/io/control.h>
#include <freeradius-devel/io/ring_buffer.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/rand.h>
#include <fcntl.h>
#include <string.h>
#include <sys/event.h>
+ Include dependency graph for control.c:

Go to the source code of this file.

Data Structures

struct  fr_control_ctx_t
 
struct  fr_control_message_t
 The header for the control message. More...
 
struct  fr_control_s
 The control structure. More...
 

Macros

#define FR_CONTROL_MAX_TYPES   (32)
 
#define MPRINT(...)
 

Typedefs

typedef enum fr_control_message_status_t fr_control_message_status_t
 Status of control messages. More...
 

Enumerations

enum  fr_control_message_status_t {
  FR_CONTROL_MESSAGE_FREE = 0 ,
  FR_CONTROL_MESSAGE_USED ,
  FR_CONTROL_MESSAGE_DONE
}
 Status of control messages. More...
 

Functions

static int _control_free (fr_control_t *c)
 Free a control structure. More...
 
int fr_control_callback_add (fr_control_t *c, uint32_t id, void *ctx, fr_control_callback_t callback)
 Register a callback for an ID. More...
 
int fr_control_callback_delete (fr_control_t *c, uint32_t id)
 Delete a callback for an ID. More...
 
fr_control_tfr_control_create (TALLOC_CTX *ctx, fr_event_list_t *el, fr_atomic_queue_t *aq)
 Create a control-plane signaling path. More...
 
int fr_control_gc (UNUSED fr_control_t *c, fr_ring_buffer_t *rb)
 Clean up messages in a control-plane buffer. More...
 
static fr_control_message_tfr_control_message_alloc (fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size)
 Allocate a control message. More...
 
ssize_t fr_control_message_pop (fr_atomic_queue_t *aq, uint32_t *p_id, void *data, size_t data_size)
 Pop control-plane message. More...
 
int fr_control_message_push (fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size)
 Push a control-plane message. More...
 
int fr_control_message_send (fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size)
 Send a control-plane message. More...
 
int fr_control_same_thread (fr_control_t *c)
 
static void pipe_read (UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
 

Detailed Description

Control-plane signaling.

Id
5f3de7e110fe4b8d0ec8f5b1041450db4d9dc70b

Definition in file control.c.


Data Structure Documentation

◆ fr_control_ctx_t

struct fr_control_ctx_t

Definition at line 69 of file control.c.

+ Collaboration diagram for fr_control_ctx_t:
Data Fields
fr_control_callback_t callback the function to call
void * ctx context for the callback
uint32_t id id of this callback

◆ fr_control_message_t

struct fr_control_message_t

The header for the control message.

Definition at line 62 of file control.c.

Data Fields
size_t data_size size of the data we're sending
uint32_t id ID of this message.
fr_control_message_status_t status status of this message

◆ fr_control_s

struct fr_control_s

The control structure.

Definition at line 79 of file control.c.

+ Collaboration diagram for fr_control_s:
Data Fields
fr_atomic_queue_t * aq destination AQ
fr_event_list_t * el our event list
int pipe[2] our pipes
bool same_thread are the two ends in the same thread
fr_control_ctx_t type[FR_CONTROL_MAX_TYPES] callbacks

Macro Definition Documentation

◆ FR_CONTROL_MAX_TYPES

#define FR_CONTROL_MAX_TYPES   (32)

Definition at line 38 of file control.c.

◆ MPRINT

#define MPRINT (   ...)

Definition at line 46 of file control.c.

Typedef Documentation

◆ fr_control_message_status_t

Status of control messages.

Enumeration Type Documentation

◆ fr_control_message_status_t

Status of control messages.

Enumerator
FR_CONTROL_MESSAGE_FREE 

the message is free

FR_CONTROL_MESSAGE_USED 

the message is used (set only by originator)

FR_CONTROL_MESSAGE_DONE 

the message is done (set only by receiver)

Definition at line 52 of file control.c.

Function Documentation

◆ _control_free()

static int _control_free ( fr_control_t c)
static

Free a control structure.

This function really only calls the underlying "garbage collect".

Parameters
[in]cthe control structure

Definition at line 125 of file control.c.

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

◆ fr_control_callback_add()

int fr_control_callback_add ( fr_control_t c,
uint32_t  id,
void *  ctx,
fr_control_callback_t  callback 
)

Register a callback for an ID.

Parameters
[in]cthe control structure
[in]idthe ident of this message.
[in]ctxthe context for the callback
[in]callbackthe callback function
Returns
  • <0 on error
  • 0 on success

Definition at line 417 of file control.c.

+ Here is the caller graph for this function:

◆ fr_control_callback_delete()

int fr_control_callback_delete ( fr_control_t c,
uint32_t  id 
)

Delete a callback for an ID.

Parameters
[in]cthe control structure
[in]idthe ident of this message.
Returns
  • <0 on error
  • 0 on success

Definition at line 454 of file control.c.

◆ fr_control_create()

fr_control_t* fr_control_create ( TALLOC_CTX *  ctx,
fr_event_list_t el,
fr_atomic_queue_t aq 
)

Create a control-plane signaling path.

Parameters
[in]ctxthe talloc context
[in]elthe event list for the control socket
[in]aqthe atomic queue where we will be pushing message data
Returns
  • NULL on error
  • fr_control_t on success

Definition at line 149 of file control.c.

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

◆ fr_control_gc()

int fr_control_gc ( UNUSED fr_control_t c,
fr_ring_buffer_t rb 
)

Clean up messages in a control-plane buffer.

Find the oldest messages which are marked FR_CONTROL_MESSAGE_DONE, and mark them FR_CONTROL_MESSAGE_FREE.

Parameters
[in]cthe fr_control_t
[in]rbthe callers ring buffer for message allocation.
Returns
  • <0 there are still messages used
  • 0 the control list is empty.

Definition at line 199 of file control.c.

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

◆ fr_control_message_alloc()

static fr_control_message_t* fr_control_message_alloc ( fr_control_t c,
fr_ring_buffer_t rb,
uint32_t  id,
void *  data,
size_t  data_size 
)
static

Allocate a control message.

Parameters
[in]cthe control structure
[in]rbthe callers ring buffer for message allocation.
[in]idthe ident of this message.
[in]datathe data to write to the control plane
[in]data_sizethe size of the data to write to the control plane.
Returns

Definition at line 251 of file control.c.

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

◆ fr_control_message_pop()

ssize_t fr_control_message_pop ( fr_atomic_queue_t aq,
uint32_t p_id,
void *  data,
size_t  data_size 
)

Pop control-plane message.

This function is called ONLY from the receiving thread.

Parameters
[in]aqthe recipients atomic queue for control-plane messages
[out]p_idthe ident of this message.
[in,out]datawhere the data is stored
[in]data_sizethe size of the buffer where we store the data.
Returns
  • <0 the size of the data we need to read the next message
  • 0 this kevent is not for us.
  • >0 the amount of data we've read

Definition at line 377 of file control.c.

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

◆ fr_control_message_push()

int fr_control_message_push ( fr_control_t c,
fr_ring_buffer_t rb,
uint32_t  id,
void *  data,
size_t  data_size 
)

Push a control-plane message.

This function is called ONLY from the originating thread.

Parameters
[in]cthe control structure
[in]rbthe callers ring buffer for message allocation.
[in]idthe ident of this message.
[in]datathe data to write to the control plane
[in]data_sizethe size of the data to write to the control plane.
Returns
  • -2 on ring buffer full
  • <0 on error
  • 0 on success

Definition at line 298 of file control.c.

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

◆ fr_control_message_send()

int fr_control_message_send ( fr_control_t c,
fr_ring_buffer_t rb,
uint32_t  id,
void *  data,
size_t  data_size 
)

Send a control-plane message.

This function is called ONLY from the originating thread.

Parameters
[in]cthe control structure
[in]rbthe callers ring buffer for message allocation.
[in]idthe ident of this message.
[in]datathe data to write to the control plane
[in]data_sizethe size of the data to write to the control plane.
Returns
  • <0 on error
  • 0 on success

Definition at line 343 of file control.c.

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

◆ fr_control_same_thread()

int fr_control_same_thread ( fr_control_t c)

Definition at line 472 of file control.c.

+ Here is the call graph for this function:

◆ pipe_read()

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

Definition at line 91 of file control.c.

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