]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OS utils: Add os_reltime_expired()
authorJohannes Berg <johannes.berg@intel.com>
Mon, 25 Nov 2013 20:56:05 +0000 (21:56 +0100)
committerJouni Malinen <j@w1.fi>
Sun, 8 Dec 2013 04:50:14 +0000 (20:50 -0800)
This helper functions checks whether a given entry has expired,
given the last active timestamp, the current time, and a timeout.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
src/utils/os.h

index 6689d447debfd36faeb00afed1c5965d347be5d5..f93329224572eb0ab84f4bb86a4ea978e91d58b7 100644 (file)
@@ -96,6 +96,18 @@ static inline void os_reltime_age(struct os_reltime *start,
 }
 
 
+static inline int os_reltime_expired(struct os_reltime *now,
+                                    struct os_reltime *ts,
+                                    os_time_t timeout_secs)
+{
+       struct os_reltime age;
+
+       os_reltime_sub(now, ts, &age);
+       return (age.sec > timeout_secs) ||
+              (age.sec == timeout_secs && age.usec > 0);
+}
+
+
 /**
  * os_mktime - Convert broken-down time into seconds since 1970-01-01
  * @year: Four digit year