The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Functions
decode.c File Reference

Generic functions for decoding protocols. More...

#include <freeradius-devel/io/test_point.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/decode.h>
+ Include dependency graph for decode.c:

Go to the source code of this file.

Functions

ssize_t fr_pair_array_from_network (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, fr_pair_decode_value_t decode_value)
 Decode an array of values from the network. More...
 
ssize_t fr_pair_dns_labels_from_network (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *start, uint8_t const *data, size_t const data_len, fr_dns_labels_t *lb, bool exact)
 Decode a DNS label or a list of DNS labels from the network. More...
 
ssize_t fr_pair_raw_from_network (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len)
 Create a "raw" pair from the network data. More...
 
ssize_t fr_pair_tlvs_from_network (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx, fr_pair_decode_value_t decode_tlv, fr_pair_tlvs_verify_t verify_tlvs, bool nested)
 Decode a list of pairs from the network. More...
 

Detailed Description

Generic functions for decoding protocols.

Id
77e30d51aabb02ff1c5064937cad835370af4378

Definition in file decode.c.

Function Documentation

◆ fr_pair_array_from_network()

ssize_t fr_pair_array_from_network ( 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,
fr_pair_decode_value_t  decode_value 
)

Decode an array of values from the network.

Parameters
[in]ctxcontext to alloc new attributes in.
[out]outWhere to write the decoded fr_pair_t
[in]parentdictionary entry, must have parent->flags.array set
[in]datato parse.
[in]data_lenof data to parse.
[in]decode_ctxpassed to decode_value
[in]decode_valuefunction to decode one value. <0 on error - decode error, or OOM data_len on success

Definition at line 41 of file decode.c.

+ Here is the caller graph for this function:

◆ fr_pair_dns_labels_from_network()

ssize_t fr_pair_dns_labels_from_network ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  start,
uint8_t const *  data,
size_t const  data_len,
fr_dns_labels_t lb,
bool  exact 
)

Decode a DNS label or a list of DNS labels from the network.

Parameters
[in]ctxcontext to alloc new attributes in.
[out]outWhere to write the decoded fr_pair_t
[in]parentdictionary entry, must have parent->flags.array set
[in]startof the DNS labels to decode
[in]datato parse.
[in]data_lenof data to parse.
[in]lbstruct to help with decoding packets.
[in]exactwhether the labels should entirely fill the buffer.
Returns
<0 on error - decode error, or OOM data_len on success

DNS labels exist in many protocols, and we also have src/lib/dns.c, so we might as well put a common function here, too.

This function assumes that the DNS label or labels take up all of the input. If they do not, then the decoded DNS labels are freed, and a raw attribute is returned instead.

Definition at line 237 of file decode.c.

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

◆ fr_pair_raw_from_network()

ssize_t fr_pair_raw_from_network ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t  data_len 
)

Create a "raw" pair from the network data.

Parameters
[in]ctxcontext to alloc new attributes in.
[out]outWhere to write the decoded fr_pair_t
[in]parentdictionary entry
[in]datato parse.
[in]data_lenof data to parse. <0 on error - decode error, or OOM data_len on success

Definition at line 79 of file decode.c.

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

◆ fr_pair_tlvs_from_network()

ssize_t fr_pair_tlvs_from_network ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t const  data_len,
void *  decode_ctx,
fr_pair_decode_value_t  decode_tlv,
fr_pair_tlvs_verify_t  verify_tlvs,
bool  nested 
)

Decode a list of pairs from the network.

Parameters
[in]ctxcontext to alloc new attributes in.
[out]outWhere to write the decoded fr_pair_t
[in]parentdictionary entry, must have parent->flags.array set
[in]datato parse.
[in]data_lenof data to parse.
[in]decode_ctxpassed to decode_tlv
[in]decode_tlvfunction to decode one attribute / option / tlv
[in]verify_tlvssimple function to see if the TLVs are even vaguely well-formed
[in]nestedwhether or not we create nested VPs. <0 on error - decode error, or OOM data_len on success

The decode_tlv function should return an error if the option is malformed. In that case, the entire list of pairs is thrown away, and a "raw" attribute is created which contains the entire data_len.

If the value is malformed, then the decode_tlv function should call fr_pair_raw_from_network() on the value, and return a positive value.

Definition at line 148 of file decode.c.

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