Skip to content

Commit 5722a4a

Browse files
author
Juha Heiskanen
committed
Wi-sun multicast neighbour and RPL update
RPL have anew callback for add new parent candidate. Wi-sun neighbour info request simplify removed multicast parameter. Wi-sun temory neighbour entries for multicast traffic purpose. Wi-sun bootstrap allocate temp buffer and make a neigbour at new RPL candidate callback. Change-Id: I80da4b79690d56e5ff4a2623dffcd7818b33d0fe
1 parent f43620f commit 5722a4a

File tree

11 files changed

+247
-70
lines changed

11 files changed

+247
-70
lines changed

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ int8_t arm_6lowpan_bootstarp_bootstrap_set(int8_t interface_id, net_6lowpan_mode
17871787
*/
17881788
if (cur->lowpan_info & INTERFACE_NWK_ROUTER_DEVICE) {
17891789
//rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
1790-
//rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, cur);
1790+
//rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, NULL, cur);
17911791
}
17921792
#endif
17931793
cur->configure_flags |= INTERFACE_BOOTSTRAP_DEFINED;
@@ -2182,7 +2182,7 @@ void nwk_6lowpan_nd_address_registartion_ready(protocol_interface_info_entry_t *
21822182
// arm_nwk_6lowpan_rpl_dodag_poison from a previous connection may have left force_leaf set
21832183
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, false);
21842184
rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
2185-
rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, cur);
2185+
rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, NULL, cur);
21862186
}
21872187
// Send unicast DIS to coordinator
21882188
nwk_bootstrap_icmp_rpl_dis_coord_msg_tx(cur);

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 71 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp
8181
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);
8282
static int8_t ws_bootsrap_event_trig(ws_bootsrap_event_type_e event_type, int8_t interface_id, arm_library_event_priority_e priority, void *event_data);
8383

84-
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast);
84+
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new);
8585
static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entry_t *cur);
8686
static uint16_t ws_bootstrap_rank_get(protocol_interface_info_entry_t *cur);
8787
static uint16_t ws_bootstrap_min_rank_inc_get(protocol_interface_info_entry_t *cur);
@@ -97,13 +97,15 @@ static void ws_bootstrap_pan_version_increment(protocol_interface_info_entry_t *
9797
static ws_nud_table_entry_t *ws_nud_entry_discover(protocol_interface_info_entry_t *cur, void *neighbor);
9898
static void ws_nud_entry_remove(protocol_interface_info_entry_t *cur, mac_neighbor_table_entry_t *entry_ptr);
9999
static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data);
100+
static bool ws_rpl_dio_new_parent_accept(struct protocol_interface_info_entry *interface);
100101

101102
typedef enum {
102103
WS_PARENT_SOFT_SYNCH = 0, /**< let FHSS make decision if synchronization is needed*/
103104
WS_PARENT_HARD_SYNCH, /**< Synch FHSS with latest synch information*/
104105
WS_EAPOL_PARENT_SYNCH, /**< Broadcast synch with EAPOL parent*/
105106
} ws_parent_synch_e;
106107

108+
107109
static void ws_bootsrap_create_ll_address(uint8_t *ll_address, const uint8_t *mac64)
108110
{
109111
memcpy(ll_address, ADDR_LINK_LOCAL_PREFIX, 8);
@@ -925,7 +927,7 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
925927
// Save route cost for all neighbours
926928
llc_neighbour_req_t neighbor_info;
927929
neighbor_info.neighbor = NULL;
928-
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false, false)) {
930+
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) {
929931
neighbor_info.ws_neighbor->routing_cost = pan_information.routing_cost;
930932
}
931933

@@ -1080,10 +1082,10 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
10801082

10811083
if (cur->ws_info->configuration_learned || cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
10821084
//If we are border router or learned configuration we only update already learned neighbours.
1083-
neighbour_pointer_valid = ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false, true);
1085+
neighbour_pointer_valid = ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false);
10841086

10851087
} else {
1086-
neighbour_pointer_valid = ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, true, true);
1088+
neighbour_pointer_valid = ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, true);
10871089
if (!neighbour_pointer_valid) {
10881090
return;
10891091
}
@@ -1169,7 +1171,7 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
11691171
*/
11701172

11711173
llc_neighbour_req_t neighbor_info;
1172-
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false, false)) {
1174+
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) {
11731175
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index);
11741176
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp);
11751177
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us);
@@ -1399,8 +1401,9 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13991401

14001402
}
14011403

