The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Enumerations | Functions | Variables
radius.h File Reference
#include <freeradius-devel/radius/defs.h>
#include <freeradius-devel/util/packet.h>
#include <freeradius-devel/util/rand.h>
#include <freeradius-devel/util/log.h>
#include <freeradius-devel/util/dbuff.h>
+ Include dependency graph for radius.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fr_radius_ctx_t
 
struct  fr_radius_decode_ctx_t
 
struct  fr_radius_encode_ctx_t
 
struct  fr_radius_tag_ctx_t
 

Macros

#define AUTH_PASS_LEN   (RADIUS_AUTH_VECTOR_LENGTH)
 
#define flag_abinary(_flags)   (!(_flags)->extra && (_flags)->subtype == FLAG_ABINARY)
 
#define flag_concat(_flags)   (!(_flags)->extra && (_flags)->subtype == FLAG_CONCAT)
 
#define flag_encrypted(_flags)   (!(_flags)->extra && (_flags)->subtype >= FLAG_TAGGED_TUNNEL_PASSWORD)
 
#define flag_extended(_flags)   (!(_flags)->extra && (((_flags)->subtype == FLAG_EXTENDED_ATTR) || (_flags)->subtype == FLAG_LONG_EXTENDED_ATTR))
 
#define flag_has_tag(_flags)   (!(_flags)->extra && (((_flags)->subtype == FLAG_HAS_TAG) || ((_flags)->subtype == FLAG_TAGGED_TUNNEL_PASSWORD)))
 
#define flag_long_extended(_flags)   (!(_flags)->extra && (_flags)->subtype == FLAG_LONG_EXTENDED_ATTR)
 
#define flag_tunnel_password(_flags)   (!(_flags)->extra && (((_flags)->subtype == FLAG_ENCRYPT_TUNNEL_PASSWORD) || ((_flags)->subtype == FLAG_TAGGED_TUNNEL_PASSWORD)))
 
#define fr_packet_log_hex(_log, _packet)   _fr_packet_log_hex(_log, _packet, __FILE__, __LINE__)
 
#define FR_RADIUS_PACKET_CODE_VALID(_x)   ((_x > 0) && (_x < FR_RADIUS_CODE_MAX))
 
#define FR_TUNNEL_FR_ENC_LENGTH(_x)   (2 + 1 + _x + PAD(_x + 1, 16))
 
#define RADIUS_AUTH_VECTOR_LENGTH   16
 
#define RADIUS_AUTH_VECTOR_OFFSET   4
 
#define RADIUS_HEADER_LENGTH   20
 
#define RADIUS_MAX_ATTRIBUTES   255
 
#define RADIUS_MAX_PACKET_SIZE   4096
 
#define RADIUS_MAX_PASS_LENGTH   256
 
#define RADIUS_MAX_STRING_LENGTH   253
 
#define RADIUS_MAX_TUNNEL_PASSWORD_LENGTH   249
 
#define RADIUS_MESSAGE_AUTHENTICATOR_LENGTH   16
 
#define RADIUS_VENDORPEC_LUCENT   4846
 
#define RADIUS_VENDORPEC_STARENT   8164
 
#define RADIUS_VENDORPEC_USR   429
 

Enumerations

enum  {
  FLAG_NONE = 0 ,
  FLAG_EXTENDED_ATTR ,
  FLAG_LONG_EXTENDED_ATTR ,
  FLAG_CONCAT ,
  FLAG_HAS_TAG ,
  FLAG_ABINARY ,
  FLAG_TAGGED_TUNNEL_PASSWORD ,
  FLAG_ENCRYPT_USER_PASSWORD ,
  FLAG_ENCRYPT_TUNNEL_PASSWORD ,
  FLAG_ENCRYPT_ASCEND_SECRET
}
 subtype values for RADIUS More...
 
enum  decode_fail_t {
  DECODE_FAIL_NONE = 0 ,
  DECODE_FAIL_MIN_LENGTH_PACKET ,
  DECODE_FAIL_MIN_LENGTH_FIELD ,
  DECODE_FAIL_MIN_LENGTH_MISMATCH ,
  DECODE_FAIL_HEADER_OVERFLOW ,
  DECODE_FAIL_UNKNOWN_PACKET_CODE ,
  DECODE_FAIL_INVALID_ATTRIBUTE ,
  DECODE_FAIL_ATTRIBUTE_TOO_SHORT ,
  DECODE_FAIL_ATTRIBUTE_OVERFLOW ,
  DECODE_FAIL_MA_INVALID_LENGTH ,
  DECODE_FAIL_ATTRIBUTE_UNDERFLOW ,
  DECODE_FAIL_TOO_MANY_ATTRIBUTES ,
  DECODE_FAIL_MA_MISSING ,
  DECODE_FAIL_MA_INVALID ,
  DECODE_FAIL_UNKNOWN ,
  DECODE_FAIL_MAX
}
 

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_ma, 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_ma)
 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...
 
