@@ -909,17 +909,17 @@ static void ws_bootstrap_ll_address_validate(struct protocol_interface_info_entr
909
909
* \return 0x0000 address unknown or other error
910
910
* \return 0x0001 no ETX statistics on this interface
911
911
*/
912
- uint16_t ws_etx_read (protocol_interface_info_entry_t * interface , addrtype_t addr_type , const uint8_t * addr_ptr )
912
+ uint16_t ws_local_etx_read (protocol_interface_info_entry_t * interface , addrtype_t addr_type , const uint8_t * mac_adddress )
913
913
{
914
914
uint16_t etx ;
915
915
916
- if (!addr_ptr || !interface ) {
916
+ if (!mac_adddress || !interface ) {
917
917
return 0 ;
918
918
}
919
919
920
920
uint8_t attribute_index ;
921
921
922
- mac_neighbor_table_entry_t * mac_neighbor = mac_neighbor_table_address_discover (mac_neighbor_info (interface ), addr_ptr + PAN_ID_LEN , addr_type );
922
+ mac_neighbor_table_entry_t * mac_neighbor = mac_neighbor_table_address_discover (mac_neighbor_info (interface ), mac_adddress , addr_type );
923
923
if (!mac_neighbor ) {
924
924
return 0xffff ;
925
925
}
@@ -933,6 +933,12 @@ uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr
933
933
934
934
etx = etx_local_etx_read (interface -> id , attribute_index );
935
935
936
+ // if we have a measurement ready then we will check the RSL validity
937
+ if (etx != 0xffff && !ws_neighbour -> candidate_parent ) {
938
+ // RSL value measured is lower than acceptable ETX will be given as MAX
939
+ return WS_ETX_MAX << 1 ; // We use 8 bit fraction and ETX is usually 7 bit fraction
940
+ }
941
+
936
942
// If we dont have valid ETX for children we assume good ETX.
937
943
// After enough packets is sent to children real calculated ETX is given.
938
944
// This might result in ICMP source route errors returned to Border router causing secondary route uses
@@ -942,6 +948,15 @@ uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr
942
948
943
949
return etx ;
944
950
}
951
+
952
+ uint16_t ws_etx_read (protocol_interface_info_entry_t * interface , addrtype_t addr_type , const uint8_t * addr_ptr )
953
+ {
954
+ if (!addr_ptr || !interface ) {
955
+ return 0 ;
956
+ }
957
+ return ws_local_etx_read (interface , addr_type , addr_ptr + PAN_ID_LEN );
958
+ }
959
+
945
960
bool ws_bootstrap_nd_ns_transmit (protocol_interface_info_entry_t * cur , ipv6_neighbour_t * entry , bool unicast , uint8_t seq )
946
961
{
947
962
(void )cur ;
@@ -3001,17 +3016,17 @@ static bool ws_rpl_new_parent_callback(uint8_t *ll_parent_address, void *handle,
3001
3016
return false;
3002
3017
}
3003
3018
// +2 Is for PAN ID space
3004
- memcpy (mac64 + 2 , replacing + 8 , 8 );
3005
- mac64 [2 ] ^= 2 ;
3019
+ memcpy (mac64 , replacing + 8 , 8 );
3020
+ mac64 [0 ] ^= 2 ;
3006
3021
3007
- if (ws_etx_read (cur , ADDR_802_15_4_LONG , mac64 ) == 0xffff ) {
3008
- //Not proped yet because ETX is 0xffff
3022
+ if (ws_local_etx_read (cur , ADDR_802_15_4_LONG , mac64 ) == 0xffff ) {
3023
+ //Not probed yet because ETX is 0xffff
3009
3024
return false;
3010
3025
}
3011
3026
3012
3027
uint16_t etx = 0 ;
3013
3028
if (neigh_buffer .neighbor ) {
3014
- etx = etx_local_etx_read (cur -> id , neigh_buffer .neighbor -> index );
3029
+ etx = ws_local_etx_read (cur , ADDR_802_15_4_LONG , neigh_buffer .neighbor -> mac64 );
3015
3030
}
3016
3031
3017
3032
// Accept now only better one's when max candidates selected and max candidate list size is reached
@@ -3554,7 +3569,7 @@ static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entr
3554
3569
return 0xffff ;
3555
3570
}
3556
3571
3557
- uint16_t etx = etx_local_etx_read (cur -> id , mac_neighbor -> index );
3572
+ uint16_t etx = ws_local_etx_read (cur , ADDR_802_15_4_LONG , mac_neighbor -> mac64 );
3558
3573
if (etx == 0 ) {
3559
3574
etx = WS_ETX_MAX ; //SET maximum value here if ETX is unknown
3560
3575
} else {
@@ -4254,7 +4269,7 @@ int ws_bootstrap_neighbor_info_get(protocol_interface_info_entry_t *cur, ws_neig
4254
4269
neighbor_ptr [count ].rsl_out = ws_neighbor_class_rsl_out_get (ws_neighbor );
4255
4270
4256
4271
// ETX is shown calculated as 8 bit integer, but more common way is to use 7 bit such that 128 means ETX:1.0
4257
- neighbor_ptr [count ].etx = etx_local_etx_read (cur -> id , mac_entry -> index );
4272
+ neighbor_ptr [count ].etx = ws_local_etx_read (cur , ADDR_802_15_4_LONG , mac_entry -> mac64 );
4258
4273
if (neighbor_ptr [count ].etx != 0xffff ) {
4259
4274
neighbor_ptr [count ].etx = neighbor_ptr [count ].etx >> 1 ;
4260
4275
}
0 commit comments