aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-27 14:20:12 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-27 14:20:12 +0000
commitfb6d4c04a9db33e63a2ce238732c7cfc6df4c798 (patch)
tree676495f2c2e1005518b941a467005bcb49ba73cb /src
parent363ce5239bd63abd18643b1a7b4b0523683d36e7 (diff)
downloadgnunet-fb6d4c04a9db33e63a2ce238732c7cfc6df4c798.tar.gz
gnunet-fb6d4c04a9db33e63a2ce238732c7cfc6df4c798.zip
helper
Diffstat (limited to 'src')
-rw-r--r--src/hello/hello.c30
-rw-r--r--src/include/gnunet_dht_service_new.h21
-rw-r--r--src/include/gnunet_hello_lib.h10
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,
590 return GNUNET_OK; 590 return GNUNET_OK;
591} 591}
592 592
593
593/** 594/**
594 * Test if two HELLO messages contain the same addresses. 595 * Test if two HELLO messages contain the same addresses.
595 * If they only differ in expiration time, the lowest 596 * If they only differ in expiration time, the lowest
@@ -629,4 +630,33 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
629} 630}
630 631
631 632
633static int
634find_min_expire (void *cls, const char *tname,
635 struct GNUNET_TIME_Absolute expiration, const void *addr,
636 uint16_t addrlen)
637{
638 struct GNUNET_TIME_Absolute *min = cls;
639
640 *min = GNUNET_TIME_absolute_min (*min, expiration);
641 return GNUNET_OK;
642}
643
644
645/**
646 * When does the last address in the given HELLO expire?
647 *
648 * @param msg HELLO to inspect
649 * @return time the last address expires, 0 if there are no addresses in the HELLO
650 */
651struct GNUNET_TIME_Absolute
652GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg)
653{
654 struct GNUNET_TIME_Absolute ret;
655
656 ret.abs_value = 0;
657 GNUNET_HELLO_iterate_addresses (msg, GNUNET_NO, &find_min_expire, &ret);
658 return ret;
659}
660
661
632/* end of hello.c */ 662/* 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,
142 * @param cls closure 142 * @param cls closure
143 * @param exp when will this value expire 143 * @param exp when will this value expire
144 * @param key key of the result 144 * @param key key of the result
145 * @param get_path NULL-terminated array of pointers 145 * @param get_path peers on reply path (or NULL if not recorded)
146 * to the peers on reverse GET path (or NULL if not recorded) 146 * @param get_path_length number of entries in get_path
147 * @param put_path NULL-terminated array of pointers 147 * @param put_path peers on the PUT path (or NULL if not recorded)
148 * to the peers on the PUT path (or NULL if not recorded) 148 * @param put_path_length number of entries in get_path
149 * @param type type of the result 149 * @param type type of the result
150 * @param size number of bytes in data 150 * @param size number of bytes in data
151 * @param data pointer to the result data 151 * @param data pointer to the result data
@@ -153,10 +153,10 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key,
153typedef void (*GNUNET_DHT_GetIterator) (void *cls, 153typedef void (*GNUNET_DHT_GetIterator) (void *cls,
154 struct GNUNET_TIME_Absolute exp, 154 struct GNUNET_TIME_Absolute exp,
155 const GNUNET_HashCode * key, 155 const GNUNET_HashCode * key,
156 const struct GNUNET_PeerIdentity * 156 const struct GNUNET_PeerIdentity *get_path,
157 const *get_path, 157 unsigned int get_path_length,
158 const struct GNUNET_PeerIdentity * 158 const struct GNUNET_PeerIdentity *put_path,
159 const *put_path, 159 unsigned int put_path_length,
160 enum GNUNET_BLOCK_Type type, 160 enum GNUNET_BLOCK_Type type,
161 size_t size, const void *data); 161 size_t size, const void *data);
162 162
@@ -173,8 +173,6 @@ typedef void (*GNUNET_DHT_GetIterator) (void *cls,
173 * @param desired_replication_level estimate of how many 173 * @param desired_replication_level estimate of how many
174 nearest peers this request should reach 174 nearest peers this request should reach
175 * @param options routing options for this message 175 * @param options routing options for this message
176 * @param bf bloom filter associated with query (can be NULL)
177 * @param bf_mutator mutation value for bf
178 * @param xquery extended query data (can be NULL, depending on type) 176 * @param xquery extended query data (can be NULL, depending on type)
179 * @param xquery_size number of bytes in xquery 177 * @param xquery_size number of bytes in xquery
180 * @param iter function to call on each result 178 * @param iter function to call on each result
@@ -188,8 +186,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
188 enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key, 186 enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key,
189 uint32_t desired_replication_level, 187 uint32_t desired_replication_level,
190 enum GNUNET_DHT_RouteOption options, 188 enum GNUNET_DHT_RouteOption options,
191 const struct GNUNET_CONTAINER_BloomFilter *bf, 189 const void *xquery,
192 int32_t bf_mutator, const void *xquery,
193 size_t xquery_size, GNUNET_DHT_GetIterator iter, 190 size_t xquery_size, GNUNET_DHT_GetIterator iter,
194 void *iter_cls); 191 void *iter_cls);
195 192
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
@@ -161,6 +161,16 @@ typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, const char *tname,
161 161
162 162
163/** 163/**
164 * When does the last address in the given HELLO expire?
165 *
166 * @param msg HELLO to inspect
167 * @return time the last address expires, 0 if there are no addresses in the HELLO
168 */
169struct GNUNET_TIME_Absolute
170GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg);
171
172
173/**
164 * Iterate over all of the addresses in the HELLO. 174 * Iterate over all of the addresses in the HELLO.
165 * 175 *
166 * @param msg HELLO to iterate over; client does not need to 176 * @param msg HELLO to iterate over; client does not need to