int fr_radius_allow_reply (int code, bool allowed[static FR_RADIUS_CODE_MAX])
 
ssize_t fr_radius_ascend_secret (fr_dbuff_t *dbuff, uint8_t const *in, size_t inlen, char const *secret, uint8_t const *vector)
 Do Ascend-Send / Recv-Secret calculation. More...
 
ssize_t fr_radius_decode (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t *packet, size_t packet_len, fr_radius_decode_ctx_t *decode_ctx)
 
ssize_t fr_radius_decode_abinary (fr_pair_t *vp, uint8_t const *data, size_t data_len)
 Print an Ascend binary filter attribute to a string,. More...
 
ssize_t fr_radius_decode_foreign (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len)
 
ssize_t fr_radius_decode_pair (TALLOC_CTX *ctx, fr_pair_list_t *list, uint8_t const *data, size_t data_len, fr_radius_decode_ctx_t *packet_ctx)
 Create a "normal" fr_pair_t from the given data. More...
 
ssize_t fr_radius_decode_pair_value (TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *parent, uint8_t const *data, size_t const attr_len, void *packet_ctx)
 Create any kind of VP from the attribute contents. More...
 
ssize_t fr_radius_decode_simple (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t *packet, size_t packet_len, uint8_t const *vector, char const *secret))
 Simple wrapper for callers who just need a shared secret. More...
 
ssize_t fr_radius_decode_tlv (TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, fr_radius_decode_ctx_t *packet_ctx)
 Convert TLVs to one or more VPs. More...
 
int fr_radius_decode_tlv_ok (uint8_t const *data, size_t length, size_t dv_type, size_t dv_length)
 Check if a set of RADIUS formatted TLVs are OK. More...
 
ssize_t fr_radius_encode (uint8_t *packet, size_t packet_len, uint8_t const *original, char const *secret, size_t secret_len, int code, int id, fr_pair_list_t *vps)
 Encode VPS into a raw RADIUS packet. More...
 
ssize_t fr_radius_encode_abinary (fr_pair_t const *vp, fr_dbuff_t *dbuff)
 Encode a string to abinary. More...
 
ssize_t fr_radius_encode_dbuff (fr_dbuff_t *dbuff, uint8_t const *original, char const *secret, UNUSED size_t secret_len, int code, int id, fr_pair_list_t *vps)
 
ssize_t fr_radius_encode_foreign (fr_dbuff_t *dbuff, fr_pair_list_t const *list)
 
ssize_t fr_radius_encode_pair (fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx)
 Encode a data structure into a RADIUS attribute. More...
 
void fr_radius_global_free (void)
 
int fr_radius_global_init (void)
 
bool fr_radius_ok (uint8_t const *packet, size_t *packet_len_p, uint32_t max_attributes, bool require_ma, decode_fail_t *reason))
 See if the data pointed to by PTR is a valid RADIUS 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)
 
ssize_t fr_radius_recv_header (int sockfd, fr_ipaddr_t *src_ipaddr, uint16_t *src_port, unsigned int *code)
 Basic validation of RADIUS packet header. More...
 
int fr_radius_sign (uint8_t *packet, uint8_t const *vector, uint8_t const *secret, size_t secret_len))
 Sign a previously encoded packet. More...
 
int fr_radius_verify (uint8_t *packet, uint8_t const *vector, uint8_t const *secret, size_t secret_len, bool require_ma))
 Verify a request / response packet. More...
 

Variables

char const * fr_radius_packet_name [FR_RADIUS_CODE_MAX]
 
fr_table_num_sorted_t const fr_radius_request_name_table []
 
size_t fr_radius_request_name_table_len
 

Data Structure Documentation

◆ fr_radius_ctx_t

struct fr_radius_ctx_t

Definition at line 110 of file radius.h.

