The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
udp_queue.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: 24fda9b6eb6eb81d7c489c544db1f5441b764f73 $
20  *
21  * @file lib/util/udp_queue.h
22  * @brief Handle queues of outgoing UDP packets
23  *
24  * @copyright 2021 Network RADIUS SAS (legal@networkradius.com)
25  */
26 RCSIDH(udp_queue_h, "$Id: 24fda9b6eb6eb81d7c489c544db1f5441b764f73 $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <freeradius-devel/util/dlist.h>
33 #include <freeradius-devel/util/inet.h>
34 #include <freeradius-devel/util/event.h>
35 
36 typedef struct {
37  fr_ipaddr_t ipaddr; //!< socket IP address
38  uint16_t port; //!< socket port
39 
40  char const *interface; //!< Interface to bind to.
41 
42  fr_time_delta_t max_queued_time; //!< maximum time a packet can be queued
43 
44  uint32_t max_queued_packets; //!< maximum queued packets
45 
46  uint32_t send_buff; //!< How big the kernel's send buffer should be.
47 
48  bool send_buff_is_set; //!< Whether we were provided with a send_buf
50 
51 typedef struct fr_udp_queue_s fr_udp_queue_t;
52 
53 typedef void (*fr_udp_queue_resume_t)(bool written, void *rctx);
54 
55 
57  fr_udp_queue_resume_t resume) CC_HINT(nonnull(2,3));
58 
59 int fr_udp_queue_write(TALLOC_CTX *ctx, fr_udp_queue_t *uq,
60  uint8_t const *packet, size_t packet_len,
61  fr_ipaddr_t const *ipaddr, int port, void *rctx) CC_HINT(nonnull(2,3,5));
62 
63 
64 #ifdef __cplusplus
65 }
66 #endif
#define RCSIDH(h, id)
Definition: build.h:445
IPv4/6 prefix.
Definition: merged_model.c:272
Stores all information relating to an event list.
Definition: event.c:411
unsigned short uint16_t
Definition: merged_model.c:31
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:188
A time delta, a difference in time measured in nanoseconds.
Definition: time.h:80
fr_udp_queue_resume_t resume
Definition: udp_queue.c:44
uint16_t port
socket port
Definition: udp_queue.h:38
uint32_t max_queued_packets
maximum queued packets
Definition: udp_queue.h:44
int fr_udp_queue_write(TALLOC_CTX *ctx, fr_udp_queue_t *uq, uint8_t const *packet, size_t packet_len, fr_ipaddr_t const *ipaddr, int port, void *rctx))
Write packet to socket, OR enqueue it if we get EAGAIN.
Definition: udp_queue.c:260
char const * interface
Interface to bind to.
Definition: udp_queue.h:40
uint32_t send_buff
How big the kernel's send buffer should be.
Definition: udp_queue.h:46
void(* fr_udp_queue_resume_t)(bool written, void *rctx)
Definition: udp_queue.h:53
fr_ipaddr_t ipaddr
socket IP address
Definition: udp_queue.h:37
fr_udp_queue_t * fr_udp_queue_alloc(TALLOC_CTX *ctx, fr_udp_queue_config_t const *config, fr_event_list_t *el, fr_udp_queue_resume_t resume))
Allocate an outbound UDP queue.
Definition: udp_queue.c:95
fr_time_delta_t max_queued_time
maximum time a packet can be queued
Definition: udp_queue.h:42
bool send_buff_is_set
Whether we were provided with a send_buf.
Definition: udp_queue.h:48
static fr_event_list_t * el
int nonnull(2, 5))