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

2-way channels based on kqueue and atomic queues. More...

#include <freeradius-devel/util/table.h>
#include <freeradius-devel/io/base.h>
#include <freeradius-devel/io/control.h>
#include <freeradius-devel/io/message.h>
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/util/heap.h>
#include <freeradius-devel/util/log.h>
#include <sys/types.h>
#include <sys/event.h>
+ Include dependency graph for channel.h:

Go to the source code of this file.

Data Structures

struct  fr_channel_data_t
 Channel information which is added to a message. More...
 
union  fr_channel_data_t.__unnamed31__
 
struct  fr_channel_data_t.__unnamed31__.channel
 
struct  fr_channel_data_t.__unnamed31__.live
 
union  fr_channel_data_t.__unnamed33__
 
struct  fr_channel_data_t.__unnamed33__.reply
 
struct  fr_channel_data_t.__unnamed33__.request
 
struct  fr_channel_stats_t
 Statistics for the channel. More...
 

Macros

#define PRIORITY_HIGH   (1 << 15)
 
#define PRIORITY_LOW   (1 << 13)
 
#define PRIORITY_NORMAL   (1 << 14)
 
#define PRIORITY_NOW   (1 << 16)
 

Typedefs

typedef enum fr_channel_event_t fr_channel_event_t
 
typedef void(* fr_channel_recv_callback_t) (void *ctx, fr_channel_t *ch, fr_channel_data_t *cd)
 
typedef struct fr_channel_s fr_channel_t
 A two-way channel (i.e. More...
 
typedef struct fr_listen fr_listen_t
 

Enumerations

enum  fr_channel_event_t {
  FR_CHANNEL_ERROR = 0 ,
  FR_CHANNEL_DATA_READY_RESPONDER ,
  FR_CHANNEL_DATA_READY_REQUESTOR ,
  FR_CHANNEL_OPEN ,
  FR_CHANNEL_CLOSE ,
  FR_CHANNEL_NOOP ,
  FR_CHANNEL_EMPTY
}
 

Functions

bool fr_channel_active (fr_channel_t *ch)
 Check if a channel is active. More...
 
fr_channel_tfr_channel_create (TALLOC_CTX *ctx, fr_control_t *frontend, fr_control_t *worker, bool same)
 Create a new channel. More...
 
int fr_channel_null_reply (fr_channel_t *ch)
 Don't send a reply message into the channel. More...
 
bool fr_channel_recv_reply (fr_channel_t *ch)
 Receive a reply message from the channel. More...
 
bool fr_channel_recv_request (fr_channel_t *ch)
 Receive a request message from the channel. More...
 
void fr_channel_requestor_uctx_add (fr_channel_t *ch, void *ctx)
 Add network-specific data to a channel. More...
 
void * fr_channel_requestor_uctx_get (fr_channel_t *ch)
 Get network-specific data from a channel. More...
 
int fr_channel_responder_ack_close (fr_channel_t *ch)
 Acknowledge that the channel is closing. More...
 
int fr_channel_responder_sleeping (fr_channel_t *ch)
 Signal a channel that the responder is sleeping. More...
 
void fr_channel_responder_uctx_add (fr_channel_t *ch, void *ctx)
 Add responder-specific data to a channel. More...
 
void * fr_channel_responder_uctx_get (fr_channel_t *ch)
 Get responder-specific data from a channel. More...
 
int fr_channel_send_reply (fr_channel_t *ch, fr_channel_data_t *cd)
 Send a reply message into the channel. More...
 
int fr_channel_send_request (fr_channel_t *ch, fr_channel_data_t *cm)
 Send a request message into the channel. More...
 
int fr_channel_service_kevent (fr_channel_t *ch, fr_control_t *c, struct kevent const *kev)
 
fr_channel_event_t fr_channel_service_message (fr_time_t when, fr_channel_t **p_channel, void const *data, size_t data_size)
 Service a control-plane message. More...
 
int fr_channel_set_recv_reply (fr_channel_t *ch, void *ctx, fr_channel_recv_callback_t recv_reply))
 
int fr_channel_set_recv_request (fr_channel_t *ch, void *ctx, fr_channel_recv_callback_t recv_reply))
 
int fr_channel_signal_open (fr_channel_t *ch)
 Send a channel to a responder. More...
 
int fr_channel_signal_responder_close (fr_channel_t *ch)
 Signal a responder that the channel is closing. More...
 
void fr_channel_stats_log (fr_channel_t const *ch, fr_log_t const *log, char const *file, int line)
 

Variables

fr_table_num_sorted_t const channel_packet_priority []
 
size_t channel_packet_priority_len
 
fr_table_num_sorted_t const channel_signals []
 
size_t channel_signals_len
 

Detailed Description

2-way channels based on kqueue and atomic queues.

Id
2caa99839ef3f484e2bbcb3aec4800e2761ba1ab

Definition in file channel.h.


Data Structure Documentation

◆ fr_channel_data_t

struct fr_channel_data_t

Channel information which is added to a message.

The messages are just for exchanging packet data. The channel data structure is for exchanging requests and replies.

Definition at line 104 of file channel.h.

+ Collaboration diagram for fr_channel_data_t:
Data Fields
union fr_channel_data_t __unnamed__
union fr_channel_data_t __unnamed__
fr_listen_t * listen for tracking packet transport, etc.
fr_message_t m the message header
void * packet_ctx Packet specific context for holding client information, and other proto_* specific information that needs to be passed to the request.
uint32_t priority Priority of this packet.

◆ fr_channel_data_t.__unnamed31__

union fr_channel_data_t.__unnamed31__

Definition at line 107 of file channel.h.

Data Fields
__unnamed31__ channel
__unnamed31__ live

◆ fr_channel_data_t.__unnamed31__.channel

struct fr_channel_data_t.__unnamed31__.channel

Definition at line 122 of file channel.h.

Data Fields
fr_channel_t * ch channel where this messages was received
fr_heap_index_t heap_id for the various queues

◆ fr_channel_data_t.__unnamed31__.live

struct fr_channel_data_t.__unnamed31__.live

Definition at line 112 of file channel.h.

Data Fields
uint64_t ack ACK of the sequence number from the other end.
uint64_t sequence sequence number

◆ fr_channel_data_t.__unnamed33__

union fr_channel_data_t.__unnamed33__

Definition at line 128 of file channel.h.

Data Fields
__unnamed33__ reply
__unnamed33__ request

◆ fr_channel_data_t.__unnamed33__.reply

struct fr_channel_data_t.__unnamed33__.reply

Definition at line 133 of file channel.h.

Data Fields
fr_time_delta_t cpu_time Total CPU time, including predicted work, (only worker -> network).
fr_time_delta_t processing_time Actual processing time for this packet (only worker -> network).
fr_time_t request_time Timestamp of the request packet.

◆ fr_channel_data_t.__unnamed33__.request

struct fr_channel_data_t.__unnamed33__.request

Definition at line 129 of file channel.h.

Data Fields
fr_time_t recv_time time original request was received (network -> worker)

◆ fr_channel_stats_t

struct fr_channel_stats_t

Statistics for the channel.

Definition at line 81 of file channel.h.

+ Collaboration diagram for fr_channel_stats_t:
Data Fields
uint64_t kevents Number of times we've looked at kevents.
fr_time_t last_read_other Last time we successfully read a message from the other the channel.
fr_time_t last_sent_signal The last time when we signaled the other end.
fr_time_t last_write Last write to the channel.
fr_time_delta_t message_interval Interval between messages.
uint64_t outstanding Number of outstanding requests with no reply.
uint64_t packets Number of actual data packets.
uint64_t resignals Number of signals resent.
uint64_t signals Number of kevent signals we've sent.

Macro Definition Documentation

◆ PRIORITY_HIGH

#define PRIORITY_HIGH   (1 << 15)

Definition at line 150 of file channel.h.

◆ PRIORITY_LOW

#define PRIORITY_LOW   (1 << 13)

Definition at line 152 of file channel.h.

◆ PRIORITY_NORMAL

#define PRIORITY_NORMAL   (1 << 14)

Definition at line 151 of file channel.h.

◆ PRIORITY_NOW

#define PRIORITY_NOW   (1 << 16)

Definition at line 149 of file channel.h.

Typedef Documentation