Data Fields
uint32_t acct_delay_time additional time to add to acct_delay_time
bool add_proxy_state do we add a Proxy-State?
uint64_t my_proxy_state if so, this is its value
char const * secret
size_t secret_length
uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH] vector for authenticating the reply

◆ fr_radius_decode_ctx_t

struct fr_radius_decode_ctx_t

Definition at line 136 of file radius.h.

+ Collaboration diagram for fr_radius_decode_ctx_t:
Data Fields
fr_radius_ctx_t * common
uint8_t const * end end of the packet
uint8_t const * request_authenticator
uint8_t request_code original code for the request.
bool require_message_authenticator
fr_pair_list_t * tag_root Where to insert tag attributes.
TALLOC_CTX * tag_root_ctx Where to allocate new tag attributes.
fr_radius_tag_ctx_t ** tags for decoding tagged attributes
TALLOC_CTX * tmp_ctx for temporary things cleaned up during decoding
bool tunnel_password_zeros check for trailing zeros on decode
bool verify can skip verify for dynamic clients

◆ fr_radius_encode_ctx_t

struct fr_radius_encode_ctx_t

Definition at line 122 of file radius.h.

+ Collaboration diagram for fr_radius_encode_ctx_t:
Data Fields
fr_radius_ctx_t * common
bool disallow_tunnel_passwords not all packets can have tunnel passwords
fr_fast_rand_t rand_ctx for tunnel passwords
uint8_t const * request_authenticator
int salt_offset for tunnel passwords
bool seen_message_authenticator
uint8_t tag current tag for encoding

◆ fr_radius_tag_ctx_t

struct fr_radius_tag_ctx_t

Definition at line 105 of file radius.h.

+ Collaboration diagram for fr_radius_tag_ctx_t:
Data Fields
fr_dcursor_t cursor
fr_pair_t * parent

Macro Definition Documentation

◆ AUTH_PASS_LEN

#define AUTH_PASS_LEN   (RADIUS_AUTH_VECTOR_LENGTH)

Definition at line 53 of file radius.h.

◆ flag_abinary

#define flag_abinary (   _flags)    (!(_flags)->extra && (_flags)->subtype == FLAG_ABINARY)

Definition at line 99 of file radius.h.

◆ flag_concat

#define flag_concat (   _flags)    (!(_flags)->extra && (_flags)->subtype == FLAG_CONCAT)

Definition at line 98 of file radius.h.

◆ flag_encrypted

#define flag_encrypted (   _flags)    (!(_flags)->extra && (_flags)->subtype >= FLAG_TAGGED_TUNNEL_PASSWORD)

Definition at line 100 of file radius.h.

◆ flag_extended

#define flag_extended (   _flags)    (!(_flags)->extra && (((_flags)->subtype == FLAG_EXTENDED_ATTR) || (_flags)->subtype == FLAG_LONG_EXTENDED_ATTR))

Definition at line 101 of file radius.h.

◆ flag_has_tag

#define flag_has_tag (   _flags)    (!(_flags)->extra && (((_flags)->subtype == FLAG_HAS_TAG) || ((_flags)->subtype == FLAG_TAGGED_TUNNEL_PASSWORD)))

Definition at line 97 of file radius.h.

◆ flag_long_extended

#define flag_long_extended (   _flags)    (!(_flags)->extra && (_flags)->subtype == FLAG_LONG_EXTENDED_ATTR)

Definition at line 102 of file radius.h.

◆ flag_tunnel_password

#define flag_tunnel_password (   _flags)    (!(_flags)->extra && (((_flags)->subtype == FLAG_ENCRYPT_TUNNEL_PASSWORD) || ((_flags)->subtype == FLAG_TAGGED_TUNNEL_PASSWORD)))

Definition at line 103 of file radius.h.

◆ fr_packet_log_hex

#define fr_packet_log_hex (   _log,
  _packet 
)    _fr_packet_log_hex(_log, _packet, __FILE__, __LINE__)

Definition at line 209 of file radius.h.

◆ FR_RADIUS_PACKET_CODE_VALID

#define FR_RADIUS_PACKET_CODE_VALID (   _x)    ((_x > 0) && (_x < FR_RADIUS_CODE_MAX))

Definition at line 51 of file radius.h.

◆ FR_TUNNEL_FR_ENC_LENGTH

#define FR_TUNNEL_FR_ENC_LENGTH (   _x)    (2 + 1 + _x + PAD(_x + 1, 16))

Definition at line 55 of file radius.h.

