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

Utility functions for managing UDP sockets. More...

#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/inet.h>
#include <freeradius-devel/util/socket.h>
#include <freeradius-devel/util/time.h>
#include <freeradius-devel/util/udpfromto.h>
+ Include dependency graph for udp.h:

Go to the source code of this file.

Macros

#define UDP_FLAGS_CONNECTED   (1 << 0)
 
#define UDP_FLAGS_NONE   (0)
 
#define UDP_FLAGS_PEEK   (1 << 1)
 

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 *socket, 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.h.

Macro Definition Documentation

◆ UDP_FLAGS_CONNECTED

#define UDP_FLAGS_CONNECTED   (1 << 0)

Definition at line 38 of file udp.h.

◆ UDP_FLAGS_NONE

#define UDP_FLAGS_NONE   (0)

Definition at line 37 of file udp.h.

◆ UDP_FLAGS_PEEK

#define UDP_FLAGS_PEEK   (1 << 1)

Definition at line 39 of file udp.h.

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: