diff --git a/src/cntlr.c b/src/cntlr.c index 6f1a39ec7f2bb175ed574d76c3f0a549d3c77395..46ab1cf2f3c65124d856a4a29629840860359cc7 100644 --- a/src/cntlr.c +++ b/src/cntlr.c @@ -1200,13 +1200,10 @@ void cntlr_radio_cur_opclass_dump(struct netif_radio *radio) static bool cntlr_radio_opclass_expired(struct netif_radio *radio) { - time_t age; - if (!radio->opclass.entry_num) return true; - age = time(NULL) - radio->opclass.entry_time; - if (((unsigned int) age) > 120) + if (timestamp_expired(&radio->opclass.entry_time, 120000)) return true; return false; diff --git a/src/cntlr_ubus.c b/src/cntlr_ubus.c index 06fefc977edfb457e898802be2990a13b920d6cf..313543c892cc0b746e5b670d8f7e19650fd0b405 100644 --- a/src/cntlr_ubus.c +++ b/src/cntlr_ubus.c @@ -438,7 +438,7 @@ static void cntlr_status_add_opclass(struct blob_buf *bb, struct opclass *opclas /* Add age */ snprintf(age, sizeof(age), "%s_age", name); - blobmsg_add_u32(bb, age, (uint32_t) (time(NULL) - opclass->entry_time)); + blobmsg_add_u32(bb, age, timestamp_elapsed_sec(&opclass->entry_time)); a = blobmsg_open_array(bb, name); for (j = 0; j < opclass->entry_num; j++) { diff --git a/src/utils/opclass.c b/src/utils/opclass.c index eaf4018be9408bd6c90401fa721da0066b4b7192..913fec615d8500bd625487686f0b89e8ff97fbaf 100644 --- a/src/utils/opclass.c +++ b/src/utils/opclass.c @@ -34,7 +34,7 @@ struct opclass_entry *opclass_new_entry(struct opclass *opclass) entry = &opclass->entry[opclass->entry_num]; opclass->entry_num++; - opclass->entry_time = time(NULL); + timestamp_update(&opclass->entry_time); return entry; } diff --git a/src/utils/opclass.h b/src/utils/opclass.h index 88bb0c4360c0083dbbfe167fd1cea38a1f97bfe5..35b0586e6724d981b1e63ab46f04dcee1f3fb264 100644 --- a/src/utils/opclass.h +++ b/src/utils/opclass.h @@ -28,7 +28,7 @@ struct opclass_entry { }; struct opclass { - time_t entry_time; + struct timespec entry_time; int entry_num; struct opclass_entry entry[64];