The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
proto_tacacs_tcp.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 29ecb3c8ff46d76117559a728d766b9c09c21270 $
19 * @file proto_tacacs_tcp.c
20 * @brief TACACS+ handler for TCP.
21 * @author Jorge Pereira <jpereira@freeradius.org>
22 *
23 * @copyright 2020 The FreeRADIUS server project.
24 * @copyright 2020 Network RADIUS SAS (legal@networkradius.com)
25 */
26
27#include <netdb.h>
28#include <freeradius-devel/util/trie.h>
29#include <freeradius-devel/io/application.h>
30#include <freeradius-devel/io/listen.h>
31#include <freeradius-devel/io/schedule.h>
32#include "proto_tacacs.h"
33
35
36#define TACACS_MAX_ATTRIBUTES 256
37
38typedef struct {
39 char const *name; //!< socket name
40 int sockfd;
41
42 fr_io_address_t *connection; //!< for connected sockets.
43
44 fr_stats_t stats; //!< statistics for this socket
46
47typedef struct {
48 CONF_SECTION *cs; //!< our configuration
49
50 fr_ipaddr_t ipaddr; //!< IP address to listen on.
51
52 char const *interface; //!< Interface to bind to.
53 char const *port_name; //!< Name of the port for getservent().
54
55 uint32_t recv_buff; //!< How big the kernel's receive buffer should be.
56
57 uint32_t max_packet_size; //!< for message ring buffer.
58 uint32_t max_attributes; //!< Limit maximum decodable attributes.
59
60 uint16_t port; //!< Port to listen on.
61
62 bool recv_buff_is_set; //!< Whether we were provided with a recv_buff
63 bool dynamic_clients; //!< whether we have dynamic clients
64
65 fr_client_list_t *clients; //!< local clients
66
67 fr_trie_t *trie; //!< for parsed networks
68 fr_ipaddr_t *allow; //!< allowed networks for dynamic clients
69 fr_ipaddr_t *deny; //!< denied networks for dynamic clients
70
71 bool read_hexdump; //!< Do we debug hexdump read packets.
72 bool write_hexdump; //!< Do we debug hexdump write packets.
74
81
86
87 { FR_CONF_OFFSET("interface", proto_tacacs_tcp_t, interface) },
88 { FR_CONF_OFFSET("port_name", proto_tacacs_tcp_t, port_name) },
89
90 { FR_CONF_OFFSET("port", proto_tacacs_tcp_t, port), .dflt = "49" },
91 { FR_CONF_OFFSET_IS_SET("recv_buff", FR_TYPE_UINT32, 0, proto_tacacs_tcp_t, recv_buff) },
92
93 { FR_CONF_OFFSET("dynamic_clients", proto_tacacs_tcp_t, dynamic_clients) } ,
94 { FR_CONF_POINTER("networks", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) networks_config },
95
96 { FR_CONF_OFFSET("max_packet_size", proto_tacacs_tcp_t, max_packet_size), .dflt = "4096" } ,
97 { FR_CONF_OFFSET("max_attributes", proto_tacacs_tcp_t, max_attributes), .dflt = STRINGIFY(TACACS_MAX_ATTRIBUTES) } ,
98
99 { FR_CONF_OFFSET("read_hexdump", proto_tacacs_tcp_t, read_hexdump) },
100 { FR_CONF_OFFSET("write_hexdump", proto_tacacs_tcp_t, write_hexdump) },
101
103};
104
105static const char *packet_name[] = {
106 [FR_TAC_PLUS_AUTHEN] = "Authentication",
107 [FR_TAC_PLUS_AUTHOR] = "Authorization",
108 [FR_TAC_PLUS_ACCT] = "Accounting",
109};
110
111/** Read TACACS data from a TCP connection
112 *
113 * @param[in] li representing a client connection.
114 * @param[in] packet_ctx UNUSED.
115 * @param[out] recv_time_p When we read the packet.
116 * For some protocols we get this for free (but not here).
117 * @param[out] buffer to read into.
118 * @param[in] buffer_len Maximum length of the buffer.
119 * @param[in,out] leftover If the previous read didn't yield a complete packet
120 * we will have written how many bytes we read in leftover
121 * and returned 0. On the next call, we use the
122 * value of leftover to offset the position we start
123 * writing into the buffer.
124 * *leftover must be subtracted from buffer_len when
125 * calculating free space in the buffer.
126 * @return
127 * - >0 when a packet was read successfully.
128 * - 0 when we read a partial packet.
129 * - <0 on error (socket should be closed).
130 */
132 size_t buffer_len, size_t *leftover)
133{
134 proto_tacacs_tcp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_tacacs_tcp_thread_t);
135 ssize_t data_size, packet_len;
136 size_t in_buffer;
137
138 /*
139 * We may have read multiple packets in the previous read. In which case the buffer may already
140 * have packets remaining. In that case, we can return packets directly from the buffer, and
141 * skip the read().
142 */
143 if (*leftover >= FR_HEADER_LENGTH) {
144 packet_len = fr_tacacs_length(buffer, *leftover);
145 if (packet_len < 0) goto invalid;
146
147 if (packet_len <= ((ssize_t) *leftover)) {
148 data_size = 0;
149 goto have_packet;
150 }
151
152 /*
153 * Else we don't have a full packet, try to read more data from the network.
154 */
155 }
156
157 /*
158 * Read data into the buffer.
159 */
160 data_size = read(thread->sockfd, buffer + (*leftover), buffer_len - (*leftover));
161 if (data_size < 0) {
162 switch (errno) {
163#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
164 case EWOULDBLOCK:
165#endif
166 case EAGAIN:
167 /*
168 * We didn't read any data leave the buffers alone.
169 *
170 * i.e. if we had a partial packet in the buffer and we didn't read any data,
171 * then the partial packet is still left in the buffer.
172 */
173 return 0;
174
175 default:
176 break;
177 }
178
179 ERROR("proto_tacacs_tcp got read error (%zd) - %s", data_size, fr_syserror(errno));
180 return data_size;
181 }
182
183 /*
184 * Note that we return ERROR for all bad packets, as
185 * there's no point in reading TACACS+ packets from a TCP
186 * connection which isn't sending us TACACS+ packets.
187 */
188
189 /*
190 * TCP read of zero means the socket is dead.
191 */
192 if (!data_size) {
193 DEBUG2("proto_tacacs_tcp - other side closed the socket.");
194 return -1;
195 }
196
197have_packet:
198 /*
199 * Represents all the data we've read since we last
200 * decoded a complete packet.
201 */
202 in_buffer = *leftover + data_size;
203
204 /*
205 * Figure out how big the complete TACACS packet should be.
206 * If we don't have enough data it'll likely come
207 * through in the next fragment.
208 */
209 packet_len = fr_tacacs_length(buffer, in_buffer);
210 if (packet_len < 0) {
211 invalid:
212 PERROR("Invalid TACACS packet");
213 return -1; /* Malformed, close the socket */
214 }
215
216 /*
217 * We don't have a complete TACACS+ packet. Tell the
218 * caller that we need to read more, but record
219 * how much we read in leftover.
220 */
221 if (in_buffer < (size_t) packet_len) {
222 *leftover = in_buffer;
223 DEBUG3("proto_tacacs_tcp - Received packet fragment of %zu bytes (%zu bytes now pending)",
224 (size_t)packet_len, *leftover);
225 return 0;
226 }
227
228 /*
229 * We've read at least one packet. Tell the caller that
230 * there's more data available, and return only one packet.
231 */
232 *leftover = in_buffer - packet_len;
233
234 *recv_time_p = fr_time();
235 thread->stats.total_requests++;
236
237 /*
238 * proto_tacacs sets the priority
239 */
240
241 /*
242 * Print out what we received.
243 */
244 FR_PROTO_HEX_DUMP(buffer, packet_len, "tacacs_tcp_recv");
245
246 if (DEBUG_ENABLED2) {
247 char bogus_type[4];
248 char const *type;
249 uint8_t packet_type = buffer[1];
250
251 if ((packet_type > 0) && (packet_type < NUM_ELEMENTS(packet_name))) {
252 type = packet_name[packet_type];
253 } else {
254 snprintf(bogus_type, sizeof(bogus_type), "%d", packet_type);
255 type = bogus_type;
256 }
257 DEBUG2("proto_tacacs_tcp - Received %s seq_no %d length %zd %s",
258 type, buffer[2],
259 packet_len, thread->name);
260 }
261
262 return packet_len;
263}
264
267 size_t buffer_len, size_t written)
268{
269 proto_tacacs_tcp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_tacacs_tcp_thread_t);
270 ssize_t data_size;
271 ssize_t total;
272
273 /*
274 * We only write TACACS packets.
275 *
276 * @todo - if buffer_len ==1, it means "do not respond".
277 * Which should be suppressed somewhere. Maybe here...
278 */
279 fr_assert(buffer_len >= sizeof(fr_tacacs_packet_hdr_t));
280 fr_assert(written < buffer_len);
281
282 /*
283 * @todo - share a stats interface with the parent? or
284 * put the stats in the listener, so that proto_tacacs
285 * can update them, too.. <sigh>
286 */
287 if (written == 0) {
288 thread->stats.total_responses++;
289 }
290
291 /*
292 * Only write replies if they're TACACS+ packets.
293 * sometimes we want to NOT send a reply...
294 */
295 data_size = write(thread->sockfd, buffer + written, buffer_len - written);
296 if (data_size <= 0) return data_size;
297
298 /*
299 * The total never exceeds buffer_len, which is far below
300 * SSIZE_MAX.
301 */
302 if (!fr_cond_assert(fr_add(&total, data_size, written))) return -1;
303
304 /*
305 * If we're supposed to close the socket, then go do that.
306 */
307 if (((data_size + written) == buffer_len) &&
309 fr_tacacs_packet_t const *pkt = (fr_tacacs_packet_t const *) buffer;
310
311 switch (pkt->hdr.type) {
313 if (pkt->authen_reply.status == FR_TAC_PLUS_AUTHEN_STATUS_ERROR) goto close_it;
314 break;
315
317 if (pkt->author_reply.status == FR_TAC_PLUS_AUTHOR_STATUS_ERROR) {
318 close_it:
319 ERROR("tacacs %s - Closing connection due to unrecoverable server error response",
320 thread->name);
321 errno = ECONNRESET;
322 return -1;
323 }
324 break;
325
326 case FR_TAC_PLUS_ACCT:
327 if (pkt->acct_reply.status == FR_TAC_PLUS_ACCT_STATUS_ERROR) goto close_it;
328 break;
329
330 default:
331 break;
332 }
333 }
334
335 /*
336 * Return the packet we wrote, plus any bytes previously
337 * left over from previous packets.
338 */
339 return total;
340}
341
343{
344 proto_tacacs_tcp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_tacacs_tcp_thread_t);
345
346 thread->connection = connection;
347
348 return 0;
349}
350
351static void mod_network_get(int *ipproto, bool *dynamic_clients, fr_trie_t const **trie, void *instance)
352{
353 proto_tacacs_tcp_t *inst = talloc_get_type_abort(instance, proto_tacacs_tcp_t);
354
355 *ipproto = IPPROTO_TCP;
356 *dynamic_clients = inst->dynamic_clients;
357 *trie = inst->trie;
358}
359
360/** Open a TCP listener for TACACS+
361 *
362 */
364{
367 proto_tacacs_tcp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_tacacs_tcp_thread_t);
368
369 int sockfd;
370 fr_ipaddr_t ipaddr = inst->ipaddr;
371 uint16_t port = inst->port;
372
373 fr_assert(!thread->connection);
374
375 li->fd = sockfd = fr_socket_server_tcp(&inst->ipaddr, &port, inst->port_name, true);
376 if (sockfd < 0) {
377 cf_log_err(li->listen->cs, "Failed opening TCP socket - %s", fr_strerror());
378 error:
379 return -1;
380 }
381
382 (void) fr_nonblock(sockfd);
383
384 if (fr_socket_bind(sockfd, inst->interface, &ipaddr, &port) < 0) {
385 close(sockfd);
386 cf_log_err(li->listen->cs, "Failed binding to socket - %s", fr_strerror());
387 cf_log_err(li->listen->cs, DOC_ROOT_REF(troubleshooting/network/bind));
388 goto error;
389 }
390
391 if (listen(sockfd, SOMAXCONN) < 0) {
392 close(sockfd);
393 cf_log_err(li->listen->cs, "Failed listening on socket - %s", fr_syserror(errno));
394 goto error;
395 }
396
397 thread->sockfd = sockfd;
398
399 fr_assert((cf_parent(inst->cs) != NULL) && (cf_parent(cf_parent(inst->cs)) != NULL)); /* listen { ... } */
400
402 NULL, 0,
403 &inst->ipaddr, inst->port,
404 inst->interface);
405
406 return 0;
407}
408
409
410/** Set the file descriptor for this socket.
411 */
412static int mod_fd_set(fr_listen_instance_t *li, int fd)
413{
415 proto_tacacs_tcp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_tacacs_tcp_thread_t);
416
417 thread->sockfd = fd;
418
420 &thread->connection->socket.inet.src_ipaddr, thread->connection->socket.inet.src_port,
421 &inst->ipaddr, inst->port,
422 inst->interface);
423
424 return 0;
425}
426
427static char const *mod_name(fr_listen_instance_t *li)
428{
429 proto_tacacs_tcp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_tacacs_tcp_thread_t);
430
431 return thread->name;
432}
433
435{
436 proto_tacacs_tcp_t *inst = talloc_get_type_abort(data, proto_tacacs_tcp_t);
437 li->listen->read_hexdump = inst->read_hexdump;
438 li->listen->write_hexdump = inst->write_hexdump;
439}
440
441static int mod_instantiate(module_inst_ctx_t const *mctx)
442{
443 proto_tacacs_tcp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_tacacs_tcp_t);
444 CONF_SECTION *conf = mctx->mi->conf;
445 size_t num;
446 CONF_ITEM *ci;
447 CONF_SECTION *server_cs;
448
449 inst->cs = conf;
450
451 /*
452 * Complain if no "ipaddr" is set.
453 */
454 if (inst->ipaddr.af == AF_UNSPEC) {
455 cf_log_err(conf, "No 'ipaddr' was specified in the 'tcp' section");
456 return -1;
457 }
458
459 if (inst->recv_buff_is_set) {
460 FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
461 FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
462 }
463
464 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 20);
465 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65536);
466
467 if (!inst->port) {
468 struct servent *s;
469
470 if (!inst->port_name) {
471 cf_log_err(conf, "No 'port' was specified in the 'tcp' section");
472 return -1;
473 }
474
475 s = getservbyname(inst->port_name, "tcp");
476 if (!s) {
477 cf_log_err(conf, "Unknown value for 'port_name = %s", inst->port_name);
478 return -1;
479 }
480
481 inst->port = ntohs(s->s_port);
482 }
483
484 /*
485 * Parse and create the trie for dynamic clients, even if
486 * there's no dynamic clients.
487 */
488 num = talloc_array_length(inst->allow);
489 if (!num) {
490 if (inst->dynamic_clients) {
491 cf_log_err(conf, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
492 return -1;
493 }
494 } else {
495 inst->trie = fr_master_io_network(inst, inst->ipaddr.af, inst->allow, inst->deny);
496 if (!inst->trie) {
497 cf_log_perr(conf, "Failed creating list of networks");
498 return -1;
499 }
500 }
501
502 ci = cf_section_to_item(mctx->mi->parent->conf); /* listen { ... } */
503 fr_assert(ci != NULL);
504 ci = cf_parent(ci);
505 fr_assert(ci != NULL);
506
507 server_cs = cf_item_to_section(ci);
508
509 /*
510 * Look up local clients, if they exist.
511 *
512 * @todo - ensure that we only parse clients which are
513 * for IPPROTO_TCP, and require a "secret".
514 */
515 if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
516 inst->clients = client_list_parse_section(server_cs, IPPROTO_TCP, false);
517 if (!inst->clients) {
518 cf_log_err(conf, "Failed creating local clients");
519 return -1;
520 }
521 }
522
523 return 0;
524}
525
527{
530
531 /*
532 * Prefer local clients.
533 */
534 if (inst->clients) {
535 fr_client_t *client;
536
537 client = client_find(inst->clients, ipaddr, ipproto);
538 if (client) return client;
539 }
540
541 return client_find(NULL, ipaddr, ipproto);
542}
543
545 .common = {
546 .magic = MODULE_MAGIC_INIT,
547 .name = "tacacs_tcp",
549 .inst_size = sizeof(proto_tacacs_tcp_t),
550 .thread_inst_size = sizeof(proto_tacacs_tcp_thread_t),
551 .instantiate = mod_instantiate,
552 },
553 .default_message_size = 4096,
554 .track_duplicates = false,
555
556 .open = mod_open,
557 .read = mod_read,
558 .write = mod_write,
559 .fd_set = mod_fd_set,
560 .connection_set = mod_connection_set,
561 .network_get = mod_network_get,
562 .client_find = mod_client_find,
563 .get_name = mod_name,
564 .hexdump_set = mod_hexdump_set,
565};
static int const char char buffer[256]
Definition acutest.h:641
char const * fr_app_io_socket_name(TALLOC_CTX *ctx, fr_app_io_t const *app_io, fr_ipaddr_t const *src_ipaddr, uint16_t src_port, fr_ipaddr_t const *dst_ipaddr, uint16_t dst_port, char const *interface)
Definition app_io.c:32
module_t common
Common fields to all loadable modules.
Definition app_io.h:34
Public structure describing an I/O path for a protocol.
Definition app_io.h:33
static int packet_ctx
the tests pass only the address of packet_ctx
#define STRINGIFY(x)
Definition build.h:233
#define UNUSED
Definition build.h:415
#define NUM_ELEMENTS(_t)
Definition build.h:437
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:722
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:572
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:280
@ CONF_FLAG_MULTI
CONF_PAIR can have multiple copies.
Definition cf_parse.h:483
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition cf_parse.h:460
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition cf_parse.h:350
#define FR_CONF_OFFSET_IS_SET(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct,...
Definition cf_parse.h:294
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:238
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:649
Common header for all CONF_* types.
Definition cf_priv.h:54
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
CONF_ITEM * cf_section_to_item(CONF_SECTION const *cs)
Cast a CONF_SECTION to a CONF_ITEM.
Definition cf_util.c:725
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition cf_util.c:671
CONF_SECTION * cf_section_find_next(CONF_SECTION const *cs, CONF_SECTION const *prev, char const *name1, char const *name2)
Return the next matching section.
Definition cf_util.c:1268
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:340
#define cf_parent(_cf)
Definition cf_util.h:115
#define cf_log_perr(_cf, _fmt,...)
Definition cf_util.h:347
#define CF_IDENT_ANY
Definition cf_util.h:80
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition debug.h:177
#define ERROR(fmt,...)
Definition dhcpclient.c:40
static int sockfd
Definition dhcpclient.c:55
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
IPv4/6 prefix.
fr_socket_t socket
src/dst ip and port.
Definition base.h:342
Describes a host allowed to send packets to the server.
Definition client.h:80
#define PERROR(_fmt,...)
Definition log.h:233
#define DEBUG_ENABLED2
True if global debug level 1-2 messages are enabled.
Definition log.h:263
#define DEBUG3(_fmt,...)
Definition log.h:271
uint64_t total_responses
Definition stats.h:38
uint64_t total_requests
Definition stats.h:35
#define fr_time()
Definition event.c:58
fr_listen_t * listen
the listener this is a socket of.
Definition listen.h:65
int fd
file descriptor for this socket - set by open
Definition listen.h:67
bool write_hexdump
Do we debug hexdump packets as they're written.
Definition listen.h:51
void const * app_io_instance
I/O path configuration context.
Definition listen.h:34
CONF_SECTION * cs
of this listener
Definition listen.h:39
void * thread_instance
thread / socket context
Definition listen.h:69
bool read_hexdump
Do we debug hexdump packets as they're read.
Definition listen.h:50
fr_trie_t * fr_master_io_network(TALLOC_CTX *ctx, int af, fr_ipaddr_t *allow, fr_ipaddr_t *deny)
Create a trie from arrays of allow / deny IP addresses.
Definition master.c:3224
#define fr_add(_out, _a, _b)
Adds two integers.
Definition math.h:190
unsigned short uint16_t
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
unsigned int uint32_t
long int ssize_t
unsigned char uint8_t
int fr_nonblock(UNUSED int fd)
Definition misc.c:293
module_instance_t * mi
Instance of the module being instantiated.
Definition module_ctx.h:51
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
static fr_client_t * mod_client_find(fr_listen_instance_t *li, fr_ipaddr_t const *ipaddr, int ipproto)
fr_trie_t * trie
for parsed networks
fr_ipaddr_t * deny
denied networks for dynamic clients
CONF_SECTION * cs
our configuration
#define TACACS_MAX_ATTRIBUTES
bool dynamic_clients
whether we have dynamic clients
bool read_hexdump
Do we debug hexdump read packets.
bool recv_buff_is_set
Whether we were provided with a recv_buff.
static void mod_hexdump_set(fr_listen_instance_t *li, void *data)
static const char * packet_name[]
fr_ipaddr_t ipaddr
IP address to listen on.
fr_client_list_t * clients
local clients
static int mod_open(fr_listen_instance_t *li)
Open a TCP listener for TACACS+.
char const * interface
Interface to bind to.
bool write_hexdump
Do we debug hexdump write packets.
static void mod_network_get(int *ipproto, bool *dynamic_clients, fr_trie_t const **trie, void *instance)
fr_io_address_t * connection
for connected sockets.
static const conf_parser_t networks_config[]
uint32_t max_attributes
Limit maximum decodable attributes.
static int mod_fd_set(fr_listen_instance_t *li, int fd)
Set the file descriptor for this socket.
uint32_t max_packet_size
for message ring buffer.
static char const * mod_name(fr_listen_instance_t *li)
fr_app_io_t proto_tacacs_tcp
fr_stats_t stats
statistics for this socket
fr_ipaddr_t * allow
allowed networks for dynamic clients
static int mod_connection_set(fr_listen_instance_t *li, fr_io_address_t *connection)
char const * port_name
Name of the port for getservent().
static ssize_t mod_write(fr_listen_instance_t *li, UNUSED void *packet_ctx, UNUSED fr_time_t request_time, uint8_t *buffer, size_t buffer_len, size_t written)
static ssize_t mod_read(fr_listen_instance_t *li, UNUSED void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover)
Read TACACS data from a TCP connection.
char const * name
socket name
uint16_t port
Port to listen on.
uint32_t recv_buff
How big the kernel's receive buffer should be.
static int mod_instantiate(module_inst_ctx_t const *mctx)
static const conf_parser_t tcp_listen_config[]
ssize_t fr_tacacs_length(uint8_t const *buffer, size_t buffer_len)
Definition base.c:210
#define fr_assert(_expr)
Definition rad_assert.h:37
#define DEBUG2(fmt,...)
static int ipproto
Definition radclient.c:91
static rs_t * conf
Definition radsniff.c:52
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:355
void * data
Module's instance data.
Definition module.h:297
module_instance_t const * parent
Parent module's instance (if any).
Definition module.h:363
conf_parser_t const * config
How to convert a CONF_SECTION to a module instance.
Definition module.h:207
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
Definition snprintf.c:689
int fr_socket_server_tcp(fr_ipaddr_t const *src_ipaddr, uint16_t *src_port, char const *port_name, bool async)
Open an IPv4/IPv6 TCP socket.
Definition socket.c:943
int fr_socket_bind(int sockfd, char const *ifname, fr_ipaddr_t *src_ipaddr, uint16_t *src_port)
Bind a UDP/TCP v4/v6 socket to a given ipaddr src port, and interface.
Definition socket.c:200
fr_client_t * client_find(fr_client_list_t const *clients, fr_ipaddr_t const *ipaddr, int proto)
Definition client.c:370
fr_client_list_t * client_list_parse_section(CONF_SECTION *section, int proto, TLS_UNUSED bool tls_required)
Definition client.c:475
Group of clients.
Definition client.c:50
eap_aka_sim_process_conf_t * inst
fr_aka_sim_id_type_t type
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
Definition syserror.c:243
#define FR_HEADER_LENGTH
Definition tacacs.h:26
@ FR_TAC_PLUS_ACCT_STATUS_ERROR
Definition tacacs.h:256
@ FR_TAC_PLUS_AUTHEN_STATUS_ERROR
Definition tacacs.h:157
#define packet_is_encrypted(p)
Definition tacacs.h:61
fr_tacacs_packet_hdr_t hdr
Definition tacacs.h:277
fr_tacacs_type_t type
Definition tacacs.h:97
@ FR_TAC_PLUS_ACCT
Definition tacacs.h:67
@ FR_TAC_PLUS_AUTHEN
Definition tacacs.h:65
@ FR_TAC_PLUS_AUTHOR
Definition tacacs.h:66
@ FR_TAC_PLUS_AUTHOR_STATUS_ERROR
Definition tacacs.h:214
#define talloc_get_type_abort_const
Definition talloc.h:117
"server local" time.
Definition time.h:69
#define FR_PROTO_HEX_DUMP(_data, _data_len, _fmt,...)
Definition proto.h:42
char const * fr_strerror(void)
Get the last library error.
Definition strerror.c:558
#define DOC_ROOT_REF(_x)
Definition version.h:90
static fr_slen_t data
Definition value.h:1366