Skip to content

Commit e6bac6a

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
Rename and refactor structures and function names.
1 parent b037628 commit e6bac6a

File tree

13 files changed

+85
-81
lines changed

13 files changed

+85
-81
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818

19+
1920
#include <string.h>
2021
#include "nsconfig.h"
2122
#include "ns_types.h"
@@ -35,7 +36,6 @@
3536
#include "6LoWPAN/ws/ws_common_defines.h"
3637
#include "6LoWPAN/ws/ws_common.h"
3738
#include "6LoWPAN/ws/ws_bootstrap.h"
38-
#include "6LoWPAN/ws/ws_neighbour_class.h"
3939
#include "RPL/rpl_control.h"
4040
#include "RPL/rpl_data.h"
4141
#include "Common_Protocols/icmpv6.h"
@@ -44,6 +44,7 @@
4444
#include "Service_Libs/Trickle/trickle.h"
4545
#include "6LoWPAN/ws/ws_common_defines.h"
4646
#include "6LoWPAN/ws/ws_llc.h"
47+
#include "6LoWPAN/ws/ws_neighbor_class.h"
4748
#include "6LoWPAN/lowpan_adaptation_interface.h"
4849
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
4950
#include "platform/topo_trace.h"
@@ -261,7 +262,7 @@ static bool ws_bootstrap_network_name_matches(const struct mcps_data_ie_list *ie
261262
return true;
262263
}
263264

264-
static bool ws_bootstrap_unicast_schedule_read(uint8_t *ptr, uint16_t length, ws_hoopping_schedule_t *uc_hopping)
265+
static bool ws_bootstrap_unicast_schedule_read(uint8_t *ptr, uint16_t length, ws_hopping_schedule_t *uc_hopping)
265266
{
266267
mac_nested_payload_IE_t nested_payload_ie;
267268
nested_payload_ie.id = WP_PAYLOAD_IE_US_TYPE;
@@ -358,7 +359,7 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
358359
}
359360

360361
ws_pan_information_t pan_information;
361-
ws_hoopping_schedule_t hopping_schedule = { 0 };
362+
ws_hopping_schedule_t hopping_schedule = { 0 };
362363

363364
if (!ws_bootstrap_pan_information_read(ie_ext->payloadIeList, ie_ext->payloadIeListLength, &pan_information)) {
364365
// Corrupted
@@ -383,15 +384,15 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
383384
if (!neighbor) {
384385
return;
385386
}
386-
ws_neighbour_class_entry_t *ws_neighbor = ws_neighbour_class_entry_get(&cur->ws_info->neighbor_storage, neighbor->index);
387+
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, neighbor->index);
387388
if (!ws_neighbor) {
388389
return;
389390
}
390391

391-
ws_neighbor->fhhs_data.utt_timestamp = data->timestamp;
392-
ws_neighbor->fhhs_data.ufsi = ufsi;
393-
ws_neighbor->fhhs_data.channel_function = hopping_schedule.channel_function;
394-
ws_neighbor->fhhs_data.unicast_dwell = hopping_schedule.fhss_uc_dwell_interval;
392+
ws_neighbor->fhss_data.utt_timestamp = data->timestamp;
393+
ws_neighbor->fhss_data.ufsi = ufsi;
394+
ws_neighbor->fhss_data.channel_function = hopping_schedule.channel_function;
395+
ws_neighbor->fhss_data.unicast_dwell = hopping_schedule.fhss_uc_dwell_interval;
395396

396397

397398

@@ -439,7 +440,7 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
439440
}
440441

441442
uint_fast24_t ufsi;
442-
ws_hoopping_schedule_t hopping_schedule = { 0 };
443+
ws_hopping_schedule_t hopping_schedule = { 0 };
443444

444445
if (!ws_bootstrap_ufsi_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ufsi)) {
445446
// Corrupted
@@ -458,15 +459,15 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
458459
if (!neighbor) {
459460
return;
460461
}
461-
ws_neighbour_class_entry_t *ws_neighbor = ws_neighbour_class_entry_get(&cur->ws_info->neighbor_storage, neighbor->index);
462+
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, neighbor->index);
462463
if (!ws_neighbor) {
463464
return;
464465
}
465466