◆ RADIUS_AUTH_VECTOR_LENGTH

#define RADIUS_AUTH_VECTOR_LENGTH   16

Definition at line 36 of file radius.h.

◆ RADIUS_AUTH_VECTOR_OFFSET

#define RADIUS_AUTH_VECTOR_OFFSET   4

Definition at line 32 of file radius.h.

◆ RADIUS_HEADER_LENGTH

#define RADIUS_HEADER_LENGTH   20

Definition at line 33 of file radius.h.

◆ RADIUS_MAX_ATTRIBUTES

#define RADIUS_MAX_ATTRIBUTES   255

Definition at line 39 of file radius.h.

◆ RADIUS_MAX_PACKET_SIZE

#define RADIUS_MAX_PACKET_SIZE   4096

Definition at line 40 of file radius.h.

◆ RADIUS_MAX_PASS_LENGTH

#define RADIUS_MAX_PASS_LENGTH   256

Definition at line 38 of file radius.h.

◆ RADIUS_MAX_STRING_LENGTH

#define RADIUS_MAX_STRING_LENGTH   253

Definition at line 34 of file radius.h.

◆ RADIUS_MAX_TUNNEL_PASSWORD_LENGTH

#define RADIUS_MAX_TUNNEL_PASSWORD_LENGTH   249

Definition at line 35 of file radius.h.

◆ RADIUS_MESSAGE_AUTHENTICATOR_LENGTH

#define RADIUS_MESSAGE_AUTHENTICATOR_LENGTH   16

Definition at line 37 of file radius.h.

◆ RADIUS_VENDORPEC_LUCENT

#define RADIUS_VENDORPEC_LUCENT   4846

Definition at line 43 of file radius.h.

◆ RADIUS_VENDORPEC_STARENT

#define RADIUS_VENDORPEC_STARENT   8164

Definition at line 44 of file radius.h.

◆ RADIUS_VENDORPEC_USR

#define RADIUS_VENDORPEC_USR   429

Definition at line 42 of file radius.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

subtype values for RADIUS

Order of the flags is important for the flag_foo() checks.

Enumerator
FLAG_NONE 

No extra flags.

FLAG_EXTENDED_ATTR 

the attribute is an extended attribute

FLAG_LONG_EXTENDED_ATTR 

the attribute is a long extended attribute

FLAG_CONCAT 

the attribute is concatenated

FLAG_HAS_TAG 

the attribute has a tag

FLAG_ABINARY 

the attribute is in "abinary" format

FLAG_TAGGED_TUNNEL_PASSWORD 

the attribute has a tag and is encrypted

FLAG_ENCRYPT_USER_PASSWORD 

Encrypt attribute RFC 2865 style.

FLAG_ENCRYPT_TUNNEL_PASSWORD 

Encrypt attribute RFC 2868 style.

FLAG_ENCRYPT_ASCEND_SECRET 

Encrypt attribute ascend style.

Definition at line 82 of file radius.h.

◆ decode_fail_t

Enumerator
DECODE_FAIL_NONE 
DECODE_FAIL_MIN_LENGTH_PACKET 
DECODE_FAIL_MIN_LENGTH_FIELD 
DECODE_FAIL_MIN_LENGTH_MISMATCH 
DECODE_FAIL_HEADER_OVERFLOW 
DECODE_FAIL_UNKNOWN_PACKET_CODE 
DECODE_FAIL_INVALID_ATTRIBUTE 
DECODE_FAIL_ATTRIBUTE_TOO_SHORT 
DECODE_FAIL_ATTRIBUTE_OVERFLOW 
DECODE_FAIL_MA_INVALID_LENGTH 
DECODE_FAIL_ATTRIBUTE_UNDERFLOW 
DECODE_FAIL_TOO_MANY_ATTRIBUTES 
DECODE_FAIL_MA_MISSING 
DECODE_FAIL_MA_INVALID 
DECODE_FAIL_UNKNOWN 
DECODE_FAIL_MAX 

Definition at line 59 of file radius.h.

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 355 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_ma,
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_mato 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 115 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_ma 
)

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

Definition at line 211 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 297 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 160 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 139 of file packet.c.

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

◆ fr_radius_allow_reply()

int fr_radius_allow_reply ( int  code,
bool  allowed[static FR_RADIUS_CODE_MAX] 
)

Definition at line 170 of file base.c.

+ Here is the caller graph for this function:

◆ fr_radius_ascend_secret()

ssize_t fr_radius_ascend_secret ( fr_dbuff_t dbuff,
uint8_t const *  in,
size_t  inlen,
char const *  secret,
uint8_t const *  vector 
)

Do Ascend-Send / Recv-Secret calculation.

The secret is hidden by xoring with a MD5 digest created from the RADIUS shared secret and the authentication vector. We put them into MD5 in the reverse order from that used when encrypting passwords to RADIUS.

Definition at line 190 of file base.c.

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

◆ fr_radius_decode()

ssize_t fr_radius_decode ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
uint8_t packet,
size_t  packet_len,
fr_radius_decode_ctx_t decode_ctx 
)

Definition at line 997 of file base.c.

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

◆ fr_radius_decode_abinary()

ssize_t fr_radius_decode_abinary ( fr_pair_t vp,
uint8_t const *  data,
size_t  data_len 
)

Print an Ascend binary filter attribute to a string,.

Grrr... Ascend makes the server do this work, instead of doing it on the NAS.

Parameters
[in,out]vpWhere the decoded string will be stored.
[in]databinary data to decodee
[in]data_lenlength of the binary data to decodee
Returns
  • 0 OK
  • <0 on error. VP is untouched.

Definition at line 1322 of file abinary.c.

+ Here is the call graph for this function:

◆ fr_radius_decode_foreign()

ssize_t fr_radius_decode_foreign ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
uint8_t const *  data,
size_t  data_len 
)

Definition at line 2087 of file decode.c.

+ Here is the call graph for this function:

◆ fr_radius_decode_pair()

ssize_t fr_radius_decode_pair ( TALLOC_CTX *  ctx,
fr_pair_list_t list,
uint8_t const *  data,
size_t  data_len,
fr_radius_decode_ctx_t packet_ctx 
)

Create a "normal" fr_pair_t from the given data.

Definition at line 1982 of file decode.c.

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

◆ fr_radius_decode_pair_value()

ssize_t fr_radius_decode_pair_value ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t const  attr_len,
void *  decode_ctx 
)

Create any kind of VP from the attribute contents.

"length" is AT LEAST the length of this attribute, as we expect the caller to have verified the data with fr_packet_ok(). "length" may be up to the length of the packet.

This function will ONLY return -1 on programmer error or OOM. If there's anything wrong with the attribute, it will ALWAYS create a "raw" attribute.

Returns
  • Length on success.
  • -1 on failure.

Definition at line 1475 of file decode.c.

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

◆ fr_radius_decode_simple()

ssize_t fr_radius_decode_simple ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
uint8_t packet,
size_t  packet_len,
uint8_t const *  vector,
char const *  secret 
)

Simple wrapper for callers who just need a shared secret.

Definition at line 1097 of file base.c.

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

◆ fr_radius_decode_tlv()

ssize_t fr_radius_decode_tlv ( TALLOC_CTX *  ctx,
fr_pair_list_t list,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t  data_len,
fr_radius_decode_ctx_t packet_ctx 
)

Convert TLVs to one or more VPs.

Definition at line 647 of file decode.c.

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

◆ fr_radius_decode_tlv_ok()

int fr_radius_decode_tlv_ok ( uint8_t const *  data,
size_t  length,
size_t  dv_type,
size_t  dv_length 
)

Check if a set of RADIUS formatted TLVs are OK.

Definition at line 250 of file decode.c.

+ Here is the caller graph for this function:

◆ fr_radius_encode()

ssize_t fr_radius_encode ( uint8_t packet,
size_t  packet_len,
uint8_t const *  original,
char const *  secret,
size_t  secret_len,
int  code,
int  id,
fr_pair_list_t vps 
)

Encode VPS into a raw RADIUS packet.

Definition at line 860 of file base.c.

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

◆ fr_radius_encode_abinary()

ssize_t fr_radius_encode_abinary ( fr_pair_t const *  vp,
fr_dbuff_t dbuff 
)

Encode a string to abinary.

This routine will call routines to parse entries from an ASCII format to a binary format recognized by the Ascend boxes.

Parameters
vpVP to encode
dbuffwhere to write the VP data
Returns
  • >0 on success == size of the data encoded
  • <=0 on failure, which is the size needed to encode the data

Definition at line 1198 of file abinary.c.

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

◆ fr_radius_encode_dbuff()

