The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions
packet.c File Reference

Functions to deal with fr_packet_t data structures. More...

#include "attrs.h"
#include <freeradius-devel/util/udp.h>
#include <freeradius-devel/util/syserror.h>
#include <fcntl.h>
+ Include dependency graph for packet.c:

Go to the source code of this file.

Data Structures

struct  radius_packet_t
 

Macros

#define FR_DEBUG_STRERROR_PRINTF   if (fr_debug_lvl) fr_strerror_printf_push
 

Functions

void _fr_packet_log_hex (fr_log_t const *log, fr_packet_t const *packet, char const *file, int line)
 
ssize_t fr_packet_encode (fr_packet_t *packet, fr_pair_list_t *list, fr_packet_t const *original, char const *secret)
 Encode a packet. More...
 
bool fr_packet_ok (fr_packet_t *packet, uint32_t max_attributes, bool require_message_authenticator, decode_fail_t *reason)
 See if the data pointed to by PTR is a valid RADIUS packet. More...
 
fr_packet_tfr_packet_recv (TALLOC_CTX *ctx, int fd, int flags, uint32_t max_attributes, bool require_message_authenticator)
 Receive UDP client requests, and fill in the basics of a fr_packet_t structure. More...
 
int fr_packet_send (fr_packet_t *packet, fr_pair_list_t *list, fr_packet_t const *original, char const *secret)
 Reply to the request. More...
 
int fr_packet_sign (fr_packet_t *packet, fr_packet_t const *original, char const *secret)
 Sign a previously encoded packet. More...
 
int fr_packet_verify (fr_packet_t *packet, fr_packet_t *original, char const *secret)
 Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet. More...
 
void fr_radius_packet_header_log (fr_log_t const *log, fr_packet_t *packet, bool received)
 
void fr_radius_packet_log (fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received)
 
static ssize_t rad_recvfrom (int sockfd, fr_packet_t *packet, int flags)
 Wrapper for recvfrom, which handles recvfromto, IPv6, and all possible combinations. More...
 

Detailed Description

Functions to deal with fr_packet_t data structures.

TCP-specific functions.

Id
5d69f394d3e3626a9eca0f076e1a75e3be725ec1
Id
c8ca250f513459c54fa7978f6e18c21d3b328173

Definition in file packet.c.


Data Structure Documentation

◆ radius_packet_t

struct radius_packet_t

Definition at line 100 of file radsniff.h.

Data Fields
uint8_t code
uint8_t data[]
uint8_t id
uint8_t length[2]
uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH]

Macro Definition Documentation

◆ FR_DEBUG_STRERROR_PRINTF

#define FR_DEBUG_STRERROR_PRINTF   if (fr_debug_lvl) fr_strerror_printf_push

Definition at line 46 of file packet.c.

Function Documentation

◆ _fr_packet_log_hex()

void _fr_packet_log_hex ( fr_log_t const *  log,
fr_packet_t const *  packet,
char const *  file,
int  line 
)

Definition at line 349 of file packet.c.

+ Here is the call graph for this function:

◆ fr_packet_encode()

ssize_t fr_packet_encode ( fr_packet_t packet,
fr_pair_list_t list,
fr_packet_t const *  original,
char const *  secret 
)

Encode a packet.

Definition at line 52 of file packet.c.

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

◆ fr_packet_ok()

bool fr_packet_ok ( fr_packet_t packet,
uint32_t  max_attributes,
bool  require_message_authenticator,
decode_fail_t reason 
)

See if the data pointed to by PTR is a valid RADIUS packet.

Packet is not 'const * const' because we may update data_len, if there's more data in the UDP packet than in the RADIUS packet.

Parameters
[in]packetto check.
[in]max_attributesto decode.
[in]require_message_authenticatorto require Message-Authenticator.
[out]reasonif not NULL, will have the failure reason written to where it points.
Returns
  • True on success.
  • False on failure.

Definition at line 119 of file packet.c.

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

◆ fr_packet_recv()

fr_packet_t* fr_packet_recv ( TALLOC_CTX *  ctx,
int  fd,
int  flags,
uint32_t  max_attributes,
bool  require_message_authenticator 
)

Receive UDP client requests, and fill in the basics of a fr_packet_t structure.

Definition at line 205 of file packet.c.

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

◆ fr_packet_send()

int fr_packet_send ( fr_packet_t packet,
fr_pair_list_t list,
fr_packet_t const *  original,
char const *  secret 
)

Reply to the request.

Also attach reply attribute value pairs and any user message provided.

Definition at line 291 of file packet.c.

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

◆ fr_packet_sign()

int fr_packet_sign ( fr_packet_t packet,
fr_packet_t const *  original,
char const *  secret 
)

Sign a previously encoded packet.

Definition at line 164 of file packet.c.

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

◆ fr_packet_verify()

int fr_packet_verify ( fr_packet_t packet,
fr_packet_t original,
char const *  secret 
)

Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet.

Definition at line 143 of file packet.c.

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

◆ fr_radius_packet_header_log()

void fr_radius_packet_header_log ( fr_log_t const *  log,
fr_packet_t packet,
bool  received 
)

Definition at line 420 of file packet.c.

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

◆ fr_radius_packet_log()

void fr_radius_packet_log ( fr_log_t const *  log,
fr_packet_t packet,
fr_pair_list_t list,
bool  received 
)

Definition at line 491 of file packet.c.

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

◆ rad_recvfrom()

static ssize_t rad_recvfrom ( int  sockfd,
fr_packet_t packet,
int  flags 
)
static

Wrapper for recvfrom, which handles recvfromto, IPv6, and all possible combinations.

Definition at line 181 of file packet.c.

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