The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
fd_priv.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: b68db10da57e85667ff0e712a61463a3559e63d9 $
20 * @file lib/bio/fd_priv.h
21 * @brief Private binary IO abstractions for file descriptors
22 *
23 * @copyright 2024 Network RADIUS SAS (legal@networkradius.com)
24 */
25RCSIDH(lib_bio_fd_privh, "$Id: b68db10da57e85667ff0e712a61463a3559e63d9 $")
26
27#include <freeradius-devel/util/syserror.h>
28
29#include <freeradius-devel/bio/bio_priv.h>
30#include <freeradius-devel/bio/fd.h>
31
32/** Our FD bio structure.
33 *
34 */
35typedef struct fr_bio_fd_s {
37
39
40 struct sockaddr_storage remote_sockaddr; //!< for connected UDP sockets.
42
43 struct {
44 fr_bio_callback_t success; //!< for fr_bio_fd_connect()
45 fr_bio_callback_t error; //!< for fr_bio_fd_connect()
46 fr_bio_callback_t timeout; //!< for fr_bio_fd_connect()
47 fr_event_list_t *el; //!< for fr_bio_fd_connect()
48 fr_timer_t *ev; //!< for fr_bio_fd_connect()
50
51 int max_tries; //!< how many times we retry on EINTR
52 size_t offset; //!< where #fr_bio_fd_packet_ctx_t is stored
53
54#if defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) || defined(IPV6_PKTINFO)
55 struct iovec iov; //!< for recvfromto
56 struct msghdr msgh; //!< for recvfromto
57
58 /*
59 * A received packet can carry two control messages: the destination address, and the
60 * receive timestamp that fr_bio_fd_common_datagram() enables. If cbuf is too small for
61 * both control messages, then the kernel sets MSG_CTRUNC, and fd_fd_recvfromto_common()
62 * drops the packet.
63 */
64 uint8_t cbuf[CMSG_SPACE(sizeof(struct in6_pktinfo)) +
65 CMSG_SPACE(sizeof(union { struct timespec ts; struct timeval tv; }))]; //!< for recvfromto and sendfromto
66#endif
68
69#define fr_bio_fd_packet_ctx(_my, _packet_ctx) ((fr_bio_fd_packet_ctx_t *) (((uint8_t *) _packet_ctx) + _my->offset))
70
71int fr_filename_to_sockaddr(struct sockaddr_un *sun, socklen_t *sunlen, char const *filename) CC_HINT(nonnull);
72
74
76
78
80
82
void(* fr_bio_callback_t)(fr_bio_t *bio)
Definition base.h:86
#define RCSIDH(h, id)
Definition build.h:604
Run-time status of the socket.
Definition fd.h:144
socklen_t remote_sockaddr_len
Definition fd_priv.h:41
struct fr_bio_fd_s::@18 connect
int fr_bio_fd_unix_shutdown(fr_bio_t *bio)
Remove the Unix domain socket which this bio created.
Definition fd_open.c:499
size_t offset
where fr_bio_fd_packet_ctx_t is stored
Definition fd_priv.h:52
int fr_bio_fd_socket_name(fr_bio_fd_t *my)
Definition fd.c:686
fr_bio_fd_info_t info
Definition fd_priv.h:38
int max_tries
how many times we retry on EINTR
Definition fd_priv.h:51
int fr_bio_fd_init_connected(fr_bio_fd_t *my)
Definition fd.c:881
void fr_bio_fd_name(fr_bio_fd_t *my)
Set the name of an FD BIO.
Definition fd_open.c:897
int fr_filename_to_sockaddr(struct sockaddr_un *sun, socklen_t *sunlen, char const *filename)
Definition fd.c:668
int fr_bio_fd_init_listen(fr_bio_fd_t *my)
Definition fd.c:990
int fr_bio_fd_init_common(fr_bio_fd_t *my)
Definition fd.c:949
struct fr_bio_fd_s fr_bio_fd_t
Our FD bio structure.
struct sockaddr_storage remote_sockaddr
for connected UDP sockets.
Definition fd_priv.h:40
Our FD bio structure.
Definition fd_priv.h:35
Stores all information relating to an event list.
Definition event.c:375
unsigned char uint8_t
A timer event.
Definition timer.c:83
static fr_event_list_t * el
int nonnull(2, 5))