The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
master.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: b49508f2f605b6e5e29d3e91f5ecc91faf36cfba $
20 *
21 * @file io/master.h
22 * @brief Master IO handler
23 *
24 * @copyright 2018 Alan DeKok (aland@freeradius.org)
25 */
26RCSIDH(master_h, "$Id: b49508f2f605b6e5e29d3e91f5ecc91faf36cfba $")
27
28#include <freeradius-devel/server/base.h>
29#include <freeradius-devel/io/schedule.h>
30#include <freeradius-devel/io/application.h>
31#include <freeradius-devel/util/trie.h>
32#include <freeradius-devel/util/talloc.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
39
40typedef struct fr_io_track_s {
41 fr_rb_node_t node; //!< rbtree node in the tracking tree.
42 fr_listen_t const *li; //!< listener associated with this tracking structure
43 fr_timer_t *ev; //!< when we clean up this tracking entry
44 fr_time_t timestamp; //!< when this packet was received
45 fr_time_t expires; //!< when this packet expires
46 int packets; //!< number of packets using this entry
47 uint8_t *reply; //!< reply packet (if any)
48 size_t reply_len; //!< length of reply, or 1 for "do not reply"
49
50 bool discard; //!< whether or not we discard the packet
51 bool do_not_respond; //!< don't respond
52 bool finished; //!< are we finished the request?
53
54 fr_time_t dynamic; //!< timestamp for packet doing dynamic client definition
55 fr_io_address_t const *address; //!< of this packet.. shared between multiple packets
56 fr_io_client_t *client; //!< client handling this packet.
57 uint8_t *packet; //!< really a tracking structure, not a packet
59
60/** The master IO instance
61 *
62 * This structure is the instance data for the "master" IO handler.
63 * The structure is exposed for simplicity right now. It may be
64 * made private in the future.
65 *
66 * The fr_master_io_listen() should be used to create a listener from
67 * this structure.
68 *
69 * Note that most entries of this structure MUST be initialized
70 * before fr_master_io_listen() is called. That function only
71 * creates the listener, and adds it to the scheduler.
72 */
73typedef struct {
74 module_instance_t *mi; //!< our parent mi
75 module_list_t *clients; //!< Holds client modules created to represent
76 ///< sockets created as clients connect to the
77 ///< listener.
78
79 uint32_t max_connections; //!< maximum number of connections to allow
80 uint32_t max_clients; //!< maximum number of dynamic clients to allow
81 uint32_t max_pending_packets; //!< maximum number of pending packets
82
83 fr_time_delta_t cleanup_delay; //!< for Access-Request packets
84 fr_time_delta_t idle_timeout; //!< for connected clients
85 fr_time_delta_t dynamic_timeout; //!< for dynamic clients
86 fr_time_delta_t nak_lifetime; //!< lifetime of NAKed clients
87 fr_time_delta_t check_interval; //!< polling for closed sockets
88
89 bool dynamic_clients; //!< do we have dynamic clients.
90 bool log_ignored_clients; //!< Whether we emit log messages when we ignore
91 ///< a client because it's unknown, or outside
92 ///< of the allowed networks. This is here for
93 ///< people who expose their RADIUS servers to
94 ///< the internet, and don't want their logs filling
95 ///< up with random connection attempts.
96
97 CONF_SECTION *server_cs; //!< server CS for this listener
98
99 module_instance_t *submodule; //!< As provided by the transport_parse
100 ///< callback. Broken out into the
101 ///< app_io_* fields below for convenience.
102 fr_app_t *app; //!< main protocol handler
103 void *app_instance; //!< instance data for main protocol handler
104
105 fr_app_io_t const *app_io; //!< Easy access to the app_io handle.
106 void *app_io_instance; //!< Easy access to the app_io instance.
107 CONF_SECTION *app_io_conf; //!< Easy access to the app_io's config section.
108
109 int ipproto; //!< IP proto by number
110 fr_trie_t const *networks; //!< trie of allowed networks
112
114
115fr_trie_t *fr_master_io_network(TALLOC_CTX *ctx, int af, fr_ipaddr_t *allow, fr_ipaddr_t *deny);
117 size_t default_message_size, size_t num_messages) CC_HINT(nonnull);
118fr_io_track_t *fr_master_io_track_alloc(fr_listen_t *li, fr_client_t *client, fr_ipaddr_t const *src_ipaddr, int src_port,
119 fr_ipaddr_t const *dst_ipaddr, int dst_port);
120
121#ifdef __cplusplus
122}
123#endif
Public structure describing an I/O path for a protocol.
Definition app_io.h:33
Describes a new application (protocol)
Definition application.h:71
#define RCSIDH(h, id)
Definition build.h:488
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
IPv4/6 prefix.
Describes a host allowed to send packets to the server.
Definition client.h:80
Client definitions for master IO.
Definition master.c:113
module_instance_t * submodule
As provided by the transport_parse callback.
Definition master.h:99
fr_timer_t * ev
when we clean up this tracking entry
Definition master.h:43
fr_time_delta_t cleanup_delay
for Access-Request packets
Definition master.h:83
uint8_t * reply
reply packet (if any)
Definition master.h:47
uint32_t max_connections
maximum number of connections to allow
Definition master.h:79
uint32_t max_clients
maximum number of dynamic clients to allow
Definition master.h:80
int packets
number of packets using this entry
Definition master.h:46
fr_time_t dynamic
timestamp for packet doing dynamic client definition
Definition master.h:54
int fr_master_io_listen(fr_io_instance_t *io, fr_schedule_t *sc, size_t default_message_size, size_t num_messages)
Definition master.c:3113
fr_time_delta_t idle_timeout
for connected clients
Definition master.h:84
fr_rb_node_t node
rbtree node in the tracking tree.
Definition master.h:41
module_instance_t * mi
our parent mi
Definition master.h:74
void * app_io_instance
Easy access to the app_io instance.
Definition master.h:106
fr_app_io_t fr_master_app_io
Definition master.c:3323
fr_app_io_t const * app_io
Easy access to the app_io handle.
Definition master.h:105
fr_io_address_t const * address
of this packet.. shared between multiple packets
Definition master.h:55
fr_time_delta_t check_interval
polling for closed sockets
Definition master.h:87
fr_app_t * app
main protocol handler
Definition master.h:102
fr_time_delta_t dynamic_timeout
for dynamic clients
Definition master.h:85
int ipproto
IP proto by number.
Definition master.h:109
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:2955
bool dynamic_clients
do we have dynamic clients.
Definition master.h:89
bool do_not_respond
don't respond
Definition master.h:51
fr_listen_t const * li
listener associated with this tracking structure
Definition master.h:42
module_list_t * clients
Holds client modules created to represent sockets created as clients connect to the listener.
Definition master.h:75
bool log_ignored_clients
Whether we emit log messages when we ignore a client because it's unknown, or outside of the allowed ...
Definition master.h:90
fr_io_track_t * fr_master_io_track_alloc(fr_listen_t *li, fr_client_t *client, fr_ipaddr_t const *src_ipaddr, int src_port, fr_ipaddr_t const *dst_ipaddr, int dst_port)
Definition master.c:3280
bool discard
whether or not we discard the packet
Definition master.h:50
fr_time_t timestamp
when this packet was received
Definition master.h:44
fr_time_delta_t nak_lifetime
lifetime of NAKed clients
Definition master.h:86
void * app_instance
instance data for main protocol handler
Definition master.h:103
fr_trie_t const * networks
trie of allowed networks
Definition master.h:110
bool finished
are we finished the request?
Definition master.h:52
uint8_t * packet
really a tracking structure, not a packet
Definition master.h:57
size_t reply_len
length of reply, or 1 for "do not reply"
Definition master.h:48
CONF_SECTION * server_cs
server CS for this listener
Definition master.h:97
CONF_SECTION * app_io_conf
Easy access to the app_io's config section.
Definition master.h:107
fr_io_client_t * client
client handling this packet.
Definition master.h:56
fr_time_t expires
when this packet expires
Definition master.h:45
uint32_t max_pending_packets
maximum number of pending packets
Definition master.h:81
struct fr_io_track_s fr_io_track_t
The master IO instance.
Definition master.h:73
unsigned int uint32_t
unsigned char uint8_t
The scheduler.
Definition schedule.c:125
Module instance data.
Definition module.h:285
A list of modules.
Definition module.h:405
static const uchar sc[16]
Definition smbdes.c:115
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
"server local" time.
Definition time.h:69
A timer event.
Definition timer.c:84
int nonnull(2, 5))