466-
ws_neighbor->fhhs_data.utt_timestamp = data->timestamp;
467-
ws_neighbor->fhhs_data.ufsi = ufsi;
468-
ws_neighbor->fhhs_data.channel_function = hopping_schedule.channel_function;
469-
ws_neighbor->fhhs_data.unicast_dwell = hopping_schedule.fhss_uc_dwell_interval;
467+
ws_neighbor->fhss_data.utt_timestamp = data->timestamp;
468+
ws_neighbor->fhss_data.ufsi = ufsi;
469+
ws_neighbor->fhss_data.channel_function = hopping_schedule.channel_function;
470+
ws_neighbor->fhss_data.unicast_dwell = hopping_schedule.fhss_uc_dwell_interval;
470471

471472
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_advertisement);
472473
}
@@ -537,7 +538,7 @@ static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_pt
537538
mac_helper_devicetable_remove(cur->mac_api, entry_ptr->index);
538539

539540
//Remove WS neighbor data
540-
ws_neighbour_class_entry_remove(&cur->ws_info->neighbor_storage, entry_ptr->index);
541+
ws_neighbor_class_entry_remove(&cur->ws_info->neighbor_storage, entry_ptr->index);
541542
topo_trace(TOPOLOGY_MLE, entry_ptr->ext64, TOPO_REMOVE);
542543

543544
//TODO Remove ETX neighbor
@@ -566,7 +567,7 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
566567
{
567568
int ret_val = 0;
568569

569-
ws_neighbour_class_t neigh_info;
570+
ws_neighbor_class_t neigh_info;
570571
neigh_info.neigh_info_list = NULL;
571572
neigh_info.list_size = 0;
572573
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
@@ -599,7 +600,7 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
599600
return -3;
600601
}
601602

602-
if (!ws_neighbour_class_alloc(&neigh_info, buffer.device_decription_table_size)) {
603+
if (!ws_neighbor_class_alloc(&neigh_info, buffer.device_decription_table_size)) {
603604
ret_val = -1;
604605
goto init_fail;
605606
}
@@ -653,7 +654,7 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
653654
init_fail:
654655
lowpan_adaptation_interface_mpx_register(interface_id, NULL, 0);
655656
mac_neighbor_table_delete(cur->mac_parameters->mac_neighbor_table);
656-
ws_neighbour_class_dealloc(&neigh_info);
657+
ws_neighbor_class_dealloc(&neigh_info);
657658
ws_llc_delete(cur);
658659
return ret_val;
659660
}

source/6LoWPAN/ws/ws_common.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
#ifndef WS_COMMON_H_
1818
#define WS_COMMON_H_
1919

20-
#include <6LoWPAN/ws/ws_neighbour_class.h>
20+
2121
#include "ns_types.h"
2222
#include "fhss_api.h"
2323
#include "fhss_config.h"
2424
#include "6LoWPAN/ws/ws_common_defines.h"
25+
#include "6LoWPAN/ws/ws_neighbor_class.h"
2526

2627
struct ws_pan_information_s;
27-
struct ws_neighbour_class_s;
28+
struct ws_neighbor_class_s;
2829

2930
typedef struct parent_info_s {
3031
uint16_t pan_id; /**< PAN ID */
@@ -47,8 +48,8 @@ typedef struct ws_info_s {
4748
uint8_t gtkhash[32];
4849

4950
struct ws_pan_information_s pan_configuration;
50-
ws_hoopping_schedule_t hopping_schdule;
51-
struct ws_neighbour_class_s neighbor_storage;
51+
ws_hopping_schedule_t hopping_schdule;
52+
struct ws_neighbor_class_s neighbor_storage;
5253
struct fhss_timer *fhss_timer_ptr; // Platform adaptation for FHSS timers.
5354
} ws_info_t;
5455

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ typedef struct ws_pan_information_s {
6464
} ws_pan_information_t;
6565

6666
/**
67-
* @brief ws_hoopping_schedule_t Chanel hopping schedule information
67+
* @brief ws_hopping_schedule_t Chanel hopping schedule information
6868
*/
69-
typedef struct ws_hoopping_schedule_s {
69+
typedef struct ws_hopping_schedule_s {
7070
uint8_t fhss_uc_dwell_interval;
7171
uint8_t fhss_bc_dwell_interval;
7272
uint8_t regulatory_domain; /**< PHY regulatory domain default to "KR" 0x09 */
@@ -83,7 +83,7 @@ typedef struct ws_hoopping_schedule_s {
8383
uint32_t fhss_broadcast_interval;
8484
uint32_t channel_mask[8];
8585
uint_fast24_t ch0_freq; // Default should be derived from regulatory domain
86-
} ws_hoopping_schedule_t;
86+
} ws_hopping_schedule_t;
8787

8888

8989
#define MPX_KEY_MANAGEMENT_ENC_USER_ID 0x0001 /**< MPX Key management user ID */

source/6LoWPAN/ws/ws_ie_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static uint8_t *ws_wh_header_base_write(uint8_t *ptr, uint16_t length, uint8_t t
3232
return ptr;
3333
}
3434

35-
uint16_t ws_wp_nested_hopping_schedule_length(struct ws_hoopping_schedule_s *hopping_schedule, bool unicast_schedule)
35+
uint16_t ws_wp_nested_hopping_schedule_length(struct ws_hopping_schedule_s *hopping_schedule, bool unicast_schedule)
3636
{
3737
uint16_t length;
3838
if (unicast_schedule) {
@@ -122,7 +122,7 @@ uint8_t *ws_wp_base_write(uint8_t *ptr, uint16_t length)
122122
return mac_ie_payload_base_write(ptr, WS_WP_NESTED_IE, length);
123123
}
124124

125-
uint8_t *ws_wp_nested_hopping_schedule_write(uint8_t *ptr,struct ws_hoopping_schedule_s *hopping_schedule, bool unicast_schedule)
125+
uint8_t *ws_wp_nested_hopping_schedule_write(uint8_t *ptr,struct ws_hopping_schedule_s *hopping_schedule, bool unicast_schedule)
126126
{
127127
//Calculate length
128128
uint16_t length = ws_wp_nested_hopping_schedule_length(hopping_schedule, unicast_schedule);

source/6LoWPAN/ws/ws_ie_lib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ uint8_t *ws_wh_vh_write(uint8_t *ptr, uint8_t *vendor_header, uint8_t vendor_hea
2929

3030
/* WS_WP_NESTED PAYLOD IE */
3131
uint8_t *ws_wp_base_write(uint8_t *ptr, uint16_t length);
32-
uint8_t *ws_wp_nested_hopping_schedule_write(uint8_t *ptr,struct ws_hoopping_schedule_s *hopping_schedule, bool unicast_schedule);
32+
uint8_t *ws_wp_nested_hopping_schedule_write(uint8_t *ptr,struct ws_hopping_schedule_s *hopping_schedule, bool unicast_schedule);
3333
uint8_t *ws_wp_nested_vp_write(uint8_t *ptr, uint8_t * vendor_payload, uint16_t vendor_payload_length);
3434
uint8_t *ws_wp_nested_pan_info_write(uint8_t *ptr, struct ws_pan_information_s *pan_congiguration);
3535
uint8_t *ws_wp_nested_netname_write(uint8_t *ptr, uint8_t *network_name, uint8_t network_name_length);
3636
uint8_t *ws_wp_nested_pan_ver_write(uint8_t *ptr, struct ws_pan_information_s *pan_congiguration);
3737
uint8_t *ws_wp_nested_gtkhash_write(uint8_t *ptr, uint8_t *gtkhash, uint8_t gtkhash_length);
38-
uint16_t ws_wp_nested_hopping_schedule_length(struct ws_hoopping_schedule_s *hopping_schedule, bool unicast_schedule);
38+
uint16_t ws_wp_nested_hopping_schedule_length(struct ws_hopping_schedule_s *hopping_schedule, bool unicast_schedule);
3939

4040
#endif /* WS_IE_LIB_H_ */

source/6LoWPAN/ws/ws_llc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct mcps_data_ie_list;
2424
struct channel_list_s;
2525
struct ws_pan_information_s;
2626
struct mlme_security_s;
27-
struct ws_hoopping_schedule_s;
27+
struct ws_hopping_schedule_s;
2828

2929

3030
/**
@@ -174,7 +174,7 @@ void ws_llc_set_pan_information_pointer(struct protocol_interface_info_entry *in
174174
* @param hopping_schedule pointer to Channel hopping schedule
175175
*
176176
*/
177-
void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interface, struct ws_hoopping_schedule_s *hopping_schedule);
177+
void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interface, struct ws_hopping_schedule_s *hopping_schedule);
178178

179179

180180

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
1819
#include "nsconfig.h"
1920
#include <string.h>
2021
#include "ns_types.h"
@@ -33,7 +34,7 @@
3334
#include "6LoWPAN/ws/ws_ie_lib.h"
3435
#include "6LoWPAN/ws/ws_llc.h"
3536
#include "6LoWPAN/ws/ws_mpx_header.h"
36-
#include "6LoWPAN/ws/ws_neighbour_class.h"
37+
#include "6LoWPAN/ws/ws_neighbor_class.h"
3738
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
3839

3940
#ifdef HAVE_WS
@@ -64,7 +65,7 @@ typedef struct {
6465
uint8_t vendor_header_length; /**< Vendor spesific header length */
6566
uint8_t gtkhash_length; /**< GTK hash length */
6667
ws_pan_information_t *pan_congiguration; /**< Pan configururation */
67-
struct ws_hoopping_schedule_s *hopping_schedule;/**< Channel hopping schedule */
68+
struct ws_hopping_schedule_s *hopping_schedule;/**< Channel hopping schedule */
6869
uint8_t *gtkhash; /**< Pointer to GTK HASH user must give pointer which include 4 64-bit HASH array */
6970
uint8_t *network_name; /**< Network name */
7071
uint8_t *vendor_header_data; /**< Vendor spesific header data */
@@ -409,24 +410,24 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
409410
}
410411
protocol_interface_info_entry_t *interface = base->interface_ptr;
411412

412-
ws_neighbour_class_entry_t * ws_neighbor = NULL;
413+
ws_neighbor_class_entry_t * ws_neighbor = NULL;
413414
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, data->SrcAddr, data->SrcAddrMode);
414415
if (neighbor) {
415-
ws_neighbor = ws_neighbour_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
416+
ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
416417
}
417418

418419

419420
const uint8_t *ptr = utt_ie.content_ptr;
420421
message_type = *ptr++ & 0x0f;
421422
if (ws_neighbor) {
422-
ws_neighbor->fhhs_data.utt_timestamp = data->timestamp;
423-
ws_neighbor->fhhs_data.ufsi = common_read_24_bit_inverse(ptr);
423+
ws_neighbor->fhss_data.utt_timestamp = data->timestamp;
424+
ws_neighbor->fhss_data.ufsi = common_read_24_bit_inverse(ptr);
424425
//Update BT if it is part of message
425426
if (5 == mac_ie_header_sub_id_discover(ie_ext->headerIeList, ie_ext->headerIeListLength, &utt_ie, WH_IE_BT_TYPE)) {
426427
ptr = utt_ie.content_ptr;
427-
ws_neighbor->fhhs_data.bt_timestamp = data->timestamp;
428-
ws_neighbor->fhhs_data.broadcast_slot_number = common_read_16_bit_inverse(ptr);
429-
ws_neighbor->fhhs_data.broadcast_interval = common_read_24_bit_inverse(ptr + 2);
428+
ws_neighbor->fhss_data.bt_timestamp = data->timestamp;
429+
ws_neighbor->fhss_data.broadcast_slot_number = common_read_16_bit_inverse(ptr);
430+
ws_neighbor->fhss_data.broadcast_interval = common_read_24_bit_inverse(ptr + 2);
430431
}
431432

432433
//Refresh Neighbor if unicast
@@ -900,7 +901,7 @@ void ws_llc_set_pan_information_pointer(struct protocol_interface_info_entry *in
900901
base->ie_params.pan_congiguration = pan_information_pointer;
901902
}
902903

903-
void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interface, struct ws_hoopping_schedule_s *hopping_schedule)
904+
void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interface, struct ws_hopping_schedule_s *hopping_schedule)
904905
{
905906
llc_data_base_t *base = ws_llc_discover_by_interface(interface);
906907
if (!base) {

source/6LoWPAN/ws/ws_neighbour_class.c renamed to source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,54 @@
1515
* limitations under the License.
1616
*/
1717

18+
1819
#include "nsconfig.h"
1920
#include <string.h>
2021
#include "ns_types.h"
2122
#include "ns_list.h"
2223
#include "ns_trace.h"
2324
#include "nsdynmemLIB.h"
24-
#include "6LoWPAN/ws/ws_neighbour_class.h"
25+
#include "6LoWPAN/ws/ws_neighbor_class.h"
2526

26-
bool ws_neighbour_class_alloc(ws_neighbour_class_t *class_data, uint8_t list_size)
27+
bool ws_neighbor_class_alloc(ws_neighbor_class_t *class_data, uint8_t list_size)
2728
{
2829

29-
class_data->neigh_info_list = ns_dyn_mem_alloc(sizeof(ws_neighbour_class_entry_t) * list_size);
30+
class_data->neigh_info_list = ns_dyn_mem_alloc(sizeof(ws_neighbor_class_entry_t) * list_size);
3031
if (!class_data->neigh_info_list) {
3132
return false;
3233
}
3334

3435
class_data->list_size = list_size;
35-
ws_neighbour_class_entry_t * list_ptr = class_data->neigh_info_list;
36+
ws_neighbor_class_entry_t * list_ptr = class_data->neigh_info_list;
3637
for (uint8_t i = 0; i< list_size; i++) {
37-
memset(list_ptr, 0, sizeof(ws_neighbour_class_entry_t));
38+
memset(list_ptr, 0, sizeof(ws_neighbor_class_entry_t));
3839
list_ptr++;
3940
}
4041
return true;
4142
}
4243

4344

44-
void ws_neighbour_class_dealloc(ws_neighbour_class_t *class_data)
45+
void ws_neighbor_class_dealloc(ws_neighbor_class_t *class_data)
4546
{
4647
ns_dyn_mem_free(class_data->neigh_info_list);
4748
class_data->neigh_info_list = NULL;
4849
class_data->list_size = 0;
4950
}
5051

51-
ws_neighbour_class_entry_t * ws_neighbour_class_entry_get(ws_neighbour_class_t *class_data, uint8_t attribute_index)
52+
ws_neighbor_class_entry_t * ws_neighbor_class_entry_get(ws_neighbor_class_t *class_data, uint8_t attribute_index)
5253
{
5354
if (!class_data->neigh_info_list || attribute_index >= class_data->list_size) {
5455
return NULL;
5556
}
5657

57-
ws_neighbour_class_entry_t *entry = class_data->neigh_info_list + attribute_index;
58+
ws_neighbor_class_entry_t *entry = class_data->neigh_info_list + attribute_index;
5859
return entry;
5960
}
6061

61-
void ws_neighbour_class_entry_remove(ws_neighbour_class_t *class_data, uint8_t attribute_index)
62+
void ws_neighbor_class_entry_remove(ws_neighbor_class_t *class_data, uint8_t attribute_index)
6263
{
63-
ws_neighbour_class_entry_t *entry = ws_neighbour_class_entry_get(class_data, attribute_index);
64+
ws_neighbor_class_entry_t *entry = ws_neighbor_class_entry_get(class_data, attribute_index);
6465
if (entry) {
65-
memset(entry, 0, sizeof(ws_neighbour_class_entry_t));
66+
memset(entry, 0, sizeof(ws_neighbor_class_entry_t));
6667
}
6768
}

0 commit comments

Comments
 (0)