mirror of https://github.com/ARMmbed/mbed-os.git
Compare the intermediate timestamps as well
parent
2229a2f2f5
commit
6192ed1480
|
@ -15,7 +15,7 @@ set(unittest-sources
|
|||
../features/frameworks/nanostack-libservice/source/libip6string/ip6tos.c
|
||||
../features/frameworks/nanostack-libservice/source/libip4string/stoip4.c
|
||||
../features/frameworks/nanostack-libservice/source/libip6string/stoip6.c
|
||||
../features/frameworks/nanostack-libservice/source/libBits/common_functions.c
|
||||
../features/frameworks/nanostack-libservice/source/libBits/common_functions.c
|
||||
)
|
||||
|
||||
set(unittest-test-sources
|
||||
|
@ -30,6 +30,7 @@ set(unittest-test-sources
|
|||
stubs/EventFlags_stub.cpp
|
||||
stubs/stoip4_stub.c
|
||||
stubs/ip4tos_stub.c
|
||||
stubs/Kernel_stub.cpp
|
||||
)
|
||||
|
||||
set(MBEDTLS_USER_CONFIG_FILE_PATH "\"../UNITTESTS/features/netsocket/DTLSSocket/dtls_test_config.h\"")
|
||||
|
|
|
@ -14,7 +14,7 @@ set(unittest-sources
|
|||
../features/frameworks/nanostack-libservice/source/libip6string/ip6tos.c
|
||||
../features/frameworks/nanostack-libservice/source/libip4string/stoip4.c
|
||||
../features/frameworks/nanostack-libservice/source/libip6string/stoip6.c
|
||||
../features/frameworks/nanostack-libservice/source/libBits/common_functions.c
|
||||
../features/frameworks/nanostack-libservice/source/libBits/common_functions.c
|
||||
)
|
||||
|
||||
set(unittest-test-sources
|
||||
|
@ -29,6 +29,7 @@ set(unittest-test-sources
|
|||
stubs/EventFlags_stub.cpp
|
||||
stubs/stoip4_stub.c
|
||||
stubs/ip4tos_stub.c
|
||||
stubs/Kernel_stub.cpp
|
||||
)
|
||||
|
||||
set(MBEDTLS_USER_CONFIG_FILE_PATH "\"../UNITTESTS/features/netsocket/DTLSSocketWrapper/dtls_test_config.h\"")
|
||||
|
|
|
@ -2,16 +2,18 @@
|
|||
#include "platform/Callback.h"
|
||||
#include "drivers/Timer.h"
|
||||
#include "events/mbed_events.h"
|
||||
#include "rtos/Kernel.h"
|
||||
|
||||
#if defined(MBEDTLS_SSL_CLI_C)
|
||||
|
||||
DTLSSocketWrapper::DTLSSocketWrapper(Socket *transport, const char *hostname, control_transport control)
|
||||
: TLSSocketWrapper(transport, hostname, control)
|
||||
DTLSSocketWrapper::DTLSSocketWrapper(Socket *transport, const char *hostname, control_transport control) :
|
||||
TLSSocketWrapper(transport, hostname, control),
|
||||
_int_ms_tick(0),
|
||||
_timer_event_id(0),
|
||||
_timer_expired(false)
|
||||
{
|
||||
mbedtls_ssl_conf_transport( get_ssl_config(), MBEDTLS_SSL_TRANSPORT_DATAGRAM);
|
||||
mbedtls_ssl_set_timer_cb( get_ssl_context(), this, timing_set_delay, timing_get_delay);
|
||||
_timer_event_id = 0;
|
||||
_timer_expired = false;
|
||||
}
|
||||
|
||||
void DTLSSocketWrapper::timing_set_delay(void *ctx, uint32_t int_ms, uint32_t fin_ms)
|
||||
|
@ -28,6 +30,7 @@ void DTLSSocketWrapper::timing_set_delay(void *ctx, uint32_t int_ms, uint32_t fi
|
|||
return;
|
||||
}
|
||||
|
||||
context->_int_ms_tick = rtos::Kernel::get_ms_count() + int_ms;
|
||||
context->_timer_event_id = mbed::mbed_event_queue()->call_in(fin_ms, context, &DTLSSocketWrapper::timer_event);
|
||||
}
|
||||
|
||||
|
@ -41,6 +44,8 @@ int DTLSSocketWrapper::timing_get_delay(void *ctx)
|
|||
return -1;
|
||||
} else if (context->_timer_expired) {
|
||||
return 2;
|
||||
} else if (context->_int_ms_tick < rtos::Kernel::get_ms_count()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ private:
|
|||
static void timing_set_delay(void *ctx, uint32_t int_ms, uint32_t fin_ms);
|
||||
static int timing_get_delay(void *ctx);
|
||||
void timer_event();
|
||||
uint64_t _int_ms_tick;
|
||||
int _timer_event_id;
|
||||
bool _timer_expired:1;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue