|  | The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
    | 
TACACS+ transport. More...
#include <freeradius-devel/io/application.h>#include <freeradius-devel/io/listen.h>#include <freeradius-devel/io/pair.h>#include <freeradius-devel/missing.h>#include <freeradius-devel/server/connection.h>#include <freeradius-devel/util/debug.h>#include <freeradius-devel/util/heap.h>#include <sys/socket.h>#include <sys/uio.h>#include "rlm_tacacs.h" Include dependency graph for rlm_tacacs_tcp.c:
 Include dependency graph for rlm_tacacs_tcp.c:Go to the source code of this file.
| Data Structures | |
| struct | rlm_tacacs_tcp_t | 
| Static configuration for the module.  More... | |
| struct | tcp_buffer_t | 
| struct | tcp_handle_t | 
| Track the handle, which is tightly correlated with the FD.  More... | |
| struct | tcp_request_s | 
| Connect request_t to local tracking structure.  More... | |
| struct | tcp_result_t | 
| struct | tcp_thread_t | 
| Typedefs | |
| typedef struct tcp_request_s | tcp_request_t | 
| Functions | |
| static int | _tcp_handle_free (tcp_handle_t *h) | 
| Free a connection handle, closing associated resources. | |
| static int | _tcp_result_free (tcp_result_t *r) | 
| Free a tcp_result_t. | |
| static bool | check_for_zombie (fr_timer_list_t *tl, trunk_connection_t *tconn, fr_time_t now, fr_time_t last_sent) | 
| See if the connection is zombied. | |
| static void | conn_close (UNUSED fr_event_list_t *el, void *handle, UNUSED void *uctx) | 
| Shutdown/close a file descriptor. | |
| static void | conn_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx) | 
| Connection errored. | |
| static connection_state_t | conn_init (void **h_out, connection_t *conn, void *uctx) | 
| Initialise a new outbound connection. | |
| static ssize_t | decode (TALLOC_CTX *ctx, fr_pair_list_t *reply, uint8_t *response_code, tcp_handle_t *h, request_t *request, tcp_request_t *req, uint8_t *data, size_t data_len) | 
| Decode response packet data, extracting relevant information and validating the packet. | |
| static int | encode (tcp_handle_t *h, request_t *request, tcp_request_t *req) | 
| static unlang_action_t | mod_enqueue (unlang_result_t *p_result, void **rctx_out, UNUSED void *instance, void *thread, request_t *request) | 
| static int | mod_instantiate (module_inst_ctx_t const *mctx) | 
| static unlang_action_t | mod_resume (unlang_result_t *p_result, module_ctx_t const *mctx, UNUSED request_t *request) | 
| Resume execution of the request, returning the rcode set during trunk execution. | |
| static void | mod_signal (module_ctx_t const *mctx, UNUSED request_t *request, fr_signal_t action) | 
| static int | mod_thread_instantiate (module_thread_inst_ctx_t const *mctx) | 
| Instantiate thread data for the submodule. | |
| static void | request_cancel (connection_t *conn, void *preq_to_reset, trunk_cancel_reason_t reason, UNUSED void *uctx) | 
| Remove the request from any tracking structures. | |
| static void | request_complete (request_t *request, NDEBUG_UNUSED void *preq, void *rctx, UNUSED void *uctx) | 
| Response has already been written to the rctx at this point. | |
| static void | request_conn_release (connection_t *conn, void *preq_to_reset, UNUSED void *uctx) | 
| Clear out anything associated with the handle from the request. | |
| static void | request_demux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx) | 
| static void | request_fail (request_t *request, NDEBUG_UNUSED void *preq, void *rctx, NDEBUG_UNUSED trunk_request_state_t state, UNUSED void *uctx) | 
| Write out a canned failure. | |
| static void | request_free (UNUSED request_t *request, void *preq_to_free, UNUSED void *uctx) | 
| Explicitly free resources associated with the protocol request. | |
| static void | request_mux (fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx) | 
| static int8_t | request_prioritise (void const *one, void const *two) | 
| static void | request_retry (fr_timer_list_t *tl, fr_time_t now, void *uctx) | 
| Handle retries. | |
| static void | revive_timeout (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx) | 
| Revive a connection after "revive_interval". | |
| static void | tcp_request_reset (tcp_handle_t *h, tcp_request_t *req) | 
| Clear out any connection specific resources from a tcp request. | |
| static connection_t * | thread_conn_alloc (trunk_connection_t *tconn, fr_event_list_t *el, connection_conf_t const *conf, char const *log_prefix, void *uctx) | 
| static void | thread_conn_notify (trunk_connection_t *tconn, connection_t *conn, fr_event_list_t *el, trunk_connection_event_t notify_on, UNUSED void *uctx) | 
| static void | zombie_timeout (fr_timer_list_t *tl, fr_time_t now, void *uctx) | 
| Mark a connection dead after "zombie_interval". | |
| Variables | |
| static fr_dict_attr_t const * | attr_packet_hdr | 
| static fr_dict_attr_t const * | attr_packet_type | 
| static fr_dict_attr_t const * | attr_session_id | 
| static fr_dict_t const * | dict_tacacs | 
| static const conf_parser_t | module_config [] | 
| rlm_tacacs_io_t | rlm_tacacs_tcp | 
| fr_dict_autoload_t | rlm_tacacs_tcp_dict [] | 
| fr_dict_attr_autoload_t | rlm_tacacs_tcp_dict_attr [] | 
| static rlm_rcode_t | tacacs_code_to_rcode [FR_TACACS_CODE_MAX] | 
TACACS+ transport.
Definition in file rlm_tacacs_tcp.c.
| struct rlm_tacacs_tcp_t | 
Static configuration for the module.
Definition at line 42 of file rlm_tacacs_tcp.c.
 Collaboration diagram for rlm_tacacs_tcp_t:
 Collaboration diagram for rlm_tacacs_tcp_t:| Data Fields | ||
|---|---|---|
| CONF_SECTION * | config | |
| fr_ipaddr_t | dst_ipaddr | IP of the home server. | 
| uint16_t | dst_port | Port of the home server. | 
| char const * | interface | Interface to bind to. | 
| uint32_t | max_packet_size | Maximum packet size. | 
| uint16_t | max_send_coalesce | Maximum number of packets to coalesce into one mmsg call. | 
| rlm_tacacs_t * | parent | rlm_tacacs instance. | 
| uint32_t | recv_buff | How big the kernel's receive buffer should be. | 
| bool | recv_buff_is_set | Whether we were provided with a recv_buf. | 
| char const * | secret | Shared secret. | 
| size_t | secretlen | length of secret | 
| 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. | 
| fr_ipaddr_t | src_ipaddr | IP we open our socket on. | 
| fr_pair_list_t * | trigger_args | Pairs passed to trigger request. | 
| struct tcp_buffer_t | 
| struct tcp_handle_t | 
Track the handle, which is tightly correlated with the FD.
Definition at line 92 of file rlm_tacacs_tcp.c.
 Collaboration diagram for tcp_handle_t:
 Collaboration diagram for tcp_handle_t:| Data Fields | ||
|---|---|---|
| int | active | active packets | 
| trunk_request_t ** | coalesced | Outbound coalesced requests. | 
| int | fd | File descriptor. | 
| fr_time_t | first_sent | first time we sent a packet since going idle | 
| int | id | starts at 1. | 
| rlm_tacacs_tcp_t const * | inst | Our module instance. | 
| fr_time_t | last_idle | last time we had nothing to do | 
| fr_time_t | last_reply | When we last received a reply. | 
| fr_time_t | last_sent | last time we sent a packet. | 
| uint32_t | max_packet_size | Our max packet size. may be different from the parent. | 
| char const * | module_name | the module that opened the connection | 
| fr_time_t | mrs_time | Most recent sent time which had a reply. | 
| char const * | name | From IP PORT to IP PORT. | 
| tcp_buffer_t | recv | receive buffer | 
| tcp_buffer_t | send | send buffer | 
| size_t | send_buff_actual | What we believe the maximum SO_SNDBUF size to be. We don't try and encode more packet data than this in one go. | 
| uint32_t | session_id | for TACACS+ "security". | 
| fr_ipaddr_t | src_ipaddr | Source IP address. May be altered on bind to be the actual IP address packets will be sent on. This is why we can't use the inst src_ipaddr field. | 
| uint16_t | src_port | Source port specific to this connection. 
 | 
| trunk_connection_t * | tconn | trunk connection | 
| tcp_thread_t * | thread | |
| trunk_request_t * | tracking[UINT8_MAX] | all sequential! | 
| fr_timer_t * | zombie_ev | Zombie timeout. | 
| struct tcp_request_s | 
Connect request_t to local tracking structure.
Definition at line 140 of file rlm_tacacs_tcp.c.
 Collaboration diagram for tcp_request_s:
 Collaboration diagram for tcp_request_s:| Data Fields | ||
|---|---|---|
| uint8_t | code | Packet code. | 
| fr_timer_t * | ev | timer for retransmissions | 
| uint8_t | id | Last ID assigned to this packet. | 
| bool | outstanding | are we waiting for a reply? | 
| uint8_t * | packet | Packet we write to the network. | 
| size_t | packet_len | Length of the packet. | 
| uint32_t | priority | copied from request->async->priority | 
| fr_time_t | recv_time | copied from request->async->recv_time | 
| fr_retry_t | retry | retransmission timers | 
| struct tcp_result_t | 
Definition at line 75 of file rlm_tacacs_tcp.c.
 Collaboration diagram for tcp_result_t:
 Collaboration diagram for tcp_result_t:| Data Fields | ||
