From fb6d4c04a9db33e63a2ce238732c7cfc6df4c798 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 27 Sep 2011 14:20:12 +0000 Subject: helper --- src/hello/hello.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/hello') diff --git a/src/hello/hello.c b/src/hello/hello.c index 501f057c8..b53bf62bc 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c @@ -590,6 +590,7 @@ find_matching (void *cls, const char *tname, return GNUNET_OK; } + /** * Test if two HELLO messages contain the same addresses. * If they only differ in expiration time, the lowest @@ -629,4 +630,33 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, } +static int +find_min_expire (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) +{ + struct GNUNET_TIME_Absolute *min = cls; + + *min = GNUNET_TIME_absolute_min (*min, expiration); + return GNUNET_OK; +} + + +/** + * When does the last address in the given HELLO expire? + * + * @param msg HELLO to inspect + * @return time the last address expires, 0 if there are no addresses in the HELLO + */ +struct GNUNET_TIME_Absolute +GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg) +{ + struct GNUNET_TIME_Absolute ret; + + ret.abs_value = 0; + GNUNET_HELLO_iterate_addresses (msg, GNUNET_NO, &find_min_expire, &ret); + return ret; +} + + /* end of hello.c */ -- cgit v1.2.3