Resolved comments.

Rebased with ARMmbed feature-wisun branch.
pull/13084/head
Debdeep Saha 2020-06-10 18:01:50 +05:30
parent 4c6dd9334a
commit 0387254ebd
4 changed files with 44 additions and 24 deletions

View File

@ -20,7 +20,7 @@
/**
* \brief Struct br_information Border router dynamic information.
*/
typedef struct br_information {
typedef struct ws_br_info {
/** Address prefix given to devices in network set to 0 if not available*/
uint8_t ipv6_prefix[8];
/** IID of Border router */
@ -35,18 +35,18 @@ typedef struct br_information {
uint64_t host_timestamp;
/** Amount of devices in the network. */
uint16_t device_count;
} br_information_t;
} ws_br_info_t;
/**
* \brief Struct br_route_info is parent child relation structure.
*/
typedef struct br_route_info {
typedef struct ws_br_route_info {
/** IID of target device
* Public IPv6 address can be formed by combining prefix + IID*/
uint8_t target[8];
/** IID of parent*/
uint8_t parent[8];
} br_route_info_t;
} ws_br_route_info_t;
/** Wi-SUN Border Router class
*
@ -189,7 +189,7 @@ public:
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t get_info(br_information_t *info_ptr);
mesh_error_t info_get(ws_br_info_t *info_ptr);
/**
* \brief Get Wi-SUN neighbor table information.
@ -205,7 +205,7 @@ public:
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t get_routing_table(br_route_info_t *table_ptr, uint16_t table_len);
mesh_error_t routing_table_get(ws_br_route_info_t *table_ptr, uint16_t table_len);
private:
int8_t _mesh_if_id = -1;

View File

@ -20,9 +20,9 @@
#include "MeshInterfaceNanostack.h"
/**
* \brief Struct router_information Wi-SUN router dynamic information.
* \brief Struct ws_rpl_info Wi-SUN router RPL information.
*/
typedef struct router_information {
typedef struct ws_rpl_info {
/** Address prefix given to devices in network set to 0 if not available*/
uint8_t ipv6_prefix[8];
/** IID of router */
@ -33,7 +33,7 @@ typedef struct router_information {
uint8_t instance_id;
/** RPL version number */
uint8_t version;
} router_information_t;
} ws_rpl_info_t;
/** Wi-SUN mesh network interface class
*
@ -460,7 +460,7 @@ public:
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t get_info(router_information_t *info_ptr);
mesh_error_t info_get(ws_rpl_info_t *info_ptr);
protected:
Nanostack::WisunInterface *get_interface() const;

View File

@ -154,7 +154,7 @@ mesh_error_t WisunBorderRouter::validate_pan_configuration(uint16_t pan_id)
return MESH_ERROR_NONE;
}
mesh_error_t WisunBorderRouter::get_info(br_information_t *info_ptr)
mesh_error_t WisunBorderRouter::info_get(ws_br_info_t *info_ptr)
{
bbr_information_t bbr_info = {0};
@ -178,7 +178,7 @@ mesh_error_t WisunBorderRouter::get_info(br_information_t *info_ptr)
return MESH_ERROR_NONE;
}
mesh_error_t WisunBorderRouter::get_routing_table(br_route_info_t *table_ptr, uint16_t table_len)
mesh_error_t WisunBorderRouter::routing_table_get(ws_br_route_info_t *table_ptr, uint16_t table_len)
{
if (table_ptr == NULL) {
return MESH_ERROR_PARAM;

View File

@ -30,9 +30,6 @@
#include "ns_trace.h"
#define TRACE_GROUP "WSIn"
#define RPL_INSTANCE_ID 1
static uint8_t current_instance_id = RPL_INSTANCE_ID;
class Nanostack::WisunInterface : public Nanostack::MeshInterface {
public:
virtual nsapi_error_t bringup(bool dhcp, const char *ip,
@ -59,7 +56,7 @@ Nanostack::WisunInterface *WisunInterface::get_interface() const
nsapi_error_t WisunInterface::do_initialize()
{
if (!_interface) {
_interface = new (std::nothrow) Nanostack::WisunInterface(*_phy);
_interface = new(std::nothrow) Nanostack::WisunInterface(*_phy);
if (!_interface) {
return NSAPI_ERROR_NO_MEMORY;
}
@ -126,8 +123,8 @@ nsapi_error_t WisunInterface::configure()
}
nsapi_error_t Nanostack::WisunInterface::bringup(bool dhcp, const char *ip,
const char *netmask, const char *gw,
nsapi_ip_stack_t stack, bool blocking)
const char *netmask, const char *gw,
nsapi_ip_stack_t stack, bool blocking)
{
nanostack_lock();
@ -547,17 +544,40 @@ mesh_error_t WisunInterface::read_mac_statistics(mesh_mac_statistics_t *statisti
return ret_val;
}
mesh_error_t WisunInterface::get_info(router_information_t *info_ptr)
mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
{
rpl_dodag_info_t dodag_ptr = {0};
uint8_t global_address[16] = {0};
if (info_ptr == NULL) {
return MESH_ERROR_PARAM;
}
int status = rpl_read_dodag_info(&dodag_ptr, current_instance_id);
if (status < 0) {
rpl_dodag_info_t dodag_ptr = {0};
uint8_t global_address[16] = {0};
uint8_t instance_id_list[10];
uint8_t rpl_instance_count;
uint8_t instance_id = RPL_INSTANCE_LOCAL;
uint8_t instance_id_new;
uint8_t instance_index;
rpl_instance_count = rpl_instance_list_read(&instance_id_list[0], sizeof(instance_id_list));
/* Find lowest global instance ID (assumption: RPL instance with lowest instance ID has
most generic routing rule and its rank should be indicated in beacon) */
for (instance_index = 0; instance_index < rpl_instance_count; instance_index++) {
instance_id_new = instance_id_list[instance_index];
if ((instance_id_new & RPL_INSTANCE_LOCAL) == RPL_INSTANCE_LOCAL) {
break;
} else {
if (instance_id_new < instance_id) {
instance_id = instance_id_new;
}
}
}
if (instance_id == RPL_INSTANCE_LOCAL) {
return MESH_ERROR_UNKNOWN;
}
if (!rpl_read_dodag_info(&dodag_ptr, instance_id)) {
return MESH_ERROR_UNKNOWN;
}