The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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: 89545a6bcac09bdd98a7a59b50aab282ac656ced $
20  *
21  * @file io/network.h
22  * @brief Receive packets
23  *
24  * @copyright 2016 Alan DeKok (aland@freeradius.org)
25  */
26 RCSIDH(network_h, "$Id: 89545a6bcac09bdd98a7a59b50aab282ac656ced $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 typedef struct fr_network_s fr_network_t;
33 
34 #ifdef __cplusplus
35 }
36 #endif
37 
38 #include <freeradius-devel/io/worker.h>
39 #include <freeradius-devel/util/log.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 typedef struct {
48 
50 
52 
54 
55 int fr_network_worker_add(fr_network_t *nr, fr_worker_t *worker) CC_HINT(nonnull);
56 
58 
60 
61 void fr_network_listen_write(fr_network_t *nr, fr_listen_t *li, uint8_t const *packet, size_t packet_len,
62  void *packet_ctx, fr_time_t request_time) CC_HINT(nonnull);
63 
64 int fr_network_listen_inject(fr_network_t *nr, fr_listen_t *li, uint8_t const *packet, size_t packet_len, fr_time_t recv_time);
65 
66 int fr_network_sendto_worker(fr_network_t *nr, fr_listen_t *li, void *packet_ctx, uint8_t const *data, size_t data_len, fr_time_t recv_time);
67 
69  const uint8_t *buffer, size_t buflen, fr_time_t recv_time, void *packet_ctx) CC_HINT(nonnull(1,2,3,4));
70 
72 
74  char const *nr, fr_log_t const *logger, fr_log_lvl_t lvl,
75  fr_network_config_t const *config) CC_HINT(nonnull(2,4));
76 
77 int fr_network_exit(fr_network_t *nr) CC_HINT(nonnull);
78 
79 int fr_network_destroy(fr_network_t *nr) CC_HINT(nonnull);
80 
81 void fr_network(fr_network_t *nr) CC_HINT(nonnull);
82 
83 int fr_network_stats(fr_network_t const *nr, int num, uint64_t *stats) CC_HINT(nonnull);
84 
85 void fr_network_stats_log(fr_network_t const *nr, fr_log_t const *log) CC_HINT(nonnull);
86 
88 
89 #ifdef __cplusplus
90 }
91 #endif
static int const char char buffer[256]
Definition: acutest.h:574
#define RCSIDH(h, id)
Definition: build.h:482
fr_cmd_table_t cmd_network_table[]
Definition: network.c:2090
size_t fr_network_listen_outstanding(fr_network_t *nr, fr_listen_t *li)
Get the number of outstanding packets.
Definition: network.c:805
int fr_network_listen_add(fr_network_t *nr, fr_listen_t *li)
Add a fr_listen_t to a network.
Definition: network.c:236
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:293
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:1882
int fr_network_destroy(fr_network_t *nr)
Stop a network thread in an orderly way.
Definition: network.c:1681
int fr_network_directory_add(fr_network_t *nr, fr_listen_t *li)
Add a "watch directory" call to a network.
Definition: network.c:278
void fr_network(fr_network_t *nr)
The main network worker function.
Definition: network.c:1794
int fr_network_listen_delete(fr_network_t *nr, fr_listen_t *li)
Delete a socket from a network.
Definition: network.c:259
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:313
int fr_network_sendto_worker(fr_network_t *nr, fr_listen_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_exit(fr_network_t *nr)
Signal a network thread to exit.
Definition: network.c:1849
int fr_network_listen_inject(fr_network_t *nr, fr_listen_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:398
int fr_network_listen_send_packet(fr_network_t *nr, fr_listen_t *parent, fr_listen_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:763
uint32_t max_outstanding
Definition: network.h:46
void fr_network_stats_log(fr_network_t const *nr, fr_log_t const *log)
Definition: network.c:2023
int fr_network_stats(fr_network_t const *nr, int num, uint64_t *stats)
Definition: network.c:2007
void fr_network_listen_read(fr_network_t *nr, fr_listen_t *li)
Signal the network to read from a listener.
Definition: network.c:324
void fr_network_listen_write(fr_network_t *nr, fr_listen_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:350
Stores all information relating to an event list.
Definition: event.c:411
fr_log_lvl_t
Definition: log.h:67
unsigned int uint32_t
Definition: merged_model.c:33
unsigned char uint8_t
Definition: merged_model.c:30
static const conf_parser_t config[]
Definition: base.c:183
static rc_stats_t stats
Definition: radclient-ng.c:74
Definition: log.h:96
"server local" time.
Definition: time.h:69
static fr_event_list_t * el
static fr_slen_t parent
Definition: pair.h:851
static fr_slen_t data
Definition: value.h:1265
int nonnull(2, 5))
A worker which takes packets from a master, and processes them.
Definition: worker.c:94