The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
udpfromto.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 /** API for sending and receiving packets on unconnected UDP sockets
19  *
20  * Like recvfrom, but also stores the destination IP address. Useful on multihomed hosts.
21  *
22  * @file src/lib/util/udpfromto.h
23  *
24  * @copyright 2015 The FreeRADIUS server project
25  */
26 RCSIDH(udpfromto_h, "$Id: 1862e8c2d178d22732f94c4d9f89a99febc5e4ed $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <freeradius-devel/build.h>
33 #include <freeradius-devel/missing.h>
34 #include <freeradius-devel/util/time.h>
35 
36 #include <netinet/in.h>
37 #include <stddef.h>
38 #include <stdlib.h>
39 
40 int udpfromto_init(int s, int af);
41 
42 int recvfromto(int s, void *buf, size_t len, int flags,
43  int *ifindex,
44  struct sockaddr *from, socklen_t *fromlen,
45  struct sockaddr *to, socklen_t *tolen,
46  fr_time_t *when);
47 
48 int sendfromto(int s, void *buf, size_t len, int flags,
49  int ifindex,
50  struct sockaddr *from, socklen_t fromlen,
51  struct sockaddr *to, socklen_t tolen);
52 #ifdef __cplusplus
53 }
54 #endif
#define RCSIDH(h, id)
Definition: build.h:482
"server local" time.
Definition: time.h:69
int sendfromto(int s, void *buf, size_t len, int flags, int ifindex, struct sockaddr *from, socklen_t fromlen, struct sockaddr *to, socklen_t tolen)
Send packet via a file descriptor, setting the src address and outbound interface.
Definition: udpfromto.c:391
int udpfromto_init(int s, int af)
Definition: udpfromto.c:92
int recvfromto(int s, void *buf, size_t len, int flags, int *ifindex, struct sockaddr *from, socklen_t *fromlen, struct sockaddr *to, socklen_t *tolen, fr_time_t *when)
Read a packet from a file descriptor, retrieving additional header information.
Definition: udpfromto.c:191