◆ fr_channel_event_t

◆ fr_channel_recv_callback_t

typedef void(* fr_channel_recv_callback_t) (void *ctx, fr_channel_t *ch, fr_channel_data_t *cd)

Definition at line 169 of file channel.h.

◆ fr_channel_t

typedef struct fr_channel_s fr_channel_t

A two-way channel (i.e.

pipe) for exchanging information

While the channels are two-way, they are designed to have a "frontend" writing requests to the channel, and a "worker" reading requests, and writing replies back to the frontend.

Definition at line 1 of file channel.h.

◆ fr_listen_t

typedef struct fr_listen fr_listen_t

Definition at line 1 of file channel.h.

Enumeration Type Documentation

◆ fr_channel_event_t

Enumerator
FR_CHANNEL_ERROR 
FR_CHANNEL_DATA_READY_RESPONDER 
FR_CHANNEL_DATA_READY_REQUESTOR 
FR_CHANNEL_OPEN 
FR_CHANNEL_CLOSE 
FR_CHANNEL_NOOP 
FR_CHANNEL_EMPTY 

Definition at line 67 of file channel.h.

Function Documentation

◆ fr_channel_active()

bool fr_channel_active ( fr_channel_t ch)

Check if a channel is active.

A channel may be closed by either end. If so, it stays alive (but inactive) until both ends acknowledge the close.

Parameters
[in]chthe channel
Returns
  • false the channel is closing.
  • true the channel is active

Definition at line 812 of file channel.c.

+ Here is the caller graph for this function:

◆ fr_channel_create()

fr_channel_t* fr_channel_create ( TALLOC_CTX *  ctx,
fr_control_t requestor,
fr_control_t responder,
bool  same 
)

Create a new channel.

Parameters
[in]ctxThe talloc_ctx to allocate channel data in.
[in]requestorcontrol plane.
[in]respondercontrol plane.
[in]samewhether or not the channel is for the same thread
Returns
  • NULL on error
  • channel on success

Definition at line 183 of file channel.c.

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

◆ fr_channel_null_reply()

int fr_channel_null_reply ( fr_channel_t ch)

Don't send a reply message into the channel.

The message should be the one we received from the network.

Parameters
[in]chthe channel on which we're dropping a packet
Returns
  • <0 on error
  • 0 on success

Definition at line 624 of file channel.c.

+ Here is the caller graph for this function:

◆ fr_channel_recv_reply()

bool fr_channel_recv_reply ( fr_channel_t ch)

Receive a reply message from the channel.

Parameters
[in]chthe channel to read data from.
Returns
  • true if there was a message received
  • false if there are no more messages

Definition at line 408 of file channel.c.

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

◆ fr_channel_recv_request()

bool fr_channel_recv_request ( fr_channel_t ch)

Receive a request message from the channel.

Parameters
[in]chthe channel
Returns
  • true if there was a message received
  • false if there are no more messages

Definition at line 472 of file channel.c.

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

◆ fr_channel_requestor_uctx_add()

void fr_channel_requestor_uctx_add ( fr_channel_t ch,
void *  uctx 
)

Add network-specific data to a channel.

Parameters
[in]chThe channel.
[in]uctxThe context to add.

Definition at line 910 of file channel.c.

+ Here is the caller graph for this function:

◆ fr_channel_requestor_uctx_get()

void* fr_channel_requestor_uctx_get ( fr_channel_t ch)

Get network-specific data from a channel.

Parameters
[in]chThe channel.

Definition at line 922 of file channel.c.

+ Here is the caller graph for this function:

◆ fr_channel_responder_ack_close()

int fr_channel_responder_ack_close ( fr_channel_t ch)

Acknowledge that the channel is closing.

Parameters
[in]chThe channel.
Returns
  • <0 on error
  • 0 on success

Definition at line 854 of file channel.c.

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

◆ fr_channel_responder_sleeping()

int fr_channel_responder_sleeping ( fr_channel_t ch)

Signal a channel that the responder is sleeping.

This function should be called from the responders idle loop. i.e. only when it has nothing else to do.

Parameters
[in]chthe channel to signal we're no longer listening on.
Returns
  • <0 on error
  • 0 on success

Definition at line 646 of file channel.c.

