All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
udp.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program 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
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 #ifndef _FR_UDP_H
17 #define _FR_UDP_H
18 /**
19  * $Id: 8f71e6c0bcf20df5a39df94c5a21ea4e1bb3bf54 $
20  *
21  * @file include/udp.h
22  * @brief Abstraction API for sending and receiving packets on UDP sockets.
23  *
24  * @copyright 2015 The FreeRADIUS server project
25  */
26 RCSIDH(udp_h, "$Id: 8f71e6c0bcf20df5a39df94c5a21ea4e1bb3bf54 $")
27 
28 #include <freeradius-devel/libradius.h>
29 
30 #ifdef WITH_UDPFROMTO
31 #include <freeradius-devel/udpfromto.h>
32 #endif
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define UDP_FLAGS_NONE (0)
39 #define UDP_FLAGS_CONNECTED (1 << 0)
40 #define UDP_FLAGS_PEEK (1 << 1)
41 
42 ssize_t udp_send(int sockfd, void *data, size_t data_len, int flags,
43  fr_ipaddr_t *src_ipaddr, uint16_t src_port, int if_index,
44  fr_ipaddr_t *dst_ipaddr, uint16_t dst_port);
45 
46 void udp_recv_discard(int sockfd);
47 
48 ssize_t udp_recv_peek(int sockfd, void *data, size_t data_len, int flags, fr_ipaddr_t *src_ipaddr, uint16_t *src_port);
49 
50 ssize_t udp_recv(int sockfd, void *data, size_t data_len, int flags,
51  fr_ipaddr_t *src_ipaddr, uint16_t *src_port,
52  fr_ipaddr_t *dst_ipaddr, uint16_t *dst_port, int *if_index,
53  struct timeval *when);
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 #endif /* _FR_UDP_H */
static int sockfd
Definition: radclient.c:59
#define RCSIDH(h, id)
Definition: build.h:136
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:125
ssize_t udp_recv(int sockfd, void *data, size_t data_len, int flags, fr_ipaddr_t *src_ipaddr, uint16_t *src_port, fr_ipaddr_t *dst_ipaddr, uint16_t *dst_port, int *if_index, struct timeval *when)
ssize_t udp_send(int sockfd, void *data, size_t data_len, int flags, fr_ipaddr_t *src_ipaddr, uint16_t src_port, int if_index, fr_ipaddr_t *dst_ipaddr, uint16_t dst_port)
uint8_t data[]
Definition: eap_pwd.h:625
IPv4/6 prefix.
Definition: inet.h:41
void udp_recv_discard(int sockfd)
Discard the next UDP packet.
Definition: udp.c:105