ndn-lite
service-discovery.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Tianyuan Yu, Zhiyi Zhang
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  * See AUTHORS.md for complete list of NDN IOT PKG authors and contributors.
9  */
10 #ifndef NDN_APP_SUPPORT_SERVICE_DISCOVERY_H
11 #define NDN_APP_SUPPORT_SERVICE_DISCOVERY_H
12 
13 #include "../encode/interest.h"
14 #include "../encode/data.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
23 typedef struct ndn_service {
27  uint8_t status;
35  uint32_t id_size;
37 
41 typedef struct ndn_sd_identity {
51 
55 typedef struct ndn_sd_context {
69 
75 void
76 ndn_sd_init(const ndn_name_t* home_prefix, const name_component_t* self_id);
77 
85 ndn_sd_register_get_self_service(const char* id_value, uint32_t id_size);
86 
93 static inline int
94 ndn_sd_set_service_status(ndn_service_t* service, uint8_t status)
95 {
96  service->status = status;
97  return 0;
98 }
99 
107 
115 ndn_sd_find_first_service_provider(const char* id_value, uint32_t id_size);
116 
121 void
123 
133 void
135  const uint8_t* params_value, uint32_t params_size);
136 
143 int
145 
152 int
153 ndn_sd_on_query_process(const ndn_interest_t* interest, ndn_data_t* response);
154 
161 int
163 
170 int
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif // NDN_APP_SUPPORT_SERVICE_DISCOVERY_H
struct ndn_sd_identity ndn_sd_identity_t
The structure to implement neighbors management in Access Control.
int ndn_sd_on_query_response_process(const ndn_data_t *response)
Process Service Discovery Query's Response.
Definition: service-discovery.c:286
int ndn_sd_on_query_timeout_process(const ndn_interest_t *interest)
Process Service Discovery Query's Timeout.
Definition: service-discovery.c:309
uint8_t id_value[NDN_APPSUPPORT_SERVICE_ID_SIZE]
The NDN service ID.
Definition: service-discovery.h:31
The structure to represent an NDN Interest packet.
Definition: interest.h:31
name_component_t identity
The neighbor identity.
Definition: service-discovery.h:45
The structure to represent an NDN Data packet The best practice of using ndn_data_t is to first decla...
Definition: data.h:30
ndn_name_t home_prefix
The home prefix of local network.
Definition: service-discovery.h:59
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.
Definition: service-discovery.c:203
The structure to implement state storage and management in Service Discovery.
Definition: service-discovery.h:55
int ndn_sd_on_query_process(const ndn_interest_t *interest, ndn_data_t *response)
Process Service Discovery Query.
Definition: service-discovery.c:252
ndn_sd_identity_t * ndn_sd_find_neigbor(const name_component_t *id)
Find a neighbor in the neighbor list by searching its identity.
Definition: service-discovery.c:163
void ndn_sd_prepare_advertisement(ndn_interest_t *interest)
Prepare a Service Discovery Advertisement.
Definition: service-discovery.c:175
int ndn_sd_on_advertisement_process(const ndn_interest_t *interest)
Process Service Discovery Advertisement.
Definition: service-discovery.c:228
struct ndn_service ndn_service_t
The structure to represent a NDN service.
The structure to represent the Name.
Definition: name.h:24
struct ndn_sd_context ndn_sd_context_t
The structure to implement state storage and management in Service Discovery.
void ndn_sd_init(const ndn_name_t *home_prefix, const name_component_t *self_id)
Init a Service Discovery State structure.
Definition: service-discovery.c:129
The structure to represent a NDN service.
Definition: service-discovery.h:23
The structure to implement neighbors management in Access Control.
Definition: service-discovery.h:41
ndn_service_t services[NDN_APPSUPPORT_SERVICES_SIZE]
The neighbor identity's service list.
Definition: service-discovery.h:49
The structure to represent the Name Component.
Definition: name-component.h:23
#define NDN_APPSUPPORT_NEIGHBORS_SIZE
Definition: ndn-constants.h:65
ndn_sd_identity_t neighbors[NDN_APPSUPPORT_NEIGHBORS_SIZE]
The neighbor list.
Definition: service-discovery.h:67
#define NDN_APPSUPPORT_SERVICES_SIZE
Definition: ndn-constants.h:67
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.
Definition: service-discovery.c:169
static int ndn_sd_set_service_status(ndn_service_t *service, uint8_t status)
Set service status of a NDN service.
Definition: service-discovery.h:94
uint32_t id_size
Size of service ID.
Definition: service-discovery.h:35
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.
Definition: service-discovery.c:141
#define NDN_APPSUPPORT_SERVICE_ID_SIZE
Definition: ndn-constants.h:68
uint8_t status
The NDN service status.
Definition: service-discovery.h:27