From fb6d4c04a9db33e63a2ce238732c7cfc6df4c798 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 27 Sep 2011 14:20:12 +0000 Subject: [PATCH] helper --- src/hello/hello.c | 30 ++++++++++++++++++++++++++++ src/include/gnunet_dht_service_new.h | 21 +++++++++---------- src/include/gnunet_hello_lib.h | 10 ++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) 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 */ diff --git a/src/include/gnunet_dht_service_new.h b/src/include/gnunet_dht_service_new.h index e180ad554..88cc390b0 100644 --- a/src/include/gnunet_dht_service_new.h +++ b/src/include/gnunet_dht_service_new.h @@ -142,10 +142,10 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key, * @param cls closure * @param exp when will this value expire * @param key key of the result - * @param get_path NULL-terminated array of pointers - * to the peers on reverse GET path (or NULL if not recorded) - * @param put_path NULL-terminated array of pointers - * to the peers on the PUT path (or NULL if not recorded) + * @param get_path peers on reply path (or NULL if not recorded) + * @param get_path_length number of entries in get_path + * @param put_path peers on the PUT path (or NULL if not recorded) + * @param put_path_length number of entries in get_path * @param type type of the result * @param size number of bytes in data * @param data pointer to the result data @@ -153,10 +153,10 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key, typedef void (*GNUNET_DHT_GetIterator) (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, - const struct GNUNET_PeerIdentity * - const *get_path, - const struct GNUNET_PeerIdentity * - const *put_path, + const struct GNUNET_PeerIdentity *get_path, + unsigned int get_path_length, + const struct GNUNET_PeerIdentity *put_path, + unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data); @@ -173,8 +173,6 @@ typedef void (*GNUNET_DHT_GetIterator) (void *cls, * @param desired_replication_level estimate of how many nearest peers this request should reach * @param options routing options for this message - * @param bf bloom filter associated with query (can be NULL) - * @param bf_mutator mutation value for bf * @param xquery extended query data (can be NULL, depending on type) * @param xquery_size number of bytes in xquery * @param iter function to call on each result @@ -188,8 +186,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, - const struct GNUNET_CONTAINER_BloomFilter *bf, - int32_t bf_mutator, const void *xquery, + const void *xquery, size_t xquery_size, GNUNET_DHT_GetIterator iter, void *iter_cls); diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index 0ec1be7d1..7f5e5fee0 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h @@ -160,6 +160,16 @@ typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, const char *tname, uint16_t addrlen); +/** + * 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); + + /** * Iterate over all of the addresses in the HELLO. * -- 2.25.1