![]() |
The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
|
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/atomic_queue.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_callbacks_t |
| What the owner of a control plane does with channel lifecycle events. More... | |
| struct | fr_channel_data_t |
| Channel information which is added to a message. More... | |
| union | fr_channel_data_t.__unnamed47__ |
| struct | fr_channel_data_t.__unnamed47__.channel |
| struct | fr_channel_data_t.__unnamed47__.live |
| union | fr_channel_data_t.__unnamed49__ |
| struct | fr_channel_data_t.__unnamed49__.reply |
| struct | fr_channel_data_t.__unnamed49__.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 void(* | fr_channel_close_t) (fr_channel_t *ch, fr_time_t now, void *uctx) |
| Called on a responder when the requestor closes a channel. | |
| typedef void(* | fr_channel_closed_t) (fr_channel_t *ch, fr_time_t now, void *uctx) |
| Called on a requestor when the responder has finished closing a channel. | |
| typedef enum fr_channel_control_event_t | fr_channel_control_event_t |
| Events channels send, in the FR_CONTROL_EVENTSET_CHANNEL event set. | |
| typedef void(* | fr_channel_open_t) (fr_channel_t *ch, fr_message_set_t *reply_ms, fr_time_t now, void *uctx) |
| Called on a responder when a requestor opens a channel to it. | |
| typedef void(* | fr_channel_recv_callback_t) (fr_channel_t *ch, fr_channel_data_t *cd, void *uctx) |
| typedef struct fr_channel_s | fr_channel_t |
| A two-way channel (i.e. | |
| typedef struct fr_listen_instance_s | fr_listen_instance_t |
| typedef struct fr_listen_s | fr_listen_t |
Enumerations | |
| enum | fr_channel_control_event_t : uint16_t { FR_CHANNEL_CONTROL_DATA_TO_RESPONDER = 0 , FR_CHANNEL_CONTROL_DATA_TO_REQUESTOR , FR_CHANNEL_CONTROL_DATA_DONE_RESPONDER , FR_CHANNEL_CONTROL_OPEN , FR_CHANNEL_CONTROL_CLOSE , FR_CHANNEL_CONTROL_CLOSE_ACK } |
| Events channels send, in the FR_CONTROL_EVENTSET_CHANNEL event set. More... | |
Functions | |
| bool | fr_channel_active (fr_channel_t *ch) |
| Check if a channel is active. | |
| int | fr_channel_callbacks_add (fr_control_t *c, fr_channel_callbacks_t const *callbacks, void *uctx) |
| Register the owner's channel callbacks on its control plane. | |
| fr_channel_t * | fr_channel_create (TALLOC_CTX *ctx, fr_control_t *frontend, fr_control_t *worker, bool same) |
| Create a new channel. | |
| int | fr_channel_null_reply (fr_channel_t *ch) |
| Don't send a reply message into the channel. | |
| bool | fr_channel_recv_reply (fr_channel_t *ch) |
| Receive a reply message from the channel. | |
| bool | fr_channel_recv_request (fr_channel_t *ch) |
| Receive a request message from the channel. | |
| fr_channel_stats_t const * | fr_channel_requestor_stats (fr_channel_t const *ch) |
| Statistics for the requestor's end of a channel. | |
| void | fr_channel_requestor_uctx_add (fr_channel_t *ch, void *ctx) |
| Add network-specific data to a channel. | |
| void * | fr_channel_requestor_uctx_get (fr_channel_t *ch) |
| Get network-specific data from a channel. | |
| int | fr_channel_responder_ack_close (fr_channel_t *ch) |
| Acknowledge that the channel is closing. | |
| unsigned int | fr_channel_responder_discard (fr_channel_t *ch) |
| Discard any requests the requestor queued but we never received. | |
| fr_channel_stats_t const * | fr_channel_responder_stats (fr_channel_t const *ch) |
| Statistics for the responder's end of a channel. | |
| void | fr_channel_responder_uctx_add (fr_channel_t *ch, void *ctx) |
| Add responder-specific data to a channel. | |
| void * | fr_channel_responder_uctx_get (fr_channel_t *ch) |
| Get responder-specific data from a channel. | |
| int | fr_channel_send_reply (fr_channel_t *ch, fr_channel_data_t *cd) |
| Send a reply message into the channel. | |
| int | fr_channel_send_request (fr_channel_t *ch, fr_channel_data_t *cm) |
| Send a request message into the channel. | |
| int | fr_channel_service_kevent (fr_channel_t *ch, fr_control_t *c, struct kevent const *kev) |
| int | fr_channel_set_recv_reply (fr_channel_t *ch, fr_channel_recv_callback_t recv_reply, void *uctx)) |
| int | fr_channel_set_recv_request (fr_channel_t *ch, fr_channel_recv_callback_t recv_request, void *uctx)) |
| int | fr_channel_signal_open (fr_channel_t *ch, fr_message_set_t *reply_ms) |
| Send a channel to a responder. | |
| int | fr_channel_signal_responder_close (fr_channel_t *ch) |
| Signal a responder that the channel is closing. | |
| 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 |
2-way channels based on kqueue and atomic queues.
Definition in file channel.h.
| struct fr_channel_callbacks_t |
What the owner of a control plane does with channel lifecycle events.
Data arriving on a channel is drained by the channel code itself, through the callbacks set with fr_channel_set_recv_request() and fr_channel_set_recv_reply(). Only the lifecycle events reach the owner. A responder gets open and close, a requestor gets closed. Leave the others NULL.
Collaboration diagram for fr_channel_callbacks_t:| Data Fields | ||
|---|---|---|
| fr_channel_close_t | close | |
| fr_channel_closed_t | closed | |
| fr_channel_open_t | open | |
| 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.
Collaboration diagram for fr_channel_data_t:| Data Fields | ||
|---|---|---|
| union fr_channel_data_t.__unnamed47__ | __unnamed__ | |
| union fr_channel_data_t.__unnamed49__ | __unnamed__ | |
| fr_listen_instance_t * | inst | 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. |
| union fr_channel_data_t.__unnamed47__ |
| Data Fields | ||
|---|---|---|
| struct fr_channel_data_t.__unnamed47__.channel | channel | |
| struct fr_channel_data_t.__unnamed47__.live | live | |
| struct fr_channel_data_t.__unnamed47__.channel |
| Data Fields | ||
|---|---|---|
| fr_channel_t * | ch | channel where this messages was received |
| fr_heap_index_t | heap_id | for the various queues |
| struct fr_channel_data_t.__unnamed47__.live |
| union fr_channel_data_t.__unnamed49__ |
| Data Fields | ||
|---|---|---|
| struct fr_channel_data_t.__unnamed49__.reply | reply | |
| struct fr_channel_data_t.__unnamed49__.request | request | |
| struct fr_channel_data_t.__unnamed49__.reply |
| 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. |
| struct fr_channel_data_t.__unnamed49__.request |
| struct fr_channel_stats_t |
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. |
| uint64_t | spurious | Number of signals we received which found no data waiting. |
| typedef void(* fr_channel_close_t) (fr_channel_t *ch, fr_time_t now, void *uctx) |
Called on a responder when the requestor closes a channel.
The responder calls fr_channel_responder_ack_close() once it has finished with the channel.
| [in] | ch | the channel. |
| [in] | now | the current time. |
| [in] | uctx | registered with the callbacks. |
| typedef void(* fr_channel_closed_t) (fr_channel_t *ch, fr_time_t now, void *uctx) |
| typedef enum fr_channel_control_event_t fr_channel_control_event_t |
Events channels send, in the FR_CONTROL_EVENTSET_CHANNEL event set.
The control plane dispatches each to its own callback, see fr_channel_callbacks_add().
| typedef void(* fr_channel_open_t) (fr_channel_t *ch, fr_message_set_t *reply_ms, fr_time_t now, void *uctx) |
| typedef void(* fr_channel_recv_callback_t) (fr_channel_t *ch, fr_channel_data_t *cd, void *uctx) |
| typedef struct fr_channel_s fr_channel_t |
| typedef struct fr_listen_instance_s fr_listen_instance_t |
| typedef struct fr_listen_s fr_listen_t |
Events channels send, in the FR_CONTROL_EVENTSET_CHANNEL event set.
The control plane dispatches each to its own callback, see fr_channel_callbacks_add().
| 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.
| [in] | ch | the channel |
Definition at line 850 of file channel.c.
Here is the caller graph for this function:| int fr_channel_callbacks_add | ( | fr_control_t * | c, |
| fr_channel_callbacks_t const * | callbacks, | ||
| void * | uctx | ||
| ) |
Register the owner's channel callbacks on its control plane.
Call before fr_control_open(). Every channel event gets its own entry in the FR_CONTROL_EVENTSET_CHANNEL event set, so the control plane dispatches straight to the handler for that event.
| [in] | c | the control plane channels will signal. |
| [in] | callbacks | what the owner does with each event. Copied. |
| [in] | uctx | passed to each callback. |
Definition at line 784 of file channel.c.
Here is the call graph for this function:
Here is the caller graph for this function:| fr_channel_t * fr_channel_create | ( | TALLOC_CTX * | ctx, |
| fr_control_t * | requestor, | ||
| fr_control_t * | responder, | ||
| bool | same | ||
| ) |
Create a new channel.
| [in] | ctx | The talloc_ctx to allocate channel data in. |
| [in] | requestor | control plane. |
| [in] | responder | control plane. |
| [in] | same | whether or not the channel is for the same thread |
Definition at line 167 of file channel.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int fr_channel_null_reply | ( | fr_channel_t * | ch | ) |
| bool fr_channel_recv_reply | ( | fr_channel_t * | ch | ) |
| bool fr_channel_recv_request | ( | fr_channel_t * | ch | ) |
| fr_channel_stats_t const * fr_channel_requestor_stats | ( | fr_channel_t const * | ch | ) |
| void fr_channel_requestor_uctx_add | ( | fr_channel_t * | ch, |
| void * | uctx | ||
| ) |
| void * fr_channel_requestor_uctx_get | ( | fr_channel_t * | ch | ) |
| int fr_channel_responder_ack_close | ( | fr_channel_t * | ch | ) |
| unsigned int fr_channel_responder_discard | ( | fr_channel_t * | ch | ) |
Discard any requests the requestor queued but we never received.
The messages belong to the requestor's message set, and it cannot reclaim them until they are marked done. A responder that closes with requests still in the queue would strand them there, and with them the memory they were allocated from.
| [in] | ch | to discard the queued requests of. |
Definition at line 895 of file channel.c.
Here is the call graph for this function:
Here is the caller graph for this function:| fr_channel_stats_t const * fr_channel_responder_stats | ( | fr_channel_t const * | ch | ) |
| void fr_channel_responder_uctx_add | ( | fr_channel_t * | ch, |
| void * | uctx | ||
| ) |
| void * fr_channel_responder_uctx_get | ( | fr_channel_t * | ch | ) |
| 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".
| [in] | ch | the channel to send the reply on. |
| [in] | cd | the message to send |
Definition at line 457 of file channel.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| [in] | ch | the channel to send the request on. |
| [in] | cd | the message to send. |
Definition at line 271 of file channel.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int fr_channel_service_kevent | ( | fr_channel_t * | ch, |
| fr_control_t * | c, | ||
| struct kevent const * | kev | ||
| ) |
| int fr_channel_set_recv_reply | ( | fr_channel_t * | ch, |
| fr_channel_recv_callback_t | recv_reply, | ||
| void * | uctx | ||
| ) |
| int fr_channel_set_recv_request | ( | fr_channel_t * | ch, |
| fr_channel_recv_callback_t | recv_request, | ||
| void * | uctx | ||
| ) |
| int fr_channel_signal_open | ( | fr_channel_t * | ch, |
| fr_message_set_t * | reply_ms | ||
| ) |
| int fr_channel_signal_responder_close | ( | fr_channel_t * | ch | ) |
| void fr_channel_stats_log | ( | fr_channel_t const * | ch, |
| fr_log_t const * | log, | ||
| char const * | file, | ||
| int | line | ||
| ) |
|
extern |
|
extern |
1.9.8