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: b529dc111611d22530837d001975acb7b307a55d $
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: b529dc111611d22530837d001975acb7b307a55d $")
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_event_timer_t const *ev; //!< when we clean up this tracking entry
43 fr_time_t timestamp; //!< when this packet was received
44 fr_time_t expires; //!< when this packet expires
45 int packets; //!< number of packets using this entry
46 uint8_t *reply; //!< reply packet (if any)
47 size_t reply_len; //!< length of reply, or 1 for "do not reply"
48
49 bool discard; //!< whether or not we discard the packet
50 bool do_not_respond; //!< don't respond
51 bool finished; //!< are we finished the request?
52
53 fr_time_t dynamic; //!< timestamp for packet doing dynamic client definition
54 fr_io_address_t const *address; //!< of this packet.. shared between multiple packets
55 fr_io_client_t *client; //!< client handling this packet.
56 uint8_t *packet; //!< really a tracking structure, not a packet
58
59/** The master IO instance
60 *
61 * This structure is the instance data for the "master" IO handler.
62 * The structure is exposed for simplicity right now. It may be
63 * made private in the future.
64 *
65 * The fr_master_io_listen() should be used to create a listener from
66 * this structure.
67 *
68 * Note that most entries of this structure MUST be initialized
69 * before fr_master_io_listen() is called. That function only
70 * creates the listener, and adds it to the scheduler.
71 */
72typedef struct {
73 module_instance_t *mi; //!< our parent mi
74 module_list_t *clients; //!< Holds client modules created to represent
75 ///< sockets created as clients connect to the
76 ///< listener.
77
78 uint32_t max_connections; //!< maximum number of connections to allow
79 uint32_t max_clients; //!< maximum number of dynamic clients to allow
80 uint32_t max_pending_packets; //!< maximum number of pending packets
81
82 fr_time_delta_t cleanup_delay; //!< for Access-Request packets
83 fr_time_delta_t idle_timeout; //!< for dynamic clients
84 fr_time_delta_t nak_lifetime; //!< lifetime of NAKed clients
85 fr_time_delta_t check_interval; //!< polling for closed sockets
86
87 bool dynamic_clients; //!< do we have dynamic clients.
88
89 CONF_SECTION *server_cs; //!< server CS for this listener
90
91 module_instance_t *submodule; //!< As provided by the transport_parse
92 ///< callback. Broken out into the
93 ///< app_io_* fields below for convenience.
94 fr_app_t *app; //!< main protocol handler
95 void *app_instance; //!< instance data for main protocol handler
96
97 fr_app_io_t const *app_io; //!< Easy access to the app_io handle.
98 void *app_io_instance; //!< Easy access to the app_io instance.
99 CONF_SECTION *app_io_conf; //!< Easy access to the app_io's config section.
100
101 int ipproto; //!< IP proto by number
102 fr_trie_t const *networks; //!< trie of allowed networks
104
106
107fr_trie_t *fr_master_io_network(TALLOC_CTX *ctx, int af, fr_ipaddr_t *allow, fr_ipaddr_t *deny);
109 size_t default_message_size, size_t num_messages) CC_HINT(nonnull);
110fr_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,
111 fr_ipaddr_t const *dst_ipaddr, int dst_port);
112
113#ifdef __cplusplus
114}
115#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:484
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
A timer event.
Definition event.c:102
Client definitions for master IO.
Definition master.c:98
module_instance_t * submodule
As provided by the transport_parse callback.
Definition master.h:91
fr_time_delta_t cleanup_delay
for Access-Request packets
Definition master.h:82
uint8_t * reply
reply packet (if any)
Definition master.h:46
uint32_t max_connections
maximum number of connections to allow
Definition master.h:78
fr_event_timer_t const * ev
when we clean up this tracking entry
Definition master.h:42
uint32_t max_clients
maximum number of dynamic clients to allow
Definition master.h:79
int packets
number of packets using this entry
Definition master.h:45
fr_time_t dynamic
timestamp for packet doing dynamic client definition
Definition master.h:53
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:2925
fr_time_delta_t idle_timeout
for dynamic clients
Definition master.h:83
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:73
void * app_io_instance
Easy access to the app_io instance.
Definition master.h:98
fr_app_io_t fr_master_app_io
Definition master.c:3134
fr_app_io_t const * app_io
Easy access to the app_io handle.
Definition master.h:97
fr_io_address_t const * address
of this packet.. shared between multiple packets
Definition master.h:54
fr_time_delta_t check_interval
polling for closed sockets
Definition master.h:85
fr_app_t * app
main protocol handler
Definition master.h:94
int ipproto
IP proto by number.
Definition master.h:101
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:2767
bool dynamic_clients
do we have dynamic clients.
Definition master.h:87
bool do_not_respond
don't respond
Definition master.h:50
module_list_t * clients
Holds client modules created to represent sockets created as clients connect to the listener.
Definition master.h:74
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:3093
bool discard
whether or not we discard the packet
Definition master.h:49
fr_time_t timestamp
when this packet was received
Definition master.h:43
fr_time_delta_t nak_lifetime
lifetime of NAKed clients
Definition master.h:84
void * app_instance
instance data for main protocol handler
Definition master.h:95
fr_trie_t const * networks
trie of allowed networks
Definition master.h:102
bool finished
are we finished the request?
Definition master.h:51
uint8_t * packet
really a tracking structure, not a packet
Definition master.h:56
size_t reply_len
length of reply, or 1 for "do not reply"
Definition master.h:47
CONF_SECTION * server_cs
server CS for this listener
Definition master.h:89
CONF_SECTION * app_io_conf
Easy access to the app_io's config section.
Definition master.h:99
fr_io_client_t * client
client handling this packet.
Definition master.h:55
fr_time_t expires
when this packet expires
Definition master.h:44
uint32_t max_pending_packets
maximum number of pending packets
Definition master.h:80
struct fr_io_track_s fr_io_track_t
The master IO instance.
Definition master.h:72
unsigned int uint32_t
unsigned char uint8_t
The scheduler.
Definition schedule.c:125
Module instance data.
Definition module.h:265
A list of modules.
Definition module.h:385
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
int nonnull(2, 5))