The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
network.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: 2e00a513038c48496036d94dd9e6773d716d345a $
20 *
21 * @file io/network.h
22 * @brief Receive packets
23 *
24 * @copyright 2016 Alan DeKok (aland@freeradius.org)
25 */
26RCSIDH(network_h, "$Id: 2e00a513038c48496036d94dd9e6773d716d345a $")
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
33
34/** Events for the network's own control messages, in the FR_CONTROL_EVENTSET_NETWORK event set
35 */
37 FR_NETWORK_CONTROL_LISTEN = 0, //!< Add a listener.
38 FR_NETWORK_CONTROL_DIRECTORY, //!< Add a directory listener.
39 FR_NETWORK_CONTROL_WORKER, //!< A worker has started.
40 FR_NETWORK_CONTROL_INJECT //!< Inject a packet into a listener.
42
43#ifdef __cplusplus
44}
45#endif
46
47#include <freeradius-devel/io/worker.h>
48#include <freeradius-devel/util/log.h>
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
57
59 fr_listen_instance_t *li) CC_HINT(nonnull) CC_HINT(warn_unused_result);
60
62 fr_listen_instance_t *li) CC_HINT(nonnull) CC_HINT(warn_unused_result);
63
65 fr_listen_instance_t *li) CC_HINT(nonnull) CC_HINT(warn_unused_result);
66
67int fr_network_worker_add(fr_network_t *nr, fr_worker_t *worker) CC_HINT(nonnull) CC_HINT(warn_unused_result);
68
70
72
74 size_t packet_len, void *packet_ctx, fr_time_t request_time) CC_HINT(nonnull);
75
77 size_t packet_len, fr_time_t recv_time) CC_HINT(warn_unused_result);
78
80 uint8_t const *data,
81 size_t data_len, fr_time_t recv_time) CC_HINT(warn_unused_result);
82
84 const uint8_t *buffer, size_t buflen, fr_time_t recv_time, void *packet_ctx) CC_HINT(nonnull(1,2,3,4)) CC_HINT(warn_unused_result);
85
87
89 char const *nr, fr_log_t const *logger, fr_log_lvl_t lvl,
90 fr_network_config_t const *config) CC_HINT(nonnull(2,4)) CC_HINT(warn_unused_result);
91
92int fr_network_exit(fr_network_t *nr) CC_HINT(nonnull) CC_HINT(warn_unused_result);
93
94int fr_network_destroy(fr_network_t *nr) CC_HINT(nonnull) CC_HINT(warn_unused_result);
95
97
99
100void fr_network(fr_network_t *nr) CC_HINT(nonnull);
101
102int fr_network_stats(fr_network_t const *nr, int num, uint64_t *stats) CC_HINT(nonnull) CC_HINT(warn_unused_result);
103
104void fr_network_stats_log(fr_network_t const *nr, fr_log_t const *log) CC_HINT(nonnull);
105
107
108#ifdef __cplusplus
109}
110#endif
static int const char char buffer[256]
Definition acutest.h:641
static int packet_ctx
the tests pass only the address of packet_ctx
#define RCSIDH(h, id)
Definition build.h:604
fr_cmd_table_t cmd_network_table[]
Definition network.c:2266
fr_network_t * fr_network_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const *nr, fr_log_t const *logger, fr_log_lvl_t lvl, fr_network_config_t const *config))
Create a network.
Definition network.c:2067
ssize_t fr_network_listen_outstanding(fr_network_t *nr, fr_listen_instance_t *li)
Get the number of outstanding packets.
Definition network.c:778
void fr_network_close_event_delete(fr_network_t *nr)
Remove "close" events from the event loop.
Definition network.c:1772
int fr_network_worker_add(fr_network_t *nr, fr_worker_t *worker)
Add a worker to a network in a different thread.
Definition network.c:260
void fr_network_listen_read(fr_network_t *nr, fr_listen_instance_t *li)
Signal the network to read from a listener.
Definition network.c:287
int fr_network_destroy(fr_network_t *nr)
Stop a network thread in an orderly way.
Definition network.c:1782
int fr_network_listen_send_packet(fr_network_t *nr, fr_listen_instance_t *parent, fr_listen_instance_t *li, const uint8_t *buffer, size_t buflen, fr_time_t recv_time, void *packet_ctx))
Send a packet to the worker.
Definition network.c:736
void fr_network(fr_network_t *nr)
Definition network.c:1936
void fr_network_worker_add_self(fr_network_t *nr, fr_worker_t *worker)
Add a worker to a network in the same thread.
Definition network.c:276
int fr_network_directory_add(fr_network_t *nr, fr_listen_instance_t *li)
Add a "watch directory" call to a network.
Definition network.c:249
int fr_network_exit(fr_network_t *nr)
Signal a network thread to exit.
Definition network.c:2034
int fr_network_listen_add(fr_network_t *nr, fr_listen_instance_t *li)
Add a fr_listen_instance_t to a network.
Definition network.c:199
int fr_network_listen_delete(fr_network_t *nr, fr_listen_instance_t *li)
Delete a socket from a network.
Definition network.c:230
uint32_t max_outstanding
Definition network.h:55
void fr_network_stats_log(fr_network_t const *nr, fr_log_t const *log)
Definition network.c:2199
int fr_network_stats(fr_network_t const *nr, int num, uint64_t *stats)
Definition network.c:2183
fr_network_control_event_t
Events for the network's own control messages, in the FR_CONTROL_EVENTSET_NETWORK event set.
Definition network.h:36
@ FR_NETWORK_CONTROL_DIRECTORY
Add a directory listener.
Definition network.h:38
@ FR_NETWORK_CONTROL_LISTEN
Add a listener.
Definition network.h:37
@ FR_NETWORK_CONTROL_INJECT
Inject a packet into a listener.
Definition network.h:40
@ FR_NETWORK_CONTROL_WORKER
A worker has started.
Definition network.h:39
void fr_network_listen_write(fr_network_t *nr, fr_listen_instance_t *li, uint8_t const *packet, size_t packet_len, void *packet_ctx, fr_time_t request_time)
Inject a packet for a listener to write.
Definition network.c:313
int fr_network_close_event_insert(fr_network_t *nr)
Add events to the loop which will exit when the number of workers has reached zero.
Definition network.c:1757
int fr_network_sendto_worker(fr_network_t *nr, fr_listen_instance_t *li, void *packet_ctx, uint8_t const *data, size_t data_len, fr_time_t recv_time)
Definition network.c:1030
int fr_network_listen_inject(fr_network_t *nr, fr_listen_instance_t *li, uint8_t const *packet, size_t packet_len, fr_time_t recv_time)
Inject a packet for a listener to read.
Definition network.c:361
Stores all information relating to an event list.
Definition event.c:375
fr_log_lvl_t
Definition log.h:64
unsigned short uint16_t
unsigned int uint32_t
long int ssize_t
unsigned char uint8_t
static const conf_parser_t config[]
Definition base.c:162
Definition log.h:93
"server local" time.
Definition time.h:69
static fr_event_list_t * el
static fr_slen_t parent
Definition pair.h:864
static fr_slen_t data
Definition value.h:1366
int nonnull(2, 5))
A worker which takes packets from a master, and processes them.
Definition worker.c:89