The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
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>
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... | |
Generic functions for decoding protocols.
Definition in file decode.c.
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.
[in] | ctx | context to alloc new attributes in. |
[out] | out | Where to write the decoded fr_pair_t |
[in] | parent | dictionary entry, must have parent->flags.array set |
[in] | data | to parse. |
[in] | data_len | of data to parse. |
[in] | decode_ctx | passed to decode_value |
[in] | decode_value | function to decode one value. <0 on error - decode error, or OOM data_len on success |
Definition at line 41 of file decode.c.
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.
[in] | ctx | context to alloc new attributes in. |
[out] | out | Where to write the decoded fr_pair_t |
[in] | parent | dictionary entry, must have parent->flags.array set |
[in] | start | of the DNS labels to decode |
[in] | data | to parse. |
[in] | data_len | of data to parse. |
[in] | lb | struct to help with decoding packets. |
[in] | exact | whether the labels should entirely fill the buffer. |
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.
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.
[in] | ctx | context to alloc new attributes in. |
[out] | out | Where to write the decoded fr_pair_t |
[in] | parent | dictionary entry |
[in] | data | to parse. |
[in] | data_len | of data to parse. <0 on error - decode error, or OOM data_len on success |
Definition at line 79 of file decode.c.
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.
[in] | ctx | context to alloc new attributes in. |
[out] | out | Where to write the decoded fr_pair_t |
[in] | parent | dictionary entry, must have parent->flags.array set |
[in] | data | to parse. |
[in] | data_len | of data to parse. |
[in] | decode_ctx | passed to decode_tlv |
[in] | decode_tlv | function to decode one attribute / option / tlv |
[in] | verify_tlvs | simple function to see if the TLVs are even vaguely well-formed |
[in] | nested | whether 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.