Some helper functions used by the forwarder.
More...
|
| 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. More...
|
| |
| 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. More...
|
| |
| int | tlv_check_type_length (uint8_t *buf, size_t buflen, uint32_t type) |
| | Check the type and length of a TLV block. More...
|
| |
| 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. More...
|
| |
| 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. More...
|
| |
| uint8_t * | tlv_interest_get_hoplimit_ptr (uint8_t *interest, size_t buflen) |
| | Get the pointer to hop limit field of a Interest packet. More...
|
| |
| uint64_t | tlv_get_uint (uint8_t *buf, size_t buflen) |
| | Decode an unsigned integer value. More...
|
| |
Some helper functions used by the forwarder.
◆ interest_options_t
Interest options which the forwarder cares.
Currently only used in the forwarder.
◆ tlv_check_type_length()
| int tlv_check_type_length |
( |
uint8_t * |
buf, |
|
|
size_t |
buflen, |
|
|
uint32_t |
type |
|
) |
| |
Check the type and length of a TLV block.
- Parameters
-
| [in] | buf | [Optional] The buffer containing the TLV block. |
| [in] | buflen | The length of buf. |
| [in] | type | The required type. |
- Return values
-
- Note
- This function will kindly check
buf != NULL.
◆ tlv_data_get_name()
| 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.
- Parameters
-
| [in] | data | The Data packet. |
| [in] | buflen | The length of data. |
| [out] | name | A pointer to the name in data. |
| [out] | name_len | The length of name. |
- Return values
-
◆ tlv_get_tlvar()
| 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.
- Parameters
-
| [in] | buf | The buffer containing the TLV encoded form. |
| [in] | buflen | The length of buf. |
| [out] | var | The decoded value. |
- Returns
- If the function succeeds, return the size
var takes. If the function fails, return 0.
◆ tlv_get_type_length()
| 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.
- Parameters
-
| [in] | buf | The buffer containing the TLV encoded form. |
| [in] | buflen | The length of buf. |
| [out] | type | The decoded type. |
| [out] | length | The decoded length. |
- Returns
- If the function succeeds, return a pointer to its content. If the function fails, return
NULL.
◆ tlv_get_uint()
| uint64_t tlv_get_uint |
( |
uint8_t * |
buf, |
|
|
size_t |
buflen |
|
) |
| |
Decode an unsigned integer value.
- Parameters
-
| [in] | buf | Buffer pointing to the value, not including T and L. |
| [in] | buflen | The length of buf. |
- Returns
- The value.
◆ tlv_interest_get_header()
| 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.
- Parameters
-
| [in] | interest | The Interest packet. |
| [in] | buflen | The length of interest. |
| [out] | options | [Optional] Options of interest. |
| [out] | name | A pointer to the name in interest. |
| [out] | name_len | The length of name. |
- Return values
-
◆ tlv_interest_get_hoplimit_ptr()
| uint8_t* tlv_interest_get_hoplimit_ptr |
( |
uint8_t * |
interest, |
|
|
size_t |
buflen |
|
) |
| |
Get the pointer to hop limit field of a Interest packet.
- Parameters
-
| [in] | interest | The Interest packet. |
| [in] | buflen | The length of interest. |
- Returns
- If the function succeeds, return a pointer to the hop limit. If
interest doesn't contain a hop limit field, return NULL.
- Precondition
- tlv_interest_get_header should succeed for
interest.