1402-
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast)
1404+
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new)
14031405
{
1406+
neighbor_buffer->ws_neighbor = NULL;
14041407
neighbor_buffer->neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), mac_64, ADDR_802_15_4_LONG);
14051408
if (neighbor_buffer->neighbor) {
14061409
neighbor_buffer->ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor_buffer->neighbor->index);
@@ -1421,27 +1424,6 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
14211424
return false;
14221425
}
14231426

1424-
if (multicast) {
1425-
//for multicast neighbour we must limit if we have already enough information
1426-
if (interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
1427-
//Border router never allocate neighbors by multicast
1428-
return false;
1429-
}
1430-
1431-
uint16_t parent_candidate_size = rpl_control_parent_candidate_list_size(interface, false);
1432-
1433-
//if we have enough candidates at list do not accept new multicast neighbours
1434-
if (parent_candidate_size >= 4) {
1435-
return false;
1436-
}
1437-
1438-
parent_candidate_size = rpl_control_parent_candidate_list_size(interface, true);
1439-
//If we have already enough parent selected Candidates count is bigger tahn 4
1440-
if (parent_candidate_size >= 2) {
1441-
return false;
1442-
}
1443-
}
1444-
14451427
ws_bootstrap_neighbor_table_clean(interface);
14461428

14471429
neighbor_buffer->neighbor = ws_bootstrap_mac_neighbor_add(interface, mac_64);
@@ -1458,6 +1440,24 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
14581440
return true;
14591441
}
14601442

1443+
static bool ws_rpl_dio_new_parent_accept(struct protocol_interface_info_entry *interface)
1444+
{
1445+
uint16_t parent_candidate_size = rpl_control_parent_candidate_list_size(interface, false);
1446+
//TODO check bootstarap state for review
1447+
//if we have enough candidates at list do not accept new multicast neighbours
1448+
if (parent_candidate_size > WS_NEIGHBOUR_MAX_CANDIDATE_PROBE) {
1449+
return false;
1450+
}
1451+
1452+
parent_candidate_size = rpl_control_parent_candidate_list_size(interface, true);
1453+
//If we have already enough parent selected Candidates count is bigger tahn 4
1454+
if (parent_candidate_size >= 2) {
1455+
return false;
1456+
}
1457+
1458+
return true;
1459+
}
1460+
14611461

14621462
static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data)
14631463
{
@@ -2010,6 +2010,48 @@ static void ws_rpl_prefix_callback(prefix_entry_t *prefix, void *handle, uint8_t
20102010
}
20112011
}
20122012

2013+
static bool ws_rpl_new_parent_callback_t(uint8_t *ll_parent_address, void *handle)
2014+
{
2015+
2016+
protocol_interface_info_entry_t *cur = handle;
2017+
if (!cur->rpl_domain || cur->interface_mode != INTERFACE_UP) {
2018+
return false;
2019+
}
2020+
2021+
uint8_t mac64[8];
2022+
memcpy(mac64, ll_parent_address + 8, 8);
2023+
mac64[0] ^= 2;
2024+
llc_neighbour_req_t neigh_buffer;
2025+
if (ws_bootstrap_neighbor_info_request(cur, mac64, &neigh_buffer, false)) {
2026+
return true;
2027+
}
2028+
2029+
if (!ws_rpl_dio_new_parent_accept(cur)) {
2030+
return false;
2031+
}
2032+
2033+
//Discover Multicast temporary entry
2034+
2035+
ws_neighbor_temp_class_t *entry = ws_llc_get_multicast_temp_entry(cur, mac64);
2036+
if (!entry) {
2037+
return false;
2038+
}
2039+
//Create entry
2040+
bool create_ok = ws_bootstrap_neighbor_info_request(cur, mac64, &neigh_buffer, true);
2041+
if (create_ok) {
2042+
ws_neighbor_class_entry_t *ws_neigh = neigh_buffer.ws_neighbor;
2043+
//Copy fhss temporary data
2044+
*ws_neigh = entry->neigh_info_list;
2045+
//ETX Create here
2046+
etx_lqi_dbm_update(cur->id, entry->mpduLinkQuality, entry->signal_dbm, neigh_buffer.neighbor->index);
2047+
mac_neighbor_table_trusted_neighbor(mac_neighbor_info(cur), neigh_buffer.neighbor, true);
2048+
}
2049+
ws_llc_free_multicast_temp_entry(cur, entry);
2050+
2051+
2052+
return create_ok;
2053+
}
2054+
20132055
static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
20142056
{
20152057
tr_debug("RPL Activate");
@@ -2018,7 +2060,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
20182060

20192061
addr_add_router_groups(cur);
20202062
rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, downstream);
2021-
rpl_control_set_callback(protocol_6lowpan_rpl_domain, ws_bootstrap_rpl_callback, ws_rpl_prefix_callback, cur);
2063+
rpl_control_set_callback(protocol_6lowpan_rpl_domain, ws_bootstrap_rpl_callback, ws_rpl_prefix_callback, ws_rpl_new_parent_callback_t, cur);
20222064
// If i am router I Do this
20232065
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, leaf);
20242066
rpl_control_request_parent_link_confirmation(true);
@@ -2520,7 +2562,7 @@ void ws_bootstrap_network_scan_process(protocol_interface_info_entry_t *cur)
25202562

25212563
// Add EAPOL neighbour
25222564
llc_neighbour_req_t neighbor_info;
2523-
if (!ws_bootstrap_neighbor_info_request(cur, cur->ws_info->parent_info.addr, &neighbor_info, true, false)) {
2565+
if (!ws_bootstrap_neighbor_info_request(cur, cur->ws_info->parent_info.addr, &neighbor_info, true)) {
25242566
return;
25252567
}
25262568

source/6LoWPAN/ws/ws_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,5 @@ uint32_t ws_common_version_timeout_get(uint8_t config);
143143
#define ws_common_etx_validate(interface, neigh) ((void) 0)
144144
#define ws_common_negative_aro_mark(interface, eui64)(false)
145145

146-
147146
#endif //HAVE_WS
148147
#endif //WS_COMMON_H_

source/6LoWPAN/ws/ws_llc.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct mlme_security_s;
3030
struct ws_hopping_schedule_s;
3131
struct ws_neighbor_class_entry;
3232
struct mac_neighbor_table_entry;
33+
struct ws_neighbor_temp_class_s;
3334

3435

3536
/**
@@ -73,10 +74,23 @@ typedef struct asynch_request_s {
7374
* @brief LLC neighbour info request parameters
7475
*/
7576
typedef struct llc_neighbour_req {
76-
struct mac_neighbor_table_entry *neighbor; /**< Generic Link Layer Neighbor information entry. */
77-
struct ws_neighbor_class_entry *ws_neighbor; /**< Wi-sun Neighbor information entry. */
77+
struct mac_neighbor_table_entry *neighbor; /**< Generic Link Layer Neighbor information entry. */
78+
struct ws_neighbor_class_entry *ws_neighbor; /**< Wi-sun Neighbor information entry. */
7879
} llc_neighbour_req_t;
7980

81+
/**
82+
* Neighbor temporary structure for storage FHSS data before create a real Neighbour info
83+
*/
84+
typedef struct ws_neighbor_temp_class_s {
85+
struct ws_neighbor_class_entry neigh_info_list; /*!< Allocated hopping info array*/
86+
uint8_t mac64[8];
87+
uint8_t mpduLinkQuality;
88+
int8_t signal_dbm;
89+
ns_list_link_t link;
90+
} ws_neighbor_temp_class_t;
91+
92+
typedef NS_LIST_HEAD(ws_neighbor_temp_class_t, link) ws_neighbor_temp_list_t;
93+
8094
/**
8195
* @brief ws_asynch_ind ws asynch data indication
8296
* @param interface Interface pointer
@@ -99,12 +113,11 @@ typedef void ws_asynch_confirm(struct protocol_interface_info_entry *interface,
99113
* @param mac_64 Neighbor 64-bit address
100114
* @param neighbor_buffer Buffer where neighbor infor is buffered
101115
* @param request_new true if is possible to allocate new entry
102-
* @param multicast true if packet is multicast
103116
*
104117
* @return true when neighbor info is available
105118
* @return false when no neighbor info
106119
*/
107-
typedef bool ws_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast);
120+
typedef bool ws_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new);
108121

109122
/**
110123
* @brief ws_llc_create ws LLC module create
@@ -204,6 +217,8 @@ void ws_llc_set_pan_information_pointer(struct protocol_interface_info_entry *in
204217
*/
205218
void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interface, struct ws_hopping_schedule_s *hopping_schedule);
206219

220+
ws_neighbor_temp_class_t *ws_llc_get_multicast_temp_entry(struct protocol_interface_info_entry *interface, const uint8_t *mac64);
207221

222+
void ws_llc_free_multicast_temp_entry(struct protocol_interface_info_entry *interface, ws_neighbor_temp_class_t *neighbor);
208223

209224
#endif /* WS_LLC_H_ */

0 commit comments

Comments
 (0)