ndn-lite
Data Structures | Typedefs | Functions
name-component.h File Reference
#include "tlv.h"
#include "decoder.h"
#include <string.h>

Go to the source code of this file.

Data Structures

struct  name_component
 The structure to represent the Name Component. More...
 
struct  name_component_block
 The structure to represent the wire format name component block. More...
 

Typedefs

typedef struct name_component name_component_t
 The structure to represent the Name Component. More...
 
typedef struct name_component_block name_component_block_t
 The structure to represent the wire format name component block. More...
 

Functions

static void name_component_init (name_component_t *component, uint32_t type)
 Init a Name Component structure. More...
 
static int name_component_from_buffer (name_component_t *component, uint32_t type, const uint8_t *value, uint32_t size)
 Init a Name Component structure from caller supplied memory block. More...
 
static int name_component_from_string (name_component_t *component, const char *string, uint32_t size)
 Init a Name Component structure from string. More...
 
int name_component_tlv_decode (ndn_decoder_t *decoder, name_component_t *component)
 Decode the Name Component from wire format (TLV block). More...
 
int name_component_from_block (name_component_t *component, const name_component_block_t *block)
 Decode an Name Component TLV block into an Name Component. More...
 
int name_component_compare (const name_component_t *lhs, const name_component_t *rhs)
 Compare two name components. More...
 
static uint32_t name_component_probe_block_size (const name_component_t *component)
 Probe the size of a Name component TLV block before encoding it from a Name Component structure. More...
 
int name_component_tlv_encode (ndn_encoder_t *encoder, const name_component_t *component)
 Encode the Name Component structure into wire format (TLV block). More...
 

Typedef Documentation

◆ name_component_block_t

The structure to represent the wire format name component block.

◆ name_component_t

The structure to represent the Name Component.

Function Documentation

◆ name_component_compare()

int name_component_compare ( const name_component_t lhs,
const name_component_t rhs 
)

Compare two name components.

Parameters
lhs.Input. Left-hand-side name component.
rhs.Input. Right-hand-side name component.
Returns
0 if lhs == rhs.

◆ name_component_from_block()

int name_component_from_block ( name_component_t component,
const name_component_block_t block 
)

Decode an Name Component TLV block into an Name Component.

This function will do memory copy.

Parameters
component.Output. The component to which the TLV block will be decoded.
block.Input. The Name Component TLV.
Returns
0 if decoding is successful.

◆ name_component_from_buffer()

static int name_component_from_buffer ( name_component_t component,
uint32_t  type,
const uint8_t *  value,
uint32_t  size 
)
inlinestatic

Init a Name Component structure from caller supplied memory block.

The function will do memory copy

Parameters
component.Output. The Name Component structure to be inited.
type.Input. Name Component Type to be set with.
value.Input. Memory block which holds the Name Component Value.
size.Input. Size of input block.
Returns
0 if there is no error.

◆ name_component_from_string()

static int name_component_from_string ( name_component_t component,
const char *  string,
uint32_t  size 
)
inlinestatic

Init a Name Component structure from string.

Please include the last byte of the string, which is "\0". The function will do memory copy.

Parameters
component.Output. The Name Component structure to be inited.
string.Input. String variable which name component initing from.
size.Input. Size of input string.
Returns
0 if there is no error.

◆ name_component_init()

static void name_component_init ( name_component_t component,
uint32_t  type 
)
inlinestatic

Init a Name Component structure.

Parameters
component.Output. The Name Component structure to be inited.
type.Input. Name Component Type to be set with.

◆ name_component_probe_block_size()

static uint32_t name_component_probe_block_size ( const name_component_t component)
inlinestatic

Probe the size of a Name component TLV block before encoding it from a Name Component structure.

This function is used to check whether the output buffer size is enough or not.

Parameters
component.Input. The name component structure to be probed.
Returns
the length of the expected name component TLV block.

◆ name_component_tlv_decode()

int name_component_tlv_decode ( ndn_decoder_t decoder,
name_component_t component 
)

Decode the Name Component from wire format (TLV block).

Parameters
decoder.Input. The decoder who keeps the decoding result and the state.
component.Output. The Name Component decoded from TLV block.
Returns
0 if there is no error.

◆ name_component_tlv_encode()

int name_component_tlv_encode ( ndn_encoder_t encoder,
const name_component_t component 
)

Encode the Name Component structure into wire format (TLV block).

Parameters
encoder.Output. The encoder who keeps the encoding result and the state.
component.Input. The Name Component structure to be encoded.
Returns
0 if there is no error.