The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
API for sending and receiving packets on unconnected UDP sockets. More...
#include <freeradius-devel/util/udpfromto.h>
#include <fcntl.h>
Go to the source code of this file.
Macros | |
#define | SOL_IP IPPROTO_IP |
Functions | |
int | recvfromto (int fd, void *buf, size_t len, int flags, int *ifindex, struct sockaddr *from, socklen_t *from_len, struct sockaddr *to, socklen_t *to_len, fr_time_t *when) |
Read a packet from a file descriptor, retrieving additional header information. More... | |
int | sendfromto (int fd, void *buf, size_t len, int flags, int ifindex, struct sockaddr *from, socklen_t from_len, struct sockaddr *to, socklen_t to_len) |
Send packet via a file descriptor, setting the src address and outbound interface. More... | |
int | udpfromto_init (int s, int af) |
API for sending and receiving packets on unconnected UDP sockets.
Like recvfrom, but also stores the destination IP address. Useful on multihomed hosts.
Definition in file udpfromto.c.
#define SOL_IP IPPROTO_IP |
Definition at line 41 of file udpfromto.c.
int recvfromto | ( | int | fd, |
void * | buf, | ||
size_t | len, | ||
int | flags, | ||
int * | ifindex, | ||
struct sockaddr * | from, | ||
socklen_t * | from_len, | ||
struct sockaddr * | to, | ||
socklen_t * | to_len, | ||
fr_time_t * | when | ||
) |
Read a packet from a file descriptor, retrieving additional header information.
Abstracts away the complexity of using the complexity of using recvmsg().
In addition to reading data from the file descriptor, the src and dst addresses and the receiving interface index are retrieved. This enables us to send replies using the correct IP interface, in the case where the server is multihomed. This is not normally possible on unconnected datagram sockets.
[in] | fd | The file descriptor to read from. |
[out] | buf | Where to write the received datagram data. |
[in] | len | of buf. |
[in] | flags | passed unmolested to recvmsg. |
[out] | ifindex | The interface which received the datagram (may be NULL). Will only be populated if to is not NULL. |
[out] | from | Where to write the source address. |
[in] | from_len | Length of the structure pointed to by from. |
[out] | to | Where to write the destination address. If NULL recvmsg() will be used instead. |
[in] | to_len | Length of the structure pointed to by to. |
[out] | when | the packet was received (may be NULL). If SO_TIMESTAMP is not available or SO_TIMESTAMP Was not set on the socket, then another method will be used instead to get the time. |
Definition at line 191 of file udpfromto.c.
int sendfromto | ( | int | fd, |
void * | buf, | ||
size_t | len, | ||
int | flags, | ||
int | ifindex, | ||
struct sockaddr * | from, | ||
socklen_t | from_len, | ||
struct sockaddr * | to, | ||
socklen_t | to_len | ||
) |
Send packet via a file descriptor, setting the src address and outbound interface.
Abstracts away the complexity of using the complexity of using sendmsg().
[in] | fd | The file descriptor to write to. |
[in] | buf | Where to read datagram data from. |
[in] | len | of datagram data. |
[in] | flags | passed unmolested to sendmsg. |
[in] | ifindex | The interface on which to send the datagram. If automatic interface selection is desired, value should be 0. |
[in] | from | The source address. |
[in] | from_len | Length of the structure pointed to by from. |
[in] | to | The destination address. |
[in] | to_len | Length of the structure pointed to by to. |
Definition at line 391 of file udpfromto.c.
int udpfromto_init | ( | int | s, |
int | af | ||
) |
Definition at line 92 of file udpfromto.c.