Skip to content

Commit c771df0

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
LLC update UTT / BT information to ws neighbor and refresh mac neighbor
1 parent a43f6ad commit c771df0

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@
2929
#include "6LoWPAN/MAC/mpx_api.h"
3030
#include "6LoWPAN/MAC/mac_ie_lib.h"
3131
#include "6LoWPAN/ws/ws_common_defines.h"
32+
#include "6LoWPAN/ws/ws_common.h"
3233
#include "6LoWPAN/ws/ws_ie_lib.h"
3334
#include "6LoWPAN/ws/ws_llc.h"
3435
#include "6LoWPAN/ws/ws_mpx_header.h"
36+
#include "6LoWPAN/ws/ws_neighbour_class.h"
37+
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
38+
39+
#ifdef HAVE_WS
3540

3641
#define TRACE_GROUP "wllc"
3742

@@ -402,8 +407,34 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
402407
// NO UTT header
403408
return;
404409
}
410+
protocol_interface_info_entry_t *interface = base->interface_ptr;
411+
412+
ws_neighbour_class_entry_t * ws_neighbor = NULL;
413+
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, data->SrcAddr, data->SrcAddrMode);
414+
if (neighbor) {
415+
ws_neighbor = ws_neighbour_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
416+
}
417+
418+
405419
const uint8_t *ptr = utt_ie.content_ptr;
406-
message_type = *ptr & 0x0f;
420+
message_type = *ptr++ & 0x0f;
421+
if (ws_neighbor) {
422+
ws_neighbor->fhhs_data.utt_timestamp = data->timestamp;
423+
ws_neighbor->fhhs_data.ufsi = common_read_24_bit_inverse(ptr);
424+
//Update BT if it is part of message
425+
if (5 == mac_ie_header_sub_id_discover(ie_ext->headerIeList, ie_ext->headerIeListLength, &utt_ie, WH_IE_BT_TYPE)) {
426+
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);
430+
}
431+
432+
//Refresh Neighbor if unicast
433+
if (message_type == WS_FT_DATA && data->DstAddrMode && addr_check_broadcast(data->DstAddr, data->DstAddrMode)) {
434+
tr_debug("Refresh neigh index %u", neighbor->index);
435+
mac_neighbor_table_neighbor_refresh(interface->mac_parameters->mac_neighbor_table, neighbor, neighbor->link_lifetime);
436+
}
437+
}
407438

408439

409440
//Discover 2 Payload Heder
@@ -876,3 +907,4 @@ void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interf
876907
}
877908
base->ie_params.hopping_schedule = hopping_schedule;
878909
}
910+
#endif

0 commit comments

Comments
 (0)