|
29 | 29 | #include "6LoWPAN/MAC/mpx_api.h"
|
30 | 30 | #include "6LoWPAN/MAC/mac_ie_lib.h"
|
31 | 31 | #include "6LoWPAN/ws/ws_common_defines.h"
|
| 32 | +#include "6LoWPAN/ws/ws_common.h" |
32 | 33 | #include "6LoWPAN/ws/ws_ie_lib.h"
|
33 | 34 | #include "6LoWPAN/ws/ws_llc.h"
|
34 | 35 | #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 |
35 | 40 |
|
36 | 41 | #define TRACE_GROUP "wllc"
|
37 | 42 |
|
@@ -402,8 +407,34 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
|
402 | 407 | // NO UTT header
|
403 | 408 | return;
|
404 | 409 | }
|
| 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 | + |
405 | 419 | 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 | + } |
407 | 438 |
|
408 | 439 |
|
409 | 440 | //Discover 2 Payload Heder
|
@@ -876,3 +907,4 @@ void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interf
|
876 | 907 | }
|
877 | 908 | base->ie_params.hopping_schedule = hopping_schedule;
|
878 | 909 | }
|
| 910 | +#endif |
0 commit comments