mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-31 09:59:15 +01:00
Merge pull request #4761 from haydenroche5/time_cb
Add time callback functionality.
This commit is contained in:
@@ -8341,9 +8341,14 @@ ProtocolVersion MakeDTLSv1_2(void)
|
||||
#endif
|
||||
|
||||
#elif defined(TIME_OVERRIDES)
|
||||
|
||||
#if !defined(NO_ASN) && !defined(NO_ASN_TIME)
|
||||
/* use same asn time overrides unless user wants tick override above */
|
||||
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
return (word32) wc_Time(0);
|
||||
}
|
||||
#else
|
||||
#ifndef HAVE_TIME_T_TYPE
|
||||
typedef long time_t;
|
||||
#endif
|
||||
@@ -8353,6 +8358,7 @@ ProtocolVersion MakeDTLSv1_2(void)
|
||||
{
|
||||
return (word32) XTIME(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
|
||||
@@ -8546,7 +8552,11 @@ ProtocolVersion MakeDTLSv1_2(void)
|
||||
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
#if !defined(NO_ASN) && !defined(NO_ASN_TIME)
|
||||
return (word32)wc_Time(0);
|
||||
#else
|
||||
return (word32)XTIME(0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
||||
@@ -1048,7 +1048,7 @@ static void Trace(int idx)
|
||||
static void TraceHeader(void)
|
||||
{
|
||||
if (TraceOn) {
|
||||
time_t ticks = XTIME(NULL);
|
||||
time_t ticks = wc_Time(NULL);
|
||||
XFPRINTF(TraceFile, "\n%s", XCTIME(&ticks));
|
||||
}
|
||||
}
|
||||
@@ -1449,7 +1449,7 @@ static word32 SessionHash(IpInfo* ipInfo, TcpInfo* tcpInfo)
|
||||
static SnifferSession* GetSnifferSession(IpInfo* ipInfo, TcpInfo* tcpInfo)
|
||||
{
|
||||
SnifferSession* session;
|
||||
time_t currTime = XTIME(NULL);
|
||||
time_t currTime = wc_Time(NULL);
|
||||
word32 row = SessionHash(ipInfo, tcpInfo);
|
||||
|
||||
wc_LockMutex(&SessionMutex);
|
||||
@@ -4487,7 +4487,7 @@ static void RemoveStaleSessions(void)
|
||||
session = SessionTable[i];
|
||||
while (session) {
|
||||
SnifferSession* next = session->next;
|
||||
if (XTIME(NULL) >= session->lastUsed + WOLFSSL_SNIFFER_TIMEOUT) {
|
||||
if (wc_Time(NULL) >= session->lastUsed + WOLFSSL_SNIFFER_TIMEOUT) {
|
||||
TraceStaleSession();
|
||||
RemoveSession(session, NULL, NULL, i);
|
||||
}
|
||||
@@ -4536,7 +4536,7 @@ static SnifferSession* CreateSession(IpInfo* ipInfo, TcpInfo* tcpInfo,
|
||||
session->cliPort = (word16)tcpInfo->srcPort;
|
||||
session->cliSeqStart = tcpInfo->sequence;
|
||||
session->cliExpected = 1; /* relative */
|
||||
session->lastUsed= XTIME(NULL);
|
||||
session->lastUsed= wc_Time(NULL);
|
||||
session->keySz = 0;
|
||||
#ifdef HAVE_SNI
|
||||
session->sni = NULL;
|
||||
|
||||
10
src/ssl.c
10
src/ssl.c
@@ -27863,7 +27863,7 @@ int wolfSSL_X509_cmp_time(const WOLFSSL_ASN1_TIME* asnTime, time_t* cmpTime)
|
||||
|
||||
if (cmpTime == NULL) {
|
||||
/* Use current time */
|
||||
*pTime = XTIME(0);
|
||||
*pTime = wc_Time(0);
|
||||
}
|
||||
else {
|
||||
pTime = cmpTime;
|
||||
@@ -27893,7 +27893,7 @@ WOLFSSL_ASN1_TIME *wolfSSL_X509_time_adj_ex(WOLFSSL_ASN1_TIME *asnTime,
|
||||
int offset_day, long offset_sec, time_t *in_tm)
|
||||
{
|
||||
/* get current time if in_tm is null */
|
||||
time_t t = in_tm ? *in_tm : XTIME(0);
|
||||
time_t t = in_tm ? *in_tm : wc_Time(0);
|
||||
return wolfSSL_ASN1_TIME_adj(asnTime, t, offset_day, offset_sec);
|
||||
}
|
||||
|
||||
@@ -28209,7 +28209,7 @@ int wolfSSL_ASN1_TIME_to_tm(const WOLFSSL_ASN1_TIME* asnTime, struct tm* tm)
|
||||
return WOLFSSL_FAILURE;
|
||||
}
|
||||
|
||||
currentTime = XTIME(0);
|
||||
currentTime = wc_Time(0);
|
||||
if (currentTime <= 0) {
|
||||
WOLFSSL_MSG("Failed to get current time.");
|
||||
return WOLFSSL_FAILURE;
|
||||
@@ -31087,7 +31087,7 @@ int wolfSSL_ASN1_TIME_diff(int *days, int *secs, const WOLFSSL_ASN1_TIME *from,
|
||||
}
|
||||
|
||||
if (from == NULL) {
|
||||
fromSecs = XTIME(0);
|
||||
fromSecs = wc_Time(0);
|
||||
fromTm = XGMTIME(&fromSecs, tmpTs);
|
||||
if (fromTm == NULL) {
|
||||
WOLFSSL_MSG("XGMTIME for from time failed.");
|
||||
@@ -31106,7 +31106,7 @@ int wolfSSL_ASN1_TIME_diff(int *days, int *secs, const WOLFSSL_ASN1_TIME *from,
|
||||
}
|
||||
|
||||
if (to == NULL) {
|
||||
toSecs = XTIME(0);
|
||||
toSecs = wc_Time(0);
|
||||
toTm = XGMTIME(&toSecs, tmpTs);
|
||||
if (toTm == NULL) {
|
||||
WOLFSSL_MSG("XGMTIME for to time failed.");
|
||||
|
||||
@@ -1279,6 +1279,12 @@ end:
|
||||
#endif
|
||||
|
||||
#elif defined(TIME_OVERRIDES)
|
||||
#if !defined(NO_ASN) && !defined(NO_ASN_TIME)
|
||||
word32 TimeNowInMilliseconds(void)
|
||||
{
|
||||
return (word32) wc_Time(0) * 1000;
|
||||
}
|
||||
#else
|
||||
#ifndef HAVE_TIME_T_TYPE
|
||||
typedef long time_t;
|
||||
#endif
|
||||
@@ -1294,6 +1300,7 @@ end:
|
||||
{
|
||||
return (word32) XTIME(0) * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(XTIME_MS)
|
||||
word32 TimeNowInMilliseconds(void)
|
||||
|
||||
Reference in New Issue
Block a user