All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
radius_encode.c File Reference
#include <freeradius-devel/libradius.h>
#include <freeradius-devel/md5.h>
+ Include dependency graph for radius_encode.c:

Go to the source code of this file.

Functions

static ssize_t attr_shift (uint8_t const *start, uint8_t const *end, uint8_t *ptr, int hdr_len, ssize_t len, int flag_offset, int vsa_offset)
 
static ssize_t encode_concat (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, UNUSED void *encoder_ctx)
 Encode an RFC format attribute, with the "concat" flag set. More...
 
static int encode_extended_hdr (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, void *encoder_ctx)
 Encode an "extended" attribute. More...
 
static void encode_password (uint8_t *out, ssize_t *outlen, uint8_t const *input, size_t inlen, char const *secret, uint8_t const *vector)
 
static int encode_rfc_hdr (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, void *encoder_ctx)
 Encode an RFC standard attribute 1..255. More...
 
static ssize_t encode_rfc_hdr_internal (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, void *encoder_ctx)
 Encode an RFC format TLV. More...
 
static ssize_t encode_tlv_hdr (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, void *encoder_ctx)
 
static ssize_t encode_tlv_hdr_internal (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, void *encoder_ctx)
 
static void encode_tunnel_password (uint8_t *out, ssize_t *outlen, uint8_t const *input, size_t inlen, size_t freespace, char const *secret, uint8_t const *vector)
 
static ssize_t encode_value (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, int depth, vp_cursor_t *cursor, void *encoder_ctx)
 Encodes the data portion of an attribute. More...
 
static ssize_t encode_vendor_attr_hdr (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, void *encoder_ctx)
 Encode a VSA which is a TLV. More...
 
static int encode_vsa_hdr (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, void *encoder_ctx)
 Encode a Vendor-Specific attribute. More...
 
static int encode_wimax_hdr (uint8_t *out, size_t outlen, fr_dict_attr_t const **tlv_stack, unsigned int depth, vp_cursor_t *cursor, void *encoder_ctx)
 Encode a WiMAX attribute. More...
 
int fr_radius_encode_pair (uint8_t *out, size_t outlen, vp_cursor_t *cursor, void *encoder_ctx)
 Encode a data structure into a RADIUS attribute. More...
 
int fr_radius_encode_password (char *passwd, size_t *pwlen, char const *secret, uint8_t const *vector)
 Encode password. More...
 
int fr_radius_encode_tunnel_password (char *passwd, size_t *pwlen, char const *secret, uint8_t const *vector)
 Encode Tunnel-Password attributes when sending them out on the wire. More...
 
ssize_t fr_radius_encode_value_hton (uint8_t const **out, VALUE_PAIR const *vp)
 Converts vp_data to network byte order. More...
 
 fr_thread_local_setup (uint8_t *, fr_radius_encode_value_hton_buff)
 

Variables

static unsigned int salt_offset = 0
 

Function Documentation

static ssize_t attr_shift ( uint8_t const *  start,
uint8_t const *  end,
uint8_t *  ptr,
int  hdr_len,
ssize_t  len,
int  flag_offset,
int  vsa_offset 
)
static

Definition at line 830 of file radius_encode.c.

+ Here is the caller graph for this function:

static ssize_t encode_concat ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
UNUSED void *  encoder_ctx 
)
static

Encode an RFC format attribute, with the "concat" flag set.

If there isn't enough freespace in the packet, the data is truncated to fit.

Definition at line 1015 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int encode_extended_hdr ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Encode an "extended" attribute.

Definition at line 888 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void encode_password ( uint8_t *  out,
ssize_t *  outlen,
uint8_t const *  input,
size_t  inlen,
char const *  secret,
uint8_t const *  vector 
)
static

Definition at line 244 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int encode_rfc_hdr ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Encode an RFC standard attribute 1..255.

Definition at line 1417 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ssize_t encode_rfc_hdr_internal ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Encode an RFC format TLV.

This could be a standard attribute, or a TLV data type. If it's a standard attribute, then vp->da->attr == attribute. Otherwise, attribute may be something else.

Definition at line 1075 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ssize_t encode_tlv_hdr ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Definition at line 555 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ssize_t encode_tlv_hdr_internal ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Definition at line 509 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void encode_tunnel_password ( uint8_t *  out,
ssize_t *  outlen,
uint8_t const *  input,
size_t  inlen,
size_t  freespace,
char const *  secret,
uint8_t const *  vector 
)
static

Definition at line 293 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ssize_t encode_value ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Encodes the data portion of an attribute.

Returns
  • Length of the data portion.
  • -1 on failure.

Definition at line 598 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ssize_t encode_vendor_attr_hdr ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Encode a VSA which is a TLV.

If it's in the RFC format, call encode_rfc_hdr_internal. Otherwise, encode it here.

Definition at line 1126 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int encode_vsa_hdr ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Encode a Vendor-Specific attribute.

Definition at line 1348 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int encode_wimax_hdr ( uint8_t *  out,
size_t  outlen,
fr_dict_attr_t const **  tlv_stack,
unsigned int  depth,
vp_cursor_t cursor,
void *  encoder_ctx 
)
static

Encode a WiMAX attribute.

Definition at line 1260 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_radius_encode_pair ( uint8_t *  out,
size_t  outlen,
vp_cursor_t cursor,
void *  encoder_ctx 
)

Encode a data structure into a RADIUS attribute.

This is the main entry point into the encoder. It sets up the encoder array we use for tracking our TLV/VSA/EVS nesting and then calls the appropriate dispatch function.

Definition at line 1488 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_radius_encode_password ( char *  passwd,
size_t *  pwlen,
char const *  secret,
uint8_t const *  vector 
)

Encode password.

We assume that the passwd buffer passed is big enough. RFC2138 says the password is max 128 chars, so the size of the passwd buffer must be at least 129 characters. Preferably it's just MAX_STRING_LEN.

int *pwlen is updated to the new length of the encrypted password - a multiple of 16 bytes.

Definition at line 187 of file radius_encode.c.

+ Here is the call graph for this function:

int fr_radius_encode_tunnel_password ( char *  passwd,
size_t *  pwlen,
char const *  secret,
uint8_t const *  vector 
)

Encode Tunnel-Password attributes when sending them out on the wire.

int *pwlen is updated to the new length of the encrypted password - a multiple of 16 bytes.

This is per RFC-2868 which adds a two char SALT to the initial intermediate value MD5 hash.

Definition at line 106 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssize_t fr_radius_encode_value_hton ( uint8_t const **  out,
VALUE_PAIR const *  vp 
)

Converts vp_data to network byte order.

Provide a pointer to a buffer which contains the value of the VALUE_PAIR in an architecture independent format.

The pointer is only guaranteed to be valid between calls to fr_radius_encode_value_hton, and so long as the source VALUE_PAIR is not freed.

Parameters
outwhere to write the pointer to the value.
vpto get the value from.
Returns
  • The length of the value.
  • -1 on failure.

Definition at line 396 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_thread_local_setup ( uint8_t *  ,
fr_radius_encode_value_hton_buff   
)

Definition at line 31 of file radius_encode.c.

+ Here is the call graph for this function:

Variable Documentation

unsigned int salt_offset = 0
static

Definition at line 29 of file radius_encode.c.