forked from acouzens/open5gs
Follow-up on #1770
This commit is contained in:
parent
0759c2da5a
commit
31fcedc12e
|
@ -125,7 +125,7 @@ ogs_time_t ogs_time_now(void)
|
|||
rc = ogs_gettimeofday(&tv);
|
||||
ogs_assert(rc == 0);
|
||||
|
||||
return tv.tv_sec * OGS_USEC_PER_SEC + tv.tv_usec;
|
||||
return ogs_time_from_sec(tv.tv_sec) + tv.tv_usec;
|
||||
}
|
||||
|
||||
/* The following code is stolen from APR library */
|
||||
|
@ -188,13 +188,13 @@ uint32_t ogs_time_ntp32_now(void)
|
|||
rc = ogs_gettimeofday(&tv);
|
||||
ogs_assert(rc == 0);
|
||||
|
||||
return ogs_time_to_ntp32(tv.tv_sec * OGS_USEC_PER_SEC + tv.tv_usec);
|
||||
return ogs_time_to_ntp32(ogs_time_from_sec(tv.tv_sec) + tv.tv_usec);
|
||||
}
|
||||
ogs_time_t ogs_time_from_ntp32(uint32_t ntp_timestamp)
|
||||
{
|
||||
if (ntp_timestamp < OGS_1970_1900_SEC_DIFF)
|
||||
return 0;
|
||||
return (ntp_timestamp - OGS_1970_1900_SEC_DIFF) * OGS_USEC_PER_SEC;
|
||||
return ogs_time_from_sec(ntp_timestamp - OGS_1970_1900_SEC_DIFF);
|
||||
}
|
||||
uint32_t ogs_time_to_ntp32(ogs_time_t time)
|
||||
{
|
||||
|
@ -242,7 +242,7 @@ ogs_time_t ogs_get_monotonic_time(void)
|
|||
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (((int64_t) ts.tv_sec * 1000000UL) + (ts.tv_nsec / 1000UL));
|
||||
return ogs_time_from_sec(ts.tv_sec) + ts.tv_nsec / 1000UL;
|
||||
#elif defined(__APPLE__)
|
||||
static mach_timebase_info_data_t info = {0};
|
||||
static double ratio = 0.0;
|
||||
|
@ -268,7 +268,7 @@ ogs_time_t ogs_get_monotonic_time(void)
|
|||
struct timeval tv;
|
||||
|
||||
ogs_gettimeofday(&tv);
|
||||
return (tv.tv_sec * 1000000UL) + tv.tv_usec;
|
||||
return ogs_time_from_sec(tv.tv_sec) + tv.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ static void get_system_time(uint64_t *uuid_time)
|
|||
|
||||
/* ### fix this call to be more portable? */
|
||||
ogs_gettimeofday(&tv);
|
||||
*uuid_time = tv.tv_sec * OGS_USEC_PER_SEC + tv.tv_usec;
|
||||
*uuid_time = ogs_time_from_sec(tv.tv_sec) + tv.tv_usec;
|
||||
|
||||
/* Offset between UUID formatted times and Unix formatted times.
|
||||
UUID UTC base time is October 15, 1582.
|
||||
|
|
|
@ -547,7 +547,8 @@ static void upf_sess_urr_acc_validity_time_setup(upf_sess_t *sess, ogs_pfcp_urr_
|
|||
if (!urr_acc->t_validity_time)
|
||||
urr_acc->t_validity_time = ogs_timer_add(ogs_app()->timer_mgr,
|
||||
upf_sess_urr_acc_timers_cb, urr);
|
||||
ogs_timer_start(urr_acc->t_validity_time, urr->quota_validity_time * OGS_USEC_PER_SEC);
|
||||
ogs_timer_start(urr_acc->t_validity_time,
|
||||
ogs_time_from_sec(urr->quota_validity_time));
|
||||
}
|
||||
static void upf_sess_urr_acc_time_quota_setup(upf_sess_t *sess, ogs_pfcp_urr_t *urr)
|
||||
{
|
||||
|
@ -558,7 +559,7 @@ static void upf_sess_urr_acc_time_quota_setup(upf_sess_t *sess, ogs_pfcp_urr_t *
|
|||
if (!urr_acc->t_time_quota)
|
||||
urr_acc->t_time_quota = ogs_timer_add(ogs_app()->timer_mgr,
|
||||
upf_sess_urr_acc_timers_cb, urr);
|
||||
ogs_timer_start(urr_acc->t_time_quota, urr->time_quota * OGS_USEC_PER_SEC);
|
||||
ogs_timer_start(urr_acc->t_time_quota, ogs_time_from_sec(urr->time_quota));
|
||||
}
|
||||
static void upf_sess_urr_acc_time_threshold_setup(upf_sess_t *sess, ogs_pfcp_urr_t *urr)
|
||||
{
|
||||
|
@ -569,7 +570,8 @@ static void upf_sess_urr_acc_time_threshold_setup(upf_sess_t *sess, ogs_pfcp_urr
|
|||
if (!urr_acc->t_time_threshold)
|
||||
urr_acc->t_time_threshold = ogs_timer_add(ogs_app()->timer_mgr,
|
||||
upf_sess_urr_acc_timers_cb, urr);
|
||||
ogs_timer_start(urr_acc->t_time_threshold, urr->time_threshold * OGS_USEC_PER_SEC);
|
||||
ogs_timer_start(urr_acc->t_time_threshold,
|
||||
ogs_time_from_sec(urr->time_threshold));
|
||||
}
|
||||
|
||||
void upf_sess_urr_acc_timers_setup(upf_sess_t *sess, ogs_pfcp_urr_t *urr)
|
||||
|
|
Loading…
Reference in New Issue