The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Encoder/decoder library interface. More...
#include <freeradius-devel/util/dcursor.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/pair.h>
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... | |
Encoder/decoder library interface.
Definition in file pair.h.
#define PAIR_DECODE_FATAL_ERROR FR_VALUE_BOX_NET_ERROR |
#define PAIR_DECODE_OOM FR_VALUE_BOX_NET_OOM |
#define PAIR_ENCODE_FATAL_ERROR SSIZE_MIN |
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.
[in] | ctx | to allocate new pairs in. |
[in] | out | to insert new pairs into. |
[in] | parent | to use for decoding |
[in] | data | to decode. |
[in] | data_len | The length of the incoming data. |
[in] | decode_ctx | Any decode specific data such as secrets or temporary allocation contexts |
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.
[out] | out | Where to write the encoded data. |
[in] | cursor | Cursor containing the list of attributes to process. |
[in] | encode_ctx | Any encoder specific data such as secrets or configurables. |