The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Typedefs
pair.h File Reference

Encoder/decoder library interface. More...

#include <freeradius-devel/util/dcursor.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/pair.h>
+ Include dependency graph for pair.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef ssize_t(* fr_pair_decode_t) (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
 A generic interface for decoding fr_pair_ts. More...
 
typedef ssize_t(* fr_pair_encode_t) (fr_dbuff_t *out, fr_dcursor_t *cursor, void *encode_ctx)
 Generic interface for encoding one or more fr_pair_ts. More...
 

Encoder errors

#define PAIR_ENCODE_FATAL_ERROR   SSIZE_MIN
 Fatal encoding error. More...
 

Decode errors

static ssize_t fr_pair_decode_slen (ssize_t slen, uint8_t const *start, uint8_t const *p)
 Return the correct adjusted slen for errors. More...
 
#define FR_PAIR_ENCODE_HAVE_SPACE(_p, _end, _num)   if (((_p) + (_num)) > (_end)) return (_end) - ((_p) + (_num));
 Checks if we have sufficient buffer space, and returns how much space we'd need as a negative integer. More...
 
static bool fr_pair_encode_is_error (ssize_t slen)
 Determine if the return code for an encoding function is a fatal error. More...
 
#define PAIR_DECODE_FATAL_ERROR   FR_VALUE_BOX_NET_ERROR
 Fatal error - Failed decoding the packet. More...
 
#define PAIR_DECODE_OOM   FR_VALUE_BOX_NET_OOM
 Fatal error - Out of memory. More...
 

Detailed Description

Encoder/decoder library interface.

Id
6f596aaa91c7d118164a98c7b9d69f076b75de1c

Definition in file pair.h.

Macro Definition Documentation

◆ FR_PAIR_ENCODE_HAVE_SPACE

#define FR_PAIR_ENCODE_HAVE_SPACE (   _p,
  _end,
  _num 
)    if (((_p) + (_num)) > (_end)) return (_end) - ((_p) + (_num));

Checks if we have sufficient buffer space, and returns how much space we'd need as a negative integer.

Definition at line 83 of file pair.h.

◆ PAIR_DECODE_FATAL_ERROR

#define PAIR_DECODE_FATAL_ERROR   FR_VALUE_BOX_NET_ERROR

Fatal error - Failed decoding the packet.

Definition at line 49 of file pair.h.

◆ PAIR_DECODE_OOM

#define PAIR_DECODE_OOM   FR_VALUE_BOX_NET_OOM

Fatal error - Out of memory.

Definition at line 45 of file pair.h.

◆ PAIR_ENCODE_FATAL_ERROR

#define PAIR_ENCODE_FATAL_ERROR   SSIZE_MIN

Fatal encoding error.

Definition at line 36 of file pair.h.

Typedef Documentation

◆ fr_pair_decode_t

typedef ssize_t(* fr_pair_decode_t) (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)

A generic interface for decoding fr_pair_ts.

A decoding function should decode a single top level fr_pair_t from wire format. If this top level fr_pair_t is a TLV, multiple child attributes may also be decoded.

Parameters
[in]ctxto allocate new pairs in.
[in]outto insert new pairs into.
[in]parentto use for decoding
[in]datato decode.
[in]data_lenThe length of the incoming data.
[in]decode_ctxAny decode specific data such as secrets or temporary allocation contexts
Returns
  • <= 0 on error. May be the offset (as a negative value) where the error occurred.
  • > 0 on success. How many bytes were decoded.

Definition at line 129 of file pair.h.

◆ fr_pair_encode_t

typedef ssize_t(* fr_pair_encode_t) (fr_dbuff_t *out, fr_dcursor_t *cursor, void *encode_ctx)

Generic interface for encoding one or more fr_pair_ts.

An encoding function should consume at most, one top level fr_pair_t and encode it in the appropriate wire format for the protocol, writing the encoded data to out, and returning the encoded length.

The exception to processing one fr_pair_t is if multiple fr_pair_ts can be aggregated into a single TLV, in which case the encoder may consume as many fr_pair_ts as will fit into that TLV.

Outlen provides the length of the buffer to write the encoded data to. The return value must not be greater than outlen.

The cursor is used to track how many pairs there are remaining.

Parameters
[out]outWhere to write the encoded data.
[in]cursorCursor containing the list of attributes to process.
[in]encode_ctxAny encoder specific data such as secrets or configurables.
Returns
  • PAIR_ENCODE_FATAL_ERROR - Encoding failed in a fatal way. Encoding the packet should be aborted in its entirety.
  • <0 - The encoder ran out of space and returned the number of bytes as a negative integer that would be required to encode the attribute.
  • >0 - The number of bytes written to out.

Definition at line 112 of file pair.h.

Function Documentation

◆ fr_pair_decode_slen()

static ssize_t fr_pair_decode_slen ( ssize_t  slen,
uint8_t const *  start,
uint8_t const *  p 
)
inlinestatic

Return the correct adjusted slen for errors.

Parameters
[in]slenreturned from the function we called.
[in]startof the buffer.
[in]poffset passed to function which returned the slen.

Definition at line 57 of file pair.h.

+ Here is the caller graph for this function:

◆ fr_pair_encode_is_error()

static bool fr_pair_encode_is_error ( ssize_t  slen)
inlinestatic

Determine if the return code for an encoding function is a fatal error.

Definition at line 74 of file pair.h.

+ Here is the caller graph for this function: