The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
client_udp.c
Go to the documentation of this file.
1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 322f0708a3efdc595d82e8990c838bc1db952357 $
19 *
20 * @file protocols/radius/client_udp.c
21 * @brief Functions to support RADIUS bio handlers for client udp sockets
22 *
23 * @copyright 2024 Network RADIUS SAS (legal@networkradius.com)
24 */
25RCSID("$Id: 322f0708a3efdc595d82e8990c838bc1db952357 $")
26
27#include <freeradius-devel/bio/packet.h>
28#include <freeradius-devel/radius/client_udp.h>
29#include <freeradius-devel/radius/client_priv.h>
30
31/** Allocate an ID, and write one packet.
32 *
33 */
35{
36 fr_radius_client_fd_bio_t *my = talloc_get_type_abort(bio, fr_radius_client_fd_bio_t);
37 ssize_t slen;
38
39 if (!packet->data) return fr_radius_client_fd_bio_write(my, pctx, packet, list);
40
41 slen = fr_bio_write(my->common.bio, &packet->socket, packet->data, packet->data_len);
42 if (slen < 0) return (int) slen;
43
44 return 0;
45}
46
47/** Allocate a RADIUS bio for writing client packets
48 *
49 * It also verifies that the packets we receive are valid for RADIUS.
50 */
52{
54
55 my = fr_radius_client_fd_bio_alloc(ctx, 2 * 4096, cfg, fd_cfg);
56 if (!my) return NULL;
57
59 talloc_free(my);
60 return NULL;
61 }
62
65
66 return (fr_bio_packet_t *) my;
67}
static ssize_t fr_bio_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
Write raw data to a bio.
Definition base.h:184
fr_bio_t * bio
underlying BIO(s) for IO
Definition packet.h:100
fr_bio_packet_write_t write
write to the underlying bio
Definition packet.h:90
fr_bio_packet_read_t read
read from the underlying bio
Definition packet.h:89
#define RCSID(id)
Definition build.h:603
fr_bio_packet_t common
Definition client_priv.h:35
fr_radius_client_config_t cfg
Definition client_priv.h:37
static int fr_radius_client_udp_bio_write(fr_bio_packet_t *bio, void *pctx, fr_packet_t *packet, fr_pair_list_t *list)
Allocate an ID, and write one packet.
Definition client_udp.c:34
fr_bio_packet_t * fr_radius_client_udp_bio_alloc(TALLOC_CTX *ctx, fr_radius_client_config_t *cfg, fr_bio_fd_config_t const *fd_cfg)
Allocate a RADIUS bio for writing client packets.
Definition client_udp.c:51
Configuration for sockets.
Definition fd.h:92
talloc_free(hp)
int fr_bio_mem_set_verify(fr_bio_t *bio, fr_bio_verify_t verify, void *verify_ctx, bool datagram)
Set the verification function for memory bios.
Definition mem.c:856
long int ssize_t
fr_bio_verify_action_t fr_radius_bio_verify_datagram(UNUSED fr_bio_t *bio, void *verify_ctx, UNUSED void *packet_ctx, const void *data, size_t *size)
And verify a datagram packet.
Definition bio.c:70
fr_radius_bio_verify_t verify
Definition client.h:38
int fr_radius_client_fd_bio_read(fr_bio_packet_t *bio, void **pctx_p, fr_packet_t **packet_p, UNUSED TALLOC_CTX *out_ctx, fr_pair_list_t *out)
Definition client.c:574
int fr_radius_client_fd_bio_write(fr_radius_client_fd_bio_t *my, void *pctx, fr_packet_t *packet, fr_pair_list_t *list)
Definition client.c:176
fr_radius_client_fd_bio_t * fr_radius_client_fd_bio_alloc(TALLOC_CTX *ctx, size_t read_size, fr_radius_client_config_t *cfg, fr_bio_fd_config_t const *fd_cfg)
Definition client.c:64
fr_socket_t socket
This packet was received on.
Definition packet.h:57
uint8_t * data
Packet data (body).
Definition packet.h:63
size_t data_len
Length of packet data.
Definition packet.h:64