+ Here is the call graph for this function:

◆ fr_channel_responder_uctx_add()

void fr_channel_responder_uctx_add ( fr_channel_t ch,
void *  uctx 
)

Add responder-specific data to a channel.

Parameters
[in]chThe channel.
[in]uctxThe context to add.

Definition at line 885 of file channel.c.

+ Here is the caller graph for this function:

◆ fr_channel_responder_uctx_get()

void* fr_channel_responder_uctx_get ( fr_channel_t ch)

Get responder-specific data from a channel.

Parameters
[in]chThe channel.

Definition at line 897 of file channel.c.

+ Here is the caller graph for this function:

◆ fr_channel_send_reply()

int fr_channel_send_reply ( fr_channel_t ch,
fr_channel_data_t cd 
)

Send a reply message into the channel.

The message should be initialized, other than "sequence" and "ack".

Parameters
[in]chthe channel to send the reply on.
[in]cdthe message to send
Returns
  • <0 on error
  • 0 on success

Definition at line 511 of file channel.c.

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

◆ fr_channel_send_request()

int fr_channel_send_request ( fr_channel_t ch,
fr_channel_data_t cd 
)

Send a request message into the channel.

The message should be initialized, other than "sequence" and "ack".

This function automatically calls the recv_reply callback if there is a reply.

Parameters
[in]chthe channel to send the request on.
[in]cdthe message to send.
Returns
  • <0 on error
  • 0 on success

Definition at line 306 of file channel.c.

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

◆ fr_channel_service_kevent()

int fr_channel_service_kevent ( fr_channel_t ch,
fr_control_t c,
struct kevent const *  kev 
)

◆ fr_channel_service_message()

fr_channel_event_t fr_channel_service_message ( fr_time_t  when,
fr_channel_t **  p_channel,
void const *  data,
size_t  data_size 
)

Service a control-plane message.

Parameters
[in]whenThe current time.
[out]p_channelThe channel which should be serviced.
[in]dataThe control message.
[in]data_sizeThe size of the control message.
Returns
  • FR_CHANNEL_ERROR on error
  • FR_CHANNEL_NOOP, on do nothing
  • FR_CHANNEL_DATA_READY on data ready
  • FR_CHANNEL_OPEN when a channel has been opened and sent to us
  • FR_CHANNEL_CLOSE when a channel should be closed

Definition at line 685 of file channel.c.

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

◆ fr_channel_set_recv_reply()

int fr_channel_set_recv_reply ( fr_channel_t ch,
void *  ctx,
fr_channel_recv_callback_t  recv_reply 
)

Definition at line 930 of file channel.c.

+ Here is the caller graph for this function:

◆ fr_channel_set_recv_request()

int fr_channel_set_recv_request ( fr_channel_t ch,
void *  ctx,
fr_channel_recv_callback_t  recv_reply 
)

Definition at line 938 of file channel.c.

+ Here is the caller graph for this function:

◆ fr_channel_signal_open()

int fr_channel_signal_open ( fr_channel_t ch)

Send a channel to a responder.

Parameters
[in]chThe channel.
Returns
  • <0 on error
  • 0 on success

Definition at line 952 of file channel.c.

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

◆ fr_channel_signal_responder_close()

int fr_channel_signal_responder_close ( fr_channel_t ch)

Signal a responder that the channel is closing.

Parameters
[in]chThe channel.
Returns
  • <0 on error
  • 0 on success

Definition at line 824 of file channel.c.

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

◆ fr_channel_stats_log()

void fr_channel_stats_log ( fr_channel_t const *  ch,
fr_log_t const *  log,
char const *  file,
int  line 
)

Definition at line 963 of file channel.c.

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

Variable Documentation

◆ channel_packet_priority

fr_table_num_sorted_t const channel_packet_priority[]
extern

Definition at line 164 of file channel.c.

◆ channel_packet_priority_len

size_t channel_packet_priority_len
extern

Definition at line 170 of file channel.c.

◆ channel_signals

fr_table_num_sorted_t const channel_signals[]
extern

Definition at line 153 of file channel.c.

◆ channel_signals_len

size_t channel_signals_len
extern

Definition at line 162 of file channel.c.