@@ -794,7 +794,7 @@ uint32_t dhcp_service_send_req(uint16_t instance_id, uint8_t options, void *ptr,
794794 msg_tr_ptr -> socket = dhcp_service -> dhcp_client_socket ;
795795 msg_tr_ptr -> recv_resp_cb = receive_resp_cb ;
796796 msg_tr_ptr -> delayed_tx = delay_tx ;
797- msg_tr_ptr -> first_transmit_time = protocol_core_monotonic_time ;
797+ msg_tr_ptr -> first_transmit_time = 0 ;
798798 dhcp_tr_set_retry_timers (msg_tr_ptr , msg_tr_ptr -> msg_ptr [0 ]);
799799 common_write_24_bit (msg_tr_ptr -> msg_tr_id , & msg_tr_ptr -> msg_ptr [1 ]);
800800
@@ -852,8 +852,9 @@ void dhcp_service_send_message(msg_tr_t *msg_tr_ptr)
852852 const uint32_t address_pref = SOCKET_IPV6_PREFER_SRC_6LOWPAN_SHORT ;
853853 dhcp_options_msg_t elapsed_time ;
854854
855- if (libdhcpv6_message_option_discover ((msg_tr_ptr -> msg_ptr + 4 ), (msg_tr_ptr -> msg_len - 4 ), DHCPV6_ELAPSED_TIME_OPTION , & elapsed_time ) == 0 &&
855+ if (msg_tr_ptr -> first_transmit_time && libdhcpv6_message_option_discover ((msg_tr_ptr -> msg_ptr + 4 ), (msg_tr_ptr -> msg_len - 4 ), DHCPV6_ELAPSED_TIME_OPTION , & elapsed_time ) == 0 &&
856856 elapsed_time .len == 2 ) {
857+
857858 uint32_t t = protocol_core_monotonic_time - msg_tr_ptr -> first_transmit_time ; // time in 1/10s ticks
858859 uint16_t cs ;
859860 if (t > 0xffff / 10 ) {
@@ -926,6 +927,10 @@ void dhcp_service_send_message(msg_tr_t *msg_tr_ptr)
926927 int16_t tc = 0 ;
927928 socket_setsockopt (msg_tr_ptr -> socket , SOCKET_IPPROTO_IPV6 , SOCKET_IPV6_TCLASS , & tc , sizeof (tc ));
928929 retval = socket_sendto (msg_tr_ptr -> socket , & msg_tr_ptr -> addr , msg_tr_ptr -> msg_ptr , msg_tr_ptr -> msg_len );
930+ if (msg_tr_ptr -> first_transmit_time == 0 && retval == 0 ) {
931+ //Mark first pushed message timestamp
932+ msg_tr_ptr -> first_transmit_time = protocol_core_monotonic_time ? protocol_core_monotonic_time : 1 ;
933+ }
929934 }
930935 }
931936 if (retval != 0 ) {
0 commit comments