ssize_t fr_radius_encode_dbuff ( fr_dbuff_t dbuff,
uint8_t const *  original,
char const *  secret,
UNUSED size_t  secret_len,
int  code,
int  id,
fr_pair_list_t vps 
)

◆ fr_radius_encode_foreign()

ssize_t fr_radius_encode_foreign ( fr_dbuff_t dbuff,
fr_pair_list_t const *  list 
)

Definition at line 1663 of file encode.c.

+ Here is the call graph for this function:

◆ fr_radius_encode_pair()

ssize_t fr_radius_encode_pair ( fr_dbuff_t dbuff,
fr_dcursor_t cursor,
void *  encode_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 nesting and then calls the appropriate dispatch function.

Parameters
[out]dbuffWhere to write encoded data.
[in]cursorSpecifying attribute to encode.
[in]encode_ctxAdditional data such as the shared secret to use.
Returns
  • >0 The number of bytes written to out.
  • 0 Nothing to encode (or attribute skipped).
  • <0 an error occurred.

Definition at line 1498 of file encode.c.

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

◆ fr_radius_global_free()

void fr_radius_global_free ( void  )

Definition at line 1142 of file base.c.

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

◆ fr_radius_global_init()

int fr_radius_global_init ( void  )

Definition at line 1119 of file base.c.

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

◆ fr_radius_ok()

bool fr_radius_ok ( uint8_t const *  packet,
size_t packet_len_p,
uint32_t  max_attributes,
bool  require_ma,
decode_fail_t reason 
)

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

Parameters
[in]packetto check.
[in,out]packet_len_pThe size of the packet data.
[in]max_attributesto allow in the packet.
[in]require_mawhether we require Message-Authenticator.
[in]reasonif not NULL, will have the failure reason written to where it points.
Returns
  • True on success.
  • False on failure.

Definition at line 259 of file merged_model.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 426 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 497 of file packet.c.

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

◆ fr_radius_recv_header()

ssize_t fr_radius_recv_header ( int  sockfd,
fr_ipaddr_t src_ipaddr,
uint16_t src_port,
unsigned int *  code 
)

Basic validation of RADIUS packet header.

Note
fr_strerror errors are only available if fr_debug_lvl > 0. This is to reduce CPU time consumed when discarding malformed packet.
Parameters
[in]sockfdwe're reading from.
[out]src_ipaddrof the packet.
[out]src_portof the packet.
[out]codePointer to where to write the packet code.
Returns
  • -1 on failure.
  • 1 on decode error.
  • >= RADIUS_HEADER_LENGTH on success. This is the packet length as specified in the header.

Definition at line 228 of file base.c.

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

◆ fr_radius_sign()

int fr_radius_sign ( uint8_t packet,
uint8_t const *  vector,
uint8_t const *  secret,
size_t  secret_len 
)

Sign a previously encoded packet.

Calculates the request/response authenticator for packets which need it, and fills in the message-authenticator value if the attribute is present in the encoded packet.

Parameters
[in,out]packet(request or response).
[in]vectororiginal packet vector to use
[in]secretto sign the packet with.
[in]secret_lenThe length of the secret.
Returns
  • <0 on error
  • 0 on success

Definition at line 301 of file base.c.

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

◆ fr_radius_verify()

int fr_radius_verify ( uint8_t packet,
uint8_t const *  vector,
uint8_t const *  secret,
size_t  secret_len,
bool  require_ma 
)

Verify a request / response packet.

This function does its work by calling fr_radius_sign(), and then comparing the signature in the packet with the one we calculated. If they differ, there's a problem.

Parameters
[in]packetthe raw RADIUS packet (request or response)
[in]vectorthe original packet vector
[in]secretthe shared secret
[in]secret_lenthe length of the secret
[in]require_mawhether we require Message-Authenticator.
Returns
  • -2 if the message authenticator or request authenticator was invalid.
  • -1 if we were unable to verify the shared secret, or the packet was in some other way malformed.
  • 0 on success.

Definition at line 719 of file base.c.

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

Variable Documentation

◆ fr_radius_packet_name

char const* fr_radius_packet_name[FR_RADIUS_CODE_MAX]
extern

Definition at line 94 of file base.c.

◆ fr_radius_request_name_table

fr_table_num_sorted_t const fr_radius_request_name_table[]
extern

Definition at line 83 of file base.c.

◆ fr_radius_request_name_table_len

size_t fr_radius_request_name_table_len
extern

Definition at line 92 of file base.c.