]> git.meshlink.io Git - catta/blobdiff - util.c
add known answer suppresion server part
[catta] / util.c
diff --git a/util.c b/util.c
index faf1ac068e03aa89f6b4e53981ac426e19b79b39..47642e815c8b21436a6850a244ceae824f3b2279 100644 (file)
--- a/util.c
+++ b/util.c
@@ -99,3 +99,27 @@ gint flx_wait_for_write(gint fd) {
 
     return 0;
 }
+
+GTimeVal *flx_elapse_time(GTimeVal *tv, guint msec, guint jitter) {
+    g_assert(tv);
+
+    g_get_current_time(tv);
+
+    if (msec)
+        g_time_val_add(tv, msec*1000);
+
+    if (jitter)
+        g_time_val_add(tv, g_random_int_range(0, jitter) * 1000);
+        
+    return tv;
+}
+
+gint flx_age(const GTimeVal *a) {
+    GTimeVal now;
+    
+    g_assert(a);
+
+    g_get_current_time(&now);
+
+    return flx_timeval_diff(&now, a);
+}