char input[8192];
char output[8192];
REQUEST *request;
- struct timeval now;
/*
* Create and initialize the new request.
*/
request = request_alloc(NULL);
- gettimeofday(&now, NULL);
request->log.dst = talloc_zero(request, log_dst_t);
request->log.dst->func = vlog_request;
#ifdef HAVE_SYSTEMD_WATCHDOG
if (sd_watchdog_interval.tv_sec || sd_watchdog_interval.tv_usec) {
- struct timeval now;
- fr_time_to_timeval(&now, fr_event_list_time(event_list));
- sd_watchdog_event(event_list, &now, NULL);
+ sd_watchdog_event(event_list, 0, NULL);
}
#endif
#define EMA_SCALE (100)
#define F_EMA_SCALE (1000000)
-static struct timeval start_time;
-static struct timeval hup_time;
+static fr_time_t start_time;
+static fr_time_t hup_time;
#define FR_STATS_INIT { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
{ 0, 0, 0, 0, 0, 0, 0, 0 }}
*/
if ((flag->vp_uint32 & 0x10) != 0) {
vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_START_TIME, VENDORPEC_FREERADIUS);
- if (vp) vp->vp_date = start_time.tv_sec;
+ if (vp) vp->vp_date = fr_time_to_sec(start_time);
vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_HUP_TIME, VENDORPEC_FREERADIUS);
- if (vp) vp->vp_date = hup_time.tv_sec;
+ if (vp) vp->vp_date = fr_time_to_sec(hup_time);
}
/*
void radius_stats_init(int flag)
{
if (!flag) {
- gettimeofday(&start_time, NULL);
+ start_time = fr_time();
hup_time = start_time; /* it's just nicer this way */
} else {
- gettimeofday(&hup_time, NULL);
+ hup_time = fr_time();
}
}
*/
case 'c': /* Current epoch time seconds */
- {
- struct timeval now;
-
- gettimeofday(&now, NULL);
-
MEM(value = fr_value_box_alloc(ctx, FR_TYPE_UINT64, NULL, false));
- value->datum.uint64 = (uint64_t)now.tv_sec;
- }
+ value->datum.uint64 = (uint64_t)fr_time_to_sec(fr_time());
+
break;
case 'C': /* Current epoch time microsecond component */
- {
- struct timeval now;
-
- gettimeofday(&now, NULL);
+ MEM(value = fr_value_box_alloc(ctx, FR_TYPE_UINT64, NULL, false));
+ value->datum.uint64 = (uint64_t)fr_time_to_usec(fr_time());
- MEM(value = fr_value_box_alloc(ctx, FR_TYPE_UINT32, NULL, false));
- value->datum.uint32 = (uint64_t)now.tv_usec;
- }
break;
/*
{
rlm_date_t const *inst = mod_inst;
struct tm tminfo;
- struct timeval now;
VALUE_PAIR *vp;
memset(&tminfo, 0, sizeof(tminfo));
}
if (strcmp(fmt, "now") == 0) {
- gettimeofday(&now, NULL);
- return date_encode_strftime(out, outlen, inst, request, now.tv_sec);
+ return date_encode_strftime(out, outlen, inst, request, fr_time_to_sec(fr_time()));
}
if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0;