Both translation tables and network coding use timeouts to do house keeping, so we might as well share the function used to compare a timestamp+timeout with current time.
Signed-off-by: Martin Hundebøll martin@hundeboll.net --- main.c | 5 +++++ main.h | 1 + translation-table.c | 8 -------- 3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/main.c b/main.c index 71b56cf..0930bb4 100644 --- a/main.c +++ b/main.c @@ -172,6 +172,11 @@ int is_my_mac(const uint8_t *addr) return 0; }
+bool is_out_of_time(unsigned long timestamp, unsigned long timeout) +{ + return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); +} + module_init(batman_init); module_exit(batman_exit);
diff --git a/main.h b/main.h index 464439f..92eb37b 100644 --- a/main.h +++ b/main.h @@ -159,6 +159,7 @@ void mesh_free(struct net_device *soft_iface); void inc_module_count(void); void dec_module_count(void); int is_my_mac(const uint8_t *addr); +bool is_out_of_time(unsigned long timestamp, unsigned long timeout);
#ifdef CONFIG_BATMAN_ADV_DEBUG int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3); diff --git a/translation-table.c b/translation-table.c index 7a7df4a..b22f8d9 100644 --- a/translation-table.c +++ b/translation-table.c @@ -108,14 +108,6 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv,
}
-static bool is_out_of_time(unsigned long starting_time, unsigned long timeout) -{ - unsigned long deadline; - deadline = starting_time + msecs_to_jiffies(timeout); - - return time_after(jiffies, deadline); -} - static void tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry) { if (atomic_dec_and_test(&tt_local_entry->common.refcount))