ndn-lite
forwarder-helper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2019 Zhiyi Zhang, Xinyu Ma
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v3.0. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 #ifndef NDN_ENCODING_FORWARD_HELPER_H
9 #define NDN_ENCODING_FORWARD_HELPER_H
10 
11 #include <stdint.h>
12 #include <stdbool.h>
13 #include <stddef.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
34 typedef struct interest_options{
35  uint64_t lifetime;
36  uint32_t nonce;
37  uint8_t hop_limit;
41 
50 size_t
51 tlv_get_tlvar(uint8_t* buf, size_t buflen, uint32_t* var);
52 
62 uint8_t*
63 tlv_get_type_length(uint8_t* buf, size_t buflen, uint32_t* type, uint32_t* length);
64 
77 int
78 tlv_check_type_length(uint8_t* buf, size_t buflen, uint32_t type);
79 
93 int
94 tlv_interest_get_header(uint8_t* interest,
95  size_t buflen,
96  interest_options_t* options,
97  uint8_t** name,
98  size_t* name_len);
99 
112 int
113 tlv_data_get_name(uint8_t* data,
114  size_t buflen,
115  uint8_t** name,
116  size_t* name_len);
117 
126 uint8_t*
127 tlv_interest_get_hoplimit_ptr(uint8_t* interest, size_t buflen);
128 
135 uint64_t
136 tlv_get_uint(uint8_t* buf, size_t buflen);
137 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif // NDN_ENCODING_FORWARD_HELPER_H
struct interest_options interest_options_t
Interest options which the forwarder cares.
uint8_t hop_limit
Definition: forwarder-helper.h:37
size_t tlv_get_tlvar(uint8_t *buf, size_t buflen, uint32_t *var)
Get the first variable of type or length from a TLV encoded form.
Definition: forwarder-helper.c:20
uint64_t lifetime
Definition: forwarder-helper.h:35
int tlv_data_get_name(uint8_t *data, size_t buflen, uint8_t **name, size_t *name_len)
Get the name of a Data packet.
Definition: forwarder-helper.c:163
int tlv_interest_get_header(uint8_t *interest, size_t buflen, interest_options_t *options, uint8_t **name, size_t *name_len)
Get the name and options of an Interest packet.
Definition: forwarder-helper.c:96
uint8_t * tlv_get_type_length(uint8_t *buf, size_t buflen, uint32_t *type, uint32_t *length)
Get type and length from a TLV encoded form.
Definition: forwarder-helper.c:43
uint64_t tlv_get_uint(uint8_t *buf, size_t buflen)
Decode an unsigned integer value.
Definition: forwarder-helper.c:86
uint32_t nonce
Definition: forwarder-helper.h:36
int tlv_check_type_length(uint8_t *buf, size_t buflen, uint32_t type)
Check the type and length of a TLV block.
Definition: forwarder-helper.c:65
uint8_t * tlv_interest_get_hoplimit_ptr(uint8_t *interest, size_t buflen)
Get the pointer to hop limit field of a Interest packet.
Definition: forwarder-helper.c:197
bool can_be_prefix
Definition: forwarder-helper.h:38
Interest options which the forwarder cares.
Definition: forwarder-helper.h:34
bool must_be_fresh
Definition: forwarder-helper.h:39