ndn-lite
Data Structures | Typedefs | Functions
service-discovery.h File Reference
#include "../encode/interest.h"
#include "../encode/data.h"

Go to the source code of this file.

Data Structures

struct  ndn_service
 The structure to represent a NDN service. More...
 
struct  ndn_sd_identity
 The structure to implement neighbors management in Access Control. More...
 
struct  ndn_sd_context
 The structure to implement state storage and management in Service Discovery. More...
 

Typedefs

typedef struct ndn_service ndn_service_t
 The structure to represent a NDN service. More...
 
typedef struct ndn_sd_identity ndn_sd_identity_t
 The structure to implement neighbors management in Access Control. More...
 
typedef struct ndn_sd_context ndn_sd_context_t
 The structure to implement state storage and management in Service Discovery. More...
 

Functions

void ndn_sd_init (const ndn_name_t *home_prefix, const name_component_t *self_id)
 Init a Service Discovery State structure. More...
 
ndn_service_tndn_sd_register_get_self_service (const char *id_value, uint32_t id_size)
 Get a pointer to a NDN service by searching its NDN service ID. More...
 
static int ndn_sd_set_service_status (ndn_service_t *service, uint8_t status)
 Set service status of a NDN service. More...
 
ndn_sd_identity_tndn_sd_find_neigbor (const name_component_t *id)
 Find a neighbor in the neighbor list by searching its identity. More...
 
ndn_sd_identity_tndn_sd_find_first_service_provider (const char *id_value, uint32_t id_size)
 Find a service provider in the neighbor list by searching service ID. More...
 
void ndn_sd_prepare_advertisement (ndn_interest_t *interest)
 Prepare a Service Discovery Advertisement. More...
 
void ndn_sd_prepare_query (ndn_interest_t *interest, name_component_t *target, ndn_service_t *service, const uint8_t *params_value, uint32_t params_size)
 Prepare a Service Discovery Query. More...
 
int ndn_sd_on_advertisement_process (const ndn_interest_t *interest)
 Process Service Discovery Advertisement. More...
 
int ndn_sd_on_query_process (const ndn_interest_t *interest, ndn_data_t *response)
 Process Service Discovery Query. More...
 
int ndn_sd_on_query_response_process (const ndn_data_t *response)
 Process Service Discovery Query's Response. More...
 
int ndn_sd_on_query_timeout_process (const ndn_interest_t *interest)
 Process Service Discovery Query's Timeout. More...
 

Typedef Documentation

◆ ndn_sd_context_t

The structure to implement state storage and management in Service Discovery.

◆ ndn_sd_identity_t

The structure to implement neighbors management in Access Control.

◆ ndn_service_t

typedef struct ndn_service ndn_service_t

The structure to represent a NDN service.

Function Documentation

◆ ndn_sd_find_first_service_provider()

ndn_sd_identity_t* ndn_sd_find_first_service_provider ( const char *  id_value,
uint32_t  id_size 
)

Find a service provider in the neighbor list by searching service ID.

Parameters
id.Input. The service ID searched.
id_size.Input. Size of input service ID.
Returns
pointer to the first service provider's neighbor identity if it exists.

◆ ndn_sd_find_neigbor()

ndn_sd_identity_t* ndn_sd_find_neigbor ( const name_component_t id)

Find a neighbor in the neighbor list by searching its identity.

Parameters
id.Input. The neighbor identity searched.
Returns
pointer to the neighbor identity if it exists.

◆ ndn_sd_init()

void ndn_sd_init ( const ndn_name_t home_prefix,
const name_component_t self_id 
)

Init a Service Discovery State structure.

Parameters
home_prefix.Input. The network home prefix to configure the state manager.
self_id.Input. The local state manager identity.

◆ ndn_sd_on_advertisement_process()

int ndn_sd_on_advertisement_process ( const ndn_interest_t interest)

Process Service Discovery Advertisement.

This function will automatically set and update local Service Discovery State and is used in receiver side onInterest callback.

Parameters
interest.Input. Decoded advertisement interest.
Returns
0 if there is no error.

◆ ndn_sd_on_query_process()

int ndn_sd_on_query_process ( const ndn_interest_t interest,
ndn_data_t response 
)

Process Service Discovery Query.

This function is used in receiver side onInterest callback.

Parameters
interest.Input. Decoded and signature verified query interest.
response.Output. Prepared query response.
Returns
0 if there is no error.

◆ ndn_sd_on_query_response_process()

int ndn_sd_on_query_response_process ( const ndn_data_t response)

Process Service Discovery Query's Response.

This function will automatically set and update local Service Discovery State and is used in sender side onData callback.

Parameters
response.Input. Decoded and signature verified query response.
Returns
0 if there is no error.

◆ ndn_sd_on_query_timeout_process()

int ndn_sd_on_query_timeout_process ( const ndn_interest_t interest)

Process Service Discovery Query's Timeout.

This function will automatically remove query target identity from local neighbor list and is used in sender side onInterestTimeout callback.

Parameters
interest.Input. Expired interest.
Returns
0 if there is no error.

◆ ndn_sd_prepare_advertisement()

void ndn_sd_prepare_advertisement ( ndn_interest_t interest)

Prepare a Service Discovery Advertisement.

This function should be called after setting local services status.

Parameters
interest.Output. The prepared advertisement interest.

◆ ndn_sd_prepare_query()

void ndn_sd_prepare_query ( ndn_interest_t interest,
name_component_t target,
ndn_service_t service,
const uint8_t *  params_value,
uint32_t  params_size 
)

Prepare a Service Discovery Query.

Users should manually sign the output query interest to obtain a valid signed query interest.

Parameters
interest.Output. The prepared unsigned query interest.
target.Input. The query target identity.
service.Input. The query target service.
params_value.Input. The query parameter buffer (optional)
params_size.Input. Size of input buffer (optional)

◆ ndn_sd_register_get_self_service()

ndn_service_t* ndn_sd_register_get_self_service ( const char *  id_value,
uint32_t  id_size 
)

Get a pointer to a NDN service by searching its NDN service ID.

Parameters
id_value.Input. Service ID buffer.
id_size.Input. Size of input service ID.
Returns
pointer to the NDN service if it exists.

◆ ndn_sd_set_service_status()

static int ndn_sd_set_service_status ( ndn_service_t service,
uint8_t  status 
)
inlinestatic

Set service status of a NDN service.

Parameters
service.Input. The NDN service whose service status will be set.
status.Input. Service status value.
Returns
0 if there is no error.