|---|---|---|
| rlm_rcode_t | rcode | from the transport | 
| trunk_request_t * | treq | |
| struct tcp_thread_t | 
Definition at line 66 of file rlm_tacacs_tcp.c.
 Collaboration diagram for tcp_thread_t:
 Collaboration diagram for tcp_thread_t:| Data Fields | ||
|---|---|---|
| fr_event_list_t * | el | Event list. | 
| rlm_tacacs_tcp_t const * | inst | our instance | 
| trunk_t * | trunk | trunk handler | 
| trunk_conf_t | trunk_conf | trunk configuration | 
| typedef struct tcp_request_s tcp_request_t | 
Definition at line 80 of file rlm_tacacs_tcp.c.
| 
 | static | 
Free a connection handle, closing associated resources.
Definition at line 248 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Free a tcp_result_t.
Allows us to set break points for debugging.
Definition at line 1374 of file rlm_tacacs_tcp.c.
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
See if the connection is zombied.
We check for zombie when major events happen: 1) request hits its final timeout 2) request timer hits, and it needs to be retransmitted 3) a DUP packet comes in, and the request needs to be retransmitted 4) we're sending a packet.
There MIGHT not be retries configured, so we MUST check for zombie when any new packet comes in. Similarly, there MIGHT not be new packets, but retries are configured, so we have to check there, too.
Also, the socket might not be writable for a while. There MIGHT be a long time between getting the timer / DUP signal, and the request finally being written to the socket. So we need to check for zombie at BOTH the timeout and the mux / write function.
Definition at line 725 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Shutdown/close a file descriptor.
Definition at line 423 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Connection errored.
We were signalled by the event loop that a fatal error occurred on this connection.
| [in] | el | The event list signalling. | 
| [in] | fd | that errored. | 
| [in] | flags | El flags. | 
| [in] | fd_errno | The nature of the error. | 
| [in] | uctx | The trunk connection handle (tconn). | 
Definition at line 473 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Initialise a new outbound connection.
| [out] | h_out | Where to write the new file descriptor. | 
| [in] | conn | to initialise. | 
| [in] | uctx | A tcp_thread_t | 
Definition at line 278 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Decode response packet data, extracting relevant information and validating the packet.
| [in] | ctx | to allocate pairs in. | 
| [out] | reply | Pointer to head of pair list to add reply attributes to. | 
| [out] | response_code | The type of response packet. | 
| [in] | h | connection handle. | 
| [in] | request | the request. | 
| [in] | req | TCP request. | 
| [in] | data | to decode. | 
| [in] | data_len | Length of input data. | 
Definition at line 565 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Definition at line 609 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
| 
 | static | 
| 
 | static | 
Resume execution of the request, returning the rcode set during trunk execution.
Definition at line 1307 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function:| 
 | static | 
| 
 | static | 
Instantiate thread data for the submodule.
Definition at line 1445 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function:| 
 | static | 
Remove the request from any tracking structures.
Frees encoded packets if the request is being moved to a new connection
Definition at line 1213 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Response has already been written to the rctx at this point.
Definition at line 1278 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Clear out anything associated with the handle from the request.
Definition at line 1238 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Definition at line 1066 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Write out a canned failure.
Definition at line 1257 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Explicitly free resources associated with the protocol request.
Definition at line 1295 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Definition at line 812 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Definition at line 533 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Handle retries.
Note that with TCP we don't actually retry on this particular connection, but the retry timer allows us to fail over from one connection to another when a connection fails.
Definition at line 769 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Revive a connection after "revive_interval".
Definition at line 665 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Clear out any connection specific resources from a tcp request.
Definition at line 220 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Definition at line 440 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Definition at line 485 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Mark a connection dead after "zombie_interval".
Definition at line 677 of file rlm_tacacs_tcp.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
Definition at line 206 of file rlm_tacacs_tcp.c.
| 
 | static | 
Definition at line 205 of file rlm_tacacs_tcp.c.
| 
 | static | 
Definition at line 207 of file rlm_tacacs_tcp.c.
| 
 | static | 
Definition at line 197 of file rlm_tacacs_tcp.c.
| 
 | static | 
Definition at line 173 of file rlm_tacacs_tcp.c.
| rlm_tacacs_io_t rlm_tacacs_tcp | 
Definition at line 1572 of file rlm_tacacs_tcp.c.
| fr_dict_autoload_t rlm_tacacs_tcp_dict | 
Definition at line 200 of file rlm_tacacs_tcp.c.
| fr_dict_attr_autoload_t rlm_tacacs_tcp_dict_attr | 
Definition at line 210 of file rlm_tacacs_tcp.c.
| 
 | static | 
Definition at line 155 of file rlm_tacacs_tcp.c.
 1.9.8
 1.9.8