The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
listen.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#include <freeradius-devel/io/base.h>
18#include <freeradius-devel/io/application.h>
19#include <freeradius-devel/server/time_tracking.h>
20
21/** A listener, as configured
22 *
23 * What a listen section produces at startup: the protocol, the virtual
24 * server and the I/O path.
25 */
26typedef struct fr_listen_s fr_listen_t;
28 fr_rb_node_t id_node; //!< Entry into the table of listeners by id.
29 uint32_t id; //!< Unique for the life of the process.
30
31 fr_dict_t const *dict; //!< dictionary for this listener
32
33 fr_app_io_t const *app_io; //!< I/O path functions.
34 void const *app_io_instance; //!< I/O path configuration context.
35
36 fr_app_t const *app;
37 void const *app_instance;
38
39 CONF_SECTION *cs; //!< of this listener
40 CONF_SECTION *server_cs; //!< CONF_SECTION of the server
41
42 bool track_duplicates; //!< do we track duplicate packets?
43 bool no_write_callback; //!< sometimes we don't need to do writes
44 bool non_socket_listener; //!< special internal listener that does not use sockets.
45 bool needs_full_setup; //!< Set to true to avoid the short cut when adding the listener.
46 ///< Added for rlm_detail which requires inst->parent->sc to be
47 ///< populated when event_list_set callback is run which doesn't
48 ///< happen if the short cut is taken.
49
50 bool read_hexdump; //!< Do we debug hexdump packets as they're read.
51 bool write_hexdump; //!< Do we debug hexdump packets as they're written.
52
53 size_t default_message_size; //!< copied from app_io, but may be changed
54 size_t num_messages; //!< for the message ring buffer
55};
56
57/** One open socket of a listener
58 *
59 * Created for global and connected sockets of the listener.
60 */
63 fr_rb_node_t virtual_server_node; //!< Entry into the virtual server's tree of listeners.
64
65 fr_listen_t *listen; //!< the listener this is a socket of.
66
67 int fd; //!< file descriptor for this socket - set by open
68 char const *name; //!< printable name for this socket - set by open
69 void *thread_instance; //!< thread / socket context
70
71 fr_socket_t *app_io_addr; //!< for tracking duplicate sockets
72
73 bool connected; //!< is this for a connected socket?
74};
75
76/**
77 * Minimal data structure to use the new code.
78 */
79struct fr_async_s {
82
85
86 fr_dlist_t entry; //!< in the list of requests associated with this channel
87 request_t *request; //!< back-pointer to the owning request so anything that
88 ///< pops this async off its dlist can reach the request
89 ///< without walking the talloc parent.
90
92 fr_listen_instance_t *inst; //!< How we received this request,
93 //!< and how we'll send the reply.
94};
95
97
98fr_listen_t *fr_listen_alloc(TALLOC_CTX *ctx, CONF_SECTION *listen_cs, CONF_SECTION *server_cs,
99 fr_app_t const *app, void const *app_instance,
100 fr_app_io_t const *app_io, void const *app_io_instance);
Public structure describing an I/O path for a protocol.
Definition app_io.h:33
Describes a new application (protocol)
Definition application.h:71
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
A full channel, which consists of two ends.
Definition channel.c:129
Entry in a doubly linked list.
Definition dlist.h:41
Stores all information relating to an event list.
Definition event.c:375
fr_rb_node_t virtual_server_node
Entry into the virtual server's tree of listeners.
Definition listen.h:63
int fr_io_listen_free(fr_listen_instance_t *li)
Free a socket's thread instance along with it.
Definition listen.c:126
fr_listen_t * fr_listen_alloc(TALLOC_CTX *ctx, CONF_SECTION *listen_cs, CONF_SECTION *server_cs, fr_app_t const *app, void const *app_instance, fr_app_io_t const *app_io, void const *app_io_instance)
Allocate a listener, and give it its id.
Definition listen.c:78
size_t num_messages
for the message ring buffer
Definition listen.h:54
fr_time_t recv_time
Definition listen.h:80
fr_channel_t * channel
Definition listen.h:84
request_t * request
back-pointer to the owning request so anything that pops this async off its dlist can reach the reque...
Definition listen.h:87
char const * name
printable name for this socket - set by open
Definition listen.h:68
fr_listen_t * listen
the listener this is a socket of.
Definition listen.h:65
bool needs_full_setup
Set to true to avoid the short cut when adding the listener.
Definition listen.h:45
fr_dict_t const * dict
dictionary for this listener
Definition listen.h:31
bool no_write_callback
sometimes we don't need to do writes
Definition listen.h:43
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
fr_rb_node_t id_node
Entry into the table of listeners by id.
Definition listen.h:28
fr_app_io_t const * app_io
I/O path functions.
Definition listen.h:33
fr_app_t const * app
Definition listen.h:36
bool track_duplicates
do we track duplicate packets?
Definition listen.h:42
fr_dlist_t entry
in the list of requests associated with this channel
Definition listen.h:86
void const * app_instance
Definition listen.h:37
void const * app_io_instance
I/O path configuration context.
Definition listen.h:34
CONF_SECTION * cs
of this listener
Definition listen.h:39
fr_time_tracking_t tracking
Definition listen.h:83
fr_socket_t * app_io_addr
for tracking duplicate sockets
Definition listen.h:71
void * packet_ctx
Definition listen.h:91
void * thread_instance
thread / socket context
Definition listen.h:69
bool non_socket_listener
special internal listener that does not use sockets.
Definition listen.h:44
uint32_t id
Unique for the life of the process.
Definition listen.h:29
CONF_SECTION * server_cs
CONF_SECTION of the server.
Definition listen.h:40
fr_listen_instance_t * fr_listen_instance_alloc(TALLOC_CTX *ctx, fr_listen_t *listen)
Allocate a socket of a listener.
Definition listen.c:111
fr_listen_instance_t * inst
How we received this request,.
Definition listen.h:92
fr_listen_t * fr_listen_by_id(uint32_t id)
Find a listener by its id.
Definition listen.c:141
bool read_hexdump
Do we debug hexdump packets as they're read.
Definition listen.h:50
size_t default_message_size
copied from app_io, but may be changed
Definition listen.h:53
fr_event_list_t * el
Definition listen.h:81
bool connected
is this for a connected socket?
Definition listen.h:73
Minimal data structure to use the new code.
Definition listen.h:79
unsigned int uint32_t
static fr_app_io_t app_io
"server local" time.
Definition time.h:69
Holds information necessary for binding or connecting to a socket.
Definition socket.h:60