9 #ifndef NDN_ENCODING_DECODER_H 10 #define NDN_ENCODING_DECODER_H 61 if (first_bit < 253) {
65 else if (first_bit == 253 && rest_size >= 3) {
70 else if (first_bit == 254 && rest_size >= 5) {
121 if (rest_length < (
int) size) {
178 for (
int i = 0; i < 4; i++) {
198 for (
int i = 0; i < 8; i++) {
219 uint8_t temp_value = 0;
221 *value = (uint64_t)temp_value;
223 else if (length == 2) {
224 uint16_t temp_value = 0;
226 *value = (uint64_t)temp_value;
228 else if (length == 4) {
229 uint32_t temp_value = 0;
231 *value = (uint64_t)temp_value;
233 else if (length == 8) {
266 int new_position = decoder->
offset - step;
267 if (new_position < 0)
278 static inline uint32_t
287 #endif // NDN_ENCODING_DECODER_H const uint8_t * input_value
The encoded wire format buffer.
Definition: decoder.h:25
uint32_t offset
The current offset after which the wire has not been decoded.
Definition: decoder.h:33
uint32_t input_size
The size of the encoded wire format buffer.
Definition: decoder.h:29
The structure to keep the state when doing NDN TLV decoding.
Definition: decoder.h:21
#define NDN_OVERSIZE_VAR
Truncation due to insufficient buffer.
Definition: ndn-error-code.h:62
#define NDN_WRONG_TLV_LENGTH
The Length specified differs from expected.
Definition: ndn-error-code.h:53
static int decoder_get_uint64_value(ndn_decoder_t *decoder, uint64_t *value)
Get the fixed size Value (V) to a uint64_t.
Definition: decoder.h:193
static int decoder_move_forward(ndn_decoder_t *decoder, uint32_t step)
Move the decoder's offset forward by.
Definition: decoder.h:249
static uint32_t decoder_get_offset(const ndn_decoder_t *decoder)
Get the offset of the decoder.
Definition: decoder.h:279
struct ndn_decoder ndn_decoder_t
The structure to keep the state when doing NDN TLV decoding.
static int decoder_get_byte_value(ndn_decoder_t *decoder, uint8_t *value)
Get the fixed size Value (V) to a single byte.
Definition: decoder.h:137
static int decoder_get_var(ndn_decoder_t *decoder, uint32_t *var)
Get the variable size Type (T) and Length (L).
Definition: decoder.h:57
static void decoder_init(ndn_decoder_t *decoder, const uint8_t *block_value, uint32_t block_size)
Init a decoder by setting the wire format buffer and its size.
Definition: decoder.h:43
static int decoder_get_uint16_value(ndn_decoder_t *decoder, uint16_t *value)
Get the fixed size Value (V) to a uint16_t.
Definition: decoder.h:154
static int decoder_move_backward(ndn_decoder_t *decoder, uint32_t step)
Move the decoder's offset backward by.
Definition: decoder.h:264
static int decoder_get_raw_buffer_value(ndn_decoder_t *decoder, uint8_t *value, uint32_t size)
Get the variable size Value (V) to bytes.
Definition: decoder.h:118
#define NDN_OVERSIZE
The object given is larger than expected.
Definition: ndn-error-code.h:33
static int decoder_get_length(ndn_decoder_t *decoder, uint32_t *length)
Get the variable size Length (L).
Definition: decoder.h:103
static int decoder_get_type(ndn_decoder_t *decoder, uint32_t *type)
Get the variable size Type (T).
Definition: decoder.h:90
static int decoder_get_uint_value(ndn_decoder_t *decoder, uint32_t length, uint64_t *value)
Get the non-negative int Value (V) to a uint64_t.
Definition: decoder.h:216
static int decoder_get_uint32_value(ndn_decoder_t *decoder, uint32_t *value)
Get the fixed size Value (V) to a uint32_t.
Definition: decoder.h:173