The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions
udp.c File Reference

Utility functions for managing UDP sockets. More...

#include <freeradius-devel/util/log.h>
#include <freeradius-devel/util/socket.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/udp.h>
+ Include dependency graph for udp.c:

Go to the source code of this file.

Macros

#define FR_DEBUG_STRERROR_PRINTF   if (fr_debug_lvl) fr_strerror_printf
 

Functions

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. More...
 
int udp_recv_discard (int sockfd)
 Discard the next UDP packet. More...
 
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. More...
 
int udp_send (fr_socket_t const *sock, int flags, void *data, size_t data_len)
 Send a packet via a UDP socket. More...
 

Detailed Description

Utility functions for managing UDP sockets.

Definition in file udp.c.

Macro Definition Documentation

◆ FR_DEBUG_STRERROR_PRINTF

#define FR_DEBUG_STRERROR_PRINTF   if (fr_debug_lvl) fr_strerror_printf

Definition at line 31 of file udp.c.

Function Documentation

◆ udp_recv()

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.

Parameters
[in]sockfdwe're reading from.
[in]flagsfor things
[out]socket_outInformation about the src/dst address of the packet and the interface it was received on.
[out]datapointer where data will be written
[in]data_lenlength of data to read
[out]whenthe packet was received.
Returns
  • > 0 on success (number of bytes read).
  • < 0 on failure.

Definition at line 145 of file udp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ udp_recv_discard()

int udp_recv_discard ( int  sockfd)

Discard the next UDP packet.

Parameters
[in]sockfdwe're reading from.

Definition at line 76 of file udp.c.

+ Here is the caller graph for this function:

◆ udp_recv_peek()

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.

Parameters
[in]sockfdwe're reading from.
[out]datapointer where data will be written
[in]data_lenlength of data to read
[in]flagsfor things
[out]src_ipaddrof the packet.
[out]src_portof the packet.

Definition at line 96 of file udp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ udp_send()

int udp_send ( fr_socket_t const *  sock,
int  flags,
void *  data,
size_t  data_len 
)

Send a packet via a UDP socket.

Parameters
[in]sockwe're reading from.
[in]flagsto pass to send(), or sendto()
[in]datato data to send
[in]data_lenlength of data to send
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 43 of file udp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: