The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
udp.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 /** Utility functions for managing UDP sockets
19  *
20  * @file src/lib/util/udp.h
21  *
22  * @copyright 2015 The FreeRADIUS server project
23  */
24 RCSIDH(udp_h, "$Id: 866314ba56fa1c8bab48541d070ecf2f434d3ca4 $")
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <freeradius-devel/build.h>
31 #include <freeradius-devel/missing.h>
32 #include <freeradius-devel/util/inet.h>
33 #include <freeradius-devel/util/socket.h>
34 #include <freeradius-devel/util/time.h>
35 #include <freeradius-devel/util/udpfromto.h>
36 
37 #define UDP_FLAGS_NONE (0)
38 #define UDP_FLAGS_CONNECTED (1 << 0)
39 #define UDP_FLAGS_PEEK (1 << 1)
40 
41 int udp_send(fr_socket_t const *socket, int flags, void *data, size_t data_len);
42 
43 int udp_recv_discard(int sockfd);
44 
45 ssize_t udp_recv_peek(int sockfd, void *data, size_t data_len, int flags, fr_ipaddr_t *src_ipaddr, uint16_t *src_port);
46 
47 ssize_t udp_recv(int sockfd, int flags,
48  fr_socket_t *socket_out, void *data, size_t data_len, fr_time_t *when);
49 
50 #ifdef __cplusplus
51 }
52 #endif
#define RCSIDH(h, id)
Definition: build.h:445
static int sockfd
Definition: dhcpclient.c:56
IPv4/6 prefix.
Definition: merged_model.c:272
unsigned short uint16_t
Definition: merged_model.c:31
long int ssize_t
Definition: merged_model.c:24
"server local" time.
Definition: time.h:69
int udp_recv_discard(int sockfd)
Discard the next UDP packet.
Definition: udp.c:76
ssize_t udp_recv_peek(int sockfd, void *data, size_t data_len, int flags, fr_ipaddr_t *src_ipaddr, uint16_t *src_port)
Peek at the header of a UDP packet.
Definition: udp.c:96
ssize_t udp_recv(int sockfd, int flags, fr_socket_t *socket_out, void *data, size_t data_len, fr_time_t *when)
Read a UDP packet.
Definition: udp.c:145
int udp_send(fr_socket_t const *socket, int flags, void *data, size_t data_len)
Send a packet via a UDP socket.
Definition: udp.c:43
Holds information necessary for binding or connecting to a socket.
Definition: socket.h:63
static fr_slen_t data
Definition: value.h:1259