#include "name-component.h"
#include <stdbool.h>
#include <stdio.h>
Go to the source code of this file.
|
static void | ndn_name_print (ndn_name_t *name) |
| Print a name. More...
|
|
int | ndn_name_init (ndn_name_t *name, const name_component_t *components, uint32_t size) |
| Init a Name structure. More...
|
|
int | ndn_name_tlv_decode (ndn_decoder_t *decoder, ndn_name_t *name) |
| Decode the Name from wire format (TLV block). More...
|
|
int | ndn_name_from_block (ndn_name_t *name, const uint8_t *block_value, uint32_t block_size) |
| Decode an Name TLV block into an Name. More...
|
|
int | ndn_name_append_component (ndn_name_t *name, const name_component_t *component) |
| Appends a component to the end of a name. More...
|
|
int | ndn_name_from_string (ndn_name_t *name, const char *string, uint32_t size) |
| Init a name block from a string. More...
|
|
static uint32_t | ndn_name_probe_block_size (const ndn_name_t *name) |
| Probe the size of a Name TLV block before encoding it from a Name structure. More...
|
|
int | ndn_name_tlv_encode (ndn_encoder_t *encoder, const ndn_name_t *name) |
| Encode the Name structure into wire format (TLV block). More...
|
|
int | ndn_name_compare (const ndn_name_t *lhs, const ndn_name_t *rhs) |
| Compare two Name. More...
|
|
int | ndn_name_compare_sub_names (const ndn_name_t *lhs, int lhs_b, int lhs_e, const ndn_name_t *rhs, int rhs_b, int rhs_e) |
| Compare sub-names of two names. More...
|
|
int | ndn_name_is_prefix_of (const ndn_name_t *lhs, const ndn_name_t *rhs) |
| Compare two Name based on the canonical order, to see whether a name is the prefix of another. More...
|
|
int | ndn_name_compare_block (const uint8_t *lhs_block_value, uint32_t lhs_block_size, const uint8_t *rhs_block_value, uint32_t rhs_block_size) |
| Compare two encoded Names. More...
|
|
◆ ndn_name_t
The structure to represent the Name.
This structure is memory expensive so please be careful when using it.
◆ ndn_name_append_component()
Appends a component to the end of a name.
This function will do memory copy.
- Parameters
-
name. | Output. The name to append to. |
component. | Input. The name component to append with. |
- Returns
- 0 if there is no error.
◆ ndn_name_compare()
Compare two Name.
- Parameters
-
lhs. | Input. Left-hand-side Name. |
rhs. | Input. Right-hand-side Name. |
- Returns
- 0 if
lhs
== rhs
.
◆ ndn_name_compare_block()
int ndn_name_compare_block |
( |
const uint8_t * |
lhs_block_value, |
|
|
uint32_t |
lhs_block_size, |
|
|
const uint8_t * |
rhs_block_value, |
|
|
uint32_t |
rhs_block_size |
|
) |
| |
Compare two encoded Names.
- Parameters
-
lhs_block_value. | Input. Left-hand-side encoded Name block value. |
lhs_block_size. | Input. Left-hand-side encoded Name block size. |
rhs_block_value. | Input. Right-hand-side encoded Name block value. |
rhs_block_size. | Input. Right-hand-side encoded Name block size. |
- Returns
- 0 if
lhs
== rhs
.
-
1, if
lhs
> rhs
and rhs
is not a prefix of lhs
.
-
2, if
lhs
> rhs
and rhs
is a proper prefix of lhs
.
-
-1, if
lhs
< rhs
and lhs
is not a prefix of rhs
.
-
-2, if
lhs
< rhs
and lhs
is a proper prefix of rhs
.
◆ ndn_name_compare_sub_names()
int ndn_name_compare_sub_names |
( |
const ndn_name_t * |
lhs, |
|
|
int |
lhs_b, |
|
|
int |
lhs_e, |
|
|
const ndn_name_t * |
rhs, |
|
|
int |
rhs_b, |
|
|
int |
rhs_e |
|
) |
| |
Compare sub-names of two names.
- Parameters
-
lhs. | Input. Left-hand-side Name. |
lhs_b. | Input. Beginning index of left-hand-side-name. |
lhs_e. | Input. Ending index of left-hand-side-name (should be one more than last index to compare) |
rhs. | Input. Right-hand-side Name. |
rhs_b. | Input. Beginning index of right-hand-side-name. |
rhs_e. | Input. Ending index of right-hand-side-name (should be one more than last index to compare) |
- Returns
- 0 if
lhs
from lhs_b to lhs_e-1 == rhs
from rhs_b to rhs_e-1.
◆ ndn_name_from_block()
int ndn_name_from_block |
( |
ndn_name_t * |
name, |
|
|
const uint8_t * |
block_value, |
|
|
uint32_t |
block_size |
|
) |
| |
Decode an Name TLV block into an Name.
This function will do memory copy.
- Parameters
-
name. | Output. The Name to which the TLV block will be decoded. |
block. | Input. The Name TLV. |
- Returns
- 0 if decoding is successful.
◆ ndn_name_from_string()
int ndn_name_from_string |
( |
ndn_name_t * |
name, |
|
|
const char * |
string, |
|
|
uint32_t |
size |
|
) |
| |
Init a name block from a string.
This funcition will do memory copy and only support regular string; not support URI currently.
- Parameters
-
name. | Output. The Name to be inited. |
string. | Input. The string from which Name is inited. |
size. | Input. Size of the input string. |
- Returns
- 0 if there is no error.
◆ ndn_name_init()
Init a Name structure.
This function will do memory copy.
- Parameters
-
name. | Output. The Name Structure to be inited. |
component. | Input. The name component array from which Name is inited. |
size. | Input. Size of input name component array. |
◆ ndn_name_is_prefix_of()
Compare two Name based on the canonical order, to see whether a name is the prefix of another.
- Parameters
-
lhs. | Input. Left-hand-side Name. |
rhs. | Input. Right-hand-side Name. |
- Returns
- 0 if
lhs
is the prefix of rhs
.
◆ ndn_name_print()
Print a name.
- Parameters
-
name. | Input. The name to be printed. |
◆ ndn_name_probe_block_size()
static uint32_t ndn_name_probe_block_size |
( |
const ndn_name_t * |
name | ) |
|
|
inlinestatic |
Probe the size of a Name TLV block before encoding it from a Name structure.
This function is used to check whether the output buffer size is enough or not.
- Parameters
-
name. | Input. The Name structure to be probed. |
- Returns
- the length of the expected Name TLV block.
◆ ndn_name_tlv_decode()
Decode the Name from wire format (TLV block).
- Parameters
-
decoder. | Input. The decoder who keeps the decoding result and the state. |
name. | Output. The Name decoded from TLV block. |
- Returns
- 0 if there is no error.
◆ ndn_name_tlv_encode()
Encode the Name structure into wire format (TLV block).
This function will do memory copy. Need to call ndn_name_probe_block_size() to initialize output block in advance.
- Parameters
-
encoder. | Output. The encoder who keeps the encoding result and the state. |
name. | Input. The Name structure to be encoded. |
- Returns
- 0 if there is no error.