diff options
Diffstat (limited to 'src/util')
78 files changed, 1448 insertions, 1793 deletions
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index d138ffba1..95ff4bfff 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c | |||
@@ -41,8 +41,7 @@ GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second) | |||
41 | struct GNUNET_BANDWIDTH_Value32NBO ret; | 41 | struct GNUNET_BANDWIDTH_Value32NBO ret; |
42 | 42 | ||
43 | #if DEBUG_BANDWIDTH | 43 | #if DEBUG_BANDWIDTH |
44 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 44 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing bandwidth of %u Bps\n", |
45 | "Initializing bandwidth of %u Bps\n", | ||
46 | (unsigned int) bytes_per_second); | 45 | (unsigned int) bytes_per_second); |
47 | #endif | 46 | #endif |
48 | ret.value__ = htonl (bytes_per_second); | 47 | ret.value__ = htonl (bytes_per_second); |
@@ -61,8 +60,9 @@ struct GNUNET_BANDWIDTH_Value32NBO | |||
61 | GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, | 60 | GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, |
62 | struct GNUNET_BANDWIDTH_Value32NBO b2) | 61 | struct GNUNET_BANDWIDTH_Value32NBO b2) |
63 | { | 62 | { |
64 | return GNUNET_BANDWIDTH_value_init (GNUNET_MIN (ntohl (b1.value__), | 63 | return |
65 | ntohl (b2.value__))); | 64 | GNUNET_BANDWIDTH_value_init (GNUNET_MIN |
65 | (ntohl (b1.value__), ntohl (b2.value__))); | ||
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
@@ -152,8 +152,7 @@ GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, | |||
152 | av->max_carry_s__ = max_carry_s; | 152 | av->max_carry_s__ = max_carry_s; |
153 | #if DEBUG_BANDWIDTH | 153 | #if DEBUG_BANDWIDTH |
154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
155 | "Tracker %p initialized with %u Bps and max carry %u\n", | 155 | "Tracker %p initialized with %u Bps and max carry %u\n", av, |
156 | av, | ||
157 | (unsigned int) av->available_bytes_per_s__, | 156 | (unsigned int) av->available_bytes_per_s__, |
158 | (unsigned int) max_carry_s); | 157 | (unsigned int) max_carry_s); |
159 | #endif | 158 | #endif |
@@ -196,8 +195,7 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av) | |||
196 | #if DEBUG_BANDWIDTH | 195 | #if DEBUG_BANDWIDTH |
197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
198 | "Tracker %p updated, have %u Bps, last update was %llu ms ago\n", | 197 | "Tracker %p updated, have %u Bps, last update was %llu ms ago\n", |
199 | av, | 198 | av, (unsigned int) av->available_bytes_per_s__, |
200 | (unsigned int) av->available_bytes_per_s__, | ||
201 | (unsigned long long) delta_time); | 199 | (unsigned long long) delta_time); |
202 | #endif | 200 | #endif |
203 | 201 | ||
@@ -222,8 +220,8 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, | |||
222 | int64_t nc; | 220 | int64_t nc; |
223 | 221 | ||
224 | #if DEBUG_BANDWIDTH | 222 | #if DEBUG_BANDWIDTH |
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p consumes %d bytes\n", av, |
226 | "Tracker %p consumes %d bytes\n", av, (int) size); | 224 | (int) size); |
227 | #endif | 225 | #endif |
228 | if (size > 0) | 226 | if (size > 0) |
229 | { | 227 | { |
@@ -239,8 +237,8 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, | |||
239 | { | 237 | { |
240 | #if DEBUG_BANDWIDTH | 238 | #if DEBUG_BANDWIDTH |
241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
242 | "Tracker %p consumption %llu bytes above limit\n", | 240 | "Tracker %p consumption %llu bytes above limit\n", av, |
243 | av, (unsigned long long) av->consumption_since_last_update__); | 241 | (unsigned long long) av->consumption_since_last_update__); |
244 | #endif | 242 | #endif |
245 | return GNUNET_YES; | 243 | return GNUNET_YES; |
246 | } | 244 | } |
@@ -282,8 +280,8 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, | |||
282 | { | 280 | { |
283 | #if DEBUG_BANDWIDTH | 281 | #if DEBUG_BANDWIDTH |
284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 282 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
285 | "Tracker %p delay for %u bytes is zero\n", | 283 | "Tracker %p delay for %u bytes is zero\n", av, |
286 | av, (unsigned int) size); | 284 | (unsigned int) size); |
287 | #endif | 285 | #endif |
288 | return GNUNET_TIME_UNIT_ZERO; | 286 | return GNUNET_TIME_UNIT_ZERO; |
289 | } | 287 | } |
@@ -291,8 +289,8 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, | |||
291 | 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__; | 289 | 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__; |
292 | #if DEBUG_BANDWIDTH | 290 | #if DEBUG_BANDWIDTH |
293 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
294 | "Tracker %p delay for %u bytes is %llu ms\n", | 292 | "Tracker %p delay for %u bytes is %llu ms\n", av, |
295 | av, (unsigned int) size, (unsigned long long) ret.rel_value); | 293 | (unsigned int) size, (unsigned long long) ret.rel_value); |
296 | #endif | 294 | #endif |
297 | return ret; | 295 | return ret; |
298 | } | 296 | } |
@@ -314,14 +312,15 @@ GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker * av) | |||
314 | 312 | ||
315 | update_tracker (av); | 313 | update_tracker (av); |
316 | bps = GNUNET_BANDWIDTH_value_init (av->available_bytes_per_s__); | 314 | bps = GNUNET_BANDWIDTH_value_init (av->available_bytes_per_s__); |
317 | avail = GNUNET_BANDWIDTH_value_get_available_until (bps, | 315 | avail = |
318 | GNUNET_TIME_absolute_get_duration | 316 | GNUNET_BANDWIDTH_value_get_available_until (bps, |
319 | (av->last_update__)); | 317 | GNUNET_TIME_absolute_get_duration |
318 | (av->last_update__)); | ||
320 | used = av->consumption_since_last_update__; | 319 | used = av->consumption_since_last_update__; |
321 | #if DEBUG_BANDWIDTH | 320 | #if DEBUG_BANDWIDTH |
322 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
323 | "Tracker %p available bandwidth is %lld bytes\n", | 322 | "Tracker %p available bandwidth is %lld bytes\n", av, |
324 | av, (long long) (int64_t) (avail - used)); | 323 | (long long) (int64_t) (avail - used)); |
325 | #endif | 324 | #endif |
326 | return (int64_t) (avail - used); | 325 | return (int64_t) (avail - used); |
327 | } | 326 | } |
@@ -344,8 +343,8 @@ GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av, | |||
344 | new_limit = ntohl (bytes_per_second_limit.value__); | 343 | new_limit = ntohl (bytes_per_second_limit.value__); |
345 | #if DEBUG_BANDWIDTH | 344 | #if DEBUG_BANDWIDTH |
346 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
347 | "Tracker %p bandwidth changed to %u Bps\n", | 346 | "Tracker %p bandwidth changed to %u Bps\n", av, |
348 | av, (unsigned int) new_limit); | 347 | (unsigned int) new_limit); |
349 | #endif | 348 | #endif |
350 | update_tracker (av); | 349 | update_tracker (av); |
351 | old_limit = av->available_bytes_per_s__; | 350 | old_limit = av->available_bytes_per_s__; |
diff --git a/src/util/bio.c b/src/util/bio.c index b29d75eb9..404b7aa3b 100644 --- a/src/util/bio.c +++ b/src/util/bio.c | |||
@@ -101,8 +101,8 @@ GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) | |||
101 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 101 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
102 | */ | 102 | */ |
103 | int | 103 | int |
104 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | 104 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, |
105 | const char *what, void *result, size_t len) | 105 | void *result, size_t len) |
106 | { | 106 | { |
107 | char *dst = result; | 107 | char *dst = result; |
108 | size_t min; | 108 | size_t min; |
@@ -131,14 +131,14 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | |||
131 | ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size); | 131 | ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size); |
132 | if (ret == -1) | 132 | if (ret == -1) |
133 | { | 133 | { |
134 | GNUNET_asprintf (&h->emsg, | 134 | GNUNET_asprintf (&h->emsg, _("Error reading `%s': %s"), what, |
135 | _("Error reading `%s': %s"), what, STRERROR (errno)); | 135 | STRERROR (errno)); |
136 | return GNUNET_SYSERR; | 136 | return GNUNET_SYSERR; |
137 | } | 137 | } |
138 | if (ret == 0) | 138 | if (ret == 0) |
139 | { | 139 | { |
140 | GNUNET_asprintf (&h->emsg, | 140 | GNUNET_asprintf (&h->emsg, _("Error reading `%s': %s"), what, |
141 | _("Error reading `%s': %s"), what, _("End of file")); | 141 | _("End of file")); |
142 | return GNUNET_SYSERR; | 142 | return GNUNET_SYSERR; |
143 | } | 143 | } |
144 | h->pos = 0; | 144 | h->pos = 0; |
@@ -160,8 +160,8 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | |||
160 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 160 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
161 | */ | 161 | */ |
162 | int | 162 | int |
163 | GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, | 163 | GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, const char *file, int line, |
164 | const char *file, int line, void *result, size_t len) | 164 | void *result, size_t len) |
165 | { | 165 | { |
166 | char what[1024]; | 166 | char what[1024]; |
167 | 167 | ||
@@ -181,8 +181,8 @@ GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, | |||
181 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 181 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
182 | */ | 182 | */ |
183 | int | 183 | int |
184 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, | 184 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, |
185 | const char *what, char **result, size_t maxLen) | 185 | char **result, size_t maxLen) |
186 | { | 186 | { |
187 | char *buf; | 187 | char *buf; |
188 | uint32_t big; | 188 | uint32_t big; |
@@ -200,8 +200,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, | |||
200 | } | 200 | } |
201 | if (big > maxLen) | 201 | if (big > maxLen) |
202 | { | 202 | { |
203 | GNUNET_asprintf (&h->emsg, | 203 | GNUNET_asprintf (&h->emsg, _("String `%s' longer than allowed (%u > %u)"), |
204 | _("String `%s' longer than allowed (%u > %u)"), | ||
205 | what, big, maxLen); | 204 | what, big, maxLen); |
206 | return GNUNET_SYSERR; | 205 | return GNUNET_SYSERR; |
207 | } | 206 | } |
@@ -229,8 +228,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, | |||
229 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 228 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
230 | */ | 229 | */ |
231 | int | 230 | int |
232 | GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | 231 | GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, |
233 | const char *what, | ||
234 | struct GNUNET_CONTAINER_MetaData **result) | 232 | struct GNUNET_CONTAINER_MetaData **result) |
235 | { | 233 | { |
236 | uint32_t size; | 234 | uint32_t size; |
@@ -280,8 +278,8 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | |||
280 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 278 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
281 | */ | 279 | */ |
282 | int | 280 | int |
283 | GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, | 281 | GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file, |
284 | const char *file, int line, int32_t * i) | 282 | int line, int32_t * i) |
285 | { | 283 | { |
286 | int32_t big; | 284 | int32_t big; |
287 | 285 | ||
@@ -302,8 +300,8 @@ GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, | |||
302 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 300 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
303 | */ | 301 | */ |
304 | int | 302 | int |
305 | GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, | 303 | GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file, |
306 | const char *file, int line, int64_t * i) | 304 | int line, int64_t * i) |
307 | { | 305 | { |
308 | int64_t big; | 306 | int64_t big; |
309 | 307 | ||
@@ -339,9 +337,8 @@ GNUNET_BIO_write_open (const char *fn) | |||
339 | struct GNUNET_BIO_WriteHandle *h; | 337 | struct GNUNET_BIO_WriteHandle *h; |
340 | 338 | ||
341 | fd = GNUNET_DISK_file_open (fn, | 339 | fd = GNUNET_DISK_file_open (fn, |
342 | GNUNET_DISK_OPEN_WRITE | | 340 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE |
343 | GNUNET_DISK_OPEN_TRUNCATE | | 341 | | GNUNET_DISK_OPEN_CREATE, |
344 | GNUNET_DISK_OPEN_CREATE, | ||
345 | GNUNET_DISK_PERM_USER_READ | | 342 | GNUNET_DISK_PERM_USER_READ | |
346 | GNUNET_DISK_PERM_USER_WRITE); | 343 | GNUNET_DISK_PERM_USER_WRITE); |
347 | if (NULL == fd) | 344 | if (NULL == fd) |
@@ -394,8 +391,8 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h) | |||
394 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 391 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
395 | */ | 392 | */ |
396 | int | 393 | int |
397 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, | 394 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer, |
398 | const void *buffer, size_t n) | 395 | size_t n) |
399 | { | 396 | { |
400 | const char *src = buffer; | 397 | const char *src = buffer; |
401 | size_t min; | 398 | size_t min; |
@@ -470,10 +467,9 @@ GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, | |||
470 | if (m == NULL) | 467 | if (m == NULL) |
471 | return GNUNET_BIO_write_int32 (h, 0); | 468 | return GNUNET_BIO_write_int32 (h, 0); |
472 | buf = NULL; | 469 | buf = NULL; |
473 | size = GNUNET_CONTAINER_meta_data_serialize (m, | 470 | size = |
474 | &buf, | 471 | GNUNET_CONTAINER_meta_data_serialize (m, &buf, MAX_META_DATA, |
475 | MAX_META_DATA, | 472 | GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); |
476 | GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); | ||
477 | if (size == -1) | 473 | if (size == -1) |
478 | { | 474 | { |
479 | GNUNET_free (buf); | 475 | GNUNET_free (buf); |
diff --git a/src/util/client.c b/src/util/client.c index 032a6c5e4..59cd26ad1 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -293,15 +293,11 @@ do_connect (const char *service_name, | |||
293 | #endif | 293 | #endif |
294 | 294 | ||
295 | if ((GNUNET_OK != | 295 | if ((GNUNET_OK != |
296 | GNUNET_CONFIGURATION_get_value_number (cfg, | 296 | GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "PORT", &port)) |
297 | service_name, | 297 | || (port > 65535) || |
298 | "PORT", | ||
299 | &port)) || | ||
300 | (port > 65535) || | ||
301 | (GNUNET_OK != | 298 | (GNUNET_OK != |
302 | GNUNET_CONFIGURATION_get_value_string (cfg, | 299 | GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "HOSTNAME", |
303 | service_name, | 300 | &hostname))) |
304 | "HOSTNAME", &hostname))) | ||
305 | { | 301 | { |
306 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 302 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
307 | _ | 303 | _ |
@@ -325,13 +321,12 @@ do_connect (const char *service_name, | |||
325 | /* try UNIX */ | 321 | /* try UNIX */ |
326 | unixpath = NULL; | 322 | unixpath = NULL; |
327 | if ((GNUNET_OK == | 323 | if ((GNUNET_OK == |
328 | GNUNET_CONFIGURATION_get_value_string (cfg, | 324 | GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", |
329 | service_name, | 325 | &unixpath)) && |
330 | "UNIXPATH", &unixpath)) && | ||
331 | (0 < strlen (unixpath))) | 326 | (0 < strlen (unixpath))) |
332 | { | 327 | { |
333 | sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, | 328 | sock = |
334 | unixpath); | 329 | GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath); |
335 | if (sock != NULL) | 330 | if (sock != NULL) |
336 | { | 331 | { |
337 | GNUNET_free (unixpath); | 332 | GNUNET_free (unixpath); |
@@ -457,8 +452,8 @@ check_complete (struct GNUNET_CLIENT_Connection *conn) | |||
457 | { | 452 | { |
458 | if ((conn->received_pos >= sizeof (struct GNUNET_MessageHeader)) && | 453 | if ((conn->received_pos >= sizeof (struct GNUNET_MessageHeader)) && |
459 | (conn->received_pos >= | 454 | (conn->received_pos >= |
460 | ntohs (((const struct GNUNET_MessageHeader *) conn->received_buf)-> | 455 | ntohs (((const struct GNUNET_MessageHeader *) conn-> |
461 | size))) | 456 | received_buf)->size))) |
462 | conn->msg_complete = GNUNET_YES; | 457 | conn->msg_complete = GNUNET_YES; |
463 | } | 458 | } |
464 | 459 | ||
@@ -476,9 +471,7 @@ check_complete (struct GNUNET_CLIENT_Connection *conn) | |||
476 | * @param errCode value of errno (on errors receiving) | 471 | * @param errCode value of errno (on errors receiving) |
477 | */ | 472 | */ |
478 | static void | 473 | static void |
479 | receive_helper (void *cls, | 474 | receive_helper (void *cls, const void *buf, size_t available, |
480 | const void *buf, | ||
481 | size_t available, | ||
482 | const struct sockaddr *addr, socklen_t addrlen, int errCode) | 475 | const struct sockaddr *addr, socklen_t addrlen, int errCode) |
483 | { | 476 | { |
484 | struct GNUNET_CLIENT_Connection *conn = cls; | 477 | struct GNUNET_CLIENT_Connection *conn = cls; |
@@ -512,8 +505,8 @@ receive_helper (void *cls, | |||
512 | 505 | ||
513 | /* slow path: append to array */ | 506 | /* slow path: append to array */ |
514 | if (conn->received_size < conn->received_pos + available) | 507 | if (conn->received_size < conn->received_pos + available) |
515 | GNUNET_array_grow (conn->received_buf, | 508 | GNUNET_array_grow (conn->received_buf, conn->received_size, |
516 | conn->received_size, conn->received_pos + available); | 509 | conn->received_pos + available); |
517 | memcpy (&conn->received_buf[conn->received_pos], buf, available); | 510 | memcpy (&conn->received_buf[conn->received_pos], buf, available); |
518 | conn->received_pos += available; | 511 | conn->received_pos += available; |
519 | check_complete (conn); | 512 | check_complete (conn); |
@@ -527,8 +520,7 @@ receive_helper (void *cls, | |||
527 | return; | 520 | return; |
528 | } | 521 | } |
529 | /* back to receive -- either for more data or to call callback! */ | 522 | /* back to receive -- either for more data or to call callback! */ |
530 | GNUNET_CLIENT_receive (conn, | 523 | GNUNET_CLIENT_receive (conn, conn->receiver_handler, |
531 | conn->receiver_handler, | ||
532 | conn->receiver_handler_cls, remaining); | 524 | conn->receiver_handler_cls, remaining); |
533 | } | 525 | } |
534 | 526 | ||
@@ -553,15 +545,15 @@ receive_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
553 | 545 | ||
554 | #if DEBUG_CLIENT | 546 | #if DEBUG_CLIENT |
555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
556 | "Received message of type %u and size %u\n", | 548 | "Received message of type %u and size %u\n", ntohs (cmsg->type), |
557 | ntohs (cmsg->type), msize); | 549 | msize); |
558 | #endif | 550 | #endif |
559 | sock->receive_task = GNUNET_SCHEDULER_NO_TASK; | 551 | sock->receive_task = GNUNET_SCHEDULER_NO_TASK; |
560 | GNUNET_assert (GNUNET_YES == sock->msg_complete); | 552 | GNUNET_assert (GNUNET_YES == sock->msg_complete); |
561 | GNUNET_assert (sock->received_pos >= msize); | 553 | GNUNET_assert (sock->received_pos >= msize); |
562 | memcpy (msg, cmsg, msize); | 554 | memcpy (msg, cmsg, msize); |
563 | memmove (sock->received_buf, | 555 | memmove (sock->received_buf, &sock->received_buf[msize], |
564 | &sock->received_buf[msize], sock->received_pos - msize); | 556 | sock->received_pos - msize); |
565 | sock->received_pos -= msize; | 557 | sock->received_pos -= msize; |
566 | sock->msg_complete = GNUNET_NO; | 558 | sock->msg_complete = GNUNET_NO; |
567 | sock->receiver_handler = NULL; | 559 | sock->receiver_handler = NULL; |
@@ -581,8 +573,8 @@ receive_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
581 | */ | 573 | */ |
582 | void | 574 | void |
583 | GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | 575 | GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, |
584 | GNUNET_CLIENT_MessageHandler handler, | 576 | GNUNET_CLIENT_MessageHandler handler, void *handler_cls, |
585 | void *handler_cls, struct GNUNET_TIME_Relative timeout) | 577 | struct GNUNET_TIME_Relative timeout) |
586 | { | 578 | { |
587 | if (sock->sock == NULL) | 579 | if (sock->sock == NULL) |
588 | { | 580 | { |
@@ -607,8 +599,7 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | |||
607 | #if DEBUG_CLIENT | 599 | #if DEBUG_CLIENT |
608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "calling GNUNET_CONNECTION_receive\n"); | 600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "calling GNUNET_CONNECTION_receive\n"); |
609 | #endif | 601 | #endif |
610 | GNUNET_CONNECTION_receive (sock->sock, | 602 | GNUNET_CONNECTION_receive (sock->sock, GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, |
611 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, | ||
612 | timeout, &receive_helper, sock); | 603 | timeout, &receive_helper, sock); |
613 | } | 604 | } |
614 | } | 605 | } |
@@ -620,8 +611,8 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | |||
620 | static void | 611 | static void |
621 | service_test_error (GNUNET_SCHEDULER_Task task, void *task_cls) | 612 | service_test_error (GNUNET_SCHEDULER_Task task, void *task_cls) |
622 | { | 613 | { |
623 | GNUNET_SCHEDULER_add_continuation (task, | 614 | GNUNET_SCHEDULER_add_continuation (task, task_cls, |
624 | task_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); | 615 | GNUNET_SCHEDULER_REASON_TIMEOUT); |
625 | } | 616 | } |
626 | 617 | ||
627 | 618 | ||
@@ -645,8 +636,7 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
645 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
646 | "Received confirmation that service is running.\n"); | 637 | "Received confirmation that service is running.\n"); |
647 | #endif | 638 | #endif |
648 | GNUNET_SCHEDULER_add_continuation (conn->test_cb, | 639 | GNUNET_SCHEDULER_add_continuation (conn->test_cb, conn->test_cb_cls, |
649 | conn->test_cb_cls, | ||
650 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 640 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
651 | } | 641 | } |
652 | else | 642 | else |
@@ -688,11 +678,9 @@ write_test (void *cls, size_t size, void *buf) | |||
688 | msg = (struct GNUNET_MessageHeader *) buf; | 678 | msg = (struct GNUNET_MessageHeader *) buf; |
689 | msg->type = htons (GNUNET_MESSAGE_TYPE_TEST); | 679 | msg->type = htons (GNUNET_MESSAGE_TYPE_TEST); |
690 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); | 680 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); |
691 | GNUNET_CLIENT_receive (conn, | 681 | GNUNET_CLIENT_receive (conn, &confirm_handler, conn, |
692 | &confirm_handler, | 682 | GNUNET_TIME_absolute_get_remaining (conn-> |
693 | conn, | 683 | test_deadline)); |
694 | GNUNET_TIME_absolute_get_remaining | ||
695 | (conn->test_deadline)); | ||
696 | return sizeof (struct GNUNET_MessageHeader); | 684 | return sizeof (struct GNUNET_MessageHeader); |
697 | } | 685 | } |
698 | 686 | ||
@@ -722,8 +710,8 @@ GNUNET_CLIENT_service_test (const char *service, | |||
722 | struct GNUNET_CLIENT_Connection *conn; | 710 | struct GNUNET_CLIENT_Connection *conn; |
723 | 711 | ||
724 | #if DEBUG_CLIENT | 712 | #if DEBUG_CLIENT |
725 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing if service `%s' is running.\n", |
726 | "Testing if service `%s' is running.\n", service); | 714 | service); |
727 | #endif | 715 | #endif |
728 | #ifdef AF_UNIX | 716 | #ifdef AF_UNIX |
729 | { | 717 | { |
@@ -761,15 +749,13 @@ GNUNET_CLIENT_service_test (const char *service, | |||
761 | s_un.sun_len = (u_char) slen; | 749 | s_un.sun_len = (u_char) slen; |
762 | #endif | 750 | #endif |
763 | if (GNUNET_OK != | 751 | if (GNUNET_OK != |
764 | GNUNET_NETWORK_socket_bind (sock, | 752 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, |
765 | (const struct sockaddr *) &s_un, | ||
766 | slen)) | 753 | slen)) |
767 | { | 754 | { |
768 | /* failed to bind => service must be running */ | 755 | /* failed to bind => service must be running */ |
769 | GNUNET_free (unixpath); | 756 | GNUNET_free (unixpath); |
770 | (void) GNUNET_NETWORK_socket_close (sock); | 757 | (void) GNUNET_NETWORK_socket_close (sock); |
771 | GNUNET_SCHEDULER_add_continuation (task, | 758 | GNUNET_SCHEDULER_add_continuation (task, task_cls, |
772 | task_cls, | ||
773 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 759 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
774 | return; | 760 | return; |
775 | } | 761 | } |
@@ -784,14 +770,11 @@ GNUNET_CLIENT_service_test (const char *service, | |||
784 | 770 | ||
785 | hostname = NULL; | 771 | hostname = NULL; |
786 | if ((GNUNET_OK != | 772 | if ((GNUNET_OK != |
787 | GNUNET_CONFIGURATION_get_value_number (cfg, | 773 | GNUNET_CONFIGURATION_get_value_number (cfg, service, "PORT", &port)) || |
788 | service, | ||
789 | "PORT", | ||
790 | &port)) || | ||
791 | (port > 65535) || | 774 | (port > 65535) || |
792 | (GNUNET_OK != | 775 | (GNUNET_OK != |
793 | GNUNET_CONFIGURATION_get_value_string (cfg, | 776 | GNUNET_CONFIGURATION_get_value_string (cfg, service, "HOSTNAME", |
794 | service, "HOSTNAME", &hostname))) | 777 | &hostname))) |
795 | { | 778 | { |
796 | /* UNIXPATH failed (if possible) AND IP failed => error */ | 779 | /* UNIXPATH failed (if possible) AND IP failed => error */ |
797 | service_test_error (task, task_cls); | 780 | service_test_error (task, task_cls); |
@@ -818,15 +801,13 @@ GNUNET_CLIENT_service_test (const char *service, | |||
818 | if (sock != NULL) | 801 | if (sock != NULL) |
819 | { | 802 | { |
820 | if (GNUNET_OK != | 803 | if (GNUNET_OK != |
821 | GNUNET_NETWORK_socket_bind (sock, | 804 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, |
822 | (const struct sockaddr *) &s_in, | ||
823 | sizeof (s_in))) | 805 | sizeof (s_in))) |
824 | { | 806 | { |
825 | /* failed to bind => service must be running */ | 807 | /* failed to bind => service must be running */ |
826 | GNUNET_free (hostname); | 808 | GNUNET_free (hostname); |
827 | (void) GNUNET_NETWORK_socket_close (sock); | 809 | (void) GNUNET_NETWORK_socket_close (sock); |
828 | GNUNET_SCHEDULER_add_continuation (task, | 810 | GNUNET_SCHEDULER_add_continuation (task, task_cls, |
829 | task_cls, | ||
830 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 811 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
831 | return; | 812 | return; |
832 | } | 813 | } |
@@ -854,15 +835,13 @@ GNUNET_CLIENT_service_test (const char *service, | |||
854 | if (sock != NULL) | 835 | if (sock != NULL) |
855 | { | 836 | { |
856 | if (GNUNET_OK != | 837 | if (GNUNET_OK != |
857 | GNUNET_NETWORK_socket_bind (sock, | 838 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, |
858 | (const struct sockaddr *) &s_in6, | ||
859 | sizeof (s_in6))) | 839 | sizeof (s_in6))) |
860 | { | 840 | { |
861 | /* failed to bind => service must be running */ | 841 | /* failed to bind => service must be running */ |
862 | GNUNET_free (hostname); | 842 | GNUNET_free (hostname); |
863 | (void) GNUNET_NETWORK_socket_close (sock); | 843 | (void) GNUNET_NETWORK_socket_close (sock); |
864 | GNUNET_SCHEDULER_add_continuation (task, | 844 | GNUNET_SCHEDULER_add_continuation (task, task_cls, |
865 | task_cls, | ||
866 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 845 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
867 | return; | 846 | return; |
868 | } | 847 | } |
@@ -889,8 +868,7 @@ GNUNET_CLIENT_service_test (const char *service, | |||
889 | if (conn == NULL) | 868 | if (conn == NULL) |
890 | { | 869 | { |
891 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 870 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
892 | _ | 871 | _("Could not connect to service `%s', must not be running.\n"), |
893 | ("Could not connect to service `%s', must not be running.\n"), | ||
894 | service); | 872 | service); |
895 | service_test_error (task, task_cls); | 873 | service_test_error (task, task_cls); |
896 | return; | 874 | return; |
@@ -899,11 +877,11 @@ GNUNET_CLIENT_service_test (const char *service, | |||
899 | conn->test_cb_cls = task_cls; | 877 | conn->test_cb_cls = task_cls; |
900 | conn->test_deadline = GNUNET_TIME_relative_to_absolute (timeout); | 878 | conn->test_deadline = GNUNET_TIME_relative_to_absolute (timeout); |
901 | 879 | ||
902 | if (NULL == GNUNET_CLIENT_notify_transmit_ready (conn, | 880 | if (NULL == |
903 | sizeof (struct | 881 | GNUNET_CLIENT_notify_transmit_ready (conn, |
904 | GNUNET_MessageHeader), | 882 | sizeof (struct GNUNET_MessageHeader), |
905 | timeout, GNUNET_YES, | 883 | timeout, GNUNET_YES, &write_test, |
906 | &write_test, conn)) | 884 | conn)) |
907 | { | 885 | { |
908 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 886 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
909 | _("Failure to transmit request to service `%s'\n"), service); | 887 | _("Failure to transmit request to service `%s'\n"), service); |
@@ -952,8 +930,8 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
952 | GNUNET_free (th); | 930 | GNUNET_free (th); |
953 | return; | 931 | return; |
954 | } | 932 | } |
955 | th->sock->sock = do_connect (th->sock->service_name, | 933 | th->sock->sock = |
956 | th->sock->cfg, th->sock->attempts++); | 934 | do_connect (th->sock->service_name, th->sock->cfg, th->sock->attempts++); |
957 | if (NULL == th->sock->sock) | 935 | if (NULL == th->sock->sock) |
958 | { | 936 | { |
959 | /* could happen if we're out of sockets */ | 937 | /* could happen if we're out of sockets */ |
@@ -970,17 +948,16 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
970 | MAX_ATTEMPTS - th->attempts_left, | 948 | MAX_ATTEMPTS - th->attempts_left, |
971 | (unsigned long long) delay.rel_value); | 949 | (unsigned long long) delay.rel_value); |
972 | #endif | 950 | #endif |
973 | th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay, | 951 | th->reconnect_task = |
974 | &client_delayed_retry, | 952 | GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); |
975 | th); | ||
976 | return; | 953 | return; |
977 | } | 954 | } |
978 | GNUNET_CONNECTION_ignore_shutdown (th->sock->sock, th->sock->ignore_shutdown); | 955 | GNUNET_CONNECTION_ignore_shutdown (th->sock->sock, th->sock->ignore_shutdown); |
979 | th->th = GNUNET_CONNECTION_notify_transmit_ready (th->sock->sock, | 956 | th->th = |
980 | th->size, | 957 | GNUNET_CONNECTION_notify_transmit_ready (th->sock->sock, th->size, |
981 | GNUNET_TIME_absolute_get_remaining | 958 | GNUNET_TIME_absolute_get_remaining |
982 | (th->timeout), | 959 | (th->timeout), &client_notify, |
983 | &client_notify, th); | 960 | th); |
984 | if (th->th == NULL) | 961 | if (th->th == NULL) |
985 | { | 962 | { |
986 | GNUNET_break (0); | 963 | GNUNET_break (0); |
@@ -1037,8 +1014,7 @@ client_notify (void *cls, size_t size, void *buf) | |||
1037 | GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); | 1014 | GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); |
1038 | th->sock->sock = NULL; | 1015 | th->sock->sock = NULL; |
1039 | delay = GNUNET_TIME_relative_min (delay, th->sock->back_off); | 1016 | delay = GNUNET_TIME_relative_min (delay, th->sock->back_off); |
1040 | th->sock->back_off | 1017 | th->sock->back_off = |
1041 | = | ||
1042 | GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply | 1018 | GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply |
1043 | (th->sock->back_off, 2), | 1019 | (th->sock->back_off, 2), |
1044 | GNUNET_TIME_UNIT_SECONDS); | 1020 | GNUNET_TIME_UNIT_SECONDS); |
@@ -1049,9 +1025,8 @@ client_notify (void *cls, size_t size, void *buf) | |||
1049 | (unsigned long long) delay.rel_value); | 1025 | (unsigned long long) delay.rel_value); |
1050 | #endif | 1026 | #endif |
1051 | th->sock->th = th; | 1027 | th->sock->th = th; |
1052 | th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay, | 1028 | th->reconnect_task = |
1053 | &client_delayed_retry, | 1029 | GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); |
1054 | th); | ||
1055 | return 0; | 1030 | return 0; |
1056 | } | 1031 | } |
1057 | GNUNET_assert (size >= th->size); | 1032 | GNUNET_assert (size >= th->size); |
@@ -1108,17 +1083,16 @@ GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *sock, | |||
1108 | sock->th = th; | 1083 | sock->th = th; |
1109 | if (sock->sock == NULL) | 1084 | if (sock->sock == NULL) |
1110 | { | 1085 | { |
1111 | th->reconnect_task = GNUNET_SCHEDULER_add_delayed (sock->back_off, | 1086 | th->reconnect_task = |
1112 | &client_delayed_retry, | 1087 | GNUNET_SCHEDULER_add_delayed (sock->back_off, &client_delayed_retry, |
1113 | th); | 1088 | th); |
1114 | 1089 | ||
1115 | } | 1090 | } |
1116 | else | 1091 | else |
1117 | { | 1092 | { |
1118 | th->th = GNUNET_CONNECTION_notify_transmit_ready (sock->sock, | 1093 | th->th = |
1119 | size, | 1094 | GNUNET_CONNECTION_notify_transmit_ready (sock->sock, size, timeout, |
1120 | timeout, | 1095 | &client_notify, th); |
1121 | &client_notify, th); | ||
1122 | if (NULL == th->th) | 1096 | if (NULL == th->th) |
1123 | { | 1097 | { |
1124 | GNUNET_break (0); | 1098 | GNUNET_break (0); |
@@ -1137,8 +1111,8 @@ GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *sock, | |||
1137 | * @param th handle from the original request. | 1111 | * @param th handle from the original request. |
1138 | */ | 1112 | */ |
1139 | void | 1113 | void |
1140 | GNUNET_CLIENT_notify_transmit_ready_cancel (struct | 1114 | GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHandle |
1141 | GNUNET_CLIENT_TransmitHandle *th) | 1115 | *th) |
1142 | { | 1116 | { |
1143 | if (th->reconnect_task != GNUNET_SCHEDULER_NO_TASK) | 1117 | if (th->reconnect_task != GNUNET_SCHEDULER_NO_TASK) |
1144 | { | 1118 | { |
@@ -1189,9 +1163,7 @@ transmit_for_response (void *cls, size_t size, void *buf) | |||
1189 | } | 1163 | } |
1190 | GNUNET_assert (size >= msize); | 1164 | GNUNET_assert (size >= msize); |
1191 | memcpy (buf, tc->hdr, msize); | 1165 | memcpy (buf, tc->hdr, msize); |
1192 | GNUNET_CLIENT_receive (tc->sock, | 1166 | GNUNET_CLIENT_receive (tc->sock, tc->rn, tc->rn_cls, |
1193 | tc->rn, | ||
1194 | tc->rn_cls, | ||
1195 | GNUNET_TIME_absolute_get_remaining (tc->timeout)); | 1167 | GNUNET_TIME_absolute_get_remaining (tc->timeout)); |
1196 | GNUNET_free (tc); | 1168 | GNUNET_free (tc); |
1197 | return msize; | 1169 | return msize; |
@@ -1220,10 +1192,8 @@ transmit_for_response (void *cls, size_t size, void *buf) | |||
1220 | * is already pending | 1192 | * is already pending |
1221 | */ | 1193 | */ |
1222 | int | 1194 | int |
1223 | GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection | 1195 | GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock, |
1224 | *sock, | 1196 | const struct GNUNET_MessageHeader *hdr, |
1225 | const struct GNUNET_MessageHeader | ||
1226 | *hdr, | ||
1227 | struct GNUNET_TIME_Relative timeout, | 1197 | struct GNUNET_TIME_Relative timeout, |
1228 | int auto_retry, | 1198 | int auto_retry, |
1229 | GNUNET_CLIENT_MessageHandler rn, | 1199 | GNUNET_CLIENT_MessageHandler rn, |
@@ -1243,11 +1213,9 @@ GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection | |||
1243 | tc->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 1213 | tc->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
1244 | tc->rn = rn; | 1214 | tc->rn = rn; |
1245 | tc->rn_cls = rn_cls; | 1215 | tc->rn_cls = rn_cls; |
1246 | if (NULL == GNUNET_CLIENT_notify_transmit_ready (sock, | 1216 | if (NULL == |
1247 | msize, | 1217 | GNUNET_CLIENT_notify_transmit_ready (sock, msize, timeout, auto_retry, |
1248 | timeout, | 1218 | &transmit_for_response, tc)) |
1249 | auto_retry, | ||
1250 | &transmit_for_response, tc)) | ||
1251 | { | 1219 | { |
1252 | GNUNET_break (0); | 1220 | GNUNET_break (0); |
1253 | GNUNET_free (tc); | 1221 | GNUNET_free (tc); |
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 6f01e8230..71aa15add 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c | |||
@@ -255,9 +255,7 @@ GNUNET_xstrndup_ (const char *str, size_t len, const char *filename, | |||
255 | * @param linenumber where in the code was the call to GNUNET_array_grow | 255 | * @param linenumber where in the code was the call to GNUNET_array_grow |
256 | */ | 256 | */ |
257 | void | 257 | void |
258 | GNUNET_xgrow_ (void **old, | 258 | GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount, |
259 | size_t elementSize, | ||
260 | unsigned int *oldCount, | ||
261 | unsigned int newCount, const char *filename, int linenumber) | 259 | unsigned int newCount, const char *filename, int linenumber) |
262 | { | 260 | { |
263 | void *tmp; | 261 | void *tmp; |
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 37f630854..ff3ac12ee 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -279,8 +279,8 @@ GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls) | |||
279 | * @param msg the actual message | 279 | * @param msg the actual message |
280 | */ | 280 | */ |
281 | static void | 281 | static void |
282 | output_message (enum GNUNET_ErrorType kind, | 282 | output_message (enum GNUNET_ErrorType kind, const char *comp, |
283 | const char *comp, const char *datestr, const char *msg) | 283 | const char *datestr, const char *msg) |
284 | { | 284 | { |
285 | struct CustomLogger *pos; | 285 | struct CustomLogger *pos; |
286 | 286 | ||
@@ -371,8 +371,8 @@ GNUNET_log_skip (unsigned int n, int check_reset) | |||
371 | * @param va arguments to the format string "message" | 371 | * @param va arguments to the format string "message" |
372 | */ | 372 | */ |
373 | static void | 373 | static void |
374 | mylog (enum GNUNET_ErrorType kind, | 374 | mylog (enum GNUNET_ErrorType kind, const char *comp, const char *message, |
375 | const char *comp, const char *message, va_list va) | 375 | va_list va) |
376 | { | 376 | { |
377 | char date[DATE_STR_SIZE]; | 377 | char date[DATE_STR_SIZE]; |
378 | char date2[DATE_STR_SIZE]; | 378 | char date2[DATE_STR_SIZE]; |
@@ -419,9 +419,8 @@ mylog (enum GNUNET_ErrorType kind, | |||
419 | } | 419 | } |
420 | else | 420 | else |
421 | strcpy (date, "localtime error"); | 421 | strcpy (date, "localtime error"); |
422 | if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && | 422 | if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && (last_bulk_time.abs_value != 0) |
423 | (last_bulk_time.abs_value != 0) && | 423 | && (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) |
424 | (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) | ||
425 | { | 424 | { |
426 | last_bulk_repeat++; | 425 | last_bulk_repeat++; |
427 | if ((GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value > | 426 | if ((GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value > |
@@ -469,8 +468,8 @@ GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...) | |||
469 | * @param ... arguments for format string | 468 | * @param ... arguments for format string |
470 | */ | 469 | */ |
471 | void | 470 | void |
472 | GNUNET_log_from (enum GNUNET_ErrorType kind, | 471 | GNUNET_log_from (enum GNUNET_ErrorType kind, const char *comp, |
473 | const char *comp, const char *message, ...) | 472 | const char *message, ...) |
474 | { | 473 | { |
475 | va_list va; | 474 | va_list va; |
476 | char comp_w_pid[128]; | 475 | char comp_w_pid[128]; |
@@ -614,10 +613,7 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) | |||
614 | off = 0; | 613 | off = 0; |
615 | if (un->sun_path[0] == '\0') | 614 | if (un->sun_path[0] == '\0') |
616 | off++; | 615 | off++; |
617 | snprintf (buf, | 616 | snprintf (buf, sizeof (buf), "%s%.*s", (off == 1) ? "@" : "", |
618 | sizeof (buf), | ||
619 | "%s%.*s", | ||
620 | (off == 1) ? "@" : "", | ||
621 | (int) (addrlen - sizeof (sa_family_t) - 1 - off), | 617 | (int) (addrlen - sizeof (sa_family_t) - 1 - off), |
622 | &un->sun_path[off]); | 618 | &un->sun_path[off]); |
623 | return buf; | 619 | return buf; |
diff --git a/src/util/configuration.c b/src/util/configuration.c index b3b9d5ea8..534949652 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -241,8 +241,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
241 | { | 241 | { |
242 | /* parse error */ | 242 | /* parse error */ |
243 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 243 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
244 | _ | 244 | _("Syntax error in configuration file `%s' at line %u.\n"), |
245 | ("Syntax error in configuration file `%s' at line %u.\n"), | ||
246 | filename, nr); | 245 | filename, nr); |
247 | ret = GNUNET_SYSERR; | 246 | ret = GNUNET_SYSERR; |
248 | break; | 247 | break; |
@@ -499,8 +498,8 @@ GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
499 | * @param value value to copy | 498 | * @param value value to copy |
500 | */ | 499 | */ |
501 | static void | 500 | static void |
502 | copy_entry (void *cls, | 501 | copy_entry (void *cls, const char *section, const char *option, |
503 | const char *section, const char *option, const char *value) | 502 | const char *value) |
504 | { | 503 | { |
505 | struct GNUNET_CONFIGURATION_Handle *dst = cls; | 504 | struct GNUNET_CONFIGURATION_Handle *dst = cls; |
506 | 505 | ||
@@ -553,8 +552,8 @@ findSection (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) | |||
553 | * @return matching entry, NULL if not found | 552 | * @return matching entry, NULL if not found |
554 | */ | 553 | */ |
555 | static struct ConfigEntry * | 554 | static struct ConfigEntry * |
556 | findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg, | 555 | findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, |
557 | const char *section, const char *key) | 556 | const char *key) |
558 | { | 557 | { |
559 | struct ConfigSection *sec; | 558 | struct ConfigSection *sec; |
560 | struct ConfigEntry *pos; | 559 | struct ConfigEntry *pos; |
@@ -580,8 +579,8 @@ findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
580 | * @param value value to copy (of the default conf.) | 579 | * @param value value to copy (of the default conf.) |
581 | */ | 580 | */ |
582 | static void | 581 | static void |
583 | compareEntries (void *cls, | 582 | compareEntries (void *cls, const char *section, const char *option, |
584 | const char *section, const char *option, const char *value) | 583 | const char *value) |
585 | { | 584 | { |
586 | struct DiffHandle *dh = cls; | 585 | struct DiffHandle *dh = cls; |
587 | struct ConfigEntry *entNew; | 586 | struct ConfigEntry *entNew; |
@@ -627,10 +626,9 @@ GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle | |||
627 | * @param value value to set | 626 | * @param value value to set |
628 | */ | 627 | */ |
629 | void | 628 | void |
630 | GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle | 629 | GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, |
631 | *cfg, | 630 | const char *section, const char *option, |
632 | const char *section, | 631 | const char *value) |
633 | const char *option, const char *value) | ||
634 | { | 632 | { |
635 | struct ConfigSection *sec; | 633 | struct ConfigSection *sec; |
636 | struct ConfigEntry *e; | 634 | struct ConfigEntry *e; |
@@ -667,9 +665,8 @@ GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle | |||
667 | * @param number value to set | 665 | * @param number value to set |
668 | */ | 666 | */ |
669 | void | 667 | void |
670 | GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle | 668 | GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, |
671 | *cfg, const char *section, | 669 | const char *section, const char *option, |
672 | const char *option, | ||
673 | unsigned long long number) | 670 | unsigned long long number) |
674 | { | 671 | { |
675 | char s[64]; | 672 | char s[64]; |
@@ -689,9 +686,8 @@ GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle | |||
689 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 686 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
690 | */ | 687 | */ |
691 | int | 688 | int |
692 | GNUNET_CONFIGURATION_get_value_number (const struct | 689 | GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle |
693 | GNUNET_CONFIGURATION_Handle *cfg, | 690 | *cfg, const char *section, |
694 | const char *section, | ||
695 | const char *option, | 691 | const char *option, |
696 | unsigned long long *number) | 692 | unsigned long long *number) |
697 | { | 693 | { |
@@ -751,9 +747,8 @@ GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle | |||
751 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 747 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
752 | */ | 748 | */ |
753 | int | 749 | int |
754 | GNUNET_CONFIGURATION_get_value_string (const struct | 750 | GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle |
755 | GNUNET_CONFIGURATION_Handle *cfg, | 751 | *cfg, const char *section, |
756 | const char *section, | ||
757 | const char *option, char **value) | 752 | const char *option, char **value) |
758 | { | 753 | { |
759 | struct ConfigEntry *e; | 754 | struct ConfigEntry *e; |
@@ -782,11 +777,10 @@ GNUNET_CONFIGURATION_get_value_string (const struct | |||
782 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 777 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
783 | */ | 778 | */ |
784 | int | 779 | int |
785 | GNUNET_CONFIGURATION_get_value_choice (const struct | 780 | GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle |
786 | GNUNET_CONFIGURATION_Handle *cfg, | 781 | *cfg, const char *section, |
787 | const char *section, | 782 | const char *option, const char **choices, |
788 | const char *option, | 783 | const char **value) |
789 | const char **choices, const char **value) | ||
790 | { | 784 | { |
791 | struct ConfigEntry *e; | 785 | struct ConfigEntry *e; |
792 | int i; | 786 | int i; |
@@ -805,8 +799,8 @@ GNUNET_CONFIGURATION_get_value_choice (const struct | |||
805 | { | 799 | { |
806 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 800 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
807 | _("Configuration value '%s' for '%s'" | 801 | _("Configuration value '%s' for '%s'" |
808 | " in section '%s' is not in set of legal choices\n"), | 802 | " in section '%s' is not in set of legal choices\n"), e->val, |
809 | e->val, option, section); | 803 | option, section); |
810 | return GNUNET_SYSERR; | 804 | return GNUNET_SYSERR; |
811 | } | 805 | } |
812 | *value = choices[i]; | 806 | *value = choices[i]; |
@@ -822,8 +816,8 @@ GNUNET_CONFIGURATION_get_value_choice (const struct | |||
822 | * @return GNUNET_YES if so, GNUNET_NO if not. | 816 | * @return GNUNET_YES if so, GNUNET_NO if not. |
823 | */ | 817 | */ |
824 | int | 818 | int |
825 | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle | 819 | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, |
826 | *cfg, const char *section, const char *option) | 820 | const char *section, const char *option) |
827 | { | 821 | { |
828 | struct ConfigEntry *e; | 822 | struct ConfigEntry *e; |
829 | 823 | ||
@@ -866,9 +860,8 @@ GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle | |||
866 | orig[i] = '\0'; | 860 | orig[i] = '\0'; |
867 | post = &orig[i + 1]; | 861 | post = &orig[i + 1]; |
868 | } | 862 | } |
869 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, | 863 | if (GNUNET_OK != |
870 | "PATHS", | 864 | GNUNET_CONFIGURATION_get_value_filename (cfg, "PATHS", &orig[1], &prefix)) |
871 | &orig[1], &prefix)) | ||
872 | { | 865 | { |
873 | if (NULL == (env = getenv (&orig[1]))) | 866 | if (NULL == (env = getenv (&orig[1]))) |
874 | { | 867 | { |
@@ -940,8 +933,8 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle | |||
940 | const char *val; | 933 | const char *val; |
941 | int ret; | 934 | int ret; |
942 | 935 | ||
943 | ret = GNUNET_CONFIGURATION_get_value_choice (cfg, | 936 | ret = |
944 | section, option, yesno, &val); | 937 | GNUNET_CONFIGURATION_get_value_choice (cfg, section, option, yesno, &val); |
945 | if (ret == GNUNET_SYSERR) | 938 | if (ret == GNUNET_SYSERR) |
946 | return ret; | 939 | return ret; |
947 | if (val == yesno[0]) | 940 | if (val == yesno[0]) |
@@ -962,8 +955,8 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle | |||
962 | */ | 955 | */ |
963 | int | 956 | int |
964 | GNUNET_CONFIGURATION_iterate_value_filenames (const struct | 957 | GNUNET_CONFIGURATION_iterate_value_filenames (const struct |
965 | GNUNET_CONFIGURATION_Handle | 958 | GNUNET_CONFIGURATION_Handle *cfg, |
966 | *cfg, const char *section, | 959 | const char *section, |
967 | const char *option, | 960 | const char *option, |
968 | GNUNET_FileNameCallback cb, | 961 | GNUNET_FileNameCallback cb, |
969 | void *cb_cls) | 962 | void *cb_cls) |
@@ -1093,8 +1086,7 @@ test_match (void *cls, const char *fn) | |||
1093 | */ | 1086 | */ |
1094 | int | 1087 | int |
1095 | GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle | 1088 | GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle |
1096 | *cfg, | 1089 | *cfg, const char *section, |
1097 | const char *section, | ||
1098 | const char *option, | 1090 | const char *option, |
1099 | const char *value) | 1091 | const char *value) |
1100 | { | 1092 | { |
@@ -1102,12 +1094,10 @@ GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle | |||
1102 | char *old; | 1094 | char *old; |
1103 | char *nw; | 1095 | char *nw; |
1104 | 1096 | ||
1105 | if (GNUNET_SYSERR | 1097 | if (GNUNET_SYSERR == |
1106 | == GNUNET_CONFIGURATION_iterate_value_filenames (cfg, | 1098 | GNUNET_CONFIGURATION_iterate_value_filenames (cfg, section, option, |
1107 | section, | 1099 | &test_match, |
1108 | option, | 1100 | (void *) value)) |
1109 | &test_match, | ||
1110 | (void *) value)) | ||
1111 | return GNUNET_NO; /* already exists */ | 1101 | return GNUNET_NO; /* already exists */ |
1112 | if (GNUNET_OK != | 1102 | if (GNUNET_OK != |
1113 | GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old)) | 1103 | GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old)) |
@@ -1140,8 +1130,7 @@ GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle | |||
1140 | */ | 1130 | */ |
1141 | int | 1131 | int |
1142 | GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle | 1132 | GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle |
1143 | *cfg, | 1133 | *cfg, const char *section, |
1144 | const char *section, | ||
1145 | const char *option, | 1134 | const char *option, |
1146 | const char *value) | 1135 | const char *value) |
1147 | { | 1136 | { |
@@ -1231,11 +1220,10 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1231 | if (ipath == NULL) | 1220 | if (ipath == NULL) |
1232 | return GNUNET_SYSERR; | 1221 | return GNUNET_SYSERR; |
1233 | baseconfig = NULL; | 1222 | baseconfig = NULL; |
1234 | GNUNET_asprintf (&baseconfig, | 1223 | GNUNET_asprintf (&baseconfig, "%s%s%s", ipath, DIR_SEPARATOR_STR, |
1235 | "%s%s%s", ipath, DIR_SEPARATOR_STR, "defaults.conf"); | 1224 | "defaults.conf"); |
1236 | GNUNET_free (ipath); | 1225 | GNUNET_free (ipath); |
1237 | if ((GNUNET_OK != | 1226 | if ((GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, baseconfig)) || |
1238 | GNUNET_CONFIGURATION_parse (cfg, baseconfig)) || | ||
1239 | (!((filename == NULL) || | 1227 | (!((filename == NULL) || |
1240 | (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename))))) | 1228 | (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename))))) |
1241 | { | 1229 | { |
@@ -1243,18 +1231,15 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1243 | return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR; | 1231 | return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR; |
1244 | } | 1232 | } |
1245 | GNUNET_free (baseconfig); | 1233 | GNUNET_free (baseconfig); |
1246 | if (((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, | 1234 | if (((GNUNET_YES != |
1247 | "PATHS", | 1235 | GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) && |
1248 | "DEFAULTCONFIG"))) && | ||
1249 | (filename != NULL)) | 1236 | (filename != NULL)) |
1250 | GNUNET_CONFIGURATION_set_value_string (cfg, | 1237 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", |
1251 | "PATHS", "DEFAULTCONFIG", filename); | 1238 | filename); |
1252 | if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, | 1239 | if ((GNUNET_YES == |
1253 | "TESTING", | 1240 | GNUNET_CONFIGURATION_have_value (cfg, "TESTING", "WEAKRANDOM")) && |
1254 | "WEAKRANDOM")) && | 1241 | (GNUNET_YES == |
1255 | (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, | 1242 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "TESTING", "WEAKRANDOM"))) |
1256 | "TESTING", | ||
1257 | "WEAKRANDOM"))) | ||
1258 | GNUNET_CRYPTO_random_disable_entropy_gathering (); | 1243 | GNUNET_CRYPTO_random_disable_entropy_gathering (); |
1259 | return GNUNET_OK; | 1244 | return GNUNET_OK; |
1260 | } | 1245 | } |
diff --git a/src/util/connection.c b/src/util/connection.c index 1ac1b2304..39cb1dde2 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -425,9 +425,8 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, | |||
425 | /* largely traditional GNU/Linux */ | 425 | /* largely traditional GNU/Linux */ |
426 | olen = sizeof (uc); | 426 | olen = sizeof (uc); |
427 | if ((0 == | 427 | if ((0 == |
428 | getsockopt (GNUNET_NETWORK_get_fd (sock), | 428 | getsockopt (GNUNET_NETWORK_get_fd (sock), SOL_SOCKET, SO_PEERCRED, &uc, |
429 | SOL_SOCKET, SO_PEERCRED, &uc, &olen)) && | 429 | &olen)) && (olen == sizeof (uc))) |
430 | (olen == sizeof (uc))) | ||
431 | { | 430 | { |
432 | gc.uid = uc.uid; | 431 | gc.uid = uc.uid; |
433 | gc.gid = uc.gid; | 432 | gc.gid = uc.gid; |
@@ -455,8 +454,8 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, | |||
455 | (GNUNET_YES != (aret = access (access_cls, gcp, uaddr, addrlen)))) | 454 | (GNUNET_YES != (aret = access (access_cls, gcp, uaddr, addrlen)))) |
456 | { | 455 | { |
457 | if (aret == GNUNET_NO) | 456 | if (aret == GNUNET_NO) |
458 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 457 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Access denied to `%s'\n"), |
459 | _("Access denied to `%s'\n"), GNUNET_a2s (uaddr, addrlen)); | 458 | GNUNET_a2s (uaddr, addrlen)); |
460 | GNUNET_break (GNUNET_OK == | 459 | GNUNET_break (GNUNET_OK == |
461 | GNUNET_NETWORK_socket_shutdown (sock, SHUT_RDWR)); | 460 | GNUNET_NETWORK_socket_shutdown (sock, SHUT_RDWR)); |
462 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock)); | 461 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock)); |
@@ -470,8 +469,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, | |||
470 | ret->addrlen = addrlen; | 469 | ret->addrlen = addrlen; |
471 | ret->sock = sock; | 470 | ret->sock = sock; |
472 | #if DEBUG_CONNECTION | 471 | #if DEBUG_CONNECTION |
473 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 472 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Accepting connection from `%s': %p\n"), |
474 | _("Accepting connection from `%s': %p\n"), | ||
475 | GNUNET_a2s (uaddr, addrlen), ret); | 473 | GNUNET_a2s (uaddr, addrlen), ret); |
476 | #endif | 474 | #endif |
477 | return ret; | 475 | return ret; |
@@ -508,8 +506,8 @@ GNUNET_CONNECTION_get_address (struct GNUNET_CONNECTION_Handle *sock, | |||
508 | * @param cls our connection handle | 506 | * @param cls our connection handle |
509 | * @param tc task context describing why we are here | 507 | * @param tc task context describing why we are here |
510 | */ | 508 | */ |
511 | static void | 509 | static void receive_again (void *cls, |
512 | receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 510 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
513 | 511 | ||
514 | 512 | ||
515 | /** | 513 | /** |
@@ -544,9 +542,9 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
544 | "Destroy waits for write_task to be done (%p)\n", sock); | 542 | "Destroy waits for write_task to be done (%p)\n", sock); |
545 | #endif | 543 | #endif |
546 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); | 544 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); |
547 | sock->destroy_task | 545 | sock->destroy_task = |
548 | = GNUNET_SCHEDULER_add_after (sock->write_task, | 546 | GNUNET_SCHEDULER_add_after (sock->write_task, &destroy_continuation, |
549 | &destroy_continuation, sock); | 547 | sock); |
550 | return; | 548 | return; |
551 | } | 549 | } |
552 | if (0 != (sock->ccs & COCO_RECEIVE_AGAIN)) | 550 | if (0 != (sock->ccs & COCO_RECEIVE_AGAIN)) |
@@ -569,9 +567,9 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
569 | if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) | 567 | if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) |
570 | { | 568 | { |
571 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); | 569 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); |
572 | sock->destroy_task | 570 | sock->destroy_task = |
573 | = GNUNET_SCHEDULER_add_after (sock->read_task, | 571 | GNUNET_SCHEDULER_add_after (sock->read_task, &destroy_continuation, |
574 | &destroy_continuation, sock); | 572 | sock); |
575 | return; | 573 | return; |
576 | } | 574 | } |
577 | #if DEBUG_CONNECTION | 575 | #if DEBUG_CONNECTION |
@@ -604,8 +602,8 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
604 | GNUNET_free_non_null (sock->hostname); | 602 | GNUNET_free_non_null (sock->hostname); |
605 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); | 603 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); |
606 | #if DEBUG_CONNECTION | 604 | #if DEBUG_CONNECTION |
607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Freeing memory of connection %p.\n", |
608 | "Freeing memory of connection %p.\n", sock); | 606 | sock); |
609 | #endif | 607 | #endif |
610 | GNUNET_free (sock->write_buffer); | 608 | GNUNET_free (sock->write_buffer); |
611 | GNUNET_free (sock); | 609 | GNUNET_free (sock); |
@@ -621,8 +619,8 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
621 | * @param cls our connection handle | 619 | * @param cls our connection handle |
622 | * @param tc task context describing why we are here | 620 | * @param tc task context describing why we are here |
623 | */ | 621 | */ |
624 | static void | 622 | static void transmit_ready (void *cls, |
625 | transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 623 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
626 | 624 | ||
627 | 625 | ||
628 | /** | 626 | /** |
@@ -634,11 +632,10 @@ static void | |||
634 | connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) | 632 | connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) |
635 | { | 633 | { |
636 | #if DEBUG_CONNECTION | 634 | #if DEBUG_CONNECTION |
637 | GNUNET_log ((0 != strncmp (h->hostname, | 635 | GNUNET_log ((0 != |
638 | "localhost:", | 636 | strncmp (h->hostname, "localhost:", |
639 | 10)) | 637 | 10)) ? GNUNET_ERROR_TYPE_INFO : |
640 | ? GNUNET_ERROR_TYPE_INFO | 638 | GNUNET_ERROR_TYPE_WARNING, |
641 | : GNUNET_ERROR_TYPE_WARNING, | ||
642 | _ | 639 | _ |
643 | ("Failed to establish TCP connection to `%s:%u', no further addresses to try.\n"), | 640 | ("Failed to establish TCP connection to `%s:%u', no further addresses to try.\n"), |
644 | h->hostname, h->port); | 641 | h->hostname, h->port); |
@@ -697,8 +694,7 @@ static void | |||
697 | connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) | 694 | connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) |
698 | { | 695 | { |
699 | #if DEBUG_CONNECTION | 696 | #if DEBUG_CONNECTION |
700 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 697 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' succeeded! (%p)\n", |
701 | "Connection to `%s' succeeded! (%p)\n", | ||
702 | GNUNET_a2s (h->addr, h->addrlen), h); | 698 | GNUNET_a2s (h->addr, h->addrlen), h); |
703 | #endif | 699 | #endif |
704 | /* trigger jobs that waited for the connection */ | 700 | /* trigger jobs that waited for the connection */ |
@@ -767,8 +763,8 @@ connect_probe_continuation (void *cls, | |||
767 | error = 0; | 763 | error = 0; |
768 | if ((0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) || | 764 | if ((0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) || |
769 | (GNUNET_OK != | 765 | (GNUNET_OK != |
770 | GNUNET_NETWORK_socket_getsockopt (ap->sock, SOL_SOCKET, SO_ERROR, | 766 | GNUNET_NETWORK_socket_getsockopt (ap->sock, SOL_SOCKET, SO_ERROR, &error, |
771 | &error, &len)) || (error != 0)) | 767 | &len)) || (error != 0)) |
772 | { | 768 | { |
773 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ap->sock)); | 769 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ap->sock)); |
774 | GNUNET_free (ap); | 770 | GNUNET_free (ap); |
@@ -804,8 +800,8 @@ connect_probe_continuation (void *cls, | |||
804 | * @param addrlen length of addr | 800 | * @param addrlen length of addr |
805 | */ | 801 | */ |
806 | static void | 802 | static void |
807 | try_connect_using_address (void *cls, | 803 | try_connect_using_address (void *cls, const struct sockaddr *addr, |
808 | const struct sockaddr *addr, socklen_t addrlen) | 804 | socklen_t addrlen) |
809 | { | 805 | { |
810 | struct GNUNET_CONNECTION_Handle *h = cls; | 806 | struct GNUNET_CONNECTION_Handle *h = cls; |
811 | struct AddressProbe *ap; | 807 | struct AddressProbe *ap; |
@@ -824,8 +820,8 @@ try_connect_using_address (void *cls, | |||
824 | /* try to connect */ | 820 | /* try to connect */ |
825 | #if DEBUG_CONNECTION | 821 | #if DEBUG_CONNECTION |
826 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 822 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
827 | "Trying to connect using address `%s:%u/%s:%u'\n", | 823 | "Trying to connect using address `%s:%u/%s:%u'\n", h->hostname, |
828 | h->hostname, h->port, GNUNET_a2s (addr, addrlen), h->port); | 824 | h->port, GNUNET_a2s (addr, addrlen), h->port); |
829 | #endif | 825 | #endif |
830 | ap = GNUNET_malloc (sizeof (struct AddressProbe) + addrlen); | 826 | ap = GNUNET_malloc (sizeof (struct AddressProbe) + addrlen); |
831 | ap->addr = (const struct sockaddr *) &ap[1]; | 827 | ap->addr = (const struct sockaddr *) &ap[1]; |
@@ -853,13 +849,11 @@ try_connect_using_address (void *cls, | |||
853 | return; /* not supported by OS */ | 849 | return; /* not supported by OS */ |
854 | } | 850 | } |
855 | #if DEBUG_CONNECTION | 851 | #if DEBUG_CONNECTION |
856 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 852 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"), |
857 | _("Trying to connect to `%s' (%p)\n"), | ||
858 | GNUNET_a2s (ap->addr, ap->addrlen), h); | 853 | GNUNET_a2s (ap->addr, ap->addrlen), h); |
859 | #endif | 854 | #endif |
860 | if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (ap->sock, | 855 | if ((GNUNET_OK != |
861 | ap->addr, | 856 | GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) && |
862 | ap->addrlen)) && | ||
863 | (errno != EINPROGRESS)) | 857 | (errno != EINPROGRESS)) |
864 | { | 858 | { |
865 | /* maybe refused / unsupported address, try next */ | 859 | /* maybe refused / unsupported address, try next */ |
@@ -871,13 +865,15 @@ try_connect_using_address (void *cls, | |||
871 | GNUNET_CONTAINER_DLL_insert (h->ap_head, h->ap_tail, ap); | 865 | GNUNET_CONTAINER_DLL_insert (h->ap_head, h->ap_tail, ap); |
872 | delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT; | 866 | delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT; |
873 | if (h->nth.notify_ready != NULL) | 867 | if (h->nth.notify_ready != NULL) |
874 | delay = GNUNET_TIME_relative_min (delay, | 868 | delay = |
875 | GNUNET_TIME_absolute_get_remaining | 869 | GNUNET_TIME_relative_min (delay, |
876 | (h->nth.transmit_timeout)); | 870 | GNUNET_TIME_absolute_get_remaining (h->nth. |
871 | transmit_timeout)); | ||
877 | if (h->receiver != NULL) | 872 | if (h->receiver != NULL) |
878 | delay = GNUNET_TIME_relative_min (delay, | 873 | delay = |
879 | GNUNET_TIME_absolute_get_remaining | 874 | GNUNET_TIME_relative_min (delay, |
880 | (h->receive_timeout)); | 875 | GNUNET_TIME_absolute_get_remaining (h-> |
876 | receive_timeout)); | ||
881 | ap->task = | 877 | ap->task = |
882 | GNUNET_SCHEDULER_add_write_net (delay, ap->sock, | 878 | GNUNET_SCHEDULER_add_write_net (delay, ap->sock, |
883 | &connect_probe_continuation, ap); | 879 | &connect_probe_continuation, ap); |
@@ -895,9 +891,9 @@ try_connect_using_address (void *cls, | |||
895 | * @return the socket handle | 891 | * @return the socket handle |
896 | */ | 892 | */ |
897 | struct GNUNET_CONNECTION_Handle * | 893 | struct GNUNET_CONNECTION_Handle * |
898 | GNUNET_CONNECTION_create_from_connect (const struct | 894 | GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle |
899 | GNUNET_CONFIGURATION_Handle *cfg, | 895 | *cfg, const char *hostname, |
900 | const char *hostname, uint16_t port) | 896 | uint16_t port) |
901 | { | 897 | { |
902 | struct GNUNET_CONNECTION_Handle *ret; | 898 | struct GNUNET_CONNECTION_Handle *ret; |
903 | 899 | ||
@@ -908,10 +904,10 @@ GNUNET_CONNECTION_create_from_connect (const struct | |||
908 | ret->write_buffer = GNUNET_malloc (ret->write_buffer_size); | 904 | ret->write_buffer = GNUNET_malloc (ret->write_buffer_size); |
909 | ret->port = port; | 905 | ret->port = port; |
910 | ret->hostname = GNUNET_strdup (hostname); | 906 | ret->hostname = GNUNET_strdup (hostname); |
911 | ret->dns_active = GNUNET_RESOLVER_ip_get (ret->hostname, | 907 | ret->dns_active = |
912 | AF_UNSPEC, | 908 | GNUNET_RESOLVER_ip_get (ret->hostname, AF_UNSPEC, |
913 | GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, | 909 | GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, |
914 | &try_connect_using_address, ret); | 910 | &try_connect_using_address, ret); |
915 | return ret; | 911 | return ret; |
916 | } | 912 | } |
917 | 913 | ||
@@ -966,8 +962,8 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
966 | GNUNET_free (ret); | 962 | GNUNET_free (ret); |
967 | return NULL; | 963 | return NULL; |
968 | } | 964 | } |
969 | if (GNUNET_OK != GNUNET_NETWORK_socket_connect (ret->sock, | 965 | if (GNUNET_OK != |
970 | ret->addr, ret->addrlen)) | 966 | GNUNET_NETWORK_socket_connect (ret->sock, ret->addr, ret->addrlen)) |
971 | { | 967 | { |
972 | /* Just return; we expect everything to work eventually so don't fail HARD */ | 968 | /* Just return; we expect everything to work eventually so don't fail HARD */ |
973 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret->sock)); | 969 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret->sock)); |
@@ -1004,18 +1000,18 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family, | |||
1004 | s = GNUNET_NETWORK_socket_create (af_family, SOCK_STREAM, 0); | 1000 | s = GNUNET_NETWORK_socket_create (af_family, SOCK_STREAM, 0); |
1005 | if (s == NULL) | 1001 | if (s == NULL) |
1006 | { | 1002 | { |
1007 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | 1003 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
1008 | GNUNET_ERROR_TYPE_BULK, "socket"); | 1004 | "socket"); |
1009 | return NULL; | 1005 | return NULL; |
1010 | } | 1006 | } |
1011 | if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) | 1007 | if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) && |
1012 | && (errno != EINPROGRESS)) | 1008 | (errno != EINPROGRESS)) |
1013 | { | 1009 | { |
1014 | /* maybe refused / unsupported address, try next */ | 1010 | /* maybe refused / unsupported address, try next */ |
1015 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "connect"); | 1011 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "connect"); |
1016 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1012 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1017 | _("Attempt to connect to `%s' failed\n"), | 1013 | _("Attempt to connect to `%s' failed\n"), GNUNET_a2s (serv_addr, |
1018 | GNUNET_a2s (serv_addr, addrlen)); | 1014 | addrlen)); |
1019 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); | 1015 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); |
1020 | return NULL; | 1016 | return NULL; |
1021 | } | 1017 | } |
@@ -1024,8 +1020,7 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family, | |||
1024 | memcpy (ret->addr, serv_addr, addrlen); | 1020 | memcpy (ret->addr, serv_addr, addrlen); |
1025 | ret->addrlen = addrlen; | 1021 | ret->addrlen = addrlen; |
1026 | #if DEBUG_CONNECTION | 1022 | #if DEBUG_CONNECTION |
1027 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1023 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"), |
1028 | _("Trying to connect to `%s' (%p)\n"), | ||
1029 | GNUNET_a2s (serv_addr, addrlen), ret); | 1024 | GNUNET_a2s (serv_addr, addrlen), ret); |
1030 | #endif | 1025 | #endif |
1031 | return ret; | 1026 | return ret; |
@@ -1157,8 +1152,9 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1158 | "Receive from `%s' encounters error: time out by %llums... (%p)\n", | 1153 | "Receive from `%s' encounters error: time out by %llums... (%p)\n", |
1159 | GNUNET_a2s (sh->addr, sh->addrlen), | 1154 | GNUNET_a2s (sh->addr, sh->addrlen), |
1160 | GNUNET_TIME_absolute_get_duration (sh->receive_timeout). | 1155 | GNUNET_TIME_absolute_get_duration (sh-> |
1161 | rel_value, sh); | 1156 | receive_timeout).rel_value, |
1157 | sh); | ||
1162 | #endif | 1158 | #endif |
1163 | signal_timeout (sh); | 1159 | signal_timeout (sh); |
1164 | return; | 1160 | return; |
@@ -1181,8 +1177,8 @@ RETRY: | |||
1181 | if (errno == EINTR) | 1177 | if (errno == EINTR) |
1182 | goto RETRY; | 1178 | goto RETRY; |
1183 | #if DEBUG_CONNECTION | 1179 | #if DEBUG_CONNECTION |
1184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error receiving: %s\n", |
1185 | "Error receiving: %s\n", STRERROR (errno)); | 1181 | STRERROR (errno)); |
1186 | #endif | 1182 | #endif |
1187 | signal_error (sh, errno); | 1183 | signal_error (sh, errno); |
1188 | return; | 1184 | return; |
@@ -1190,8 +1186,8 @@ RETRY: | |||
1190 | #if DEBUG_CONNECTION | 1186 | #if DEBUG_CONNECTION |
1191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1192 | "receive_ready read %u/%u bytes from `%s' (%p)!\n", | 1188 | "receive_ready read %u/%u bytes from `%s' (%p)!\n", |
1193 | (unsigned int) ret, | 1189 | (unsigned int) ret, sh->max, GNUNET_a2s (sh->addr, sh->addrlen), |
1194 | sh->max, GNUNET_a2s (sh->addr, sh->addrlen), sh); | 1190 | sh); |
1195 | #endif | 1191 | #endif |
1196 | GNUNET_assert (NULL != (receiver = sh->receiver)); | 1192 | GNUNET_assert (NULL != (receiver = sh->receiver)); |
1197 | sh->receiver = NULL; | 1193 | sh->receiver = NULL; |
@@ -1260,8 +1256,7 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1260 | * @param receiver_cls closure for receiver | 1256 | * @param receiver_cls closure for receiver |
1261 | */ | 1257 | */ |
1262 | void | 1258 | void |
1263 | GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *sock, | 1259 | GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *sock, size_t max, |
1264 | size_t max, | ||
1265 | struct GNUNET_TIME_Relative timeout, | 1260 | struct GNUNET_TIME_Relative timeout, |
1266 | GNUNET_CONNECTION_Receiver receiver, | 1261 | GNUNET_CONNECTION_Receiver receiver, |
1267 | void *receiver_cls) | 1262 | void *receiver_cls) |
@@ -1358,15 +1353,16 @@ process_notify (struct GNUNET_CONNECTION_Handle *sock) | |||
1358 | if (sock->write_buffer_size - sock->write_buffer_off < size) | 1353 | if (sock->write_buffer_size - sock->write_buffer_off < size) |
1359 | { | 1354 | { |
1360 | /* need to compact */ | 1355 | /* need to compact */ |
1361 | memmove (sock->write_buffer, | 1356 | memmove (sock->write_buffer, &sock->write_buffer[sock->write_buffer_pos], |
1362 | &sock->write_buffer[sock->write_buffer_pos], used); | 1357 | used); |
1363 | sock->write_buffer_off -= sock->write_buffer_pos; | 1358 | sock->write_buffer_off -= sock->write_buffer_pos; |
1364 | sock->write_buffer_pos = 0; | 1359 | sock->write_buffer_pos = 0; |
1365 | } | 1360 | } |
1366 | avail = sock->write_buffer_size - sock->write_buffer_off; | 1361 | avail = sock->write_buffer_size - sock->write_buffer_off; |
1367 | GNUNET_assert (avail >= size); | 1362 | GNUNET_assert (avail >= size); |
1368 | size = notify (sock->nth.notify_ready_cls, | 1363 | size = |
1369 | avail, &sock->write_buffer[sock->write_buffer_off]); | 1364 | notify (sock->nth.notify_ready_cls, avail, |
1365 | &sock->write_buffer[sock->write_buffer_off]); | ||
1370 | GNUNET_assert (size <= avail); | 1366 | GNUNET_assert (size <= avail); |
1371 | sock->write_buffer_off += size; | 1367 | sock->write_buffer_off += size; |
1372 | return GNUNET_YES; | 1368 | return GNUNET_YES; |
@@ -1397,8 +1393,8 @@ transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1397 | #if DEBUG_CONNECTION | 1393 | #if DEBUG_CONNECTION |
1398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1399 | "Transmit to `%s:%u/%s' fails, time out reached (%p).\n", | 1395 | "Transmit to `%s:%u/%s' fails, time out reached (%p).\n", |
1400 | sock->hostname, | 1396 | sock->hostname, sock->port, GNUNET_a2s (sock->addr, |
1401 | sock->port, GNUNET_a2s (sock->addr, sock->addrlen), sock); | 1397 | sock->addrlen), sock); |
1402 | #endif | 1398 | #endif |
1403 | GNUNET_assert (0 != (sock->ccs & COCO_TRANSMIT_READY)); | 1399 | GNUNET_assert (0 != (sock->ccs & COCO_TRANSMIT_READY)); |
1404 | sock->ccs -= COCO_TRANSMIT_READY; /* remove request */ | 1400 | sock->ccs -= COCO_TRANSMIT_READY; /* remove request */ |
@@ -1541,8 +1537,8 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1541 | if ((sock->nth.notify_ready != NULL) && | 1537 | if ((sock->nth.notify_ready != NULL) && |
1542 | (sock->write_buffer_size < sock->nth.notify_size)) | 1538 | (sock->write_buffer_size < sock->nth.notify_size)) |
1543 | { | 1539 | { |
1544 | sock->write_buffer = GNUNET_realloc (sock->write_buffer, | 1540 | sock->write_buffer = |
1545 | sock->nth.notify_size); | 1541 | GNUNET_realloc (sock->write_buffer, sock->nth.notify_size); |
1546 | sock->write_buffer_size = sock->nth.notify_size; | 1542 | sock->write_buffer_size = sock->nth.notify_size; |
1547 | } | 1543 | } |
1548 | process_notify (sock); | 1544 | process_notify (sock); |
@@ -1556,9 +1552,10 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1556 | GNUNET_assert (have + sock->write_buffer_pos <= sock->write_buffer_size); | 1552 | GNUNET_assert (have + sock->write_buffer_pos <= sock->write_buffer_size); |
1557 | GNUNET_assert (sock->write_buffer_pos <= sock->write_buffer_size); | 1553 | GNUNET_assert (sock->write_buffer_pos <= sock->write_buffer_size); |
1558 | RETRY: | 1554 | RETRY: |
1559 | ret = GNUNET_NETWORK_socket_send (sock->sock, | 1555 | ret = |
1560 | &sock->write_buffer[sock->write_buffer_pos], | 1556 | GNUNET_NETWORK_socket_send (sock->sock, |
1561 | have); | 1557 | &sock->write_buffer[sock->write_buffer_pos], |
1558 | have); | ||
1562 | if (ret == -1) | 1559 | if (ret == -1) |
1563 | { | 1560 | { |
1564 | if (errno == EINTR) | 1561 | if (errno == EINTR) |
@@ -1566,8 +1563,7 @@ RETRY: | |||
1566 | #if 0 | 1563 | #if 0 |
1567 | int en = errno; | 1564 | int en = errno; |
1568 | 1565 | ||
1569 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1566 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to send to `%s': %s\n"), |
1570 | _("Failed to send to `%s': %s\n"), | ||
1571 | GNUNET_a2s (sock->addr, sock->addrlen), STRERROR (en)); | 1567 | GNUNET_a2s (sock->addr, sock->addrlen), STRERROR (en)); |
1572 | #endif | 1568 | #endif |
1573 | #if DEBUG_CONNECTION | 1569 | #if DEBUG_CONNECTION |
@@ -1579,8 +1575,8 @@ RETRY: | |||
1579 | #if DEBUG_CONNECTION | 1575 | #if DEBUG_CONNECTION |
1580 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1581 | "transmit_ready transmitted %u/%u bytes to `%s' (%p)\n", | 1577 | "transmit_ready transmitted %u/%u bytes to `%s' (%p)\n", |
1582 | (unsigned int) ret, | 1578 | (unsigned int) ret, have, GNUNET_a2s (sock->addr, sock->addrlen), |
1583 | have, GNUNET_a2s (sock->addr, sock->addrlen), sock); | 1579 | sock); |
1584 | #endif | 1580 | #endif |
1585 | sock->write_buffer_pos += ret; | 1581 | sock->write_buffer_pos += ret; |
1586 | if (sock->write_buffer_pos == sock->write_buffer_off) | 1582 | if (sock->write_buffer_pos == sock->write_buffer_off) |
@@ -1601,9 +1597,8 @@ SCHEDULE_WRITE: | |||
1601 | GNUNET_assert ((sock->nth.notify_ready != NULL) || (have > 0)); | 1597 | GNUNET_assert ((sock->nth.notify_ready != NULL) || (have > 0)); |
1602 | if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) | 1598 | if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) |
1603 | sock->write_task = | 1599 | sock->write_task = |
1604 | GNUNET_SCHEDULER_add_write_net ((sock->nth.notify_ready == NULL) | 1600 | GNUNET_SCHEDULER_add_write_net ((sock->nth.notify_ready == |
1605 | ? GNUNET_TIME_UNIT_FOREVER_REL | 1601 | NULL) ? GNUNET_TIME_UNIT_FOREVER_REL : |
1606 | : | ||
1607 | GNUNET_TIME_absolute_get_remaining | 1602 | GNUNET_TIME_absolute_get_remaining |
1608 | (sock->nth.transmit_timeout), | 1603 | (sock->nth.transmit_timeout), |
1609 | sock->sock, &transmit_ready, sock); | 1604 | sock->sock, &transmit_ready, sock); |
@@ -1625,8 +1620,8 @@ SCHEDULE_WRITE: | |||
1625 | * NULL if we are already going to notify someone else (busy) | 1620 | * NULL if we are already going to notify someone else (busy) |
1626 | */ | 1621 | */ |
1627 | struct GNUNET_CONNECTION_TransmitHandle * | 1622 | struct GNUNET_CONNECTION_TransmitHandle * |
1628 | GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle | 1623 | GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *sock, |
1629 | *sock, size_t size, | 1624 | size_t size, |
1630 | struct GNUNET_TIME_Relative timeout, | 1625 | struct GNUNET_TIME_Relative timeout, |
1631 | GNUNET_CONNECTION_TransmitReadyNotify | 1626 | GNUNET_CONNECTION_TransmitReadyNotify |
1632 | notify, void *notify_cls) | 1627 | notify, void *notify_cls) |
@@ -1647,8 +1642,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle | |||
1647 | sock->nth.notify_size = size; | 1642 | sock->nth.notify_size = size; |
1648 | sock->nth.transmit_timeout = GNUNET_TIME_relative_to_absolute (timeout); | 1643 | sock->nth.transmit_timeout = GNUNET_TIME_relative_to_absolute (timeout); |
1649 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->nth.timeout_task); | 1644 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->nth.timeout_task); |
1650 | if ((sock->sock == NULL) && | 1645 | if ((sock->sock == NULL) && (sock->ap_head == NULL) && |
1651 | (sock->ap_head == NULL) && (sock->dns_active == NULL)) | 1646 | (sock->dns_active == NULL)) |
1652 | { | 1647 | { |
1653 | if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) | 1648 | if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) |
1654 | GNUNET_SCHEDULER_cancel (sock->write_task); | 1649 | GNUNET_SCHEDULER_cancel (sock->write_task); |
@@ -1660,8 +1655,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle | |||
1660 | if (sock->sock != NULL) | 1655 | if (sock->sock != NULL) |
1661 | { | 1656 | { |
1662 | #if DEBUG_CONNECTION | 1657 | #if DEBUG_CONNECTION |
1663 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1658 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling transmit_ready (%p).\n", |
1664 | "Scheduling transmit_ready (%p).\n", sock); | 1659 | sock); |
1665 | #endif | 1660 | #endif |
1666 | sock->write_task = | 1661 | sock->write_task = |
1667 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining | 1662 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining |
@@ -1676,9 +1671,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle | |||
1676 | sock); | 1671 | sock); |
1677 | #endif | 1672 | #endif |
1678 | sock->ccs |= COCO_TRANSMIT_READY; | 1673 | sock->ccs |= COCO_TRANSMIT_READY; |
1679 | sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | 1674 | sock->nth.timeout_task = |
1680 | &transmit_timeout, | 1675 | GNUNET_SCHEDULER_add_delayed (timeout, &transmit_timeout, sock); |
1681 | sock); | ||
1682 | } | 1676 | } |
1683 | return &sock->nth; | 1677 | return &sock->nth; |
1684 | } | 1678 | } |
diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c index a0749a18a..ebd056128 100644 --- a/src/util/container_bloomfilter.c +++ b/src/util/container_bloomfilter.c | |||
@@ -102,8 +102,7 @@ struct GNUNET_CONTAINER_BloomFilter * | |||
102 | GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter | 102 | GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter |
103 | *bf) | 103 | *bf) |
104 | { | 104 | { |
105 | return GNUNET_CONTAINER_bloomfilter_init (bf->bitArray, | 105 | return GNUNET_CONTAINER_bloomfilter_init (bf->bitArray, bf->bitArraySize, |
106 | bf->bitArraySize, | ||
107 | bf->addressesPerElement); | 106 | bf->addressesPerElement); |
108 | } | 107 | } |
109 | 108 | ||
@@ -209,9 +208,8 @@ incrementBit (char *bitArray, unsigned int bitIdx, | |||
209 | high++; | 208 | high++; |
210 | } | 209 | } |
211 | value = ((high << 4) | low); | 210 | value = ((high << 4) | low); |
212 | GNUNET_assert (fileSlot == GNUNET_DISK_file_seek (fh, | 211 | GNUNET_assert (fileSlot == |
213 | fileSlot, | 212 | GNUNET_DISK_file_seek (fh, fileSlot, GNUNET_DISK_SEEK_SET)); |
214 | GNUNET_DISK_SEEK_SET)); | ||
215 | GNUNET_assert (1 == GNUNET_DISK_file_write (fh, &value, 1)); | 213 | GNUNET_assert (1 == GNUNET_DISK_file_write (fh, &value, 1)); |
216 | } | 214 | } |
217 | 215 | ||
@@ -348,8 +346,7 @@ iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf, | |||
348 | { | 346 | { |
349 | while (slot < (sizeof (GNUNET_HashCode) / sizeof (uint32_t))) | 347 | while (slot < (sizeof (GNUNET_HashCode) / sizeof (uint32_t))) |
350 | { | 348 | { |
351 | callback (arg, | 349 | callback (arg, bf, |
352 | bf, | ||
353 | (((uint32_t *) & tmp[round & 1])[slot]) & | 350 | (((uint32_t *) & tmp[round & 1])[slot]) & |
354 | ((bf->bitArraySize * 8) - 1)); | 351 | ((bf->bitArraySize * 8) - 1)); |
355 | slot++; | 352 | slot++; |
@@ -375,8 +372,7 @@ iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf, | |||
375 | * @param bit the bit to increment | 372 | * @param bit the bit to increment |
376 | */ | 373 | */ |
377 | static void | 374 | static void |
378 | incrementBitCallback (void *cls, | 375 | incrementBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, |
379 | const struct GNUNET_CONTAINER_BloomFilter *bf, | ||
380 | unsigned int bit) | 376 | unsigned int bit) |
381 | { | 377 | { |
382 | struct GNUNET_CONTAINER_BloomFilter *b = cls; | 378 | struct GNUNET_CONTAINER_BloomFilter *b = cls; |
@@ -392,8 +388,7 @@ incrementBitCallback (void *cls, | |||
392 | * @param bit the bit to decrement | 388 | * @param bit the bit to decrement |
393 | */ | 389 | */ |
394 | static void | 390 | static void |
395 | decrementBitCallback (void *cls, | 391 | decrementBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, |
396 | const struct GNUNET_CONTAINER_BloomFilter *bf, | ||
397 | unsigned int bit) | 392 | unsigned int bit) |
398 | { | 393 | { |
399 | struct GNUNET_CONTAINER_BloomFilter *b = cls; | 394 | struct GNUNET_CONTAINER_BloomFilter *b = cls; |
@@ -409,8 +404,7 @@ decrementBitCallback (void *cls, | |||
409 | * @param bit the bit to test | 404 | * @param bit the bit to test |
410 | */ | 405 | */ |
411 | static void | 406 | static void |
412 | testBitCallback (void *cls, | 407 | testBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, |
413 | const struct GNUNET_CONTAINER_BloomFilter *bf, | ||
414 | unsigned int bit) | 408 | unsigned int bit) |
415 | { | 409 | { |
416 | int *arg = cls; | 410 | int *arg = cls; |
@@ -432,8 +426,8 @@ testBitCallback (void *cls, | |||
432 | * @return the bloomfilter | 426 | * @return the bloomfilter |
433 | */ | 427 | */ |
434 | struct GNUNET_CONTAINER_BloomFilter * | 428 | struct GNUNET_CONTAINER_BloomFilter * |
435 | GNUNET_CONTAINER_bloomfilter_load (const char *filename, | 429 | GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size, |
436 | size_t size, unsigned int k) | 430 | unsigned int k) |
437 | { | 431 | { |
438 | struct GNUNET_CONTAINER_BloomFilter *bf; | 432 | struct GNUNET_CONTAINER_BloomFilter *bf; |
439 | char *rbuff; | 433 | char *rbuff; |
@@ -453,10 +447,12 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, | |||
453 | 447 | ||
454 | bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter)); | 448 | bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter)); |
455 | /* Try to open a bloomfilter file */ | 449 | /* Try to open a bloomfilter file */ |
456 | bf->fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READWRITE | 450 | bf->fh = |
457 | | GNUNET_DISK_OPEN_CREATE, | 451 | GNUNET_DISK_file_open (filename, |
458 | GNUNET_DISK_PERM_USER_READ | | 452 | GNUNET_DISK_OPEN_READWRITE | |
459 | GNUNET_DISK_PERM_USER_WRITE); | 453 | GNUNET_DISK_OPEN_CREATE, |
454 | GNUNET_DISK_PERM_USER_READ | | ||
455 | GNUNET_DISK_PERM_USER_WRITE); | ||
460 | if (NULL == bf->fh) | 456 | if (NULL == bf->fh) |
461 | { | 457 | { |
462 | GNUNET_free (bf); | 458 | GNUNET_free (bf); |
@@ -487,8 +483,8 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, | |||
487 | res = GNUNET_DISK_file_read (bf->fh, rbuff, BUFFSIZE); | 483 | res = GNUNET_DISK_file_read (bf->fh, rbuff, BUFFSIZE); |
488 | if (res == -1) | 484 | if (res == -1) |
489 | { | 485 | { |
490 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 486 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", |
491 | "read", bf->filename); | 487 | bf->filename); |
492 | } | 488 | } |
493 | if (res == 0) | 489 | if (res == 0) |
494 | break; /* is ok! we just did not use that many bits yet */ | 490 | break; /* is ok! we just did not use that many bits yet */ |
@@ -522,8 +518,8 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, | |||
522 | * @return the bloomfilter | 518 | * @return the bloomfilter |
523 | */ | 519 | */ |
524 | struct GNUNET_CONTAINER_BloomFilter * | 520 | struct GNUNET_CONTAINER_BloomFilter * |
525 | GNUNET_CONTAINER_bloomfilter_init (const char *data, | 521 | GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size, |
526 | size_t size, unsigned int k) | 522 | unsigned int k) |
527 | { | 523 | { |
528 | struct GNUNET_CONTAINER_BloomFilter *bf; | 524 | struct GNUNET_CONTAINER_BloomFilter *bf; |
529 | size_t ui; | 525 | size_t ui; |
@@ -752,8 +748,8 @@ GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
752 | void | 748 | void |
753 | GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, | 749 | GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, |
754 | GNUNET_HashCodeIterator iterator, | 750 | GNUNET_HashCodeIterator iterator, |
755 | void *iterator_cls, | 751 | void *iterator_cls, size_t size, |
756 | size_t size, unsigned int k) | 752 | unsigned int k) |
757 | { | 753 | { |
758 | GNUNET_HashCode hc; | 754 | GNUNET_HashCode hc; |
759 | unsigned int i; | 755 | unsigned int i; |
diff --git a/src/util/container_heap.c b/src/util/container_heap.c index c1d478e06..ef6bcc892 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c | |||
@@ -218,11 +218,11 @@ node_iterator (const struct GNUNET_CONTAINER_Heap *heap, | |||
218 | { | 218 | { |
219 | if (node == NULL) | 219 | if (node == NULL) |
220 | return GNUNET_YES; | 220 | return GNUNET_YES; |
221 | if (GNUNET_YES != node_iterator (heap, | 221 | if (GNUNET_YES != |
222 | node->left_child, iterator, iterator_cls)) | 222 | node_iterator (heap, node->left_child, iterator, iterator_cls)) |
223 | return GNUNET_NO; | 223 | return GNUNET_NO; |
224 | if (GNUNET_YES != node_iterator (heap, | 224 | if (GNUNET_YES != |
225 | node->right_child, iterator, iterator_cls)) | 225 | node_iterator (heap, node->right_child, iterator, iterator_cls)) |
226 | return GNUNET_NO; | 226 | return GNUNET_NO; |
227 | return iterator (iterator_cls, node, node->element, node->cost); | 227 | return iterator (iterator_cls, node, node->element, node->cost); |
228 | } | 228 | } |
@@ -267,9 +267,10 @@ GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap) | |||
267 | if (pos == NULL) | 267 | if (pos == NULL) |
268 | pos = heap->root; | 268 | pos = heap->root; |
269 | element = pos->element; | 269 | element = pos->element; |
270 | heap->walk_pos | 270 | heap->walk_pos = |
271 | = (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2)) | 271 | (0 == |
272 | ? pos->right_child : pos->left_child; | 272 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
273 | 2)) ? pos->right_child : pos->left_child; | ||
273 | return element; | 274 | return element; |
274 | } | 275 | } |
275 | 276 | ||
@@ -290,8 +291,12 @@ insert_node (struct GNUNET_CONTAINER_Heap *heap, | |||
290 | struct GNUNET_CONTAINER_HeapNode *parent; | 291 | struct GNUNET_CONTAINER_HeapNode *parent; |
291 | 292 | ||
292 | GNUNET_assert (node->parent == NULL); | 293 | GNUNET_assert (node->parent == NULL); |
293 | while ((heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) | 294 | while ((heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) ? (pos->cost >= |
294 | ? (pos->cost >= node->cost) : (pos->cost <= node->cost)) | 295 | node-> |
296 | cost) : (pos-> | ||
297 | cost <= | ||
298 | node-> | ||
299 | cost)) | ||
295 | { | 300 | { |
296 | /* node is descendent of pos */ | 301 | /* node is descendent of pos */ |
297 | pos->tree_size += (1 + node->tree_size); | 302 | pos->tree_size += (1 + node->tree_size); |
@@ -343,8 +348,8 @@ insert_node (struct GNUNET_CONTAINER_Heap *heap, | |||
343 | * @return node for the new element | 348 | * @return node for the new element |
344 | */ | 349 | */ |
345 | struct GNUNET_CONTAINER_HeapNode * | 350 | struct GNUNET_CONTAINER_HeapNode * |
346 | GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, | 351 | GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, void *element, |
347 | void *element, GNUNET_CONTAINER_HeapCostType cost) | 352 | GNUNET_CONTAINER_HeapCostType cost) |
348 | { | 353 | { |
349 | struct GNUNET_CONTAINER_HeapNode *node; | 354 | struct GNUNET_CONTAINER_HeapNode *node; |
350 | 355 | ||
@@ -399,8 +404,7 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap) | |||
399 | } | 404 | } |
400 | GNUNET_free (root); | 405 | GNUNET_free (root); |
401 | #if DEBUG | 406 | #if DEBUG |
402 | GNUNET_assert (((heap->size == 0) && | 407 | GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || |
403 | (heap->root == NULL)) || | ||
404 | (heap->size == heap->root->tree_size + 1)); | 408 | (heap->size == heap->root->tree_size + 1)); |
405 | CHECK (heap->root); | 409 | CHECK (heap->root); |
406 | #endif | 410 | #endif |
@@ -502,8 +506,7 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node) | |||
502 | GNUNET_free (node); | 506 | GNUNET_free (node); |
503 | #if DEBUG | 507 | #if DEBUG |
504 | CHECK (heap->root); | 508 | CHECK (heap->root); |
505 | GNUNET_assert (((heap->size == 0) && | 509 | GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || |
506 | (heap->root == NULL)) || | ||
507 | (heap->size == heap->root->tree_size + 1)); | 510 | (heap->size == heap->root->tree_size + 1)); |
508 | #endif | 511 | #endif |
509 | return ret; | 512 | return ret; |
@@ -523,16 +526,14 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, | |||
523 | GNUNET_CONTAINER_HeapCostType new_cost) | 526 | GNUNET_CONTAINER_HeapCostType new_cost) |
524 | { | 527 | { |
525 | #if DEBUG | 528 | #if DEBUG |
526 | GNUNET_assert (((heap->size == 0) && | 529 | GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || |
527 | (heap->root == NULL)) || | ||
528 | (heap->size == heap->root->tree_size + 1)); | 530 | (heap->size == heap->root->tree_size + 1)); |
529 | CHECK (heap->root); | 531 | CHECK (heap->root); |
530 | #endif | 532 | #endif |
531 | remove_node (node); | 533 | remove_node (node); |
532 | #if DEBUG | 534 | #if DEBUG |
533 | CHECK (heap->root); | 535 | CHECK (heap->root); |
534 | GNUNET_assert (((heap->size == 1) && | 536 | GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) || |
535 | (heap->root == NULL)) || | ||
536 | (heap->size == heap->root->tree_size + 2)); | 537 | (heap->size == heap->root->tree_size + 2)); |
537 | #endif | 538 | #endif |
538 | node->cost = new_cost; | 539 | node->cost = new_cost; |
@@ -542,8 +543,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, | |||
542 | insert_node (heap, heap->root, node); | 543 | insert_node (heap, heap->root, node); |
543 | #if DEBUG | 544 | #if DEBUG |
544 | CHECK (heap->root); | 545 | CHECK (heap->root); |
545 | GNUNET_assert (((heap->size == 0) && | 546 | GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || |
546 | (heap->root == NULL)) || | ||
547 | (heap->size == heap->root->tree_size + 1)); | 547 | (heap->size == heap->root->tree_size + 1)); |
548 | #endif | 548 | #endif |
549 | } | 549 | } |
diff --git a/src/util/container_meta_data.c b/src/util/container_meta_data.c index 64a58e133..c67e96dac 100644 --- a/src/util/container_meta_data.c +++ b/src/util/container_meta_data.c | |||
@@ -224,8 +224,7 @@ GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData | |||
224 | j = md2->items; | 224 | j = md2->items; |
225 | while (NULL != j) | 225 | while (NULL != j) |
226 | { | 226 | { |
227 | if ((i->type == j->type) && | 227 | if ((i->type == j->type) && (i->format == j->format) && |
228 | (i->format == j->format) && | ||
229 | (i->data_size == j->data_size) && | 228 | (i->data_size == j->data_size) && |
230 | (0 == memcmp (i->data, j->data, i->data_size))) | 229 | (0 == memcmp (i->data, j->data, i->data_size))) |
231 | { | 230 | { |
@@ -265,8 +264,8 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, | |||
265 | const char *plugin_name, | 264 | const char *plugin_name, |
266 | enum EXTRACTOR_MetaType type, | 265 | enum EXTRACTOR_MetaType type, |
267 | enum EXTRACTOR_MetaFormat format, | 266 | enum EXTRACTOR_MetaFormat format, |
268 | const char *data_mime_type, | 267 | const char *data_mime_type, const char *data, |
269 | const char *data, size_t data_len) | 268 | size_t data_len) |
270 | { | 269 | { |
271 | struct MetaItem *prev; | 270 | struct MetaItem *prev; |
272 | struct MetaItem *pos; | 271 | struct MetaItem *pos; |
@@ -279,8 +278,7 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, | |||
279 | { | 278 | { |
280 | if (pos->data_size < data_len) | 279 | if (pos->data_size < data_len) |
281 | break; | 280 | break; |
282 | if ((pos->type == type) && | 281 | if ((pos->type == type) && (pos->data_size == data_len) && |
283 | (pos->data_size == data_len) && | ||
284 | (0 == memcmp (pos->data, data, data_len))) | 282 | (0 == memcmp (pos->data, data, data_len))) |
285 | { | 283 | { |
286 | if ((pos->mime_type == NULL) && (data_mime_type != NULL)) | 284 | if ((pos->mime_type == NULL) && (data_mime_type != NULL)) |
@@ -349,16 +347,13 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, | |||
349 | * @return 0 (to continue) | 347 | * @return 0 (to continue) |
350 | */ | 348 | */ |
351 | static int | 349 | static int |
352 | merge_helper (void *cls, | 350 | merge_helper (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, |
353 | const char *plugin_name, | 351 | enum EXTRACTOR_MetaFormat format, const char *data_mime_type, |
354 | enum EXTRACTOR_MetaType type, | 352 | const char *data, size_t data_len) |
355 | enum EXTRACTOR_MetaFormat format, | ||
356 | const char *data_mime_type, const char *data, size_t data_len) | ||
357 | { | 353 | { |
358 | struct GNUNET_CONTAINER_MetaData *md = cls; | 354 | struct GNUNET_CONTAINER_MetaData *md = cls; |
359 | 355 | ||
360 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, | 356 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, |
361 | type, format, | ||
362 | data_mime_type, data, data_len); | 357 | data_mime_type, data, data_len); |
363 | return 0; | 358 | return 0; |
364 | } | 359 | } |
@@ -436,15 +431,13 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct | |||
436 | struct GNUNET_TIME_Absolute t; | 431 | struct GNUNET_TIME_Absolute t; |
437 | 432 | ||
438 | t = GNUNET_TIME_absolute_get (); | 433 | t = GNUNET_TIME_absolute_get (); |
439 | GNUNET_CONTAINER_meta_data_delete (md, | 434 | GNUNET_CONTAINER_meta_data_delete (md, EXTRACTOR_METATYPE_PUBLICATION_DATE, |
440 | EXTRACTOR_METATYPE_PUBLICATION_DATE, | ||
441 | NULL, 0); | 435 | NULL, 0); |
442 | dat = GNUNET_STRINGS_absolute_time_to_string (t); | 436 | dat = GNUNET_STRINGS_absolute_time_to_string (t); |
443 | GNUNET_CONTAINER_meta_data_insert (md, | 437 | GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>", |
444 | "<gnunet>", | ||
445 | EXTRACTOR_METATYPE_PUBLICATION_DATE, | 438 | EXTRACTOR_METATYPE_PUBLICATION_DATE, |
446 | EXTRACTOR_METAFORMAT_UTF8, | 439 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
447 | "text/plain", dat, strlen (dat) + 1); | 440 | dat, strlen (dat) + 1); |
448 | GNUNET_free (dat); | 441 | GNUNET_free (dat); |
449 | } | 442 | } |
450 | 443 | ||
@@ -458,10 +451,9 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct | |||
458 | * @return number of entries | 451 | * @return number of entries |
459 | */ | 452 | */ |
460 | int | 453 | int |
461 | GNUNET_CONTAINER_meta_data_iterate (const struct | 454 | GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md, |
462 | GNUNET_CONTAINER_MetaData *md, | 455 | EXTRACTOR_MetaDataProcessor iter, |
463 | EXTRACTOR_MetaDataProcessor | 456 | void *iter_cls) |
464 | iter, void *iter_cls) | ||
465 | { | 457 | { |
466 | struct MetaItem *pos; | 458 | struct MetaItem *pos; |
467 | 459 | ||
@@ -472,10 +464,9 @@ GNUNET_CONTAINER_meta_data_iterate (const struct | |||
472 | pos = md->items; | 464 | pos = md->items; |
473 | while (NULL != pos) | 465 | while (NULL != pos) |
474 | { | 466 | { |
475 | if (0 != iter (iter_cls, | 467 | if (0 != |
476 | pos->plugin_name, | 468 | iter (iter_cls, pos->plugin_name, pos->type, pos->format, |
477 | pos->type, | 469 | pos->mime_type, pos->data, pos->data_size)) |
478 | pos->format, pos->mime_type, pos->data, pos->data_size)) | ||
479 | return md->item_count; | 470 | return md->item_count; |
480 | pos = pos->next; | 471 | pos = pos->next; |
481 | } | 472 | } |
@@ -562,9 +553,8 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct | |||
562 | * @return number of bytes in thumbnail, 0 if not available | 553 | * @return number of bytes in thumbnail, 0 if not available |
563 | */ | 554 | */ |
564 | size_t | 555 | size_t |
565 | GNUNET_CONTAINER_meta_data_get_thumbnail (const struct | 556 | GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData |
566 | GNUNET_CONTAINER_MetaData * md, | 557 | * md, unsigned char **thumb) |
567 | unsigned char **thumb) | ||
568 | { | 558 | { |
569 | struct MetaItem *pos; | 559 | struct MetaItem *pos; |
570 | struct MetaItem *match; | 560 | struct MetaItem *match; |
@@ -576,8 +566,7 @@ GNUNET_CONTAINER_meta_data_get_thumbnail (const struct | |||
576 | while (NULL != pos) | 566 | while (NULL != pos) |
577 | { | 567 | { |
578 | if ((NULL != pos->mime_type) && | 568 | if ((NULL != pos->mime_type) && |
579 | (0 == strncasecmp ("image/", pos->mime_type, | 569 | (0 == strncasecmp ("image/", pos->mime_type, strlen ("image/"))) && |
580 | strlen ("image/"))) && | ||
581 | (pos->format == EXTRACTOR_METAFORMAT_BINARY)) | 570 | (pos->format == EXTRACTOR_METAFORMAT_BINARY)) |
582 | { | 571 | { |
583 | if (match == NULL) | 572 | if (match == NULL) |
@@ -615,12 +604,9 @@ GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData | |||
615 | pos = md->items; | 604 | pos = md->items; |
616 | while (NULL != pos) | 605 | while (NULL != pos) |
617 | { | 606 | { |
618 | GNUNET_CONTAINER_meta_data_insert (ret, | 607 | GNUNET_CONTAINER_meta_data_insert (ret, pos->plugin_name, pos->type, |
619 | pos->plugin_name, | 608 | pos->format, pos->mime_type, pos->data, |
620 | pos->type, | 609 | pos->data_size); |
621 | pos->format, | ||
622 | pos->mime_type, | ||
623 | pos->data, pos->data_size); | ||
624 | pos = pos->next; | 610 | pos = pos->next; |
625 | } | 611 | } |
626 | return ret; | 612 | return ret; |
@@ -642,8 +628,8 @@ GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData | |||
642 | * GNUNET_NO if compression did not help | 628 | * GNUNET_NO if compression did not help |
643 | */ | 629 | */ |
644 | static int | 630 | static int |
645 | try_compression (const char *data, | 631 | try_compression (const char *data, size_t oldSize, char **result, |
646 | size_t oldSize, char **result, size_t * newSize) | 632 | size_t * newSize) |
647 | { | 633 | { |
648 | char *tmp; | 634 | char *tmp; |
649 | uLongf dlen; | 635 | uLongf dlen; |
@@ -656,8 +642,8 @@ try_compression (const char *data, | |||
656 | * should be able to overshoot by more to be safe */ | 642 | * should be able to overshoot by more to be safe */ |
657 | #endif | 643 | #endif |
658 | tmp = GNUNET_malloc (dlen); | 644 | tmp = GNUNET_malloc (dlen); |
659 | if (Z_OK == compress2 ((Bytef *) tmp, | 645 | if (Z_OK == |
660 | &dlen, (const Bytef *) data, oldSize, 9)) | 646 | compress2 ((Bytef *) tmp, &dlen, (const Bytef *) data, oldSize, 9)) |
661 | { | 647 | { |
662 | if (dlen < oldSize) | 648 | if (dlen < oldSize) |
663 | { | 649 | { |
@@ -990,10 +976,9 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct | |||
990 | if (md->sbuf != NULL) | 976 | if (md->sbuf != NULL) |
991 | return md->sbuf_size; | 977 | return md->sbuf_size; |
992 | ptr = NULL; | 978 | ptr = NULL; |
993 | ret = GNUNET_CONTAINER_meta_data_serialize (md, | 979 | ret = |
994 | &ptr, | 980 | GNUNET_CONTAINER_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED, |
995 | GNUNET_MAX_MALLOC_CHECKED, | 981 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); |
996 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); | ||
997 | if (ret != -1) | 982 | if (ret != -1) |
998 | GNUNET_free (ptr); | 983 | GNUNET_free (ptr); |
999 | return ret; | 984 | return ret; |
@@ -1018,8 +1003,8 @@ decompress (const char *input, size_t inputSize, size_t outputSize) | |||
1018 | 1003 | ||
1019 | olen = outputSize; | 1004 | olen = outputSize; |
1020 | output = GNUNET_malloc (olen); | 1005 | output = GNUNET_malloc (olen); |
1021 | if (Z_OK == uncompress ((Bytef *) output, | 1006 | if (Z_OK == |
1022 | &olen, (const Bytef *) input, inputSize)) | 1007 | uncompress ((Bytef *) output, &olen, (const Bytef *) input, inputSize)) |
1023 | { | 1008 | { |
1024 | return output; | 1009 | return output; |
1025 | } | 1010 | } |
@@ -1119,8 +1104,7 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size) | |||
1119 | mdata = &cdata[ic * sizeof (struct MetaDataEntry)]; | 1104 | mdata = &cdata[ic * sizeof (struct MetaDataEntry)]; |
1120 | for (i = 0; i < ic; i++) | 1105 | for (i = 0; i < ic; i++) |
1121 | { | 1106 | { |
1122 | memcpy (&ent, | 1107 | memcpy (&ent, &cdata[i * sizeof (struct MetaDataEntry)], |
1123 | &cdata[i * sizeof (struct MetaDataEntry)], | ||
1124 | sizeof (struct MetaDataEntry)); | 1108 | sizeof (struct MetaDataEntry)); |
1125 | format = (enum EXTRACTOR_MetaFormat) ntohl (ent.format); | 1109 | format = (enum EXTRACTOR_MetaFormat) ntohl (ent.format); |
1126 | if ((format != EXTRACTOR_METAFORMAT_UTF8) && | 1110 | if ((format != EXTRACTOR_METAFORMAT_UTF8) && |
@@ -1180,11 +1164,10 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size) | |||
1180 | mime_type = NULL; | 1164 | mime_type = NULL; |
1181 | else | 1165 | else |
1182 | mime_type = &mdata[left]; | 1166 | mime_type = &mdata[left]; |
1183 | GNUNET_CONTAINER_meta_data_insert (md, | 1167 | GNUNET_CONTAINER_meta_data_insert (md, plugin_name, |
1184 | plugin_name, | 1168 | (enum EXTRACTOR_MetaType) ntohl (ent. |
1185 | (enum EXTRACTOR_MetaType) | 1169 | type), |
1186 | ntohl (ent.type), format, mime_type, | 1170 | format, mime_type, meta_data, dlen); |
1187 | meta_data, dlen); | ||
1188 | } | 1171 | } |
1189 | GNUNET_free_non_null (data); | 1172 | GNUNET_free_non_null (data); |
1190 | return md; | 1173 | return md; |
diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c index 9635af17d..974d6c7f7 100644 --- a/src/util/container_multihashmap.c +++ b/src/util/container_multihashmap.c | |||
@@ -230,9 +230,8 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct | |||
230 | * is not in the map | 230 | * is not in the map |
231 | */ | 231 | */ |
232 | int | 232 | int |
233 | GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap | 233 | GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, |
234 | *map, const GNUNET_HashCode * key, | 234 | const GNUNET_HashCode * key, void *value) |
235 | void *value) | ||
236 | { | 235 | { |
237 | struct MapEntry *e; | 236 | struct MapEntry *e; |
238 | struct MapEntry *p; | 237 | struct MapEntry *p; |
@@ -348,8 +347,7 @@ GNUNET_CONTAINER_multihashmap_contains (const struct | |||
348 | int | 347 | int |
349 | GNUNET_CONTAINER_multihashmap_contains_value (const struct | 348 | GNUNET_CONTAINER_multihashmap_contains_value (const struct |
350 | GNUNET_CONTAINER_MultiHashMap | 349 | GNUNET_CONTAINER_MultiHashMap |
351 | *map, | 350 | *map, const GNUNET_HashCode * key, |
352 | const GNUNET_HashCode * key, | ||
353 | const void *value) | 351 | const void *value) |
354 | { | 352 | { |
355 | struct MapEntry *e; | 353 | struct MapEntry *e; |
@@ -416,8 +414,7 @@ grow (struct GNUNET_CONTAINER_MultiHashMap *map) | |||
416 | */ | 414 | */ |
417 | int | 415 | int |
418 | GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, | 416 | GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, |
419 | const GNUNET_HashCode * key, | 417 | const GNUNET_HashCode * key, void *value, |
420 | void *value, | ||
421 | enum GNUNET_CONTAINER_MultiHashMapOption opt) | 418 | enum GNUNET_CONTAINER_MultiHashMapOption opt) |
422 | { | 419 | { |
423 | struct MapEntry *e; | 420 | struct MapEntry *e; |
@@ -467,10 +464,10 @@ GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, | |||
467 | */ | 464 | */ |
468 | int | 465 | int |
469 | GNUNET_CONTAINER_multihashmap_get_multiple (const struct | 466 | GNUNET_CONTAINER_multihashmap_get_multiple (const struct |
470 | GNUNET_CONTAINER_MultiHashMap | 467 | GNUNET_CONTAINER_MultiHashMap *map, |
471 | *map, const GNUNET_HashCode * key, | 468 | const GNUNET_HashCode * key, |
472 | GNUNET_CONTAINER_HashMapIterator | 469 | GNUNET_CONTAINER_HashMapIterator it, |
473 | it, void *it_cls) | 470 | void *it_cls) |
474 | { | 471 | { |
475 | int count; | 472 | int count; |
476 | struct MapEntry *e; | 473 | struct MapEntry *e; |
diff --git a/src/util/container_slist.c b/src/util/container_slist.c index c06d70e91..2d7c24c03 100644 --- a/src/util/container_slist.c +++ b/src/util/container_slist.c | |||
@@ -107,8 +107,8 @@ struct GNUNET_CONTAINER_SList_Iterator | |||
107 | * @return a new element | 107 | * @return a new element |
108 | */ | 108 | */ |
109 | static struct GNUNET_CONTAINER_SList_Elem * | 109 | static struct GNUNET_CONTAINER_SList_Elem * |
110 | create_elem (enum GNUNET_CONTAINER_SListDisposition disp, | 110 | create_elem (enum GNUNET_CONTAINER_SListDisposition disp, const void *buf, |
111 | const void *buf, size_t len) | 111 | size_t len) |
112 | { | 112 | { |
113 | struct GNUNET_CONTAINER_SList_Elem *e; | 113 | struct GNUNET_CONTAINER_SList_Elem *e; |
114 | 114 | ||
@@ -186,8 +186,9 @@ GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst, | |||
186 | { | 186 | { |
187 | struct GNUNET_CONTAINER_SList_Iterator *i; | 187 | struct GNUNET_CONTAINER_SList_Iterator *i; |
188 | 188 | ||
189 | for (i = GNUNET_CONTAINER_slist_begin (src); GNUNET_CONTAINER_slist_end (i) != | 189 | for (i = GNUNET_CONTAINER_slist_begin (src); |
190 | GNUNET_YES; GNUNET_CONTAINER_slist_next (i)) | 190 | GNUNET_CONTAINER_slist_end (i) != GNUNET_YES; |
191 | GNUNET_CONTAINER_slist_next (i)) | ||
191 | 192 | ||
192 | { | 193 | { |
193 | GNUNET_CONTAINER_slist_add (dst, | 194 | GNUNET_CONTAINER_slist_add (dst, |
diff --git a/src/util/crypto_aes.c b/src/util/crypto_aes.c index 200c367c1..a984e17fc 100644 --- a/src/util/crypto_aes.c +++ b/src/util/crypto_aes.c | |||
@@ -73,12 +73,11 @@ GNUNET_CRYPTO_aes_check_session_key (const struct GNUNET_CRYPTO_AesSessionKey | |||
73 | * @returns the size of the encrypted block, -1 for errors | 73 | * @returns the size of the encrypted block, -1 for errors |
74 | */ | 74 | */ |
75 | ssize_t | 75 | ssize_t |
76 | GNUNET_CRYPTO_aes_encrypt (const void *block, | 76 | GNUNET_CRYPTO_aes_encrypt (const void *block, size_t len, |
77 | size_t len, | 77 | const struct GNUNET_CRYPTO_AesSessionKey * |
78 | const struct GNUNET_CRYPTO_AesSessionKey | 78 | sessionkey, |
79 | * sessionkey, | 79 | const struct GNUNET_CRYPTO_AesInitializationVector * |
80 | const struct GNUNET_CRYPTO_AesInitializationVector | 80 | iv, void *result) |
81 | * iv, void *result) | ||
82 | { | 81 | { |
83 | gcry_cipher_hd_t handle; | 82 | gcry_cipher_hd_t handle; |
84 | int rc; | 83 | int rc; |
@@ -89,9 +88,9 @@ GNUNET_CRYPTO_aes_encrypt (const void *block, | |||
89 | GNUNET_break (0); | 88 | GNUNET_break (0); |
90 | return -1; | 89 | return -1; |
91 | } | 90 | } |
92 | GNUNET_assert (0 == gcry_cipher_open (&handle, | 91 | GNUNET_assert (0 == |
93 | GCRY_CIPHER_AES256, | 92 | gcry_cipher_open (&handle, GCRY_CIPHER_AES256, |
94 | GCRY_CIPHER_MODE_CFB, 0)); | 93 | GCRY_CIPHER_MODE_CFB, 0)); |
95 | rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); | 94 | rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); |
96 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); | 95 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); |
97 | rc = gcry_cipher_setiv (handle, iv, | 96 | rc = gcry_cipher_setiv (handle, iv, |
@@ -115,12 +114,11 @@ GNUNET_CRYPTO_aes_encrypt (const void *block, | |||
115 | * @return -1 on failure, size of decrypted block on success | 114 | * @return -1 on failure, size of decrypted block on success |
116 | */ | 115 | */ |
117 | ssize_t | 116 | ssize_t |
118 | GNUNET_CRYPTO_aes_decrypt (const void *block, | 117 | GNUNET_CRYPTO_aes_decrypt (const void *block, size_t size, |
119 | size_t size, | 118 | const struct GNUNET_CRYPTO_AesSessionKey * |
120 | const struct GNUNET_CRYPTO_AesSessionKey | 119 | sessionkey, |
121 | * sessionkey, | 120 | const struct GNUNET_CRYPTO_AesInitializationVector * |
122 | const struct GNUNET_CRYPTO_AesInitializationVector | 121 | iv, void *result) |
123 | * iv, void *result) | ||
124 | { | 122 | { |
125 | gcry_cipher_hd_t handle; | 123 | gcry_cipher_hd_t handle; |
126 | int rc; | 124 | int rc; |
@@ -131,9 +129,9 @@ GNUNET_CRYPTO_aes_decrypt (const void *block, | |||
131 | GNUNET_break (0); | 129 | GNUNET_break (0); |
132 | return -1; | 130 | return -1; |
133 | } | 131 | } |
134 | GNUNET_assert (0 == gcry_cipher_open (&handle, | 132 | GNUNET_assert (0 == |
135 | GCRY_CIPHER_AES256, | 133 | gcry_cipher_open (&handle, GCRY_CIPHER_AES256, |
136 | GCRY_CIPHER_MODE_CFB, 0)); | 134 | GCRY_CIPHER_MODE_CFB, 0)); |
137 | rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); | 135 | rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); |
138 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); | 136 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); |
139 | rc = gcry_cipher_setiv (handle, iv, | 137 | rc = gcry_cipher_setiv (handle, iv, |
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index c693ed081..6438784ba 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -175,8 +175,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
175 | */ | 175 | */ |
176 | struct GNUNET_CRYPTO_FileHashContext * | 176 | struct GNUNET_CRYPTO_FileHashContext * |
177 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | 177 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, |
178 | const char *filename, | 178 | const char *filename, size_t blocksize, |
179 | size_t blocksize, | ||
180 | GNUNET_CRYPTO_HashCompletedCallback callback, | 179 | GNUNET_CRYPTO_HashCompletedCallback callback, |
181 | void *callback_cls) | 180 | void *callback_cls) |
182 | { | 181 | { |
@@ -202,17 +201,17 @@ GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | |||
202 | GNUNET_free (fhc); | 201 | GNUNET_free (fhc); |
203 | return NULL; | 202 | return NULL; |
204 | } | 203 | } |
205 | fhc->fh = GNUNET_DISK_file_open (filename, | 204 | fhc->fh = |
206 | GNUNET_DISK_OPEN_READ, | 205 | GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, |
207 | GNUNET_DISK_PERM_NONE); | 206 | GNUNET_DISK_PERM_NONE); |
208 | if (!fhc->fh) | 207 | if (!fhc->fh) |
209 | { | 208 | { |
210 | GNUNET_free (fhc->filename); | 209 | GNUNET_free (fhc->filename); |
211 | GNUNET_free (fhc); | 210 | GNUNET_free (fhc); |
212 | return NULL; | 211 | return NULL; |
213 | } | 212 | } |
214 | fhc->task | 213 | fhc->task = |
215 | = GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); | 214 | GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); |
216 | return fhc; | 215 | return fhc; |
217 | } | 216 | } |
218 | 217 | ||
@@ -390,8 +389,8 @@ GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a, | |||
390 | 389 | ||
391 | 390 | ||
392 | void | 391 | void |
393 | GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, | 392 | GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, const GNUNET_HashCode * b, |
394 | const GNUNET_HashCode * b, GNUNET_HashCode * result) | 393 | GNUNET_HashCode * result) |
395 | { | 394 | { |
396 | int i; | 395 | int i; |
397 | 396 | ||
@@ -542,12 +541,11 @@ GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, | |||
542 | void | 541 | void |
543 | GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, | 542 | GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, |
544 | const struct GNUNET_CRYPTO_AesSessionKey *rkey, | 543 | const struct GNUNET_CRYPTO_AesSessionKey *rkey, |
545 | const void *salt, | 544 | const void *salt, size_t salt_len, |
546 | size_t salt_len, va_list argp) | 545 | va_list argp) |
547 | { | 546 | { |
548 | GNUNET_CRYPTO_kdf_v (key->key, | 547 | GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key), salt, salt_len, rkey->key, |
549 | sizeof (key->key), | 548 | sizeof (rkey->key), argp); |
550 | salt, salt_len, rkey->key, sizeof (rkey->key), argp); | ||
551 | } | 549 | } |
552 | 550 | ||
553 | 551 | ||
@@ -561,15 +559,14 @@ GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, | |||
561 | */ | 559 | */ |
562 | void | 560 | void |
563 | GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | 561 | GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, |
564 | const void *plaintext, | 562 | const void *plaintext, size_t plaintext_len, |
565 | size_t plaintext_len, GNUNET_HashCode * hmac) | 563 | GNUNET_HashCode * hmac) |
566 | { | 564 | { |
567 | gcry_md_hd_t md; | 565 | gcry_md_hd_t md; |
568 | const unsigned char *mc; | 566 | const unsigned char *mc; |
569 | 567 | ||
570 | GNUNET_assert (GPG_ERR_NO_ERROR == gcry_md_open (&md, | 568 | GNUNET_assert (GPG_ERR_NO_ERROR == |
571 | GCRY_MD_SHA512, | 569 | gcry_md_open (&md, GCRY_MD_SHA512, GCRY_MD_FLAG_HMAC)); |
572 | GCRY_MD_FLAG_HMAC)); | ||
573 | gcry_md_setkey (md, key->key, sizeof (key->key)); | 570 | gcry_md_setkey (md, key->key, sizeof (key->key)); |
574 | gcry_md_write (md, plaintext, plaintext_len); | 571 | gcry_md_write (md, plaintext, plaintext_len); |
575 | mc = gcry_md_read (md, GCRY_MD_SHA512); | 572 | mc = gcry_md_read (md, GCRY_MD_SHA512); |
diff --git a/src/util/crypto_hkdf.c b/src/util/crypto_hkdf.c index d97f516fe..0654b51f6 100644 --- a/src/util/crypto_hkdf.c +++ b/src/util/crypto_hkdf.c | |||
@@ -71,8 +71,8 @@ | |||
71 | * @return HMAC, freed by caller via gcry_md_close/_reset | 71 | * @return HMAC, freed by caller via gcry_md_close/_reset |
72 | */ | 72 | */ |
73 | static const void * | 73 | static const void * |
74 | doHMAC (gcry_md_hd_t mac, | 74 | doHMAC (gcry_md_hd_t mac, const void *key, size_t key_len, const void *buf, |
75 | const void *key, size_t key_len, const void *buf, size_t buf_len) | 75 | size_t buf_len) |
76 | { | 76 | { |
77 | gcry_md_setkey (mac, key, key_len); | 77 | gcry_md_setkey (mac, key, key_len); |
78 | gcry_md_write (mac, buf, buf_len); | 78 | gcry_md_write (mac, buf, buf_len); |
@@ -91,9 +91,8 @@ doHMAC (gcry_md_hd_t mac, | |||
91 | * @return GNUNET_YES on success | 91 | * @return GNUNET_YES on success |
92 | */ | 92 | */ |
93 | static int | 93 | static int |
94 | getPRK (gcry_md_hd_t mac, | 94 | getPRK (gcry_md_hd_t mac, const void *xts, size_t xts_len, const void *skm, |
95 | const void *xts, size_t xts_len, | 95 | size_t skm_len, void *prk) |
96 | const void *skm, size_t skm_len, void *prk) | ||
97 | { | 96 | { |
98 | const void *ret; | 97 | const void *ret; |
99 | 98 | ||
@@ -136,10 +135,9 @@ dump (const char *src, const void *p, unsigned int l) | |||
136 | * @return GNUNET_YES on success | 135 | * @return GNUNET_YES on success |
137 | */ | 136 | */ |
138 | int | 137 | int |
139 | GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, | 138 | GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_algo, |
140 | int xtr_algo, int prf_algo, | 139 | const void *xts, size_t xts_len, const void *skm, |
141 | const void *xts, size_t xts_len, | 140 | size_t skm_len, va_list argp) |
142 | const void *skm, size_t skm_len, va_list argp) | ||
143 | { | 141 | { |
144 | const void *hc; | 142 | const void *hc; |
145 | unsigned long i, t, d; | 143 | unsigned long i, t, d; |
@@ -280,17 +278,17 @@ hkdf_ok: | |||
280 | * @return GNUNET_YES on success | 278 | * @return GNUNET_YES on success |
281 | */ | 279 | */ |
282 | int | 280 | int |
283 | GNUNET_CRYPTO_hkdf (void *result, size_t out_len, | 281 | GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_algo, |
284 | int xtr_algo, int prf_algo, | 282 | const void *xts, size_t xts_len, const void *skm, |
285 | const void *xts, size_t xts_len, | 283 | size_t skm_len, ...) |
286 | const void *skm, size_t skm_len, ...) | ||
287 | { | 284 | { |
288 | va_list argp; | 285 | va_list argp; |
289 | int ret; | 286 | int ret; |
290 | 287 | ||
291 | va_start (argp, skm_len); | 288 | va_start (argp, skm_len); |
292 | ret = GNUNET_CRYPTO_hkdf_v (result, out_len, xtr_algo, prf_algo, xts, | 289 | ret = |
293 | xts_len, skm, skm_len, argp); | 290 | GNUNET_CRYPTO_hkdf_v (result, out_len, xtr_algo, prf_algo, xts, xts_len, |
291 | skm, skm_len, argp); | ||
294 | va_end (argp); | 292 | va_end (argp); |
295 | 293 | ||
296 | return ret; | 294 | return ret; |
diff --git a/src/util/crypto_kdf.c b/src/util/crypto_kdf.c index dc2e667af..cd665ad23 100644 --- a/src/util/crypto_kdf.c +++ b/src/util/crypto_kdf.c | |||
@@ -41,9 +41,9 @@ | |||
41 | * @return GNUNET_YES on success | 41 | * @return GNUNET_YES on success |
42 | */ | 42 | */ |
43 | int | 43 | int |
44 | GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, | 44 | GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts, |
45 | const void *xts, size_t xts_len, const void *skm, | 45 | size_t xts_len, const void *skm, size_t skm_len, |
46 | size_t skm_len, va_list argp) | 46 | va_list argp) |
47 | { | 47 | { |
48 | /* | 48 | /* |
49 | * "Finally, we point out to a particularly advantageous instantiation using | 49 | * "Finally, we point out to a particularly advantageous instantiation using |
@@ -73,9 +73,8 @@ GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, | |||
73 | * @return GNUNET_YES on success | 73 | * @return GNUNET_YES on success |
74 | */ | 74 | */ |
75 | int | 75 | int |
76 | GNUNET_CRYPTO_kdf (void *result, size_t out_len, | 76 | GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts, |
77 | const void *xts, size_t xts_len, const void *skm, | 77 | size_t xts_len, const void *skm, size_t skm_len, ...) |
78 | size_t skm_len, ...) | ||
79 | { | 78 | { |
80 | va_list argp; | 79 | va_list argp; |
81 | int ret; | 80 | int ret; |
diff --git a/src/util/crypto_ksk.c b/src/util/crypto_ksk.c index 7c23fc1e0..bec87c803 100644 --- a/src/util/crypto_ksk.c +++ b/src/util/crypto_ksk.c | |||
@@ -397,8 +397,8 @@ gen_prime (gcry_mpi_t * ptest, unsigned int nbits, GNUNET_HashCode * hc) | |||
397 | * @param hc the HC to use for PRNG (modified!) | 397 | * @param hc the HC to use for PRNG (modified!) |
398 | */ | 398 | */ |
399 | static void | 399 | static void |
400 | generate_kblock_key (KBlock_secret_key *sk, | 400 | generate_kblock_key (KBlock_secret_key *sk, unsigned int nbits, |
401 | unsigned int nbits, GNUNET_HashCode * hc) | 401 | GNUNET_HashCode * hc) |
402 | { | 402 | { |
403 | gcry_mpi_t t1, t2; | 403 | gcry_mpi_t t1, t2; |
404 | gcry_mpi_t phi; /* helper: (p-1)(q-1) */ | 404 | gcry_mpi_t phi; /* helper: (p-1)(q-1) */ |
@@ -569,10 +569,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) | |||
569 | 569 | ||
570 | pos = 0; | 570 | pos = 0; |
571 | size = ntohs (encoding->sizen); | 571 | size = ntohs (encoding->sizen); |
572 | rc = gcry_mpi_scan (&n, | 572 | rc = gcry_mpi_scan (&n, GCRYMPI_FMT_USG, |
573 | GCRYMPI_FMT_USG, | 573 | &((const unsigned char *) (&encoding[1]))[pos], size, |
574 | &((const unsigned char *) (&encoding[1]))[pos], | 574 | &size); |
575 | size, &size); | ||
576 | pos += ntohs (encoding->sizen); | 575 | pos += ntohs (encoding->sizen); |
577 | if (rc) | 576 | if (rc) |
578 | { | 577 | { |
@@ -580,10 +579,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) | |||
580 | return NULL; | 579 | return NULL; |
581 | } | 580 | } |
582 | size = ntohs (encoding->sizee); | 581 | size = ntohs (encoding->sizee); |
583 | rc = gcry_mpi_scan (&e, | 582 | rc = gcry_mpi_scan (&e, GCRYMPI_FMT_USG, |
584 | GCRYMPI_FMT_USG, | 583 | &((const unsigned char *) (&encoding[1]))[pos], size, |
585 | &((const unsigned char *) (&encoding[1]))[pos], | 584 | &size); |
586 | size, &size); | ||
587 | pos += ntohs (encoding->sizee); | 585 | pos += ntohs (encoding->sizee); |
588 | if (rc) | 586 | if (rc) |
589 | { | 587 | { |
@@ -592,10 +590,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) | |||
592 | return NULL; | 590 | return NULL; |
593 | } | 591 | } |
594 | size = ntohs (encoding->sized); | 592 | size = ntohs (encoding->sized); |
595 | rc = gcry_mpi_scan (&d, | 593 | rc = gcry_mpi_scan (&d, GCRYMPI_FMT_USG, |
596 | GCRYMPI_FMT_USG, | 594 | &((const unsigned char *) (&encoding[1]))[pos], size, |
597 | &((const unsigned char *) (&encoding[1]))[pos], | 595 | &size); |
598 | size, &size); | ||
599 | pos += ntohs (encoding->sized); | 596 | pos += ntohs (encoding->sized); |
600 | if (rc) | 597 | if (rc) |
601 | { | 598 | { |
@@ -608,10 +605,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) | |||
608 | size = ntohs (encoding->sizep); | 605 | size = ntohs (encoding->sizep); |
609 | if (size > 0) | 606 | if (size > 0) |
610 | { | 607 | { |
611 | rc = gcry_mpi_scan (&q, | 608 | rc = gcry_mpi_scan (&q, GCRYMPI_FMT_USG, |
612 | GCRYMPI_FMT_USG, | 609 | &((const unsigned char *) (&encoding[1]))[pos], size, |
613 | &((const unsigned char *) (&encoding[1]))[pos], | 610 | &size); |
614 | size, &size); | ||
615 | pos += ntohs (encoding->sizep); | 611 | pos += ntohs (encoding->sizep); |
616 | if (rc) | 612 | if (rc) |
617 | { | 613 | { |
@@ -627,10 +623,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) | |||
627 | size = ntohs (encoding->sizeq); | 623 | size = ntohs (encoding->sizeq); |
628 | if (size > 0) | 624 | if (size > 0) |
629 | { | 625 | { |
630 | rc = gcry_mpi_scan (&p, | 626 | rc = gcry_mpi_scan (&p, GCRYMPI_FMT_USG, |
631 | GCRYMPI_FMT_USG, | 627 | &((const unsigned char *) (&encoding[1]))[pos], size, |
632 | &((const unsigned char *) (&encoding[1]))[pos], | 628 | &size); |
633 | size, &size); | ||
634 | pos += ntohs (encoding->sizeq); | 629 | pos += ntohs (encoding->sizeq); |
635 | if (rc) | 630 | if (rc) |
636 | { | 631 | { |
@@ -652,10 +647,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) | |||
652 | pos; | 647 | pos; |
653 | if (size > 0) | 648 | if (size > 0) |
654 | { | 649 | { |
655 | rc = gcry_mpi_scan (&u, | 650 | rc = gcry_mpi_scan (&u, GCRYMPI_FMT_USG, |
656 | GCRYMPI_FMT_USG, | 651 | &((const unsigned char *) (&encoding[1]))[pos], size, |
657 | &((const unsigned char *) (&encoding[1]))[pos], | 652 | &size); |
658 | size, &size); | ||
659 | if (rc) | 653 | if (rc) |
660 | { | 654 | { |
661 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); | 655 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); |
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c index 03f6c0e98..bb105437d 100644 --- a/src/util/crypto_random.c +++ b/src/util/crypto_random.c | |||
@@ -71,8 +71,8 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i) | |||
71 | ul = UINT32_MAX - (UINT32_MAX % i); | 71 | ul = UINT32_MAX - (UINT32_MAX % i); |
72 | do | 72 | do |
73 | { | 73 | { |
74 | gcry_randomize ((unsigned char *) &ret, | 74 | gcry_randomize ((unsigned char *) &ret, sizeof (uint32_t), |
75 | sizeof (uint32_t), GCRY_STRONG_RANDOM); | 75 | GCRY_STRONG_RANDOM); |
76 | } | 76 | } |
77 | while (ret >= ul); | 77 | while (ret >= ul); |
78 | return ret % i; | 78 | return ret % i; |
@@ -147,8 +147,8 @@ GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max) | |||
147 | ul = UINT64_MAX - (UINT64_MAX % max); | 147 | ul = UINT64_MAX - (UINT64_MAX % max); |
148 | do | 148 | do |
149 | { | 149 | { |
150 | gcry_randomize ((unsigned char *) &ret, | 150 | gcry_randomize ((unsigned char *) &ret, sizeof (uint64_t), |
151 | sizeof (uint64_t), GCRY_STRONG_RANDOM); | 151 | GCRY_STRONG_RANDOM); |
152 | } | 152 | } |
153 | while (ret >= ul); | 153 | while (ret >= ul); |
154 | return ret % max; | 154 | return ret % max; |
@@ -195,8 +195,8 @@ static struct GNUNET_OS_Process *genproc; | |||
195 | * blocked gathering entropy. | 195 | * blocked gathering entropy. |
196 | */ | 196 | */ |
197 | static void | 197 | static void |
198 | entropy_generator (void *cls, | 198 | entropy_generator (void *cls, const char *what, int printchar, int current, |
199 | const char *what, int printchar, int current, int total) | 199 | int total) |
200 | { | 200 | { |
201 | unsigned long code; | 201 | unsigned long code; |
202 | enum GNUNET_OS_ProcessStatusType type; | 202 | enum GNUNET_OS_ProcessStatusType type; |
@@ -234,11 +234,10 @@ entropy_generator (void *cls, | |||
234 | } | 234 | } |
235 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 235 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
236 | _("Starting `%s' process to generate entropy\n"), "find"); | 236 | _("Starting `%s' process to generate entropy\n"), "find"); |
237 | genproc = GNUNET_OS_start_process (NULL, NULL, "sh", | 237 | genproc = |
238 | "sh", | 238 | GNUNET_OS_start_process (NULL, NULL, "sh", "sh", "-c", |
239 | "-c", | 239 | "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null", |
240 | "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null", | 240 | NULL); |
241 | NULL); | ||
242 | } | 241 | } |
243 | 242 | ||
244 | 243 | ||
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 6be2f53c0..3607998e4 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -108,10 +108,10 @@ GNUNET_CRYPTO_rsa_key_create () | |||
108 | gcry_sexp_t s_key; | 108 | gcry_sexp_t s_key; |
109 | gcry_sexp_t s_keyparam; | 109 | gcry_sexp_t s_keyparam; |
110 | 110 | ||
111 | GNUNET_assert (0 == gcry_sexp_build (&s_keyparam, | 111 | GNUNET_assert (0 == |
112 | NULL, | 112 | gcry_sexp_build (&s_keyparam, NULL, |
113 | "(genkey(rsa(nbits %d)(rsa-use-e 3:257)))", | 113 | "(genkey(rsa(nbits %d)(rsa-use-e 3:257)))", |
114 | HOSTKEY_LEN)); | 114 | HOSTKEY_LEN)); |
115 | GNUNET_assert (0 == gcry_pk_genkey (&s_key, s_keyparam)); | 115 | GNUNET_assert (0 == gcry_pk_genkey (&s_key, s_keyparam)); |
116 | gcry_sexp_release (s_keyparam); | 116 | gcry_sexp_release (s_keyparam); |
117 | #if EXTRA_CHECKS | 117 | #if EXTRA_CHECKS |
@@ -133,8 +133,8 @@ GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
133 | } | 133 | } |
134 | 134 | ||
135 | static int | 135 | static int |
136 | key_from_sexp (gcry_mpi_t * array, | 136 | key_from_sexp (gcry_mpi_t * array, gcry_sexp_t sexp, const char *topname, |
137 | gcry_sexp_t sexp, const char *topname, const char *elems) | 137 | const char *elems) |
138 | { | 138 | { |
139 | gcry_sexp_t list, l2; | 139 | gcry_sexp_t list, l2; |
140 | const char *s; | 140 | const char *s; |
@@ -192,8 +192,8 @@ key_from_sexp (gcry_mpi_t * array, | |||
192 | void | 192 | void |
193 | GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey | 193 | GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey |
194 | *priv, | 194 | *priv, |
195 | struct | 195 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
196 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pub) | 196 | *pub) |
197 | { | 197 | { |
198 | gcry_mpi_t skey[2]; | 198 | gcry_mpi_t skey[2]; |
199 | size_t size; | 199 | size_t size; |
@@ -211,14 +211,15 @@ GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey | |||
211 | pub->sizen = htons (GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH); | 211 | pub->sizen = htons (GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH); |
212 | pub->padding = 0; | 212 | pub->padding = 0; |
213 | size = GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH; | 213 | size = GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH; |
214 | GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, | 214 | GNUNET_assert (0 == |
215 | &pub->key[0], size, &size, skey[0])); | 215 | gcry_mpi_print (GCRYMPI_FMT_USG, &pub->key[0], size, &size, |
216 | skey[0])); | ||
216 | adjust (&pub->key[0], size, GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH); | 217 | adjust (&pub->key[0], size, GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH); |
217 | size = GNUNET_CRYPTO_RSA_KEY_LENGTH - GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH; | 218 | size = GNUNET_CRYPTO_RSA_KEY_LENGTH - GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH; |
218 | GNUNET_assert (0 == | 219 | GNUNET_assert (0 == |
219 | gcry_mpi_print (GCRYMPI_FMT_USG, | 220 | gcry_mpi_print (GCRYMPI_FMT_USG, |
220 | &pub->key | 221 | &pub-> |
221 | [GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH], | 222 | key[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH], |
222 | size, &size, skey[1])); | 223 | size, &size, skey[1])); |
223 | adjust (&pub->key[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH], size, | 224 | adjust (&pub->key[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH], size, |
224 | GNUNET_CRYPTO_RSA_KEY_LENGTH - | 225 | GNUNET_CRYPTO_RSA_KEY_LENGTH - |
@@ -271,8 +272,8 @@ public2PrivateKey (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | |||
271 | gcry_mpi_release (n); | 272 | gcry_mpi_release (n); |
272 | return NULL; | 273 | return NULL; |
273 | } | 274 | } |
274 | rc = gcry_sexp_build (&result, | 275 | rc = gcry_sexp_build (&result, &erroff, "(public-key(rsa(n %m)(e %m)))", n, |
275 | &erroff, "(public-key(rsa(n %m)(e %m)))", n, e); | 276 | e); |
276 | gcry_mpi_release (n); | 277 | gcry_mpi_release (n); |
277 | gcry_mpi_release (e); | 278 | gcry_mpi_release (e); |
278 | if (rc) | 279 | if (rc) |
@@ -329,9 +330,10 @@ rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
329 | { | 330 | { |
330 | if (pkv[i] != NULL) | 331 | if (pkv[i] != NULL) |
331 | { | 332 | { |
332 | GNUNET_assert (0 == gcry_mpi_aprint (GCRYMPI_FMT_USG, | 333 | GNUNET_assert (0 == |
333 | (unsigned char **) &pbu[i], | 334 | gcry_mpi_aprint (GCRYMPI_FMT_USG, |
334 | &sizes[i], pkv[i])); | 335 | (unsigned char **) &pbu[i], &sizes[i], |
336 | pkv[i])); | ||
335 | size += sizes[i]; | 337 | size += sizes[i]; |
336 | } | 338 | } |
337 | else | 339 | else |
@@ -399,10 +401,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
399 | 401 | ||
400 | pos = 0; | 402 | pos = 0; |
401 | size = ntohs (encoding->sizen); | 403 | size = ntohs (encoding->sizen); |
402 | rc = gcry_mpi_scan (&n, | 404 | rc = gcry_mpi_scan (&n, GCRYMPI_FMT_USG, |
403 | GCRYMPI_FMT_USG, | 405 | &((const unsigned char *) (&encoding[1]))[pos], size, |
404 | &((const unsigned char *) (&encoding[1]))[pos], | 406 | &size); |
405 | size, &size); | ||
406 | pos += ntohs (encoding->sizen); | 407 | pos += ntohs (encoding->sizen); |
407 | if (rc) | 408 | if (rc) |
408 | { | 409 | { |
@@ -410,10 +411,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
410 | return NULL; | 411 | return NULL; |
411 | } | 412 | } |
412 | size = ntohs (encoding->sizee); | 413 | size = ntohs (encoding->sizee); |
413 | rc = gcry_mpi_scan (&e, | 414 | rc = gcry_mpi_scan (&e, GCRYMPI_FMT_USG, |
414 | GCRYMPI_FMT_USG, | 415 | &((const unsigned char *) (&encoding[1]))[pos], size, |
415 | &((const unsigned char *) (&encoding[1]))[pos], | 416 | &size); |
416 | size, &size); | ||
417 | pos += ntohs (encoding->sizee); | 417 | pos += ntohs (encoding->sizee); |
418 | if (rc) | 418 | if (rc) |
419 | { | 419 | { |
@@ -422,10 +422,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
422 | return NULL; | 422 | return NULL; |
423 | } | 423 | } |
424 | size = ntohs (encoding->sized); | 424 | size = ntohs (encoding->sized); |
425 | rc = gcry_mpi_scan (&d, | 425 | rc = gcry_mpi_scan (&d, GCRYMPI_FMT_USG, |
426 | GCRYMPI_FMT_USG, | 426 | &((const unsigned char *) (&encoding[1]))[pos], size, |
427 | &((const unsigned char *) (&encoding[1]))[pos], | 427 | &size); |
428 | size, &size); | ||
429 | pos += ntohs (encoding->sized); | 428 | pos += ntohs (encoding->sized); |
430 | if (rc) | 429 | if (rc) |
431 | { | 430 | { |
@@ -438,10 +437,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
438 | size = ntohs (encoding->sizep); | 437 | size = ntohs (encoding->sizep); |
439 | if (size > 0) | 438 | if (size > 0) |
440 | { | 439 | { |
441 | rc = gcry_mpi_scan (&q, | 440 | rc = gcry_mpi_scan (&q, GCRYMPI_FMT_USG, |
442 | GCRYMPI_FMT_USG, | 441 | &((const unsigned char *) (&encoding[1]))[pos], size, |
443 | &((const unsigned char *) (&encoding[1]))[pos], | 442 | &size); |
444 | size, &size); | ||
445 | pos += ntohs (encoding->sizep); | 443 | pos += ntohs (encoding->sizep); |
446 | if (rc) | 444 | if (rc) |
447 | { | 445 | { |
@@ -457,10 +455,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
457 | size = ntohs (encoding->sizeq); | 455 | size = ntohs (encoding->sizeq); |
458 | if (size > 0) | 456 | if (size > 0) |
459 | { | 457 | { |
460 | rc = gcry_mpi_scan (&p, | 458 | rc = gcry_mpi_scan (&p, GCRYMPI_FMT_USG, |
461 | GCRYMPI_FMT_USG, | 459 | &((const unsigned char *) (&encoding[1]))[pos], size, |
462 | &((const unsigned char *) (&encoding[1]))[pos], | 460 | &size); |
463 | size, &size); | ||
464 | pos += ntohs (encoding->sizeq); | 461 | pos += ntohs (encoding->sizeq); |
465 | if (rc) | 462 | if (rc) |
466 | { | 463 | { |
@@ -481,10 +478,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
481 | ntohs (encoding->len) - sizeof (struct RsaPrivateKeyBinaryEncoded) - pos; | 478 | ntohs (encoding->len) - sizeof (struct RsaPrivateKeyBinaryEncoded) - pos; |
482 | if (size > 0) | 479 | if (size > 0) |
483 | { | 480 | { |
484 | rc = gcry_mpi_scan (&u, | 481 | rc = gcry_mpi_scan (&u, GCRYMPI_FMT_USG, |
485 | GCRYMPI_FMT_USG, | 482 | &((const unsigned char *) (&encoding[1]))[pos], size, |
486 | &((const unsigned char *) (&encoding[1]))[pos], | 483 | &size); |
487 | size, &size); | ||
488 | if (rc) | 484 | if (rc) |
489 | { | 485 | { |
490 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); | 486 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); |
@@ -577,9 +573,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
577 | while (GNUNET_YES != GNUNET_DISK_file_test (filename)) | 573 | while (GNUNET_YES != GNUNET_DISK_file_test (filename)) |
578 | { | 574 | { |
579 | fd = GNUNET_DISK_file_open (filename, | 575 | fd = GNUNET_DISK_file_open (filename, |
580 | GNUNET_DISK_OPEN_WRITE | | 576 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE |
581 | GNUNET_DISK_OPEN_CREATE | | 577 | | GNUNET_DISK_OPEN_FAILIFEXISTS, |
582 | GNUNET_DISK_OPEN_FAILIFEXISTS, | ||
583 | GNUNET_DISK_PERM_USER_READ | | 578 | GNUNET_DISK_PERM_USER_READ | |
584 | GNUNET_DISK_PERM_USER_WRITE); | 579 | GNUNET_DISK_PERM_USER_WRITE); |
585 | if (NULL == fd) | 580 | if (NULL == fd) |
@@ -590,8 +585,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
590 | { | 585 | { |
591 | /* must exist but not be accessible, fail for good! */ | 586 | /* must exist but not be accessible, fail for good! */ |
592 | if (0 != ACCESS (filename, R_OK)) | 587 | if (0 != ACCESS (filename, R_OK)) |
593 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 588 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "access", |
594 | "access", filename); | 589 | filename); |
595 | else | 590 | else |
596 | GNUNET_break (0); /* what is going on!? */ | 591 | GNUNET_break (0); /* what is going on!? */ |
597 | return NULL; | 592 | return NULL; |
@@ -605,8 +600,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
605 | 600 | ||
606 | while (GNUNET_YES != | 601 | while (GNUNET_YES != |
607 | GNUNET_DISK_file_lock (fd, 0, | 602 | GNUNET_DISK_file_lock (fd, 0, |
608 | sizeof (struct | 603 | sizeof (struct RsaPrivateKeyBinaryEncoded), |
609 | RsaPrivateKeyBinaryEncoded), | ||
610 | GNUNET_YES)) | 604 | GNUNET_YES)) |
611 | { | 605 | { |
612 | sleep (1); | 606 | sleep (1); |
@@ -614,9 +608,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
614 | { | 608 | { |
615 | ec = errno; | 609 | ec = errno; |
616 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 610 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
617 | _ | 611 | _("Could not aquire lock on file `%s': %s...\n"), filename, |
618 | ("Could not aquire lock on file `%s': %s...\n"), | 612 | STRERROR (ec)); |
619 | filename, STRERROR (ec)); | ||
620 | } | 613 | } |
621 | } | 614 | } |
622 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 615 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -662,8 +655,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
662 | { | 655 | { |
663 | ec = errno; | 656 | ec = errno; |
664 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 657 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
665 | _("Could not aquire lock on file `%s': %s...\n"), | 658 | _("Could not aquire lock on file `%s': %s...\n"), filename, |
666 | filename, STRERROR (ec)); | 659 | STRERROR (ec)); |
667 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 660 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
668 | _ | 661 | _ |
669 | ("This may be ok if someone is currently generating a hostkey.\n")); | 662 | ("This may be ok if someone is currently generating a hostkey.\n")); |
@@ -754,10 +747,9 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
754 | * @returns GNUNET_SYSERR on error, GNUNET_OK if ok | 747 | * @returns GNUNET_SYSERR on error, GNUNET_OK if ok |
755 | */ | 748 | */ |
756 | int | 749 | int |
757 | GNUNET_CRYPTO_rsa_encrypt (const void *block, | 750 | GNUNET_CRYPTO_rsa_encrypt (const void *block, size_t size, |
758 | size_t size, | 751 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
759 | const struct | 752 | *publicKey, |
760 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey, | ||
761 | struct GNUNET_CRYPTO_RsaEncryptedData *target) | 753 | struct GNUNET_CRYPTO_RsaEncryptedData *target) |
762 | { | 754 | { |
763 | gcry_sexp_t result; | 755 | gcry_sexp_t result; |
@@ -786,9 +778,9 @@ GNUNET_CRYPTO_rsa_encrypt (const void *block, | |||
786 | GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "a")); | 778 | GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "a")); |
787 | gcry_sexp_release (result); | 779 | gcry_sexp_release (result); |
788 | isize = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData); | 780 | isize = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData); |
789 | GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, | 781 | GNUNET_assert (0 == |
790 | (unsigned char *) target, isize, &isize, | 782 | gcry_mpi_print (GCRYMPI_FMT_USG, (unsigned char *) target, |
791 | rval)); | 783 | isize, &isize, rval)); |
792 | gcry_mpi_release (rval); | 784 | gcry_mpi_release (rval); |
793 | adjust (&target->encoding[0], isize, | 785 | adjust (&target->encoding[0], isize, |
794 | sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); | 786 | sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); |
@@ -807,8 +799,8 @@ GNUNET_CRYPTO_rsa_encrypt (const void *block, | |||
807 | */ | 799 | */ |
808 | ssize_t | 800 | ssize_t |
809 | GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey * key, | 801 | GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey * key, |
810 | const struct GNUNET_CRYPTO_RsaEncryptedData * | 802 | const struct GNUNET_CRYPTO_RsaEncryptedData * block, |
811 | block, void *result, size_t max) | 803 | void *result, size_t max) |
812 | { | 804 | { |
813 | gcry_sexp_t resultsexp; | 805 | gcry_sexp_t resultsexp; |
814 | gcry_sexp_t data; | 806 | gcry_sexp_t data; |
@@ -822,12 +814,12 @@ GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey * key, | |||
822 | GNUNET_assert (0 == gcry_pk_testkey (key->sexp)); | 814 | GNUNET_assert (0 == gcry_pk_testkey (key->sexp)); |
823 | #endif | 815 | #endif |
824 | size = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData); | 816 | size = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData); |
825 | GNUNET_assert (0 == gcry_mpi_scan (&val, | ||
826 | GCRYMPI_FMT_USG, &block->encoding[0], | ||
827 | size, &size)); | ||
828 | GNUNET_assert (0 == | 817 | GNUNET_assert (0 == |
829 | gcry_sexp_build (&data, &erroff, | 818 | gcry_mpi_scan (&val, GCRYMPI_FMT_USG, &block->encoding[0], |
830 | "(enc-val(flags)(rsa(a %m)))", val)); | 819 | size, &size)); |
820 | GNUNET_assert (0 == | ||
821 | gcry_sexp_build (&data, &erroff, "(enc-val(flags)(rsa(a %m)))", | ||
822 | val)); | ||
831 | gcry_mpi_release (val); | 823 | gcry_mpi_release (val); |
832 | GNUNET_assert (0 == gcry_pk_decrypt (&resultsexp, data, key->sexp)); | 824 | GNUNET_assert (0 == gcry_pk_decrypt (&resultsexp, data, key->sexp)); |
833 | gcry_sexp_release (data); | 825 | gcry_sexp_release (data); |
@@ -858,8 +850,8 @@ GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey * key, | |||
858 | */ | 850 | */ |
859 | int | 851 | int |
860 | GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 852 | GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
861 | const struct GNUNET_CRYPTO_RsaSignaturePurpose | 853 | const struct GNUNET_CRYPTO_RsaSignaturePurpose *purpose, |
862 | *purpose, struct GNUNET_CRYPTO_RsaSignature *sig) | 854 | struct GNUNET_CRYPTO_RsaSignature *sig) |
863 | { | 855 | { |
864 | gcry_sexp_t result; | 856 | gcry_sexp_t result; |
865 | gcry_sexp_t data; | 857 | gcry_sexp_t data; |
@@ -886,9 +878,9 @@ GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
886 | GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "s")); | 878 | GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "s")); |
887 | gcry_sexp_release (result); | 879 | gcry_sexp_release (result); |
888 | ssize = sizeof (struct GNUNET_CRYPTO_RsaSignature); | 880 | ssize = sizeof (struct GNUNET_CRYPTO_RsaSignature); |
889 | GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, | 881 | GNUNET_assert (0 == |
890 | (unsigned char *) sig, ssize, &ssize, | 882 | gcry_mpi_print (GCRYMPI_FMT_USG, (unsigned char *) sig, ssize, |
891 | rval)); | 883 | &ssize, rval)); |
892 | gcry_mpi_release (rval); | 884 | gcry_mpi_release (rval); |
893 | adjust (sig->sig, ssize, sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 885 | adjust (sig->sig, ssize, sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
894 | return GNUNET_OK; | 886 | return GNUNET_OK; |
@@ -927,9 +919,9 @@ GNUNET_CRYPTO_rsa_verify (uint32_t purpose, | |||
927 | return GNUNET_SYSERR; /* purpose mismatch */ | 919 | return GNUNET_SYSERR; /* purpose mismatch */ |
928 | GNUNET_CRYPTO_hash (validate, ntohl (validate->size), &hc); | 920 | GNUNET_CRYPTO_hash (validate, ntohl (validate->size), &hc); |
929 | size = sizeof (struct GNUNET_CRYPTO_RsaSignature); | 921 | size = sizeof (struct GNUNET_CRYPTO_RsaSignature); |
930 | GNUNET_assert (0 == gcry_mpi_scan (&val, | 922 | GNUNET_assert (0 == |
931 | GCRYMPI_FMT_USG, | 923 | gcry_mpi_scan (&val, GCRYMPI_FMT_USG, |
932 | (const unsigned char *) sig, size, &size)); | 924 | (const unsigned char *) sig, size, &size)); |
933 | GNUNET_assert (0 == | 925 | GNUNET_assert (0 == |
934 | gcry_sexp_build (&sigdata, &erroff, "(sig-val(rsa(s %m)))", | 926 | gcry_sexp_build (&sigdata, &erroff, "(sig-val(rsa(s %m)))", |
935 | val)); | 927 | val)); |
@@ -937,9 +929,10 @@ GNUNET_CRYPTO_rsa_verify (uint32_t purpose, | |||
937 | bufSize = strlen (FORMATSTRING) + 1; | 929 | bufSize = strlen (FORMATSTRING) + 1; |
938 | buff = GNUNET_malloc (bufSize); | 930 | buff = GNUNET_malloc (bufSize); |
939 | memcpy (buff, FORMATSTRING, bufSize); | 931 | memcpy (buff, FORMATSTRING, bufSize); |
940 | memcpy (&buff[strlen (FORMATSTRING) - | 932 | memcpy (&buff |
941 | strlen | 933 | [strlen (FORMATSTRING) - |
942 | ("0123456789012345678901234567890123456789012345678901234567890123))")], | 934 | strlen |
935 | ("0123456789012345678901234567890123456789012345678901234567890123))")], | ||
943 | &hc, sizeof (GNUNET_HashCode)); | 936 | &hc, sizeof (GNUNET_HashCode)); |
944 | GNUNET_assert (0 == gcry_sexp_new (&data, buff, bufSize, 0)); | 937 | GNUNET_assert (0 == gcry_sexp_new (&data, buff, bufSize, 0)); |
945 | GNUNET_free (buff); | 938 | GNUNET_free (buff); |
@@ -957,8 +950,8 @@ GNUNET_CRYPTO_rsa_verify (uint32_t purpose, | |||
957 | if (rc) | 950 | if (rc) |
958 | { | 951 | { |
959 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 952 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
960 | _("RSA signature verification failed at %s:%d: %s\n"), | 953 | _("RSA signature verification failed at %s:%d: %s\n"), __FILE__, |
961 | __FILE__, __LINE__, gcry_strerror (rc)); | 954 | __LINE__, gcry_strerror (rc)); |
962 | return GNUNET_SYSERR; | 955 | return GNUNET_SYSERR; |
963 | } | 956 | } |
964 | return GNUNET_OK; | 957 | return GNUNET_OK; |
diff --git a/src/util/disk.c b/src/util/disk.c index dd7db7d73..6ba5db773 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -172,8 +172,7 @@ getSizeRec (void *cls, const char *fn) | |||
172 | #endif | 172 | #endif |
173 | if ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)) | 173 | if ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)) |
174 | gfsd->total += buf.st_size; | 174 | gfsd->total += buf.st_size; |
175 | if ((S_ISDIR (buf.st_mode)) && | 175 | if ((S_ISDIR (buf.st_mode)) && (0 == ACCESS (fn, X_OK)) && |
176 | (0 == ACCESS (fn, X_OK)) && | ||
177 | ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))) | 176 | ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))) |
178 | { | 177 | { |
179 | if (GNUNET_SYSERR == GNUNET_DISK_directory_scan (fn, &getSizeRec, gfsd)) | 178 | if (GNUNET_SYSERR == GNUNET_DISK_directory_scan (fn, &getSizeRec, gfsd)) |
@@ -255,8 +254,8 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset, | |||
255 | * @return GNUNET_SYSERR on error, GNUNET_OK on success | 254 | * @return GNUNET_SYSERR on error, GNUNET_OK on success |
256 | */ | 255 | */ |
257 | int | 256 | int |
258 | GNUNET_DISK_file_size (const char *filename, | 257 | GNUNET_DISK_file_size (const char *filename, uint64_t * size, |
259 | uint64_t * size, int includeSymLinks) | 258 | int includeSymLinks) |
260 | { | 259 | { |
261 | struct GetFileSizeData gfsd; | 260 | struct GetFileSizeData gfsd; |
262 | int ret; | 261 | int ret; |
@@ -286,8 +285,8 @@ GNUNET_DISK_file_size (const char *filename, | |||
286 | * @return GNUNET_OK on success | 285 | * @return GNUNET_OK on success |
287 | */ | 286 | */ |
288 | int | 287 | int |
289 | GNUNET_DISK_file_get_identifiers (const char *filename, | 288 | GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev, |
290 | uint64_t * dev, uint64_t * ino) | 289 | uint64_t * ino) |
291 | { | 290 | { |
292 | #if LINUX | 291 | #if LINUX |
293 | struct stat sbuf; | 292 | struct stat sbuf; |
@@ -427,8 +426,8 @@ GNUNET_DISK_get_blocks_available (const char *part) | |||
427 | if (!GetDiskFreeSpace (szDrive, &dwDummy, &dwDummy, &dwBlocks, &dwDummy)) | 426 | if (!GetDiskFreeSpace (szDrive, &dwDummy, &dwDummy, &dwBlocks, &dwDummy)) |
428 | { | 427 | { |
429 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 428 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
430 | _("`%s' failed for drive `%s': %u\n"), | 429 | _("`%s' failed for drive `%s': %u\n"), "GetDiskFreeSpace", |
431 | "GetDiskFreeSpace", szDrive, GetLastError ()); | 430 | szDrive, GetLastError ()); |
432 | 431 | ||
433 | return -1; | 432 | return -1; |
434 | } | 433 | } |
@@ -772,15 +771,14 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h, | |||
772 | * @return number of bytes written on success, GNUNET_SYSERR on error | 771 | * @return number of bytes written on success, GNUNET_SYSERR on error |
773 | */ | 772 | */ |
774 | ssize_t | 773 | ssize_t |
775 | GNUNET_DISK_fn_write (const char *fn, const void *buffer, | 774 | GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, |
776 | size_t n, enum GNUNET_DISK_AccessPermissions mode) | 775 | enum GNUNET_DISK_AccessPermissions mode) |
777 | { | 776 | { |
778 | struct GNUNET_DISK_FileHandle *fh; | 777 | struct GNUNET_DISK_FileHandle *fh; |
779 | ssize_t ret; | 778 | ssize_t ret; |
780 | 779 | ||
781 | fh = GNUNET_DISK_file_open (fn, | 780 | fh = GNUNET_DISK_file_open (fn, |
782 | GNUNET_DISK_OPEN_WRITE | 781 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE |
783 | | GNUNET_DISK_OPEN_TRUNCATE | ||
784 | | GNUNET_DISK_OPEN_CREATE, mode); | 782 | | GNUNET_DISK_OPEN_CREATE, mode); |
785 | if (!fh) | 783 | if (!fh) |
786 | return GNUNET_SYSERR; | 784 | return GNUNET_SYSERR; |
@@ -862,10 +860,7 @@ GNUNET_DISK_directory_scan (const char *dirName, | |||
862 | /* dname can end in "/" only if dname == "/"; | 860 | /* dname can end in "/" only if dname == "/"; |
863 | * if dname does not end in "/", we need to add | 861 | * if dname does not end in "/", we need to add |
864 | * a "/" (otherwise, we must not!) */ | 862 | * a "/" (otherwise, we must not!) */ |
865 | GNUNET_snprintf (name, | 863 | GNUNET_snprintf (name, n_size, "%s%s%s", dname, |
866 | n_size, | ||
867 | "%s%s%s", | ||
868 | dname, | ||
869 | (strcmp (dname, DIR_SEPARATOR_STR) == | 864 | (strcmp (dname, DIR_SEPARATOR_STR) == |
870 | 0) ? "" : DIR_SEPARATOR_STR, finfo->d_name); | 865 | 0) ? "" : DIR_SEPARATOR_STR, finfo->d_name); |
871 | if (GNUNET_OK != callback (callback_cls, name)) | 866 | if (GNUNET_OK != callback (callback_cls, name)) |
@@ -954,8 +949,8 @@ directory_iterator_task (void *cls, | |||
954 | * GNUNET_SYSERR if abort was YES | 949 | * GNUNET_SYSERR if abort was YES |
955 | */ | 950 | */ |
956 | int | 951 | int |
957 | GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator | 952 | GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter, |
958 | *iter, int can) | 953 | int can) |
959 | { | 954 | { |
960 | struct dirent *finfo; | 955 | struct dirent *finfo; |
961 | 956 | ||
@@ -972,8 +967,8 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator | |||
972 | if ((0 == strcmp (finfo->d_name, ".")) || | 967 | if ((0 == strcmp (finfo->d_name, ".")) || |
973 | (0 == strcmp (finfo->d_name, ".."))) | 968 | (0 == strcmp (finfo->d_name, ".."))) |
974 | continue; | 969 | continue; |
975 | GNUNET_asprintf (&iter->next_name, | 970 | GNUNET_asprintf (&iter->next_name, "%s%s%s", iter->dirname, |
976 | "%s%s%s", iter->dirname, DIR_SEPARATOR_STR, finfo->d_name); | 971 | DIR_SEPARATOR_STR, finfo->d_name); |
977 | break; | 972 | break; |
978 | } | 973 | } |
979 | if (finfo == NULL) | 974 | if (finfo == NULL) |
@@ -981,8 +976,8 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator | |||
981 | GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES); | 976 | GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES); |
982 | return GNUNET_NO; | 977 | return GNUNET_NO; |
983 | } | 978 | } |
984 | GNUNET_SCHEDULER_add_with_priority (iter->priority, | 979 | GNUNET_SCHEDULER_add_with_priority (iter->priority, &directory_iterator_task, |
985 | &directory_iterator_task, iter); | 980 | iter); |
986 | return GNUNET_YES; | 981 | return GNUNET_YES; |
987 | } | 982 | } |
988 | 983 | ||
@@ -1101,13 +1096,14 @@ GNUNET_DISK_file_copy (const char *src, const char *dst) | |||
1101 | GNUNET_DISK_PERM_NONE); | 1096 | GNUNET_DISK_PERM_NONE); |
1102 | if (!in) | 1097 | if (!in) |
1103 | return GNUNET_SYSERR; | 1098 | return GNUNET_SYSERR; |
1104 | out = GNUNET_DISK_file_open (dst, GNUNET_DISK_OPEN_WRITE | 1099 | out = |
1105 | | GNUNET_DISK_OPEN_CREATE | | 1100 | GNUNET_DISK_file_open (dst, |
1106 | GNUNET_DISK_OPEN_FAILIFEXISTS, | 1101 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | |
1107 | GNUNET_DISK_PERM_USER_READ | | 1102 | GNUNET_DISK_OPEN_FAILIFEXISTS, |
1108 | GNUNET_DISK_PERM_USER_WRITE | | 1103 | GNUNET_DISK_PERM_USER_READ | |
1109 | GNUNET_DISK_PERM_GROUP_READ | | 1104 | GNUNET_DISK_PERM_USER_WRITE | |
1110 | GNUNET_DISK_PERM_GROUP_WRITE); | 1105 | GNUNET_DISK_PERM_GROUP_READ | |
1106 | GNUNET_DISK_PERM_GROUP_WRITE); | ||
1111 | if (!out) | 1107 | if (!out) |
1112 | { | 1108 | { |
1113 | GNUNET_DISK_file_close (in); | 1109 | GNUNET_DISK_file_close (in); |
@@ -1152,8 +1148,8 @@ GNUNET_DISK_filename_canonicalize (char *fn) | |||
1152 | { | 1148 | { |
1153 | c = *idx; | 1149 | c = *idx; |
1154 | 1150 | ||
1155 | if (c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || | 1151 | if (c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || c == '"' || |
1156 | c == '"' || c == '<' || c == '>' || c == '|') | 1152 | c == '<' || c == '>' || c == '|') |
1157 | { | 1153 | { |
1158 | *idx = '_'; | 1154 | *idx = '_'; |
1159 | } | 1155 | } |
@@ -1181,8 +1177,8 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user) | |||
1181 | if (pws == NULL) | 1177 | if (pws == NULL) |
1182 | { | 1178 | { |
1183 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1179 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1184 | _("Cannot obtain information about user `%s': %s\n"), | 1180 | _("Cannot obtain information about user `%s': %s\n"), user, |
1185 | user, STRERROR (errno)); | 1181 | STRERROR (errno)); |
1186 | return GNUNET_SYSERR; | 1182 | return GNUNET_SYSERR; |
1187 | } | 1183 | } |
1188 | if (0 != chown (filename, pws->pw_uid, pws->pw_gid)) | 1184 | if (0 != chown (filename, pws->pw_uid, pws->pw_gid)) |
@@ -1226,8 +1222,9 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, | |||
1226 | memset (&o, 0, sizeof (OVERLAPPED)); | 1222 | memset (&o, 0, sizeof (OVERLAPPED)); |
1227 | o.Offset = lockStart; | 1223 | o.Offset = lockStart; |
1228 | 1224 | ||
1229 | if (!LockFileEx (fh->h, (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) | 1225 | if (!LockFileEx |
1230 | | LOCKFILE_FAIL_IMMEDIATELY, 0, lockEnd - lockStart, 0, &o)) | 1226 | (fh->h, (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) | LOCKFILE_FAIL_IMMEDIATELY, |
1227 | 0, lockEnd - lockStart, 0, &o)) | ||
1231 | { | 1228 | { |
1232 | SetErrnoFromWinError (GetLastError ()); | 1229 | SetErrnoFromWinError (GetLastError ()); |
1233 | return GNUNET_SYSERR; | 1230 | return GNUNET_SYSERR; |
@@ -1295,8 +1292,7 @@ GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart, | |||
1295 | * @return IO handle on success, NULL on error | 1292 | * @return IO handle on success, NULL on error |
1296 | */ | 1293 | */ |
1297 | struct GNUNET_DISK_FileHandle * | 1294 | struct GNUNET_DISK_FileHandle * |
1298 | GNUNET_DISK_file_open (const char *fn, | 1295 | GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, |
1299 | enum GNUNET_DISK_OpenFlags flags, | ||
1300 | enum GNUNET_DISK_AccessPermissions perm) | 1296 | enum GNUNET_DISK_AccessPermissions perm) |
1301 | { | 1297 | { |
1302 | char *expfn; | 1298 | char *expfn; |
@@ -1385,8 +1381,9 @@ GNUNET_DISK_file_open (const char *fn, | |||
1385 | } | 1381 | } |
1386 | 1382 | ||
1387 | /* TODO: access priviledges? */ | 1383 | /* TODO: access priviledges? */ |
1388 | h = CreateFile (expfn, access, FILE_SHARE_DELETE | FILE_SHARE_READ | 1384 | h = CreateFile (expfn, access, |
1389 | | FILE_SHARE_WRITE, NULL, disp, FILE_ATTRIBUTE_NORMAL, NULL); | 1385 | FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, |
1386 | disp, FILE_ATTRIBUTE_NORMAL, NULL); | ||
1390 | if (h == INVALID_HANDLE_VALUE) | 1387 | if (h == INVALID_HANDLE_VALUE) |
1391 | { | 1388 | { |
1392 | SetErrnoFromWinError (GetLastError ()); | 1389 | SetErrnoFromWinError (GetLastError ()); |
@@ -1713,10 +1710,9 @@ GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h) | |||
1713 | Note that the return value is either NO_ERROR or GetLastError, | 1710 | Note that the return value is either NO_ERROR or GetLastError, |
1714 | unlike CreatePipe, which returns a bool for success or failure. */ | 1711 | unlike CreatePipe, which returns a bool for success or failure. */ |
1715 | static int | 1712 | static int |
1716 | create_selectable_pipe (PHANDLE read_pipe_ptr, | 1713 | create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr, |
1717 | PHANDLE write_pipe_ptr, | 1714 | LPSECURITY_ATTRIBUTES sa_ptr, DWORD psize, |
1718 | LPSECURITY_ATTRIBUTES sa_ptr, | 1715 | DWORD dwReadMode, DWORD dwWriteMode) |
1719 | DWORD psize, DWORD dwReadMode, DWORD dwWriteMode) | ||
1720 | { | 1716 | { |
1721 | /* Default to error. */ | 1717 | /* Default to error. */ |
1722 | *read_pipe_ptr = *write_pipe_ptr = INVALID_HANDLE_VALUE; | 1718 | *read_pipe_ptr = *write_pipe_ptr = INVALID_HANDLE_VALUE; |
@@ -1921,10 +1917,9 @@ GNUNET_DISK_pipe (int blocking, int inherit_read, int inherit_write) | |||
1921 | SetErrnoFromWinError (GetLastError ()); | 1917 | SetErrnoFromWinError (GetLastError ()); |
1922 | return NULL; | 1918 | return NULL; |
1923 | } | 1919 | } |
1924 | if (!DuplicateHandle (GetCurrentProcess (), p->fd[0]->h, | 1920 | if (!DuplicateHandle |
1925 | GetCurrentProcess (), &tmp_handle, 0, | 1921 | (GetCurrentProcess (), p->fd[0]->h, GetCurrentProcess (), &tmp_handle, 0, |
1926 | inherit_read == GNUNET_YES ? TRUE : FALSE, | 1922 | inherit_read == GNUNET_YES ? TRUE : FALSE, DUPLICATE_SAME_ACCESS)) |
1927 | DUPLICATE_SAME_ACCESS)) | ||
1928 | { | 1923 | { |
1929 | SetErrnoFromWinError (GetLastError ()); | 1924 | SetErrnoFromWinError (GetLastError ()); |
1930 | CloseHandle (p->fd[0]->h); | 1925 | CloseHandle (p->fd[0]->h); |
@@ -1935,10 +1930,9 @@ GNUNET_DISK_pipe (int blocking, int inherit_read, int inherit_write) | |||
1935 | CloseHandle (p->fd[0]->h); | 1930 | CloseHandle (p->fd[0]->h); |
1936 | p->fd[0]->h = tmp_handle; | 1931 | p->fd[0]->h = tmp_handle; |
1937 | 1932 | ||
1938 | if (!DuplicateHandle (GetCurrentProcess (), p->fd[1]->h, | 1933 | if (!DuplicateHandle |
1939 | GetCurrentProcess (), &tmp_handle, 0, | 1934 | (GetCurrentProcess (), p->fd[1]->h, GetCurrentProcess (), &tmp_handle, 0, |
1940 | inherit_write == GNUNET_YES ? TRUE : FALSE, | 1935 | inherit_write == GNUNET_YES ? TRUE : FALSE, DUPLICATE_SAME_ACCESS)) |
1941 | DUPLICATE_SAME_ACCESS)) | ||
1942 | { | 1936 | { |
1943 | SetErrnoFromWinError (GetLastError ()); | 1937 | SetErrnoFromWinError (GetLastError ()); |
1944 | CloseHandle (p->fd[0]->h); | 1938 | CloseHandle (p->fd[0]->h); |
@@ -2093,8 +2087,7 @@ GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p) | |||
2093 | * @return pipe handle on success, NULL on error | 2087 | * @return pipe handle on success, NULL on error |
2094 | */ | 2088 | */ |
2095 | struct GNUNET_DISK_FileHandle * | 2089 | struct GNUNET_DISK_FileHandle * |
2096 | GNUNET_DISK_npipe_create (char **fn, | 2090 | GNUNET_DISK_npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags, |
2097 | enum GNUNET_DISK_OpenFlags flags, | ||
2098 | enum GNUNET_DISK_AccessPermissions perm) | 2091 | enum GNUNET_DISK_AccessPermissions perm) |
2099 | { | 2092 | { |
2100 | #ifdef MINGW | 2093 | #ifdef MINGW |
@@ -2226,8 +2219,7 @@ GNUNET_DISK_npipe_create (char **fn, | |||
2226 | * @return pipe handle on success, NULL on error | 2219 | * @return pipe handle on success, NULL on error |
2227 | */ | 2220 | */ |
2228 | struct GNUNET_DISK_FileHandle * | 2221 | struct GNUNET_DISK_FileHandle * |
2229 | GNUNET_DISK_npipe_open (const char *fn, | 2222 | GNUNET_DISK_npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, |
2230 | enum GNUNET_DISK_OpenFlags flags, | ||
2231 | enum GNUNET_DISK_AccessPermissions perm) | 2223 | enum GNUNET_DISK_AccessPermissions perm) |
2232 | { | 2224 | { |
2233 | #ifdef MINGW | 2225 | #ifdef MINGW |
diff --git a/src/util/getopt.c b/src/util/getopt.c index 2a35ab278..db81d1c3d 100644 --- a/src/util/getopt.c +++ b/src/util/getopt.c | |||
@@ -410,8 +410,8 @@ _getopt_initialize (argc, argv, optstring) | |||
410 | { | 410 | { |
411 | if (nonoption_flags_max_len == 0) | 411 | if (nonoption_flags_max_len == 0) |
412 | { | 412 | { |
413 | if (__getopt_nonoption_flags == NULL | 413 | if (__getopt_nonoption_flags == NULL || |
414 | || __getopt_nonoption_flags[0] == '\0') | 414 | __getopt_nonoption_flags[0] == '\0') |
415 | nonoption_flags_max_len = -1; | 415 | nonoption_flags_max_len = -1; |
416 | else | 416 | else |
417 | { | 417 | { |
@@ -497,11 +497,9 @@ _getopt_initialize (argc, argv, optstring) | |||
497 | long-named options. */ | 497 | long-named options. */ |
498 | 498 | ||
499 | static int | 499 | static int |
500 | GN_getopt_internal (int argc, | 500 | GN_getopt_internal (int argc, char *const *argv, const char *optstring, |
501 | char *const *argv, | 501 | const struct GNoption *longopts, int *longind, |
502 | const char *optstring, | 502 | int long_only) |
503 | const struct GNoption *longopts, | ||
504 | int *longind, int long_only) | ||
505 | { | 503 | { |
506 | static int __getopt_initialized = 0; | 504 | static int __getopt_initialized = 0; |
507 | static int GNopterr = 1; | 505 | static int GNopterr = 1; |
@@ -600,8 +598,8 @@ GN_getopt_internal (int argc, | |||
600 | /* We have found another option-ARGV-element. | 598 | /* We have found another option-ARGV-element. |
601 | * Skip the initial punctuation. */ | 599 | * Skip the initial punctuation. */ |
602 | 600 | ||
603 | nextchar = (argv[GNoptind] + 1 | 601 | nextchar = |
604 | + (longopts != NULL && argv[GNoptind][1] == '-')); | 602 | (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-')); |
605 | } | 603 | } |
606 | 604 | ||
607 | /* Decode the current option-ARGV-element. */ | 605 | /* Decode the current option-ARGV-element. */ |
@@ -619,11 +617,10 @@ GN_getopt_internal (int argc, | |||
619 | * | 617 | * |
620 | * This distinction seems to be the most useful approach. */ | 618 | * This distinction seems to be the most useful approach. */ |
621 | 619 | ||
622 | if (longopts != NULL | 620 | if (longopts != NULL && |
623 | && (argv[GNoptind][1] == '-' | 621 | (argv[GNoptind][1] == '-' || |
624 | || (long_only | 622 | (long_only && |
625 | && (argv[GNoptind][2] | 623 | (argv[GNoptind][2] || !my_index (optstring, argv[GNoptind][1]))))) |
626 | || !my_index (optstring, argv[GNoptind][1]))))) | ||
627 | { | 624 | { |
628 | char *nameend; | 625 | char *nameend; |
629 | const struct GNoption *p; | 626 | const struct GNoption *p; |
@@ -641,8 +638,8 @@ GN_getopt_internal (int argc, | |||
641 | for (p = longopts, option_index = 0; p->name; p++, option_index++) | 638 | for (p = longopts, option_index = 0; p->name; p++, option_index++) |
642 | if (!strncmp (p->name, nextchar, nameend - nextchar)) | 639 | if (!strncmp (p->name, nextchar, nameend - nextchar)) |
643 | { | 640 | { |
644 | if ((unsigned int) (nameend - nextchar) | 641 | if ((unsigned int) (nameend - nextchar) == |
645 | == (unsigned int) strlen (p->name)) | 642 | (unsigned int) strlen (p->name)) |
646 | { | 643 | { |
647 | /* Exact match found. */ | 644 | /* Exact match found. */ |
648 | pfound = p; | 645 | pfound = p; |
@@ -664,8 +661,8 @@ GN_getopt_internal (int argc, | |||
664 | if (ambig && !exact) | 661 | if (ambig && !exact) |
665 | { | 662 | { |
666 | if (GNopterr) | 663 | if (GNopterr) |
667 | fprintf (stderr, _("%s: option `%s' is ambiguous\n"), | 664 | fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], |
668 | argv[0], argv[GNoptind]); | 665 | argv[GNoptind]); |
669 | nextchar += strlen (nextchar); | 666 | nextchar += strlen (nextchar); |
670 | GNoptind++; | 667 | GNoptind++; |
671 | return '?'; | 668 | return '?'; |
@@ -688,14 +685,12 @@ GN_getopt_internal (int argc, | |||
688 | if (argv[GNoptind - 1][1] == '-') | 685 | if (argv[GNoptind - 1][1] == '-') |
689 | /* --option */ | 686 | /* --option */ |
690 | fprintf (stderr, | 687 | fprintf (stderr, |
691 | _ | 688 | _("%s: option `--%s' does not allow an argument\n"), |
692 | ("%s: option `--%s' does not allow an argument\n"), | ||
693 | argv[0], pfound->name); | 689 | argv[0], pfound->name); |
694 | else | 690 | else |
695 | /* +option or -option */ | 691 | /* +option or -option */ |
696 | fprintf (stderr, | 692 | fprintf (stderr, |
697 | _ | 693 | _("%s: option `%c%s' does not allow an argument\n"), |
698 | ("%s: option `%c%s' does not allow an argument\n"), | ||
699 | argv[0], argv[GNoptind - 1][0], pfound->name); | 694 | argv[0], argv[GNoptind - 1][0], pfound->name); |
700 | } | 695 | } |
701 | nextchar += strlen (nextchar); | 696 | nextchar += strlen (nextchar); |
@@ -712,8 +707,7 @@ GN_getopt_internal (int argc, | |||
712 | { | 707 | { |
713 | if (GNopterr) | 708 | if (GNopterr) |
714 | { | 709 | { |
715 | fprintf (stderr, | 710 | fprintf (stderr, _("%s: option `%s' requires an argument\n"), |
716 | _("%s: option `%s' requires an argument\n"), | ||
717 | argv[0], argv[GNoptind - 1]); | 711 | argv[0], argv[GNoptind - 1]); |
718 | } | 712 | } |
719 | nextchar += strlen (nextchar); | 713 | nextchar += strlen (nextchar); |
@@ -735,19 +729,19 @@ GN_getopt_internal (int argc, | |||
735 | * or the option starts with '--' or is not a valid short | 729 | * or the option starts with '--' or is not a valid short |
736 | * option, then it's an error. | 730 | * option, then it's an error. |
737 | * Otherwise interpret it as a short option. */ | 731 | * Otherwise interpret it as a short option. */ |
738 | if (!long_only || argv[GNoptind][1] == '-' | 732 | if (!long_only || argv[GNoptind][1] == '-' || |
739 | || my_index (optstring, *nextchar) == NULL) | 733 | my_index (optstring, *nextchar) == NULL) |
740 | { | 734 | { |
741 | if (GNopterr) | 735 | if (GNopterr) |
742 | { | 736 | { |
743 | if (argv[GNoptind][1] == '-') | 737 | if (argv[GNoptind][1] == '-') |
744 | /* --option */ | 738 | /* --option */ |
745 | fprintf (stderr, _("%s: unrecognized option `--%s'\n"), | 739 | fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], |
746 | argv[0], nextchar); | 740 | nextchar); |
747 | else | 741 | else |
748 | /* +option or -option */ | 742 | /* +option or -option */ |
749 | fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), | 743 | fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], |
750 | argv[0], argv[GNoptind][0], nextchar); | 744 | argv[GNoptind][0], nextchar); |
751 | } | 745 | } |
752 | nextchar = (char *) ""; | 746 | nextchar = (char *) ""; |
753 | GNoptind++; | 747 | GNoptind++; |
@@ -849,8 +843,8 @@ GN_getopt_internal (int argc, | |||
849 | if (ambig && !exact) | 843 | if (ambig && !exact) |
850 | { | 844 | { |
851 | if (GNopterr) | 845 | if (GNopterr) |
852 | fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), | 846 | fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], |
853 | argv[0], argv[GNoptind]); | 847 | argv[GNoptind]); |
854 | nextchar += strlen (nextchar); | 848 | nextchar += strlen (nextchar); |
855 | GNoptind++; | 849 | GNoptind++; |
856 | return '?'; | 850 | return '?'; |
@@ -881,8 +875,7 @@ GN_getopt_internal (int argc, | |||
881 | else | 875 | else |
882 | { | 876 | { |
883 | if (GNopterr) | 877 | if (GNopterr) |
884 | fprintf (stderr, | 878 | fprintf (stderr, _("%s: option `%s' requires an argument\n"), |
885 | _("%s: option `%s' requires an argument\n"), | ||
886 | argv[0], argv[GNoptind - 1]); | 879 | argv[0], argv[GNoptind - 1]); |
887 | nextchar += strlen (nextchar); | 880 | nextchar += strlen (nextchar); |
888 | return optstring[0] == ':' ? ':' : '?'; | 881 | return optstring[0] == ':' ? ':' : '?'; |
@@ -930,8 +923,8 @@ GN_getopt_internal (int argc, | |||
930 | if (GNopterr) | 923 | if (GNopterr) |
931 | { | 924 | { |
932 | /* 1003.2 specifies the format of this message. */ | 925 | /* 1003.2 specifies the format of this message. */ |
933 | fprintf (stderr, | 926 | fprintf (stderr, _("%s: option requires an argument -- %c\n"), |
934 | _("%s: option requires an argument -- %c\n"), argv[0], c); | 927 | argv[0], c); |
935 | } | 928 | } |
936 | if (optstring[0] == ':') | 929 | if (optstring[0] == ':') |
937 | c = ':'; | 930 | c = ':'; |
@@ -950,9 +943,7 @@ GN_getopt_internal (int argc, | |||
950 | } | 943 | } |
951 | 944 | ||
952 | static int | 945 | static int |
953 | GNgetopt_long (int argc, | 946 | GNgetopt_long (int argc, char *const *argv, const char *options, |
954 | char *const *argv, | ||
955 | const char *options, | ||
956 | const struct GNoption *long_options, int *opt_index) | 947 | const struct GNoption *long_options, int *opt_index) |
957 | { | 948 | { |
958 | return GN_getopt_internal (argc, argv, options, long_options, opt_index, 0); | 949 | return GN_getopt_internal (argc, argv, options, long_options, opt_index, 0); |
@@ -1028,9 +1019,9 @@ GNUNET_GETOPT_run (const char *binaryOptions, | |||
1028 | clpc.currentArgument = GNoptind - 1; | 1019 | clpc.currentArgument = GNoptind - 1; |
1029 | if ((char) c == allOptions[i].shortName) | 1020 | if ((char) c == allOptions[i].shortName) |
1030 | { | 1021 | { |
1031 | cont = allOptions[i].processor (&clpc, | 1022 | cont = |
1032 | allOptions[i].scls, | 1023 | allOptions[i].processor (&clpc, allOptions[i].scls, |
1033 | allOptions[i].name, GNoptarg); | 1024 | allOptions[i].name, GNoptarg); |
1034 | break; | 1025 | break; |
1035 | } | 1026 | } |
1036 | } | 1027 | } |
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c index aa85bf536..d0c8c0e6a 100644 --- a/src/util/getopt_helpers.c +++ b/src/util/getopt_helpers.c | |||
@@ -166,9 +166,8 @@ OUTER: | |||
166 | * @return GNUNET_OK | 166 | * @return GNUNET_OK |
167 | */ | 167 | */ |
168 | int | 168 | int |
169 | GNUNET_GETOPT_increment_value (struct | 169 | GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext |
170 | GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 170 | *ctx, void *scls, const char *option, |
171 | void *scls, const char *option, | ||
172 | const char *value) | 171 | const char *value) |
173 | { | 172 | { |
174 | int *val = scls; | 173 | int *val = scls; |
@@ -218,9 +217,8 @@ GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
218 | * @return GNUNET_OK | 217 | * @return GNUNET_OK |
219 | */ | 218 | */ |
220 | int | 219 | int |
221 | GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext | 220 | GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
222 | *ctx, void *scls, const char *option, | 221 | void *scls, const char *option, const char *value) |
223 | const char *value) | ||
224 | { | 222 | { |
225 | char **val = scls; | 223 | char **val = scls; |
226 | 224 | ||
@@ -246,9 +244,8 @@ GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
246 | * @return GNUNET_OK if parsing the value worked | 244 | * @return GNUNET_OK if parsing the value worked |
247 | */ | 245 | */ |
248 | int | 246 | int |
249 | GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext | 247 | GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
250 | *ctx, void *scls, const char *option, | 248 | void *scls, const char *option, const char *value) |
251 | const char *value) | ||
252 | { | 249 | { |
253 | unsigned long long *val = scls; | 250 | unsigned long long *val = scls; |
254 | 251 | ||
diff --git a/src/util/gnunet-config-diff.c b/src/util/gnunet-config-diff.c index 02ffa77a1..207b9518a 100644 --- a/src/util/gnunet-config-diff.c +++ b/src/util/gnunet-config-diff.c | |||
@@ -14,8 +14,7 @@ main (int argc, char **argv) | |||
14 | } | 14 | } |
15 | i1 = GNUNET_CONFIGURATION_create (); | 15 | i1 = GNUNET_CONFIGURATION_create (); |
16 | i2 = GNUNET_CONFIGURATION_create (); | 16 | i2 = GNUNET_CONFIGURATION_create (); |
17 | if ((GNUNET_OK != | 17 | if ((GNUNET_OK != GNUNET_CONFIGURATION_load (i1, argv[1])) || |
18 | GNUNET_CONFIGURATION_load (i1, argv[1])) || | ||
19 | (GNUNET_OK != GNUNET_CONFIGURATION_load (i2, argv[2]))) | 18 | (GNUNET_OK != GNUNET_CONFIGURATION_load (i2, argv[2]))) |
20 | return 1; | 19 | return 1; |
21 | if (GNUNET_OK != GNUNET_CONFIGURATION_write_diffs (i1, i2, argv[2])) | 20 | if (GNUNET_OK != GNUNET_CONFIGURATION_write_diffs (i1, i2, argv[2])) |
diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c index 125d6665f..131693dd1 100644 --- a/src/util/gnunet-resolver.c +++ b/src/util/gnunet-resolver.c | |||
@@ -50,9 +50,8 @@ printer (void *cls, const struct sockaddr *addr, socklen_t addrlen) | |||
50 | * @param cfg configuration | 50 | * @param cfg configuration |
51 | */ | 51 | */ |
52 | static void | 52 | static void |
53 | run (void *cls, | 53 | run (void *cls, char *const *args, const char *cfgfile, |
54 | char *const *args, | 54 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
55 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
56 | { | 55 | { |
57 | if (args[0] == NULL) | 56 | if (args[0] == NULL) |
58 | return; | 57 | return; |
@@ -73,11 +72,8 @@ main (int argc, char *const *argv) | |||
73 | GNUNET_GETOPT_OPTION_END | 72 | GNUNET_GETOPT_OPTION_END |
74 | }; | 73 | }; |
75 | return (GNUNET_OK == | 74 | return (GNUNET_OK == |
76 | GNUNET_PROGRAM_run (argc, | 75 | GNUNET_PROGRAM_run (argc, argv, "gnunet-resolver [hostname]", |
77 | argv, | 76 | gettext_noop ("Test GNUnet DNS resolver code."), |
78 | "gnunet-resolver [hostname]", | ||
79 | gettext_noop | ||
80 | ("Test GNUnet DNS resolver code."), | ||
81 | options, &run, NULL)) ? 0 : 1; | 77 | options, &run, NULL)) ? 0 : 1; |
82 | } | 78 | } |
83 | 79 | ||
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c index f49ec3882..5d4c5c224 100644 --- a/src/util/gnunet-service-resolver.c +++ b/src/util/gnunet-service-resolver.c | |||
@@ -87,8 +87,9 @@ getnameinfo_resolve (struct IPCache *cache) | |||
87 | { | 87 | { |
88 | char hostname[256]; | 88 | char hostname[256]; |
89 | 89 | ||
90 | if (0 == getnameinfo (cache->sa, | 90 | if (0 == |
91 | cache->salen, hostname, sizeof (hostname), NULL, 0, 0)) | 91 | getnameinfo (cache->sa, cache->salen, hostname, sizeof (hostname), NULL, |
92 | 0, 0)) | ||
92 | cache->addr = GNUNET_strdup (hostname); | 93 | cache->addr = GNUNET_strdup (hostname); |
93 | } | 94 | } |
94 | #endif | 95 | #endif |
@@ -108,12 +109,14 @@ gethostbyaddr_resolve (struct IPCache *cache) | |||
108 | switch (cache->sa->sa_family) | 109 | switch (cache->sa->sa_family) |
109 | { | 110 | { |
110 | case AF_INET: | 111 | case AF_INET: |
111 | ent = gethostbyaddr (&((struct sockaddr_in *) cache->sa)->sin_addr, | 112 | ent = |
112 | sizeof (struct in_addr), AF_INET); | 113 | gethostbyaddr (&((struct sockaddr_in *) cache->sa)->sin_addr, |
114 | sizeof (struct in_addr), AF_INET); | ||
113 | break; | 115 | break; |
114 | case AF_INET6: | 116 | case AF_INET6: |
115 | ent = gethostbyaddr (&((struct sockaddr_in6 *) cache->sa)->sin6_addr, | 117 | ent = |
116 | sizeof (struct in6_addr), AF_INET6); | 118 | gethostbyaddr (&((struct sockaddr_in6 *) cache->sa)->sin6_addr, |
119 | sizeof (struct in6_addr), AF_INET6); | ||
117 | break; | 120 | break; |
118 | default: | 121 | default: |
119 | ent = NULL; | 122 | ent = NULL; |
@@ -225,8 +228,7 @@ get_ip_as_string (struct GNUNET_SERVER_Client *client, | |||
225 | } | 228 | } |
226 | tc = GNUNET_SERVER_transmit_context_create (client); | 229 | tc = GNUNET_SERVER_transmit_context_create (client); |
227 | if (cache->addr != NULL) | 230 | if (cache->addr != NULL) |
228 | GNUNET_SERVER_transmit_context_append_data (tc, | 231 | GNUNET_SERVER_transmit_context_append_data (tc, cache->addr, |
229 | cache->addr, | ||
230 | strlen (cache->addr) + 1, | 232 | strlen (cache->addr) + 1, |
231 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); | 233 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); |
232 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | 234 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, |
@@ -256,11 +258,10 @@ getaddrinfo_resolve (struct GNUNET_SERVER_TransmitContext *tc, | |||
256 | 258 | ||
257 | if (0 != (s = getaddrinfo (hostname, NULL, &hints, &result))) | 259 | if (0 != (s = getaddrinfo (hostname, NULL, &hints, &result))) |
258 | { | 260 | { |
259 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 261 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Could not resolve `%s' (%s): %s\n"), |
260 | _("Could not resolve `%s' (%s): %s\n"), hostname, | 262 | hostname, |
261 | (domain == | 263 | (domain == |
262 | AF_INET) ? "IPv4" : ((domain == | 264 | AF_INET) ? "IPv4" : ((domain == AF_INET6) ? "IPv6" : "any"), |
263 | AF_INET6) ? "IPv6" : "any"), | ||
264 | gai_strerror (s)); | 265 | gai_strerror (s)); |
265 | if ((s == EAI_BADFLAGS) || (s == EAI_MEMORY) | 266 | if ((s == EAI_BADFLAGS) || (s == EAI_MEMORY) |
266 | #ifndef MINGW | 267 | #ifndef MINGW |
@@ -278,8 +279,7 @@ getaddrinfo_resolve (struct GNUNET_SERVER_TransmitContext *tc, | |||
278 | pos = result; | 279 | pos = result; |
279 | while (pos != NULL) | 280 | while (pos != NULL) |
280 | { | 281 | { |
281 | GNUNET_SERVER_transmit_context_append_data (tc, | 282 | GNUNET_SERVER_transmit_context_append_data (tc, pos->ai_addr, |
282 | pos->ai_addr, | ||
283 | pos->ai_addrlen, | 283 | pos->ai_addrlen, |
284 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); | 284 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); |
285 | pos = pos->ai_next; | 285 | pos = pos->ai_next; |
@@ -314,8 +314,8 @@ gethostbyname2_resolve (struct GNUNET_SERVER_TransmitContext *tc, | |||
314 | if (hp == NULL) | 314 | if (hp == NULL) |
315 | { | 315 | { |
316 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 316 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
317 | _("Could not find IP of host `%s': %s\n"), | 317 | _("Could not find IP of host `%s': %s\n"), hostname, |
318 | hostname, hstrerror (h_errno)); | 318 | hstrerror (h_errno)); |
319 | return GNUNET_SYSERR; | 319 | return GNUNET_SYSERR; |
320 | } | 320 | } |
321 | GNUNET_assert (hp->h_addrtype == domain); | 321 | GNUNET_assert (hp->h_addrtype == domain); |
@@ -328,9 +328,7 @@ gethostbyname2_resolve (struct GNUNET_SERVER_TransmitContext *tc, | |||
328 | a4.sin_len = (u_char) sizeof (struct sockaddr_in); | 328 | a4.sin_len = (u_char) sizeof (struct sockaddr_in); |
329 | #endif | 329 | #endif |
330 | memcpy (&a4.sin_addr, hp->h_addr_list[0], hp->h_length); | 330 | memcpy (&a4.sin_addr, hp->h_addr_list[0], hp->h_length); |
331 | GNUNET_SERVER_transmit_context_append_data (tc, | 331 | GNUNET_SERVER_transmit_context_append_data (tc, &a4, sizeof (a4), |
332 | &a4, | ||
333 | sizeof (a4), | ||
334 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); | 332 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); |
335 | } | 333 | } |
336 | else | 334 | else |
@@ -342,9 +340,7 @@ gethostbyname2_resolve (struct GNUNET_SERVER_TransmitContext *tc, | |||
342 | a6.sin6_len = (u_char) sizeof (struct sockaddr_in6); | 340 | a6.sin6_len = (u_char) sizeof (struct sockaddr_in6); |
343 | #endif | 341 | #endif |
344 | memcpy (&a6.sin6_addr, hp->h_addr_list[0], hp->h_length); | 342 | memcpy (&a6.sin6_addr, hp->h_addr_list[0], hp->h_length); |
345 | GNUNET_SERVER_transmit_context_append_data (tc, | 343 | GNUNET_SERVER_transmit_context_append_data (tc, &a6, sizeof (a6), |
346 | &a6, | ||
347 | sizeof (a6), | ||
348 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); | 344 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); |
349 | } | 345 | } |
350 | return GNUNET_OK; | 346 | return GNUNET_OK; |
@@ -363,8 +359,8 @@ gethostbyname_resolve (struct GNUNET_SERVER_TransmitContext *tc, | |||
363 | if (hp == NULL) | 359 | if (hp == NULL) |
364 | { | 360 | { |
365 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 361 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
366 | _("Could not find IP of host `%s': %s\n"), | 362 | _("Could not find IP of host `%s': %s\n"), hostname, |
367 | hostname, hstrerror (h_errno)); | 363 | hstrerror (h_errno)); |
368 | return GNUNET_SYSERR; | 364 | return GNUNET_SYSERR; |
369 | } | 365 | } |
370 | if (hp->h_addrtype != AF_INET) | 366 | if (hp->h_addrtype != AF_INET) |
@@ -379,9 +375,7 @@ gethostbyname_resolve (struct GNUNET_SERVER_TransmitContext *tc, | |||
379 | addr.sin_len = (u_char) sizeof (struct sockaddr_in); | 375 | addr.sin_len = (u_char) sizeof (struct sockaddr_in); |
380 | #endif | 376 | #endif |
381 | memcpy (&addr.sin_addr, hp->h_addr_list[0], hp->h_length); | 377 | memcpy (&addr.sin_addr, hp->h_addr_list[0], hp->h_length); |
382 | GNUNET_SERVER_transmit_context_append_data (tc, | 378 | GNUNET_SERVER_transmit_context_append_data (tc, &addr, sizeof (addr), |
383 | &addr, | ||
384 | sizeof (addr), | ||
385 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); | 379 | GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); |
386 | return GNUNET_OK; | 380 | return GNUNET_OK; |
387 | } | 381 | } |
@@ -396,8 +390,8 @@ gethostbyname_resolve (struct GNUNET_SERVER_TransmitContext *tc, | |||
396 | * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" | 390 | * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" |
397 | */ | 391 | */ |
398 | static void | 392 | static void |
399 | get_ip_from_hostname (struct GNUNET_SERVER_Client *client, | 393 | get_ip_from_hostname (struct GNUNET_SERVER_Client *client, const char *hostname, |
400 | const char *hostname, int domain) | 394 | int domain) |
401 | { | 395 | { |
402 | int ret; | 396 | int ret; |
403 | struct GNUNET_SERVER_TransmitContext *tc; | 397 | struct GNUNET_SERVER_TransmitContext *tc; |
@@ -430,8 +424,7 @@ get_ip_from_hostname (struct GNUNET_SERVER_Client *client, | |||
430 | * @param message the actual message | 424 | * @param message the actual message |
431 | */ | 425 | */ |
432 | static void | 426 | static void |
433 | handle_get (void *cls, | 427 | handle_get (void *cls, struct GNUNET_SERVER_Client *client, |
434 | struct GNUNET_SERVER_Client *client, | ||
435 | const struct GNUNET_MessageHeader *message) | 428 | const struct GNUNET_MessageHeader *message) |
436 | { | 429 | { |
437 | uint16_t msize; | 430 | uint16_t msize; |
@@ -464,8 +457,8 @@ handle_get (void *cls, | |||
464 | return; | 457 | return; |
465 | } | 458 | } |
466 | #if DEBUG_RESOLVER | 459 | #if DEBUG_RESOLVER |
467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 460 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolver asked to look up `%s'.\n"), |
468 | _("Resolver asked to look up `%s'.\n"), hostname); | 461 | hostname); |
469 | #endif | 462 | #endif |
470 | get_ip_from_hostname (client, hostname, domain); | 463 | get_ip_from_hostname (client, hostname, domain); |
471 | } | 464 | } |
@@ -527,8 +520,7 @@ handle_get (void *cls, | |||
527 | * @param cfg configuration to use | 520 | * @param cfg configuration to use |
528 | */ | 521 | */ |
529 | static void | 522 | static void |
530 | run (void *cls, | 523 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
531 | struct GNUNET_SERVER_Handle *server, | ||
532 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 524 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
533 | { | 525 | { |
534 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 526 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
@@ -552,11 +544,10 @@ main (int argc, char *const *argv) | |||
552 | int ret; | 544 | int ret; |
553 | struct IPCache *pos; | 545 | struct IPCache *pos; |
554 | 546 | ||
555 | ret = (GNUNET_OK == | 547 | ret = |
556 | GNUNET_SERVICE_run (argc, | 548 | (GNUNET_OK == |
557 | argv, | 549 | GNUNET_SERVICE_run (argc, argv, "resolver", GNUNET_SERVICE_OPTION_NONE, |
558 | "resolver", GNUNET_SERVICE_OPTION_NONE, | 550 | &run, NULL)) ? 0 : 1; |
559 | &run, NULL)) ? 0 : 1; | ||
560 | 551 | ||
561 | while (head != NULL) | 552 | while (head != NULL) |
562 | { | 553 | { |
diff --git a/src/util/network.c b/src/util/network.c index b533ce183..e071b8b54 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -212,8 +212,7 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, | |||
212 | int gsn = getsockname (desc->fd, &name, &namelen); | 212 | int gsn = getsockname (desc->fd, &name, &namelen); |
213 | 213 | ||
214 | if (gsn == 0) | 214 | if (gsn == 0) |
215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Accepting connection on `%s'\n", |
216 | "Accepting connection on `%s'\n", | ||
217 | GNUNET_a2s (&name, namelen)); | 216 | GNUNET_a2s (&name, namelen)); |
218 | } | 217 | } |
219 | #endif | 218 | #endif |
@@ -357,8 +356,8 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc) | |||
357 | const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; | 356 | const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; |
358 | 357 | ||
359 | if (0 != unlink (un->sun_path)) | 358 | if (0 != unlink (un->sun_path)) |
360 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 359 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", |
361 | "unlink", un->sun_path); | 360 | un->sun_path); |
362 | } | 361 | } |
363 | #endif | 362 | #endif |
364 | #endif | 363 | #endif |
@@ -480,8 +479,8 @@ GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, | |||
480 | * @param desc socket | 479 | * @param desc socket |
481 | */ | 480 | */ |
482 | ssize_t | 481 | ssize_t |
483 | GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle | 482 | GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle * |
484 | * desc) | 483 | desc) |
485 | { | 484 | { |
486 | int error; | 485 | int error; |
487 | 486 | ||
@@ -645,9 +644,8 @@ GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle * desc, | |||
645 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | 644 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise |
646 | */ | 645 | */ |
647 | int | 646 | int |
648 | GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, | 647 | GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, int level, |
649 | int level, int option_name, | 648 | int option_name, const void *option_value, |
650 | const void *option_value, | ||
651 | socklen_t option_len) | 649 | socklen_t option_len) |
652 | { | 650 | { |
653 | int ret; | 651 | int ret; |
@@ -945,8 +943,8 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, | |||
945 | { | 943 | { |
946 | #ifdef MINGW | 944 | #ifdef MINGW |
947 | GNUNET_CONTAINER_slist_add (fds->handles, | 945 | GNUNET_CONTAINER_slist_add (fds->handles, |
948 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, | 946 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, h, |
949 | h, sizeof (struct GNUNET_DISK_FileHandle)); | 947 | sizeof (struct GNUNET_DISK_FileHandle)); |
950 | 948 | ||
951 | #else | 949 | #else |
952 | int fd; | 950 | int fd; |
@@ -1569,10 +1567,9 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1569 | "send to the socket %d returned %d (%u)\n", i, status, | 1567 | "send to the socket %d returned %d (%u)\n", i, status, |
1570 | error); | 1568 | error); |
1571 | #endif | 1569 | #endif |
1572 | if (status == 0 | 1570 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) || |
1573 | || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) | 1571 | (status == -1 && gso_result == 0 && error == WSAENOTCONN && |
1574 | || (status == -1 && gso_result == 0 && error == WSAENOTCONN && | 1572 | so_error == WSAECONNREFUSED)) |
1575 | so_error == WSAECONNREFUSED)) | ||
1576 | { | 1573 | { |
1577 | FD_SET (wfds->sds.fd_array[i], &awrite); | 1574 | FD_SET (wfds->sds.fd_array[i], &awrite); |
1578 | retcode += 1; | 1575 | retcode += 1; |
diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 188401abb..00825f2b7 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c | |||
@@ -57,9 +57,9 @@ get_path_from_proc_maps () | |||
57 | return NULL; | 57 | return NULL; |
58 | while (NULL != fgets (line, sizeof (line), f)) | 58 | while (NULL != fgets (line, sizeof (line), f)) |
59 | { | 59 | { |
60 | if ((1 == sscanf (line, | 60 | if ((1 == |
61 | "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", | 61 | sscanf (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir)) && |
62 | dir)) && (NULL != (lgu = strstr (dir, "libgnunetutil")))) | 62 | (NULL != (lgu = strstr (dir, "libgnunetutil")))) |
63 | { | 63 | { |
64 | lgu[0] = '\0'; | 64 | lgu[0] = '\0'; |
65 | fclose (f); | 65 | fclose (f); |
@@ -476,8 +476,8 @@ GNUNET_OS_check_helper_binary (const char *binary) | |||
476 | } | 476 | } |
477 | if (0 != STAT (p, &statbuf)) | 477 | if (0 != STAT (p, &statbuf)) |
478 | { | 478 | { |
479 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 479 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p, |
480 | _("stat (%s) failed: %s\n"), p, STRERROR (errno)); | 480 | STRERROR (errno)); |
481 | GNUNET_free (p); | 481 | GNUNET_free (p); |
482 | return GNUNET_SYSERR; | 482 | return GNUNET_SYSERR; |
483 | } | 483 | } |
diff --git a/src/util/os_network.c b/src/util/os_network.c index af8046814..21376f94c 100644 --- a/src/util/os_network.c +++ b/src/util/os_network.c | |||
@@ -131,15 +131,12 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, | |||
131 | 131 | ||
132 | /* Set entry */ | 132 | /* Set entry */ |
133 | memset (bPhysAddr, 0, MAXLEN_PHYSADDR); | 133 | memset (bPhysAddr, 0, MAXLEN_PHYSADDR); |
134 | memcpy (bPhysAddr, | 134 | memcpy (bPhysAddr, pTable->table[dwIfIdx].bPhysAddr, |
135 | pTable->table[dwIfIdx].bPhysAddr, | ||
136 | pTable->table[dwIfIdx].dwPhysAddrLen); | 135 | pTable->table[dwIfIdx].dwPhysAddrLen); |
137 | 136 | ||
138 | snprintf (szEntry, 1000, "%s (%s - %I64u)", | 137 | snprintf (szEntry, 1000, "%s (%s - %I64u)", |
139 | pszIfName ? pszIfName : (char *) | 138 | pszIfName ? pszIfName : (char *) pTable->table[dwIfIdx]. |
140 | pTable->table[dwIfIdx].bDescr, inet_ntop (AF_INET, | 139 | bDescr, inet_ntop (AF_INET, &dwIP, dst, INET_ADDRSTRLEN), |
141 | &dwIP, dst, | ||
142 | INET_ADDRSTRLEN), | ||
143 | *((unsigned long long *) bPhysAddr)); | 140 | *((unsigned long long *) bPhysAddr)); |
144 | szEntry[1000] = 0; | 141 | szEntry[1000] = 0; |
145 | 142 | ||
@@ -153,8 +150,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, | |||
153 | sa.sin_addr.S_un.S_addr = dwIP; | 150 | sa.sin_addr.S_un.S_addr = dwIP; |
154 | 151 | ||
155 | if (GNUNET_OK != | 152 | if (GNUNET_OK != |
156 | proc (proc_cls, | 153 | proc (proc_cls, szEntry, |
157 | szEntry, | ||
158 | pTable->table[dwIfIdx].dwIndex == dwExternalNIC, | 154 | pTable->table[dwIfIdx].dwIndex == dwExternalNIC, |
159 | (const struct sockaddr *) &sa, sizeof (sa))) | 155 | (const struct sockaddr *) &sa, sizeof (sa))) |
160 | break; | 156 | break; |
@@ -176,8 +172,8 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, | |||
176 | { | 172 | { |
177 | for (ifa_ptr = ifa_first; ifa_ptr != NULL; ifa_ptr = ifa_ptr->ifa_next) | 173 | for (ifa_ptr = ifa_first; ifa_ptr != NULL; ifa_ptr = ifa_ptr->ifa_next) |
178 | { | 174 | { |
179 | if (ifa_ptr->ifa_name != NULL && | 175 | if (ifa_ptr->ifa_name != NULL && ifa_ptr->ifa_addr != NULL && |
180 | ifa_ptr->ifa_addr != NULL && (ifa_ptr->ifa_flags & IFF_UP) != 0) | 176 | (ifa_ptr->ifa_flags & IFF_UP) != 0) |
181 | { | 177 | { |
182 | if ((ifa_ptr->ifa_addr->sa_family != AF_INET) && | 178 | if ((ifa_ptr->ifa_addr->sa_family != AF_INET) && |
183 | (ifa_ptr->ifa_addr->sa_family != AF_INET6)) | 179 | (ifa_ptr->ifa_addr->sa_family != AF_INET6)) |
@@ -186,11 +182,10 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, | |||
186 | alen = sizeof (struct sockaddr_in); | 182 | alen = sizeof (struct sockaddr_in); |
187 | else | 183 | else |
188 | alen = sizeof (struct sockaddr_in6); | 184 | alen = sizeof (struct sockaddr_in6); |
189 | if (GNUNET_OK != proc (proc_cls, | 185 | if (GNUNET_OK != |
190 | ifa_ptr->ifa_name, | 186 | proc (proc_cls, ifa_ptr->ifa_name, |
191 | 0 == strcmp (ifa_ptr->ifa_name, | 187 | 0 == strcmp (ifa_ptr->ifa_name, GNUNET_DEFAULT_INTERFACE), |
192 | GNUNET_DEFAULT_INTERFACE), | 188 | ifa_ptr->ifa_addr, alen)) |
193 | ifa_ptr->ifa_addr, alen)) | ||
194 | break; | 189 | break; |
195 | } | 190 | } |
196 | } | 191 | } |
@@ -261,9 +256,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, | |||
261 | #endif | 256 | #endif |
262 | a4.sin_addr = v4; | 257 | a4.sin_addr = v4; |
263 | if (GNUNET_OK != | 258 | if (GNUNET_OK != |
264 | proc (proc_cls, | 259 | proc (proc_cls, ifc, 0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE), |
265 | ifc, | ||
266 | 0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE), | ||
267 | (const struct sockaddr *) &a4, sizeof (a4))) | 260 | (const struct sockaddr *) &a4, sizeof (a4))) |
268 | break; | 261 | break; |
269 | continue; | 262 | continue; |
@@ -278,9 +271,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, | |||
278 | #endif | 271 | #endif |
279 | a6.sin6_addr = v6; | 272 | a6.sin6_addr = v6; |
280 | if (GNUNET_OK != | 273 | if (GNUNET_OK != |
281 | proc (proc_cls, | 274 | proc (proc_cls, ifc, 0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE), |
282 | ifc, | ||
283 | 0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE), | ||
284 | (const struct sockaddr *) &a6, sizeof (a6))) | 275 | (const struct sockaddr *) &a6, sizeof (a6))) |
285 | break; | 276 | break; |
286 | continue; | 277 | continue; |
diff --git a/src/util/os_priority.c b/src/util/os_priority.c index bccde8d46..d27642a58 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c | |||
@@ -60,19 +60,20 @@ parent_control_handler (void *cls, | |||
60 | int sig; | 60 | int sig; |
61 | 61 | ||
62 | #if DEBUG_OS | 62 | #if DEBUG_OS |
63 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 63 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", |
64 | "`%s' invoked because of %d\n", __FUNCTION__, tc->reason); | 64 | __FUNCTION__, tc->reason); |
65 | #endif | 65 | #endif |
66 | if (tc->reason & (GNUNET_SCHEDULER_REASON_SHUTDOWN | | 66 | if (tc-> |
67 | GNUNET_SCHEDULER_REASON_TIMEOUT | | 67 | reason & (GNUNET_SCHEDULER_REASON_SHUTDOWN | |
68 | GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 68 | GNUNET_SCHEDULER_REASON_TIMEOUT | |
69 | GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | ||
69 | { | 70 | { |
70 | GNUNET_DISK_npipe_close (control_pipe); | 71 | GNUNET_DISK_npipe_close (control_pipe); |
71 | } | 72 | } |
72 | else | 73 | else |
73 | { | 74 | { |
74 | if (GNUNET_DISK_file_read (control_pipe, | 75 | if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) != |
75 | &sig, sizeof (sig)) != sizeof (sig)) | 76 | sizeof (sig)) |
76 | { | 77 | { |
77 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read"); | 78 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read"); |
78 | GNUNET_DISK_npipe_close (control_pipe); | 79 | GNUNET_DISK_npipe_close (control_pipe); |
@@ -80,12 +81,12 @@ parent_control_handler (void *cls, | |||
80 | else | 81 | else |
81 | { | 82 | { |
82 | #if DEBUG_OS | 83 | #if DEBUG_OS |
83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 84 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", |
84 | "Got control code %d from parent\n", sig); | 85 | sig); |
85 | #endif | 86 | #endif |
86 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 87 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
87 | control_pipe, | 88 | control_pipe, &parent_control_handler, |
88 | &parent_control_handler, control_pipe); | 89 | control_pipe); |
89 | raise (sig); | 90 | raise (sig); |
90 | } | 91 | } |
91 | } | 92 | } |
@@ -111,10 +112,10 @@ GNUNET_OS_install_parent_control_handler (void *cls, | |||
111 | GNUNET_OS_CONTROL_PIPE, env_buf); | 112 | GNUNET_OS_CONTROL_PIPE, env_buf); |
112 | return; | 113 | return; |
113 | } | 114 | } |
114 | control_pipe = GNUNET_DISK_npipe_open (env_buf, | 115 | control_pipe = |
115 | GNUNET_DISK_OPEN_READ, | 116 | GNUNET_DISK_npipe_open (env_buf, GNUNET_DISK_OPEN_READ, |
116 | GNUNET_DISK_PERM_USER_READ | | 117 | GNUNET_DISK_PERM_USER_READ | |
117 | GNUNET_DISK_PERM_USER_WRITE); | 118 | GNUNET_DISK_PERM_USER_WRITE); |
118 | if (control_pipe == NULL) | 119 | if (control_pipe == NULL) |
119 | { | 120 | { |
120 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "open", env_buf); | 121 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "open", env_buf); |
@@ -125,8 +126,7 @@ GNUNET_OS_install_parent_control_handler (void *cls, | |||
125 | "Adding parent control handler pipe `%s' to the scheduler\n", | 126 | "Adding parent control handler pipe `%s' to the scheduler\n", |
126 | env_buf); | 127 | env_buf); |
127 | #endif | 128 | #endif |
128 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 129 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, control_pipe, |
129 | control_pipe, | ||
130 | &parent_control_handler, control_pipe); | 130 | &parent_control_handler, control_pipe); |
131 | } | 131 | } |
132 | 132 | ||
@@ -219,13 +219,14 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
219 | */ | 219 | */ |
220 | while (1) | 220 | while (1) |
221 | { | 221 | { |
222 | ret = GNUNET_NETWORK_socket_select (rfds, NULL, efds, | 222 | ret = |
223 | GNUNET_TIME_relative_multiply | 223 | GNUNET_NETWORK_socket_select (rfds, NULL, efds, |
224 | (GNUNET_TIME_relative_get_unit (), | 224 | GNUNET_TIME_relative_multiply |
225 | 5000)); | 225 | (GNUNET_TIME_relative_get_unit (), |
226 | 226 | 5000)); | |
227 | if (ret < 1 || GNUNET_NETWORK_fdset_handle_isset (efds, | 227 | |
228 | proc->control_pipe)) | 228 | if (ret < 1 || |
229 | GNUNET_NETWORK_fdset_handle_isset (efds, proc->control_pipe)) | ||
229 | { | 230 | { |
230 | /* Just to be sure */ | 231 | /* Just to be sure */ |
231 | PLIBC_KILL (proc->pid, sig); | 232 | PLIBC_KILL (proc->pid, sig); |
@@ -234,8 +235,8 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
234 | } | 235 | } |
235 | else | 236 | else |
236 | { | 237 | { |
237 | if (GNUNET_DISK_file_read (proc->control_pipe, &ret, | 238 | if (GNUNET_DISK_file_read (proc->control_pipe, &ret, sizeof (ret)) != |
238 | sizeof (ret)) != GNUNET_OK) | 239 | GNUNET_OK) |
239 | res = PLIBC_KILL (proc->pid, sig); | 240 | res = PLIBC_KILL (proc->pid, sig); |
240 | 241 | ||
241 | /* Child signaled shutdown is in progress */ | 242 | /* Child signaled shutdown is in progress */ |
@@ -394,8 +395,8 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, | |||
394 | errno = 0; | 395 | errno = 0; |
395 | if ((delta != 0) && (rprio == nice (delta)) && (errno != 0)) | 396 | if ((delta != 0) && (rprio == nice (delta)) && (errno != 0)) |
396 | { | 397 | { |
397 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | 398 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
398 | GNUNET_ERROR_TYPE_BULK, "nice"); | 399 | "nice"); |
399 | return GNUNET_SYSERR; | 400 | return GNUNET_SYSERR; |
400 | } | 401 | } |
401 | } | 402 | } |
@@ -403,8 +404,8 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, | |||
403 | { | 404 | { |
404 | if (0 != setpriority (PRIO_PROCESS, pid, rprio)) | 405 | if (0 != setpriority (PRIO_PROCESS, pid, rprio)) |
405 | { | 406 | { |
406 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | 407 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
407 | GNUNET_ERROR_TYPE_BULK, "setpriority"); | 408 | "setpriority"); |
408 | return GNUNET_SYSERR; | 409 | return GNUNET_SYSERR; |
409 | } | 410 | } |
410 | } | 411 | } |
@@ -552,10 +553,10 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin, | |||
552 | int fd_stdin_write; | 553 | int fd_stdin_write; |
553 | 554 | ||
554 | #if ENABLE_WINDOWS_WORKAROUNDS | 555 | #if ENABLE_WINDOWS_WORKAROUNDS |
555 | control_pipe = GNUNET_DISK_npipe_create (&childpipename, | 556 | control_pipe = |
556 | GNUNET_DISK_OPEN_WRITE, | 557 | GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, |
557 | GNUNET_DISK_PERM_USER_READ | | 558 | GNUNET_DISK_PERM_USER_READ | |
558 | GNUNET_DISK_PERM_USER_WRITE); | 559 | GNUNET_DISK_PERM_USER_WRITE); |
559 | if (control_pipe == NULL) | 560 | if (control_pipe == NULL) |
560 | return NULL; | 561 | return NULL; |
561 | #endif | 562 | #endif |
@@ -776,10 +777,10 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin, | |||
776 | start.hStdOutput = stdout_handle; | 777 | start.hStdOutput = stdout_handle; |
777 | } | 778 | } |
778 | 779 | ||
779 | control_pipe = GNUNET_DISK_npipe_create (&childpipename, | 780 | control_pipe = |
780 | GNUNET_DISK_OPEN_WRITE, | 781 | GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, |
781 | GNUNET_DISK_PERM_USER_READ | | 782 | GNUNET_DISK_PERM_USER_READ | |
782 | GNUNET_DISK_PERM_USER_WRITE); | 783 | GNUNET_DISK_PERM_USER_WRITE); |
783 | if (control_pipe == NULL) | 784 | if (control_pipe == NULL) |
784 | { | 785 | { |
785 | GNUNET_free (cmd); | 786 | GNUNET_free (cmd); |
@@ -865,8 +866,8 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, | |||
865 | * @return process ID of the new process, -1 on error | 866 | * @return process ID of the new process, -1 on error |
866 | */ | 867 | */ |
867 | struct GNUNET_OS_Process * | 868 | struct GNUNET_OS_Process * |
868 | GNUNET_OS_start_process_v (const int *lsocks, | 869 | GNUNET_OS_start_process_v (const int *lsocks, const char *filename, |
869 | const char *filename, char *const argv[]) | 870 | char *const argv[]) |
870 | { | 871 | { |
871 | #if ENABLE_WINDOWS_WORKAROUNDS | 872 | #if ENABLE_WINDOWS_WORKAROUNDS |
872 | struct GNUNET_DISK_FileHandle *control_pipe = NULL; | 873 | struct GNUNET_DISK_FileHandle *control_pipe = NULL; |
@@ -887,10 +888,10 @@ GNUNET_OS_start_process_v (const int *lsocks, | |||
887 | unsigned int ls; | 888 | unsigned int ls; |
888 | 889 | ||
889 | #if ENABLE_WINDOWS_WORKAROUNDS | 890 | #if ENABLE_WINDOWS_WORKAROUNDS |
890 | control_pipe = GNUNET_DISK_npipe_create (&childpipename, | 891 | control_pipe = |
891 | GNUNET_DISK_OPEN_WRITE, | 892 | GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, |
892 | GNUNET_DISK_PERM_USER_READ | | 893 | GNUNET_DISK_PERM_USER_READ | |
893 | GNUNET_DISK_PERM_USER_WRITE); | 894 | GNUNET_DISK_PERM_USER_WRITE); |
894 | if (control_pipe == NULL) | 895 | if (control_pipe == NULL) |
895 | return NULL; | 896 | return NULL; |
896 | #endif | 897 | #endif |
@@ -1121,10 +1122,10 @@ GNUNET_OS_start_process_v (const int *lsocks, | |||
1121 | memset (&start, 0, sizeof (start)); | 1122 | memset (&start, 0, sizeof (start)); |
1122 | start.cb = sizeof (start); | 1123 | start.cb = sizeof (start); |
1123 | 1124 | ||
1124 | control_pipe = GNUNET_DISK_npipe_create (&childpipename, | 1125 | control_pipe = |
1125 | GNUNET_DISK_OPEN_WRITE, | 1126 | GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, |
1126 | GNUNET_DISK_PERM_USER_READ | | 1127 | GNUNET_DISK_PERM_USER_READ | |
1127 | GNUNET_DISK_PERM_USER_WRITE); | 1128 | GNUNET_DISK_PERM_USER_WRITE); |
1128 | if (control_pipe == NULL) | 1129 | if (control_pipe == NULL) |
1129 | { | 1130 | { |
1130 | GNUNET_free (cmd); | 1131 | GNUNET_free (cmd); |
@@ -1414,9 +1415,9 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1414 | proc (cmd->proc_cls, NULL); | 1415 | proc (cmd->proc_cls, NULL); |
1415 | return; | 1416 | return; |
1416 | } | 1417 | } |
1417 | ret = GNUNET_DISK_file_read (cmd->r, | 1418 | ret = |
1418 | &cmd->buf[cmd->off], | 1419 | GNUNET_DISK_file_read (cmd->r, &cmd->buf[cmd->off], |
1419 | sizeof (cmd->buf) - cmd->off); | 1420 | sizeof (cmd->buf) - cmd->off); |
1420 | if (ret <= 0) | 1421 | if (ret <= 0) |
1421 | { | 1422 | { |
1422 | if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf))) | 1423 | if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf))) |
@@ -1457,10 +1458,9 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1457 | * @return NULL on error | 1458 | * @return NULL on error |
1458 | */ | 1459 | */ |
1459 | struct GNUNET_OS_CommandHandle * | 1460 | struct GNUNET_OS_CommandHandle * |
1460 | GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, | 1461 | GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, void *proc_cls, |
1461 | void *proc_cls, | 1462 | struct GNUNET_TIME_Relative timeout, const char *binary, |
1462 | struct GNUNET_TIME_Relative timeout, | 1463 | ...) |
1463 | const char *binary, ...) | ||
1464 | { | 1464 | { |
1465 | struct GNUNET_OS_CommandHandle *cmd; | 1465 | struct GNUNET_OS_CommandHandle *cmd; |
1466 | struct GNUNET_OS_Process *eip; | 1466 | struct GNUNET_OS_Process *eip; |
diff --git a/src/util/peer.c b/src/util/peer.c index 91a706040..62fa0e2f2 100644 --- a/src/util/peer.c +++ b/src/util/peer.c | |||
@@ -148,8 +148,7 @@ GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid) | |||
148 | table[ret].rc = 1; | 148 | table[ret].rc = 1; |
149 | table[ret].pid = ret; | 149 | table[ret].pid = ret; |
150 | GNUNET_break (GNUNET_OK == | 150 | GNUNET_break (GNUNET_OK == |
151 | GNUNET_CONTAINER_multihashmap_put (map, | 151 | GNUNET_CONTAINER_multihashmap_put (map, &pid->hashPubKey, |
152 | &pid->hashPubKey, | ||
153 | (void *) (long) ret, | 152 | (void *) (long) ret, |
154 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 153 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
155 | return ret; | 154 | return ret; |
@@ -182,8 +181,8 @@ GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids, unsigned int count) | |||
182 | { | 181 | { |
183 | GNUNET_break (GNUNET_OK == | 182 | GNUNET_break (GNUNET_OK == |
184 | GNUNET_CONTAINER_multihashmap_remove (map, | 183 | GNUNET_CONTAINER_multihashmap_remove (map, |
185 | &table[id]. | 184 | &table[id].id. |
186 | id.hashPubKey, | 185 | hashPubKey, |
187 | (void *) (long) id)); | 186 | (void *) (long) id)); |
188 | table[id].pid = free_list_start; | 187 | table[id].pid = free_list_start; |
189 | free_list_start = id; | 188 | free_list_start = id; |
@@ -211,8 +210,8 @@ GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta) | |||
211 | { | 210 | { |
212 | GNUNET_break (GNUNET_OK == | 211 | GNUNET_break (GNUNET_OK == |
213 | GNUNET_CONTAINER_multihashmap_remove (map, | 212 | GNUNET_CONTAINER_multihashmap_remove (map, |
214 | &table[id]. | 213 | &table[id].id. |
215 | id.hashPubKey, | 214 | hashPubKey, |
216 | (void *) (long) id)); | 215 | (void *) (long) id)); |
217 | table[id].pid = free_list_start; | 216 | table[id].pid = free_list_start; |
218 | free_list_start = id; | 217 | free_list_start = id; |
diff --git a/src/util/perf_crypto_hash.c b/src/util/perf_crypto_hash.c index d883776b4..689781835 100644 --- a/src/util/perf_crypto_hash.c +++ b/src/util/perf_crypto_hash.c | |||
@@ -58,12 +58,12 @@ main (int argc, char *argv[]) | |||
58 | start = GNUNET_TIME_absolute_get (); | 58 | start = GNUNET_TIME_absolute_get (); |
59 | perfHash (); | 59 | perfHash (); |
60 | printf ("Hash perf took %llu ms\n", | 60 | printf ("Hash perf took %llu ms\n", |
61 | (unsigned long long) | 61 | (unsigned long long) GNUNET_TIME_absolute_get_duration (start). |
62 | GNUNET_TIME_absolute_get_duration (start).rel_value); | 62 | rel_value); |
63 | GAUGER ("UTIL", "Cryptographic hashing", | 63 | GAUGER ("UTIL", "Cryptographic hashing", |
64 | 1024 * 64 * 1024 / (1 + | 64 | 1024 * 64 * 1024 / (1 + |
65 | GNUNET_TIME_absolute_get_duration | 65 | GNUNET_TIME_absolute_get_duration (start). |
66 | (start).rel_value), "kb/s"); | 66 | rel_value), "kb/s"); |
67 | return 0; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
diff --git a/src/util/plugin.c b/src/util/plugin.c index b1c979dff..08b32b295 100644 --- a/src/util/plugin.c +++ b/src/util/plugin.c | |||
@@ -84,8 +84,7 @@ plugin_init () | |||
84 | err = lt_dlinit (); | 84 | err = lt_dlinit (); |
85 | if (err > 0) | 85 | if (err > 0) |
86 | { | 86 | { |
87 | fprintf (stderr, | 87 | fprintf (stderr, _("Initialization of plugin mechanism failed: %s!\n"), |
88 | _("Initialization of plugin mechanism failed: %s!\n"), | ||
89 | lt_dlerror ()); | 88 | lt_dlerror ()); |
90 | return; | 89 | return; |
91 | } | 90 | } |
diff --git a/src/util/program.c b/src/util/program.c index cccb7db73..f1e95477d 100644 --- a/src/util/program.c +++ b/src/util/program.c | |||
@@ -124,9 +124,7 @@ cmd_sorter (__const void *a1, __const void *a2) | |||
124 | * @return GNUNET_SYSERR on error, GNUNET_OK on success | 124 | * @return GNUNET_SYSERR on error, GNUNET_OK on success |
125 | */ | 125 | */ |
126 | int | 126 | int |
127 | GNUNET_PROGRAM_run (int argc, | 127 | GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName, |
128 | char *const *argv, | ||
129 | const char *binaryName, | ||
130 | const char *binaryHelp, | 128 | const char *binaryHelp, |
131 | const struct GNUNET_GETOPT_CommandLineOption *options, | 129 | const struct GNUNET_GETOPT_CommandLineOption *options, |
132 | GNUNET_PROGRAM_Main task, void *task_cls) | 130 | GNUNET_PROGRAM_Main task, void *task_cls) |
@@ -217,13 +215,10 @@ GNUNET_PROGRAM_run (int argc, | |||
217 | lpfx = GNUNET_strdup (binaryName); | 215 | lpfx = GNUNET_strdup (binaryName); |
218 | if (NULL != (spc = strstr (lpfx, " "))) | 216 | if (NULL != (spc = strstr (lpfx, " "))) |
219 | *spc = '\0'; | 217 | *spc = '\0'; |
220 | if ((-1 == (ret = GNUNET_GETOPT_run (binaryName, | 218 | if ((-1 == |
221 | allopts, | 219 | (ret = |
222 | (unsigned int) argc, argv))) || | 220 | GNUNET_GETOPT_run (binaryName, allopts, (unsigned int) argc, argv))) || |
223 | ((GNUNET_OK != | 221 | ((GNUNET_OK != GNUNET_log_setup (lpfx, loglev, logfile)) || |
224 | GNUNET_log_setup (lpfx, | ||
225 | loglev, | ||
226 | logfile)) || | ||
227 | (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cc.cfgfile)))) | 222 | (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cc.cfgfile)))) |
228 | { | 223 | { |
229 | GNUNET_CONFIGURATION_destroy (cfg); | 224 | GNUNET_CONFIGURATION_destroy (cfg); |
diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c index 254decb76..85a485098 100644 --- a/src/util/pseudonym.c +++ b/src/util/pseudonym.c | |||
@@ -99,8 +99,7 @@ internal_notify (const GNUNET_HashCode * id, | |||
99 | */ | 99 | */ |
100 | int | 100 | int |
101 | GNUNET_PSEUDONYM_discovery_callback_register (const struct | 101 | GNUNET_PSEUDONYM_discovery_callback_register (const struct |
102 | GNUNET_CONFIGURATION_Handle | 102 | GNUNET_CONFIGURATION_Handle *cfg, |
103 | *cfg, | ||
104 | GNUNET_PSEUDONYM_Iterator | 103 | GNUNET_PSEUDONYM_Iterator |
105 | iterator, void *closure) | 104 | iterator, void *closure) |
106 | { | 105 | { |
@@ -155,16 +154,14 @@ GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator | |||
155 | * @return filename of the pseudonym (if psid != NULL) or directory with the data (if psid == NULL) | 154 | * @return filename of the pseudonym (if psid != NULL) or directory with the data (if psid == NULL) |
156 | */ | 155 | */ |
157 | static char * | 156 | static char * |
158 | get_data_filename (const struct GNUNET_CONFIGURATION_Handle | 157 | get_data_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, |
159 | *cfg, const char *prefix, const GNUNET_HashCode * psid) | 158 | const char *prefix, const GNUNET_HashCode * psid) |
160 | { | 159 | { |
161 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; | 160 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; |
162 | 161 | ||
163 | if (psid != NULL) | 162 | if (psid != NULL) |
164 | GNUNET_CRYPTO_hash_to_enc (psid, &enc); | 163 | GNUNET_CRYPTO_hash_to_enc (psid, &enc); |
165 | return GNUNET_DISK_get_home_filename (cfg, | 164 | return GNUNET_DISK_get_home_filename (cfg, GNUNET_CLIENT_SERVICE_NAME, prefix, |
166 | GNUNET_CLIENT_SERVICE_NAME, | ||
167 | prefix, | ||
168 | (psid == | 165 | (psid == |
169 | NULL) ? NULL : (const char *) &enc, | 166 | NULL) ? NULL : (const char *) &enc, |
170 | NULL); | 167 | NULL); |
@@ -228,8 +225,8 @@ write_pseudonym_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
228 | static int | 225 | static int |
229 | read_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | 226 | read_info (const struct GNUNET_CONFIGURATION_Handle *cfg, |
230 | const GNUNET_HashCode * nsid, | 227 | const GNUNET_HashCode * nsid, |
231 | struct GNUNET_CONTAINER_MetaData **meta, | 228 | struct GNUNET_CONTAINER_MetaData **meta, int32_t * ranking, |
232 | int32_t * ranking, char **ns_name) | 229 | char **ns_name) |
233 | { | 230 | { |
234 | char *fn; | 231 | char *fn; |
235 | char *emsg; | 232 | char *emsg; |
@@ -309,16 +306,17 @@ GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
309 | if (GNUNET_OK == read_info (cfg, nsid, &meta, rank, &name)) | 306 | if (GNUNET_OK == read_info (cfg, nsid, &meta, rank, &name)) |
310 | { | 307 | { |
311 | if ((meta != NULL) && (name == NULL)) | 308 | if ((meta != NULL) && (name == NULL)) |
312 | name = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 309 | name = |
313 | EXTRACTOR_METATYPE_TITLE, | 310 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
314 | EXTRACTOR_METATYPE_FILENAME, | 311 | EXTRACTOR_METATYPE_TITLE, |
315 | EXTRACTOR_METATYPE_DESCRIPTION, | 312 | EXTRACTOR_METATYPE_FILENAME, |
316 | EXTRACTOR_METATYPE_SUBJECT, | 313 | EXTRACTOR_METATYPE_DESCRIPTION, |
317 | EXTRACTOR_METATYPE_PUBLISHER, | 314 | EXTRACTOR_METATYPE_SUBJECT, |
318 | EXTRACTOR_METATYPE_AUTHOR_NAME, | 315 | EXTRACTOR_METATYPE_PUBLISHER, |
319 | EXTRACTOR_METATYPE_COMMENT, | 316 | EXTRACTOR_METATYPE_AUTHOR_NAME, |
320 | EXTRACTOR_METATYPE_SUMMARY, | 317 | EXTRACTOR_METATYPE_COMMENT, |
321 | -1); | 318 | EXTRACTOR_METATYPE_SUMMARY, |
319 | -1); | ||
322 | if (meta != NULL) | 320 | if (meta != NULL) |
323 | { | 321 | { |
324 | GNUNET_CONTAINER_meta_data_destroy (meta); | 322 | GNUNET_CONTAINER_meta_data_destroy (meta); |
@@ -334,15 +332,16 @@ GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
334 | len = 0; | 332 | len = 0; |
335 | if (0 == STAT (fn, &sbuf)) | 333 | if (0 == STAT (fn, &sbuf)) |
336 | GNUNET_DISK_file_size (fn, &len, GNUNET_YES); | 334 | GNUNET_DISK_file_size (fn, &len, GNUNET_YES); |
337 | fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_CREATE | 335 | fh = GNUNET_DISK_file_open (fn, |
338 | | GNUNET_DISK_OPEN_READWRITE, | 336 | GNUNET_DISK_OPEN_CREATE | |
337 | GNUNET_DISK_OPEN_READWRITE, | ||
339 | GNUNET_DISK_PERM_USER_READ | | 338 | GNUNET_DISK_PERM_USER_READ | |
340 | GNUNET_DISK_PERM_USER_WRITE); | 339 | GNUNET_DISK_PERM_USER_WRITE); |
341 | i = 0; | 340 | i = 0; |
342 | idx = -1; | 341 | idx = -1; |
343 | while ((len >= sizeof (GNUNET_HashCode)) && | 342 | while ((len >= sizeof (GNUNET_HashCode)) && |
344 | (sizeof (GNUNET_HashCode) | 343 | (sizeof (GNUNET_HashCode) == |
345 | == GNUNET_DISK_file_read (fh, &nh, sizeof (GNUNET_HashCode)))) | 344 | GNUNET_DISK_file_read (fh, &nh, sizeof (GNUNET_HashCode)))) |
346 | { | 345 | { |
347 | if (0 == memcmp (&nh, nsid, sizeof (GNUNET_HashCode))) | 346 | if (0 == memcmp (&nh, nsid, sizeof (GNUNET_HashCode))) |
348 | { | 347 | { |
@@ -407,8 +406,9 @@ GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
407 | GNUNET_free (fn); | 406 | GNUNET_free (fn); |
408 | return GNUNET_SYSERR; | 407 | return GNUNET_SYSERR; |
409 | } | 408 | } |
410 | fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_CREATE | 409 | fh = GNUNET_DISK_file_open (fn, |
411 | | GNUNET_DISK_OPEN_READWRITE, | 410 | GNUNET_DISK_OPEN_CREATE | |
411 | GNUNET_DISK_OPEN_READWRITE, | ||
412 | GNUNET_DISK_PERM_USER_READ | | 412 | GNUNET_DISK_PERM_USER_READ | |
413 | GNUNET_DISK_PERM_USER_WRITE); | 413 | GNUNET_DISK_PERM_USER_WRITE); |
414 | GNUNET_free (fn); | 414 | GNUNET_free (fn); |
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index ef48faf59..3aa8bff9c 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -191,17 +191,16 @@ check_config (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
191 | v6.sin6_len = sizeof (v6); | 191 | v6.sin6_len = sizeof (v6); |
192 | #endif | 192 | #endif |
193 | if (GNUNET_OK != | 193 | if (GNUNET_OK != |
194 | GNUNET_CONFIGURATION_get_value_string (cfg, | 194 | GNUNET_CONFIGURATION_get_value_string (cfg, "resolver", "HOSTNAME", |
195 | "resolver", "HOSTNAME", &hostname)) | 195 | &hostname)) |
196 | { | 196 | { |
197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
198 | _("Must specify `%s' for `%s' in configuration!\n"), | 198 | _("Must specify `%s' for `%s' in configuration!\n"), "HOSTNAME", |
199 | "HOSTNAME", "resolver"); | 199 | "resolver"); |
200 | GNUNET_assert (0); | 200 | GNUNET_assert (0); |
201 | } | 201 | } |
202 | if ((1 != inet_pton (AF_INET, | 202 | if ((1 != inet_pton (AF_INET, hostname, &v4)) || |
203 | hostname, | 203 | (1 != inet_pton (AF_INET6, hostname, &v6))) |
204 | &v4)) || (1 != inet_pton (AF_INET6, hostname, &v6))) | ||
205 | { | 204 | { |
206 | GNUNET_free (hostname); | 205 | GNUNET_free (hostname); |
207 | return; | 206 | return; |
@@ -288,9 +287,8 @@ no_resolve (const struct sockaddr *sa, socklen_t salen) | |||
288 | if (salen != sizeof (struct sockaddr_in)) | 287 | if (salen != sizeof (struct sockaddr_in)) |
289 | return NULL; | 288 | return NULL; |
290 | if (NULL == | 289 | if (NULL == |
291 | inet_ntop (AF_INET, | 290 | inet_ntop (AF_INET, &((struct sockaddr_in *) sa)->sin_addr, inet4, |
292 | &((struct sockaddr_in *) sa)->sin_addr, | 291 | INET_ADDRSTRLEN)) |
293 | inet4, INET_ADDRSTRLEN)) | ||
294 | { | 292 | { |
295 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); | 293 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); |
296 | return NULL; | 294 | return NULL; |
@@ -301,9 +299,8 @@ no_resolve (const struct sockaddr *sa, socklen_t salen) | |||
301 | if (salen != sizeof (struct sockaddr_in6)) | 299 | if (salen != sizeof (struct sockaddr_in6)) |
302 | return NULL; | 300 | return NULL; |
303 | if (NULL == | 301 | if (NULL == |
304 | inet_ntop (AF_INET6, | 302 | inet_ntop (AF_INET6, &((struct sockaddr_in6 *) sa)->sin6_addr, inet6, |
305 | &((struct sockaddr_in6 *) sa)->sin6_addr, | 303 | INET6_ADDRSTRLEN)) |
306 | inet6, INET6_ADDRSTRLEN)) | ||
307 | { | 304 | { |
308 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); | 305 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); |
309 | return NULL; | 306 | return NULL; |
@@ -427,15 +424,13 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
427 | } | 424 | } |
428 | #if DEBUG_RESOLVER | 425 | #if DEBUG_RESOLVER |
429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
430 | _("Resolver returns `%s' for IP `%s'.\n"), | 427 | _("Resolver returns `%s' for IP `%s'.\n"), hostname, |
431 | hostname, GNUNET_a2s ((const void *) &rh[1], rh->data_len)); | 428 | GNUNET_a2s ((const void *) &rh[1], rh->data_len)); |
432 | #endif | 429 | #endif |
433 | if (rh->was_transmitted != GNUNET_SYSERR) | 430 | if (rh->was_transmitted != GNUNET_SYSERR) |
434 | rh->name_callback (rh->cls, hostname); | 431 | rh->name_callback (rh->cls, hostname); |
435 | rh->received_response = GNUNET_YES; | 432 | rh->received_response = GNUNET_YES; |
436 | GNUNET_CLIENT_receive (client, | 433 | GNUNET_CLIENT_receive (client, &handle_response, rh, |
437 | &handle_response, | ||
438 | rh, | ||
439 | GNUNET_TIME_absolute_get_remaining (rh->timeout)); | 434 | GNUNET_TIME_absolute_get_remaining (rh->timeout)); |
440 | } | 435 | } |
441 | /* return lookup results to caller */ | 436 | /* return lookup results to caller */ |
@@ -459,16 +454,13 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
459 | { | 454 | { |
460 | char *ips = no_resolve (sa, salen); | 455 | char *ips = no_resolve (sa, salen); |
461 | 456 | ||
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s' for `%s'.\n", |
463 | "Resolver returns `%s' for `%s'.\n", | ||
464 | ips, (const char *) &rh[1]); | 458 | ips, (const char *) &rh[1]); |
465 | GNUNET_free (ips); | 459 | GNUNET_free (ips); |
466 | } | 460 | } |
467 | #endif | 461 | #endif |
468 | rh->addr_callback (rh->cls, sa, salen); | 462 | rh->addr_callback (rh->cls, sa, salen); |
469 | GNUNET_CLIENT_receive (client, | 463 | GNUNET_CLIENT_receive (client, &handle_response, rh, |
470 | &handle_response, | ||
471 | rh, | ||
472 | GNUNET_TIME_absolute_get_remaining (rh->timeout)); | 464 | GNUNET_TIME_absolute_get_remaining (rh->timeout)); |
473 | } | 465 | } |
474 | } | 466 | } |
@@ -610,8 +602,9 @@ process_requests () | |||
610 | { | 602 | { |
611 | /* nothing to do, release socket really soon if there is nothing | 603 | /* nothing to do, release socket really soon if there is nothing |
612 | * else happening... */ | 604 | * else happening... */ |
613 | s_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 605 | s_task = |
614 | &shutdown_task, NULL); | 606 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, |
607 | &shutdown_task, NULL); | ||
615 | return; | 608 | return; |
616 | } | 609 | } |
617 | if (GNUNET_YES == rh->was_transmitted) | 610 | if (GNUNET_YES == rh->was_transmitted) |
@@ -628,8 +621,7 @@ process_requests () | |||
628 | "Transmitting DNS resolution request to DNS service\n"); | 621 | "Transmitting DNS resolution request to DNS service\n"); |
629 | #endif | 622 | #endif |
630 | if (GNUNET_OK != | 623 | if (GNUNET_OK != |
631 | GNUNET_CLIENT_transmit_and_get_response (client, | 624 | GNUNET_CLIENT_transmit_and_get_response (client, &msg->header, |
632 | &msg->header, | ||
633 | GNUNET_TIME_absolute_get_remaining | 625 | GNUNET_TIME_absolute_get_remaining |
634 | (rh->timeout), GNUNET_YES, | 626 | (rh->timeout), GNUNET_YES, |
635 | &handle_response, rh)) | 627 | &handle_response, rh)) |
@@ -726,8 +718,7 @@ reconnect () | |||
726 | * @return handle that can be used to cancel the request, NULL on error | 718 | * @return handle that can be used to cancel the request, NULL on error |
727 | */ | 719 | */ |
728 | struct GNUNET_RESOLVER_RequestHandle * | 720 | struct GNUNET_RESOLVER_RequestHandle * |
729 | GNUNET_RESOLVER_ip_get (const char *hostname, | 721 | GNUNET_RESOLVER_ip_get (const char *hostname, int domain, |
730 | int domain, | ||
731 | struct GNUNET_TIME_Relative timeout, | 722 | struct GNUNET_TIME_Relative timeout, |
732 | GNUNET_RESOLVER_AddressCallback callback, | 723 | GNUNET_RESOLVER_AddressCallback callback, |
733 | void *callback_cls) | 724 | void *callback_cls) |
@@ -754,13 +745,9 @@ GNUNET_RESOLVER_ip_get (const char *hostname, | |||
754 | rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 745 | rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
755 | rh->direction = GNUNET_NO; | 746 | rh->direction = GNUNET_NO; |
756 | /* first, check if this is a numeric address */ | 747 | /* first, check if this is a numeric address */ |
757 | if (((1 == inet_pton (AF_INET, | 748 | if (((1 == inet_pton (AF_INET, hostname, &v4)) && |
758 | hostname, | ||
759 | &v4)) && | ||
760 | ((domain == AF_INET) || (domain == AF_UNSPEC))) || | 749 | ((domain == AF_INET) || (domain == AF_UNSPEC))) || |
761 | ((1 == inet_pton (AF_INET6, | 750 | ((1 == inet_pton (AF_INET6, hostname, &v6)) && |
762 | hostname, | ||
763 | &v6)) && | ||
764 | ((domain == AF_INET6) || (domain == AF_UNSPEC)))) | 751 | ((domain == AF_INET6) || (domain == AF_UNSPEC)))) |
765 | { | 752 | { |
766 | rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution, rh); | 753 | rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution, rh); |
@@ -826,8 +813,7 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
826 | * @return handle that can be used to cancel the request | 813 | * @return handle that can be used to cancel the request |
827 | */ | 814 | */ |
828 | struct GNUNET_RESOLVER_RequestHandle * | 815 | struct GNUNET_RESOLVER_RequestHandle * |
829 | GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, | 816 | GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, socklen_t salen, |
830 | socklen_t salen, | ||
831 | int do_resolve, | 817 | int do_resolve, |
832 | struct GNUNET_TIME_Relative timeout, | 818 | struct GNUNET_TIME_Relative timeout, |
833 | GNUNET_RESOLVER_HostnameCallback callback, | 819 | GNUNET_RESOLVER_HostnameCallback callback, |
@@ -881,19 +867,19 @@ GNUNET_RESOLVER_local_fqdn_get () | |||
881 | 867 | ||
882 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) | 868 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) |
883 | { | 869 | { |
884 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | | 870 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
885 | GNUNET_ERROR_TYPE_BULK, "gethostname"); | 871 | "gethostname"); |
886 | return NULL; | 872 | return NULL; |
887 | } | 873 | } |
888 | #if DEBUG_RESOLVER | 874 | #if DEBUG_RESOLVER |
889 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 875 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our FQDN `%s'\n"), |
890 | _("Resolving our FQDN `%s'\n"), hostname); | 876 | hostname); |
891 | #endif | 877 | #endif |
892 | host = gethostbyname (hostname); | 878 | host = gethostbyname (hostname); |
893 | if (NULL == host) | 879 | if (NULL == host) |
894 | { | 880 | { |
895 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 881 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not resolve our FQDN : %s\n"), |
896 | _("Could not resolve our FQDN : %s\n"), hstrerror (h_errno)); | 882 | hstrerror (h_errno)); |
897 | return NULL; | 883 | return NULL; |
898 | } | 884 | } |
899 | return GNUNET_strdup (host->h_name); | 885 | return GNUNET_strdup (host->h_name); |
@@ -919,13 +905,13 @@ GNUNET_RESOLVER_hostname_resolve (int domain, | |||
919 | 905 | ||
920 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) | 906 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) |
921 | { | 907 | { |
922 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | | 908 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
923 | GNUNET_ERROR_TYPE_BULK, "gethostname"); | 909 | "gethostname"); |
924 | return NULL; | 910 | return NULL; |
925 | } | 911 | } |
926 | #if DEBUG_RESOLVER | 912 | #if DEBUG_RESOLVER |
927 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 913 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our hostname `%s'\n"), |
928 | _("Resolving our hostname `%s'\n"), hostname); | 914 | hostname); |
929 | #endif | 915 | #endif |
930 | return GNUNET_RESOLVER_ip_get (hostname, domain, timeout, callback, cls); | 916 | return GNUNET_RESOLVER_ip_get (hostname, domain, timeout, callback, cls); |
931 | } | 917 | } |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 9412457f6..844531b37 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -349,8 +349,7 @@ is_pending (GNUNET_SCHEDULER_TaskIdentifier id) | |||
349 | * @param timeout next timeout (updated) | 349 | * @param timeout next timeout (updated) |
350 | */ | 350 | */ |
351 | static void | 351 | static void |
352 | update_sets (struct GNUNET_NETWORK_FDSet *rs, | 352 | update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws, |
353 | struct GNUNET_NETWORK_FDSet *ws, | ||
354 | struct GNUNET_TIME_Relative *timeout) | 353 | struct GNUNET_TIME_Relative *timeout) |
355 | { | 354 | { |
356 | struct Task *pos; | 355 | struct Task *pos; |
@@ -434,8 +433,7 @@ set_overlaps (const struct GNUNET_NETWORK_FDSet *ready, | |||
434 | * @return GNUNET_YES if we can run it, GNUNET_NO if not. | 433 | * @return GNUNET_YES if we can run it, GNUNET_NO if not. |
435 | */ | 434 | */ |
436 | static int | 435 | static int |
437 | is_ready (struct Task *task, | 436 | is_ready (struct Task *task, struct GNUNET_TIME_Absolute now, |
438 | struct GNUNET_TIME_Absolute now, | ||
439 | const struct GNUNET_NETWORK_FDSet *rs, | 437 | const struct GNUNET_NETWORK_FDSet *rs, |
440 | const struct GNUNET_NETWORK_FDSet *ws) | 438 | const struct GNUNET_NETWORK_FDSet *ws) |
441 | { | 439 | { |
@@ -525,8 +523,8 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs, | |||
525 | { | 523 | { |
526 | #if DEBUG_TASKS | 524 | #if DEBUG_TASKS |
527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
528 | "Checking readiness of task: %llu / %p\n", | 526 | "Checking readiness of task: %llu / %p\n", pos->id, |
529 | pos->id, pos->callback_cls); | 527 | pos->callback_cls); |
530 | #endif | 528 | #endif |
531 | next = pos->next; | 529 | next = pos->next; |
532 | if (GNUNET_YES == is_ready (pos, now, rs, ws)) | 530 | if (GNUNET_YES == is_ready (pos, now, rs, ws)) |
@@ -657,11 +655,10 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) | |||
657 | DELAY_THRESHOLD.rel_value) | 655 | DELAY_THRESHOLD.rel_value) |
658 | { | 656 | { |
659 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 657 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
660 | "Task %llu took %llums to be scheduled\n", | 658 | "Task %llu took %llums to be scheduled\n", pos->id, |
661 | pos->id, | 659 | (unsigned long long) GNUNET_TIME_absolute_get_duration (pos-> |
662 | (unsigned long long) | 660 | start_time). |
663 | GNUNET_TIME_absolute_get_duration | 661 | rel_value); |
664 | (pos->start_time).rel_value); | ||
665 | } | 662 | } |
666 | #endif | 663 | #endif |
667 | tc.reason = pos->reason; | 664 | tc.reason = pos->reason; |
@@ -678,17 +675,16 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) | |||
678 | (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd))) | 675 | (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd))) |
679 | abort (); // added to ready in previous select loop! | 676 | abort (); // added to ready in previous select loop! |
680 | #if DEBUG_TASKS | 677 | #if DEBUG_TASKS |
681 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 678 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running task: %llu / %p\n", pos->id, |
682 | "Running task: %llu / %p\n", pos->id, pos->callback_cls); | 679 | pos->callback_cls); |
683 | #endif | 680 | #endif |
684 | pos->callback (pos->callback_cls, &tc); | 681 | pos->callback (pos->callback_cls, &tc); |
685 | #if EXECINFO | 682 | #if EXECINFO |
686 | int i; | 683 | int i; |
687 | 684 | ||
688 | for (i = 0; i < pos->num_backtrace_strings; i++) | 685 | for (i = 0; i < pos->num_backtrace_strings; i++) |
689 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 686 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Task %llu trace %d: %s\n", pos->id, |
690 | "Task %llu trace %d: %s\n", | 687 | i, pos->backtrace_strings[i]); |
691 | pos->id, i, pos->backtrace_strings[i]); | ||
692 | #endif | 688 | #endif |
693 | active_task = NULL; | 689 | active_task = NULL; |
694 | destroy_task (pos); | 690 | destroy_task (pos); |
@@ -809,8 +805,8 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) | |||
809 | #endif | 805 | #endif |
810 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; | 806 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; |
811 | current_lifeness = GNUNET_YES; | 807 | current_lifeness = GNUNET_YES; |
812 | GNUNET_SCHEDULER_add_continuation (task, | 808 | GNUNET_SCHEDULER_add_continuation (task, task_cls, |
813 | task_cls, GNUNET_SCHEDULER_REASON_STARTUP); | 809 | GNUNET_SCHEDULER_REASON_STARTUP); |
814 | #if ENABLE_WINDOWS_WORKAROUNDS | 810 | #if ENABLE_WINDOWS_WORKAROUNDS |
815 | active_task = (void *) (long) -1; /* force passing of sanity check */ | 811 | active_task = (void *) (long) -1; /* force passing of sanity check */ |
816 | GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, | 812 | GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, |
@@ -1031,8 +1027,8 @@ GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task) | |||
1031 | } | 1027 | } |
1032 | ret = t->callback_cls; | 1028 | ret = t->callback_cls; |
1033 | #if DEBUG_TASKS | 1029 | #if DEBUG_TASKS |
1034 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1030 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Canceling task: %llu / %p\n", task, |
1035 | "Canceling task: %llu / %p\n", task, t->callback_cls); | 1031 | t->callback_cls); |
1036 | #endif | 1032 | #endif |
1037 | destroy_task (t); | 1033 | destroy_task (t); |
1038 | return ret; | 1034 | return ret; |
@@ -1049,8 +1045,7 @@ GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task) | |||
1049 | * @param reason reason for task invocation | 1045 | * @param reason reason for task invocation |
1050 | */ | 1046 | */ |
1051 | void | 1047 | void |
1052 | GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, | 1048 | GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, void *task_cls, |
1053 | void *task_cls, | ||
1054 | enum GNUNET_SCHEDULER_Reason reason) | 1049 | enum GNUNET_SCHEDULER_Reason reason) |
1055 | { | 1050 | { |
1056 | struct Task *t; | 1051 | struct Task *t; |
@@ -1080,8 +1075,8 @@ GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, | |||
1080 | t->priority = current_priority; | 1075 | t->priority = current_priority; |
1081 | t->lifeness = current_lifeness; | 1076 | t->lifeness = current_lifeness; |
1082 | #if DEBUG_TASKS | 1077 | #if DEBUG_TASKS |
1083 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding continuation task: %llu / %p\n", |
1084 | "Adding continuation task: %llu / %p\n", t->id, t->callback_cls); | 1079 | t->id, t->callback_cls); |
1085 | #endif | 1080 | #endif |
1086 | queue_ready_task (t); | 1081 | queue_ready_task (t); |
1087 | } | 1082 | } |
@@ -1109,8 +1104,7 @@ GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, | |||
1109 | GNUNET_SCHEDULER_Task task, void *task_cls) | 1104 | GNUNET_SCHEDULER_Task task, void *task_cls) |
1110 | { | 1105 | { |
1111 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, | 1106 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, |
1112 | prerequisite_task, | 1107 | prerequisite_task, GNUNET_TIME_UNIT_ZERO, |
1113 | GNUNET_TIME_UNIT_ZERO, | ||
1114 | NULL, NULL, task, task_cls); | 1108 | NULL, NULL, task, task_cls); |
1115 | } | 1109 | } |
1116 | 1110 | ||
@@ -1128,10 +1122,9 @@ GNUNET_SCHEDULER_TaskIdentifier | |||
1128 | GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, | 1122 | GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, |
1129 | GNUNET_SCHEDULER_Task task, void *task_cls) | 1123 | GNUNET_SCHEDULER_Task task, void *task_cls) |
1130 | { | 1124 | { |
1131 | return GNUNET_SCHEDULER_add_select (prio, | 1125 | return GNUNET_SCHEDULER_add_select (prio, GNUNET_SCHEDULER_NO_TASK, |
1132 | GNUNET_SCHEDULER_NO_TASK, | 1126 | GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, |
1133 | GNUNET_TIME_UNIT_ZERO, | 1127 | task_cls); |
1134 | NULL, NULL, task, task_cls); | ||
1135 | } | 1128 | } |
1136 | 1129 | ||
1137 | 1130 | ||
@@ -1212,23 +1205,23 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, | |||
1212 | pending_timeout_last = t; | 1205 | pending_timeout_last = t; |
1213 | 1206 | ||
1214 | #if DEBUG_TASKS | 1207 | #if DEBUG_TASKS |
1215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, |
1216 | "Adding task: %llu / %p\n", t->id, t->callback_cls); | 1209 | t->callback_cls); |
1217 | #endif | 1210 | #endif |
1218 | #if EXECINFO | 1211 | #if EXECINFO |
1219 | int i; | 1212 | int i; |
1220 | 1213 | ||
1221 | for (i = 0; i < t->num_backtrace_strings; i++) | 1214 | for (i = 0; i < t->num_backtrace_strings; i++) |
1222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, |
1223 | "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); | 1216 | t->backtrace_strings[i]); |
1224 | #endif | 1217 | #endif |
1225 | return t->id; | 1218 | return t->id; |
1226 | 1219 | ||
1227 | #else | 1220 | #else |
1228 | /* unoptimized version */ | 1221 | /* unoptimized version */ |
1229 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, | 1222 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, |
1230 | GNUNET_SCHEDULER_NO_TASK, delay, | 1223 | GNUNET_SCHEDULER_NO_TASK, delay, NULL, |
1231 | NULL, NULL, task, task_cls); | 1224 | NULL, task, task_cls); |
1232 | #endif | 1225 | #endif |
1233 | } | 1226 | } |
1234 | 1227 | ||
@@ -1248,8 +1241,8 @@ GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task, void *task_cls) | |||
1248 | { | 1241 | { |
1249 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, | 1242 | return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, |
1250 | GNUNET_SCHEDULER_NO_TASK, | 1243 | GNUNET_SCHEDULER_NO_TASK, |
1251 | GNUNET_TIME_UNIT_ZERO, | 1244 | GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, |
1252 | NULL, NULL, task, task_cls); | 1245 | task_cls); |
1253 | } | 1246 | } |
1254 | 1247 | ||
1255 | 1248 | ||
@@ -1274,10 +1267,11 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, | |||
1274 | { | 1267 | { |
1275 | GNUNET_SCHEDULER_TaskIdentifier ret; | 1268 | GNUNET_SCHEDULER_TaskIdentifier ret; |
1276 | 1269 | ||
1277 | ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, | 1270 | ret = |
1278 | GNUNET_SCHEDULER_NO_TASK, | 1271 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, |
1279 | GNUNET_TIME_UNIT_ZERO, | 1272 | GNUNET_SCHEDULER_NO_TASK, |
1280 | NULL, NULL, task, task_cls); | 1273 | GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, |
1274 | task_cls); | ||
1281 | GNUNET_assert (pending->id == ret); | 1275 | GNUNET_assert (pending->id == ret); |
1282 | pending->lifeness = lifeness; | 1276 | pending->lifeness = lifeness; |
1283 | return ret; | 1277 | return ret; |
@@ -1314,8 +1308,8 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, | |||
1314 | */ | 1308 | */ |
1315 | #ifndef MINGW | 1309 | #ifndef MINGW |
1316 | GNUNET_SCHEDULER_TaskIdentifier | 1310 | GNUNET_SCHEDULER_TaskIdentifier |
1317 | add_without_sets (struct GNUNET_TIME_Relative delay, | 1311 | add_without_sets (struct GNUNET_TIME_Relative delay, int rfd, int wfd, |
1318 | int rfd, int wfd, GNUNET_SCHEDULER_Task task, void *task_cls) | 1312 | GNUNET_SCHEDULER_Task task, void *task_cls) |
1319 | { | 1313 | { |
1320 | struct Task *t; | 1314 | struct Task *t; |
1321 | 1315 | ||
@@ -1346,8 +1340,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1346 | int i; | 1340 | int i; |
1347 | 1341 | ||
1348 | for (i = 0; i < t->num_backtrace_strings; i++) | 1342 | for (i = 0; i < t->num_backtrace_strings; i++) |
1349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trace: %s\n", |
1350 | "Trace: %s\n", t->backtrace_strings[i]); | 1344 | t->backtrace_strings[i]); |
1351 | #endif | 1345 | #endif |
1352 | GNUNET_assert (0); | 1346 | GNUNET_assert (0); |
1353 | } | 1347 | } |
@@ -1364,8 +1358,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1364 | int i; | 1358 | int i; |
1365 | 1359 | ||
1366 | for (i = 0; i < t->num_backtrace_strings; i++) | 1360 | for (i = 0; i < t->num_backtrace_strings; i++) |
1367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trace: %s\n", |
1368 | "Trace: %s\n", t->backtrace_strings[i]); | 1362 | t->backtrace_strings[i]); |
1369 | #endif | 1363 | #endif |
1370 | GNUNET_assert (0); | 1364 | GNUNET_assert (0); |
1371 | } | 1365 | } |
@@ -1386,15 +1380,15 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1386 | pending = t; | 1380 | pending = t; |
1387 | max_priority_added = GNUNET_MAX (max_priority_added, t->priority); | 1381 | max_priority_added = GNUNET_MAX (max_priority_added, t->priority); |
1388 | #if DEBUG_TASKS | 1382 | #if DEBUG_TASKS |
1389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, |
1390 | "Adding task: %llu / %p\n", t->id, t->callback_cls); | 1384 | t->callback_cls); |
1391 | #endif | 1385 | #endif |
1392 | #if EXECINFO | 1386 | #if EXECINFO |
1393 | int i; | 1387 | int i; |
1394 | 1388 | ||
1395 | for (i = 0; i < t->num_backtrace_strings; i++) | 1389 | for (i = 0; i < t->num_backtrace_strings; i++) |
1396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, |
1397 | "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); | 1391 | t->backtrace_strings[i]); |
1398 | #endif | 1392 | #endif |
1399 | return t->id; | 1393 | return t->id; |
1400 | } | 1394 | } |
@@ -1430,14 +1424,15 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, | |||
1430 | GNUNET_assert (rfd != NULL); | 1424 | GNUNET_assert (rfd != NULL); |
1431 | rs = GNUNET_NETWORK_fdset_create (); | 1425 | rs = GNUNET_NETWORK_fdset_create (); |
1432 | GNUNET_NETWORK_fdset_set (rs, rfd); | 1426 | GNUNET_NETWORK_fdset_set (rs, rfd); |
1433 | ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), | 1427 | ret = |
1434 | GNUNET_SCHEDULER_NO_TASK, delay, | 1428 | GNUNET_SCHEDULER_add_select (check_priority (current_priority), |
1435 | rs, NULL, task, task_cls); | 1429 | GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, |
1430 | task, task_cls); | ||
1436 | GNUNET_NETWORK_fdset_destroy (rs); | 1431 | GNUNET_NETWORK_fdset_destroy (rs); |
1437 | return ret; | 1432 | return ret; |
1438 | #else | 1433 | #else |
1439 | return add_without_sets (delay, | 1434 | return add_without_sets (delay, GNUNET_NETWORK_get_fd (rfd), -1, task, |
1440 | GNUNET_NETWORK_get_fd (rfd), -1, task, task_cls); | 1435 | task_cls); |
1441 | #endif | 1436 | #endif |
1442 | } | 1437 | } |
1443 | 1438 | ||
@@ -1470,15 +1465,16 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, | |||
1470 | GNUNET_assert (wfd != NULL); | 1465 | GNUNET_assert (wfd != NULL); |
1471 | ws = GNUNET_NETWORK_fdset_create (); | 1466 | ws = GNUNET_NETWORK_fdset_create (); |
1472 | GNUNET_NETWORK_fdset_set (ws, wfd); | 1467 | GNUNET_NETWORK_fdset_set (ws, wfd); |
1473 | ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), | 1468 | ret = |
1474 | GNUNET_SCHEDULER_NO_TASK, delay, | 1469 | GNUNET_SCHEDULER_add_select (check_priority (current_priority), |
1475 | NULL, ws, task, task_cls); | 1470 | GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, |
1471 | task, task_cls); | ||
1476 | GNUNET_NETWORK_fdset_destroy (ws); | 1472 | GNUNET_NETWORK_fdset_destroy (ws); |
1477 | return ret; | 1473 | return ret; |
1478 | #else | 1474 | #else |
1479 | GNUNET_assert (GNUNET_NETWORK_get_fd (wfd) >= 0); | 1475 | GNUNET_assert (GNUNET_NETWORK_get_fd (wfd) >= 0); |
1480 | return add_without_sets (delay, | 1476 | return add_without_sets (delay, -1, GNUNET_NETWORK_get_fd (wfd), task, |
1481 | -1, GNUNET_NETWORK_get_fd (wfd), task, task_cls); | 1477 | task_cls); |
1482 | #endif | 1478 | #endif |
1483 | } | 1479 | } |
1484 | 1480 | ||
@@ -1511,9 +1507,10 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, | |||
1511 | GNUNET_assert (rfd != NULL); | 1507 | GNUNET_assert (rfd != NULL); |
1512 | rs = GNUNET_NETWORK_fdset_create (); | 1508 | rs = GNUNET_NETWORK_fdset_create (); |
1513 | GNUNET_NETWORK_fdset_handle_set (rs, rfd); | 1509 | GNUNET_NETWORK_fdset_handle_set (rs, rfd); |
1514 | ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), | 1510 | ret = |
1515 | GNUNET_SCHEDULER_NO_TASK, delay, | 1511 | GNUNET_SCHEDULER_add_select (check_priority (current_priority), |
1516 | rs, NULL, task, task_cls); | 1512 | GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, |
1513 | task, task_cls); | ||
1517 | GNUNET_NETWORK_fdset_destroy (rs); | 1514 | GNUNET_NETWORK_fdset_destroy (rs); |
1518 | return ret; | 1515 | return ret; |
1519 | #else | 1516 | #else |
@@ -1554,9 +1551,10 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
1554 | GNUNET_assert (wfd != NULL); | 1551 | GNUNET_assert (wfd != NULL); |
1555 | ws = GNUNET_NETWORK_fdset_create (); | 1552 | ws = GNUNET_NETWORK_fdset_create (); |
1556 | GNUNET_NETWORK_fdset_handle_set (ws, wfd); | 1553 | GNUNET_NETWORK_fdset_handle_set (ws, wfd); |
1557 | ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), | 1554 | ret = |
1558 | GNUNET_SCHEDULER_NO_TASK, | 1555 | GNUNET_SCHEDULER_add_select (check_priority (current_priority), |
1559 | delay, NULL, ws, task, task_cls); | 1556 | GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, |
1557 | task, task_cls); | ||
1560 | GNUNET_NETWORK_fdset_destroy (ws); | 1558 | GNUNET_NETWORK_fdset_destroy (ws); |
1561 | return ret; | 1559 | return ret; |
1562 | #else | 1560 | #else |
@@ -1605,8 +1603,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
1605 | */ | 1603 | */ |
1606 | GNUNET_SCHEDULER_TaskIdentifier | 1604 | GNUNET_SCHEDULER_TaskIdentifier |
1607 | GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | 1605 | GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, |
1608 | GNUNET_SCHEDULER_TaskIdentifier | 1606 | GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, |
1609 | prerequisite_task, | ||
1610 | struct GNUNET_TIME_Relative delay, | 1607 | struct GNUNET_TIME_Relative delay, |
1611 | const struct GNUNET_NETWORK_FDSet *rs, | 1608 | const struct GNUNET_NETWORK_FDSet *rs, |
1612 | const struct GNUNET_NETWORK_FDSet *ws, | 1609 | const struct GNUNET_NETWORK_FDSet *ws, |
@@ -1648,22 +1645,22 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1648 | t->timeout = GNUNET_TIME_relative_to_absolute (delay); | 1645 | t->timeout = GNUNET_TIME_relative_to_absolute (delay); |
1649 | t->priority = | 1646 | t->priority = |
1650 | check_priority ((prio == | 1647 | check_priority ((prio == |
1651 | GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority | 1648 | GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority : |
1652 | : prio); | 1649 | prio); |
1653 | t->lifeness = current_lifeness; | 1650 | t->lifeness = current_lifeness; |
1654 | t->next = pending; | 1651 | t->next = pending; |
1655 | pending = t; | 1652 | pending = t; |
1656 | max_priority_added = GNUNET_MAX (max_priority_added, t->priority); | 1653 | max_priority_added = GNUNET_MAX (max_priority_added, t->priority); |
1657 | #if DEBUG_TASKS | 1654 | #if DEBUG_TASKS |
1658 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, |
1659 | "Adding task: %llu / %p\n", t->id, t->callback_cls); | 1656 | t->callback_cls); |
1660 | #endif | 1657 | #endif |
1661 | #if EXECINFO | 1658 | #if EXECINFO |
1662 | int i; | 1659 | int i; |
1663 | 1660 | ||
1664 | for (i = 0; i < t->num_backtrace_strings; i++) | 1661 | for (i = 0; i < t->num_backtrace_strings; i++) |
1665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1662 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, |
1666 | "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); | 1663 | t->backtrace_strings[i]); |
1667 | #endif | 1664 | #endif |
1668 | return t->id; | 1665 | return t->id; |
1669 | } | 1666 | } |
diff --git a/src/util/server.c b/src/util/server.c index 935cf04f8..504391bc7 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -381,9 +381,7 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) | |||
381 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); | 381 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); |
382 | if (port != 0) | 382 | if (port != 0) |
383 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 383 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
384 | _ | 384 | _("`%s' failed for port %d (%s).\n"), "bind", port, |
385 | ("`%s' failed for port %d (%s).\n"), | ||
386 | "bind", port, | ||
387 | (serverAddr->sa_family == AF_INET) ? "IPv4" : "IPv6"); | 385 | (serverAddr->sa_family == AF_INET) ? "IPv4" : "IPv6"); |
388 | eno = 0; | 386 | eno = 0; |
389 | } | 387 | } |
@@ -391,15 +389,12 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) | |||
391 | { | 389 | { |
392 | if (port != 0) | 390 | if (port != 0) |
393 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 391 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
394 | _ | 392 | _("`%s' failed for port %d (%s): address already in use\n"), |
395 | ("`%s' failed for port %d (%s): address already in use\n"), | ||
396 | "bind", port, | 393 | "bind", port, |
397 | (serverAddr->sa_family == AF_INET) ? "IPv4" : "IPv6"); | 394 | (serverAddr->sa_family == AF_INET) ? "IPv4" : "IPv6"); |
398 | else if (serverAddr->sa_family == AF_UNIX) | 395 | else if (serverAddr->sa_family == AF_UNIX) |
399 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
400 | _ | 397 | _("`%s' failed for `%s': address already in use\n"), "bind", |
401 | ("`%s' failed for `%s': address already in use\n"), | ||
402 | "bind", | ||
403 | ((const struct sockaddr_un *) serverAddr)->sun_path); | 398 | ((const struct sockaddr_un *) serverAddr)->sun_path); |
404 | 399 | ||
405 | } | 400 | } |
@@ -483,12 +478,11 @@ GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, | |||
483 | * (typically, "port" already in use) | 478 | * (typically, "port" already in use) |
484 | */ | 479 | */ |
485 | struct GNUNET_SERVER_Handle * | 480 | struct GNUNET_SERVER_Handle * |
486 | GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, | 481 | GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cls, |
487 | void *access_cls, | ||
488 | struct sockaddr *const *serverAddr, | 482 | struct sockaddr *const *serverAddr, |
489 | const socklen_t * socklen, | 483 | const socklen_t * socklen, |
490 | struct GNUNET_TIME_Relative | 484 | struct GNUNET_TIME_Relative idle_timeout, |
491 | idle_timeout, int require_found) | 485 | int require_found) |
492 | { | 486 | { |
493 | struct GNUNET_NETWORK_Handle **lsocks; | 487 | struct GNUNET_NETWORK_Handle **lsocks; |
494 | unsigned int i; | 488 | unsigned int i; |
@@ -521,8 +515,7 @@ GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, | |||
521 | { | 515 | { |
522 | lsocks = NULL; | 516 | lsocks = NULL; |
523 | } | 517 | } |
524 | return GNUNET_SERVER_create_with_sockets (access, access_cls, | 518 | return GNUNET_SERVER_create_with_sockets (access, access_cls, lsocks, |
525 | lsocks, | ||
526 | idle_timeout, require_found); | 519 | idle_timeout, require_found); |
527 | } | 520 | } |
528 | 521 | ||
@@ -610,17 +603,17 @@ warn_no_receive_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
610 | { | 603 | { |
611 | struct GNUNET_SERVER_Client *client = cls; | 604 | struct GNUNET_SERVER_Client *client = cls; |
612 | 605 | ||
613 | client->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 606 | client->warn_task = |
614 | &warn_no_receive_done, | 607 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
615 | client); | 608 | &warn_no_receive_done, client); |
616 | if (0 == (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 609 | if (0 == (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) |
617 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 610 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
618 | _ | 611 | _ |
619 | ("Processing code for message of type %u did not call GNUNET_SERVER_receive_done after %llums\n"), | 612 | ("Processing code for message of type %u did not call GNUNET_SERVER_receive_done after %llums\n"), |
620 | (unsigned int) client->warn_type, | 613 | (unsigned int) client->warn_type, |
621 | (unsigned long long) | 614 | (unsigned long long) GNUNET_TIME_absolute_get_duration (client-> |
622 | GNUNET_TIME_absolute_get_duration | 615 | warn_start). |
623 | (client->warn_start).rel_value); | 616 | rel_value); |
624 | } | 617 | } |
625 | 618 | ||
626 | 619 | ||
@@ -737,11 +730,9 @@ GNUNET_SERVER_inject (struct GNUNET_SERVER_Handle *server, | |||
737 | * @param addrlen length of addr | 730 | * @param addrlen length of addr |
738 | * @param errCode code indicating errors receiving, 0 for success | 731 | * @param errCode code indicating errors receiving, 0 for success |
739 | */ | 732 | */ |
740 | static void | 733 | static void process_incoming (void *cls, const void *buf, size_t available, |
741 | process_incoming (void *cls, | 734 | const struct sockaddr *addr, socklen_t addrlen, |
742 | const void *buf, | 735 | int errCode); |
743 | size_t available, | ||
744 | const struct sockaddr *addr, socklen_t addrlen, int errCode); | ||
745 | 736 | ||
746 | 737 | ||
747 | /** | 738 | /** |
@@ -760,8 +751,7 @@ process_incoming (void *cls, | |||
760 | static void | 751 | static void |
761 | process_mst (struct GNUNET_SERVER_Client *client, int ret) | 752 | process_mst (struct GNUNET_SERVER_Client *client, int ret) |
762 | { | 753 | { |
763 | while ((ret != GNUNET_SYSERR) && | 754 | while ((ret != GNUNET_SYSERR) && (client->server != NULL) && |
764 | (client->server != NULL) && | ||
765 | (GNUNET_YES != client->shutdown_now) && (0 == client->suspended)) | 755 | (GNUNET_YES != client->shutdown_now) && (0 == client->suspended)) |
766 | { | 756 | { |
767 | if (ret == GNUNET_OK) | 757 | if (ret == GNUNET_OK) |
@@ -774,8 +764,8 @@ process_mst (struct GNUNET_SERVER_Client *client, int ret) | |||
774 | #endif | 764 | #endif |
775 | GNUNET_CONNECTION_receive (client->connection, | 765 | GNUNET_CONNECTION_receive (client->connection, |
776 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, | 766 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, |
777 | client->idle_timeout, | 767 | client->idle_timeout, &process_incoming, |
778 | &process_incoming, client); | 768 | client); |
779 | break; | 769 | break; |
780 | } | 770 | } |
781 | #if DEBUG_SERVER | 771 | #if DEBUG_SERVER |
@@ -817,9 +807,7 @@ process_mst (struct GNUNET_SERVER_Client *client, int ret) | |||
817 | * @param errCode code indicating errors receiving, 0 for success | 807 | * @param errCode code indicating errors receiving, 0 for success |
818 | */ | 808 | */ |
819 | static void | 809 | static void |
820 | process_incoming (void *cls, | 810 | process_incoming (void *cls, const void *buf, size_t available, |
821 | const void *buf, | ||
822 | size_t available, | ||
823 | const struct sockaddr *addr, socklen_t addrlen, int errCode) | 811 | const struct sockaddr *addr, socklen_t addrlen, int errCode) |
824 | { | 812 | { |
825 | struct GNUNET_SERVER_Client *client = cls; | 813 | struct GNUNET_SERVER_Client *client = cls; |
@@ -834,8 +822,7 @@ process_incoming (void *cls, | |||
834 | end = GNUNET_TIME_absolute_add (client->last_activity, client->idle_timeout); | 822 | end = GNUNET_TIME_absolute_add (client->last_activity, client->idle_timeout); |
835 | 823 | ||
836 | if ((buf == NULL) && (available == 0) && (addr == NULL) && (errCode == 0) && | 824 | if ((buf == NULL) && (available == 0) && (addr == NULL) && (errCode == 0) && |
837 | (client->shutdown_now != GNUNET_YES) && | 825 | (client->shutdown_now != GNUNET_YES) && (server != NULL) && |
838 | (server != NULL) && | ||
839 | (GNUNET_YES == GNUNET_CONNECTION_check (client->connection)) && | 826 | (GNUNET_YES == GNUNET_CONNECTION_check (client->connection)) && |
840 | (end.abs_value > now.abs_value)) | 827 | (end.abs_value > now.abs_value)) |
841 | { | 828 | { |
@@ -852,10 +839,7 @@ process_incoming (void *cls, | |||
852 | &process_incoming, client); | 839 | &process_incoming, client); |
853 | return; | 840 | return; |
854 | } | 841 | } |
855 | if ((buf == NULL) || | 842 | if ((buf == NULL) || (available == 0) || (errCode != 0) || (server == NULL) || |
856 | (available == 0) || | ||
857 | (errCode != 0) || | ||
858 | (server == NULL) || | ||
859 | (client->shutdown_now == GNUNET_YES) || | 843 | (client->shutdown_now == GNUNET_YES) || |
860 | (GNUNET_YES != GNUNET_CONNECTION_check (client->connection))) | 844 | (GNUNET_YES != GNUNET_CONNECTION_check (client->connection))) |
861 | { | 845 | { |
@@ -864,8 +848,7 @@ process_incoming (void *cls, | |||
864 | return; | 848 | return; |
865 | } | 849 | } |
866 | #if DEBUG_SERVER | 850 | #if DEBUG_SERVER |
867 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 851 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server receives %u bytes from `%s'.\n", |
868 | "Server receives %u bytes from `%s'.\n", | ||
869 | (unsigned int) available, GNUNET_a2s (addr, addrlen)); | 852 | (unsigned int) available, GNUNET_a2s (addr, addrlen)); |
870 | #endif | 853 | #endif |
871 | GNUNET_SERVER_client_keep (client); | 854 | GNUNET_SERVER_client_keep (client); |
@@ -928,8 +911,7 @@ restart_processing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
928 | * @param message the actual message | 911 | * @param message the actual message |
929 | */ | 912 | */ |
930 | static void | 913 | static void |
931 | client_message_tokenizer_callback (void *cls, | 914 | client_message_tokenizer_callback (void *cls, void *client, |
932 | void *client, | ||
933 | const struct GNUNET_MessageHeader *message) | 915 | const struct GNUNET_MessageHeader *message) |
934 | { | 916 | { |
935 | struct GNUNET_SERVER_Handle *server = cls; | 917 | struct GNUNET_SERVER_Handle *server = cls; |
@@ -963,17 +945,15 @@ client_message_tokenizer_callback (void *cls, | |||
963 | * "client_drop" on the return value eventually) | 945 | * "client_drop" on the return value eventually) |
964 | */ | 946 | */ |
965 | struct GNUNET_SERVER_Client * | 947 | struct GNUNET_SERVER_Client * |
966 | GNUNET_SERVER_connect_socket (struct | 948 | GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server, |
967 | GNUNET_SERVER_Handle | ||
968 | *server, | ||
969 | struct GNUNET_CONNECTION_Handle *connection) | 949 | struct GNUNET_CONNECTION_Handle *connection) |
970 | { | 950 | { |
971 | struct GNUNET_SERVER_Client *client; | 951 | struct GNUNET_SERVER_Client *client; |
972 | 952 | ||
973 | client = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Client)); | 953 | client = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Client)); |
974 | client->connection = connection; | 954 | client->connection = connection; |
975 | client->mst = GNUNET_SERVER_mst_create (&client_message_tokenizer_callback, | 955 | client->mst = |
976 | server); | 956 | GNUNET_SERVER_mst_create (&client_message_tokenizer_callback, server); |
977 | client->reference_count = 1; | 957 | client->reference_count = 1; |
978 | client->server = server; | 958 | client->server = server; |
979 | client->last_activity = GNUNET_TIME_absolute_get (); | 959 | client->last_activity = GNUNET_TIME_absolute_get (); |
@@ -1274,8 +1254,7 @@ GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client, | |||
1274 | { | 1254 | { |
1275 | client->callback_cls = callback_cls; | 1255 | client->callback_cls = callback_cls; |
1276 | client->callback = callback; | 1256 | client->callback = callback; |
1277 | return GNUNET_CONNECTION_notify_transmit_ready (client->connection, | 1257 | return GNUNET_CONNECTION_notify_transmit_ready (client->connection, size, |
1278 | size, | ||
1279 | timeout, | 1258 | timeout, |
1280 | &transmit_ready_callback_wrapper, | 1259 | &transmit_ready_callback_wrapper, |
1281 | client); | 1260 | client); |
diff --git a/src/util/server_mst.c b/src/util/server_mst.c index f48ef5475..07a7b30b8 100644 --- a/src/util/server_mst.c +++ b/src/util/server_mst.c | |||
@@ -119,9 +119,8 @@ GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb, | |||
119 | */ | 119 | */ |
120 | int | 120 | int |
121 | GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst, | 121 | GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst, |
122 | void *client_identity, | 122 | void *client_identity, const char *buf, size_t size, |
123 | const char *buf, | 123 | int purge, int one_shot) |
124 | size_t size, int purge, int one_shot) | ||
125 | { | 124 | { |
126 | const struct GNUNET_MessageHeader *hdr; | 125 | const struct GNUNET_MessageHeader *hdr; |
127 | size_t delta; | 126 | size_t delta; |
diff --git a/src/util/server_nc.c b/src/util/server_nc.c index f8e300029..a1cb43f00 100644 --- a/src/util/server_nc.c +++ b/src/util/server_nc.c | |||
@@ -323,10 +323,10 @@ transmit_message (void *cls, size_t size, void *buf) | |||
323 | "Have %u messages left in NC queue, will try transmission again\n", | 323 | "Have %u messages left in NC queue, will try transmission again\n", |
324 | cl->num_pending); | 324 | cl->num_pending); |
325 | #endif | 325 | #endif |
326 | cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client, | 326 | cl->th = |
327 | ntohs (pml->msg->size), | 327 | GNUNET_SERVER_notify_transmit_ready (cl->client, ntohs (pml->msg->size), |
328 | GNUNET_TIME_UNIT_FOREVER_REL, | 328 | GNUNET_TIME_UNIT_FOREVER_REL, |
329 | &transmit_message, cl); | 329 | &transmit_message, cl); |
330 | } | 330 | } |
331 | else | 331 | else |
332 | GNUNET_assert (cl->num_pending == 0); | 332 | GNUNET_assert (cl->num_pending == 0); |
@@ -344,8 +344,8 @@ transmit_message (void *cls, size_t size, void *buf) | |||
344 | */ | 344 | */ |
345 | static void | 345 | static void |
346 | do_unicast (struct GNUNET_SERVER_NotificationContext *nc, | 346 | do_unicast (struct GNUNET_SERVER_NotificationContext *nc, |
347 | struct ClientList *client, | 347 | struct ClientList *client, const struct GNUNET_MessageHeader *msg, |
348 | const struct GNUNET_MessageHeader *msg, int can_drop) | 348 | int can_drop) |
349 | { | 349 | { |
350 | struct PendingMessageList *pml; | 350 | struct PendingMessageList *pml; |
351 | uint16_t size; | 351 | uint16_t size; |
@@ -354,8 +354,8 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc, | |||
354 | { | 354 | { |
355 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 355 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
356 | "Dropping message of type %u and size %u due to full queue (%u entries)\n", | 356 | "Dropping message of type %u and size %u due to full queue (%u entries)\n", |
357 | ntohs (msg->type), | 357 | ntohs (msg->type), ntohs (msg->size), |
358 | ntohs (msg->size), (unsigned int) nc->queue_length); | 358 | (unsigned int) nc->queue_length); |
359 | return; /* drop! */ | 359 | return; /* drop! */ |
360 | } | 360 | } |
361 | if (client->num_pending > nc->queue_length) | 361 | if (client->num_pending > nc->queue_length) |
@@ -371,21 +371,20 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc, | |||
371 | #if DEBUG_SERVER_NC | 371 | #if DEBUG_SERVER_NC |
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
373 | "Adding message of type %u and size %u to pending queue (which has %u entries)\n", | 373 | "Adding message of type %u and size %u to pending queue (which has %u entries)\n", |
374 | ntohs (msg->type), | 374 | ntohs (msg->type), ntohs (msg->size), |
375 | ntohs (msg->size), (unsigned int) nc->queue_length); | 375 | (unsigned int) nc->queue_length); |
376 | #endif | 376 | #endif |
377 | memcpy (&pml[1], msg, size); | 377 | memcpy (&pml[1], msg, size); |
378 | /* append */ | 378 | /* append */ |
379 | GNUNET_CONTAINER_DLL_insert_tail (client->pending_head, | 379 | GNUNET_CONTAINER_DLL_insert_tail (client->pending_head, client->pending_tail, |
380 | client->pending_tail, pml); | 380 | pml); |
381 | if (client->th == NULL) | 381 | if (client->th == NULL) |
382 | client->th = GNUNET_SERVER_notify_transmit_ready (client->client, | 382 | client->th = |
383 | ntohs | 383 | GNUNET_SERVER_notify_transmit_ready (client->client, |
384 | (client->pending_head-> | 384 | ntohs (client->pending_head->msg-> |
385 | msg->size), | 385 | size), |
386 | GNUNET_TIME_UNIT_FOREVER_REL, | 386 | GNUNET_TIME_UNIT_FOREVER_REL, |
387 | &transmit_message, | 387 | &transmit_message, client); |
388 | client); | ||
389 | } | 388 | } |
390 | 389 | ||
391 | 390 | ||
diff --git a/src/util/server_tc.c b/src/util/server_tc.c index eda82e50f..127131032 100644 --- a/src/util/server_tc.c +++ b/src/util/server_tc.c | |||
@@ -103,13 +103,13 @@ transmit_response (void *cls, size_t size, void *buf) | |||
103 | } | 103 | } |
104 | else | 104 | else |
105 | { | 105 | { |
106 | if (NULL == GNUNET_SERVER_notify_transmit_ready (tc->client, | 106 | if (NULL == |
107 | GNUNET_MIN | 107 | GNUNET_SERVER_notify_transmit_ready (tc->client, |
108 | (MIN_BLOCK_SIZE, | 108 | GNUNET_MIN (MIN_BLOCK_SIZE, |
109 | tc->total - tc->off), | 109 | tc->total - tc->off), |
110 | GNUNET_TIME_absolute_get_remaining | 110 | GNUNET_TIME_absolute_get_remaining |
111 | (tc->timeout), | 111 | (tc->timeout), &transmit_response, |
112 | &transmit_response, tc)) | 112 | tc)) |
113 | { | 113 | { |
114 | GNUNET_break (0); | 114 | GNUNET_break (0); |
115 | GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR); | 115 | GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR); |
diff --git a/src/util/service.c b/src/util/service.c index 308267bd6..9b60dc56b 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -99,12 +99,10 @@ parse_ipv4_specification (const char *routeList) | |||
99 | pos = 0; | 99 | pos = 0; |
100 | while (i < count) | 100 | while (i < count) |
101 | { | 101 | { |
102 | cnt = sscanf (&routeList[pos], | 102 | cnt = |
103 | "%u.%u.%u.%u/%u.%u.%u.%u;", | 103 | sscanf (&routeList[pos], "%u.%u.%u.%u/%u.%u.%u.%u;", &temps[0], |
104 | &temps[0], | 104 | &temps[1], &temps[2], &temps[3], &temps[4], &temps[5], |
105 | &temps[1], | 105 | &temps[6], &temps[7]); |
106 | &temps[2], | ||
107 | &temps[3], &temps[4], &temps[5], &temps[6], &temps[7]); | ||
108 | if (cnt == 8) | 106 | if (cnt == 8) |
109 | { | 107 | { |
110 | for (j = 0; j < 8; j++) | 108 | for (j = 0; j < 8; j++) |
@@ -115,8 +113,7 @@ parse_ipv4_specification (const char *routeList) | |||
115 | GNUNET_free (result); | 113 | GNUNET_free (result); |
116 | return NULL; | 114 | return NULL; |
117 | } | 115 | } |
118 | result[i].network.s_addr | 116 | result[i].network.s_addr = |
119 | = | ||
120 | htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + | 117 | htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + |
121 | temps[3]); | 118 | temps[3]); |
122 | result[i].netmask.s_addr = | 119 | result[i].netmask.s_addr = |
@@ -129,9 +126,9 @@ parse_ipv4_specification (const char *routeList) | |||
129 | continue; | 126 | continue; |
130 | } | 127 | } |
131 | /* try second notation */ | 128 | /* try second notation */ |
132 | cnt = sscanf (&routeList[pos], | 129 | cnt = |
133 | "%u.%u.%u.%u/%u;", | 130 | sscanf (&routeList[pos], "%u.%u.%u.%u/%u;", &temps[0], &temps[1], |
134 | &temps[0], &temps[1], &temps[2], &temps[3], &slash); | 131 | &temps[2], &temps[3], &slash); |
135 | if (cnt == 5) | 132 | if (cnt == 5) |
136 | { | 133 | { |
137 | for (j = 0; j < 4; j++) | 134 | for (j = 0; j < 4; j++) |
@@ -142,8 +139,7 @@ parse_ipv4_specification (const char *routeList) | |||
142 | GNUNET_free (result); | 139 | GNUNET_free (result); |
143 | return NULL; | 140 | return NULL; |
144 | } | 141 | } |
145 | result[i].network.s_addr | 142 | result[i].network.s_addr = |
146 | = | ||
147 | htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + | 143 | htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + |
148 | temps[3]); | 144 | temps[3]); |
149 | if ((slash <= 32) && (slash >= 0)) | 145 | if ((slash <= 32) && (slash >= 0)) |
@@ -151,8 +147,8 @@ parse_ipv4_specification (const char *routeList) | |||
151 | result[i].netmask.s_addr = 0; | 147 | result[i].netmask.s_addr = 0; |
152 | while (slash > 0) | 148 | while (slash > 0) |
153 | { | 149 | { |
154 | result[i].netmask.s_addr | 150 | result[i].netmask.s_addr = |
155 | = (result[i].netmask.s_addr >> 1) + 0x80000000; | 151 | (result[i].netmask.s_addr >> 1) + 0x80000000; |
156 | slash--; | 152 | slash--; |
157 | } | 153 | } |
158 | result[i].netmask.s_addr = htonl (result[i].netmask.s_addr); | 154 | result[i].netmask.s_addr = htonl (result[i].netmask.s_addr); |
@@ -174,8 +170,9 @@ parse_ipv4_specification (const char *routeList) | |||
174 | } | 170 | } |
175 | /* try third notation */ | 171 | /* try third notation */ |
176 | slash = 32; | 172 | slash = 32; |
177 | cnt = sscanf (&routeList[pos], | 173 | cnt = |
178 | "%u.%u.%u.%u;", &temps[0], &temps[1], &temps[2], &temps[3]); | 174 | sscanf (&routeList[pos], "%u.%u.%u.%u;", &temps[0], &temps[1], |
175 | &temps[2], &temps[3]); | ||
179 | if (cnt == 4) | 176 | if (cnt == 4) |
180 | { | 177 | { |
181 | for (j = 0; j < 4; j++) | 178 | for (j = 0; j < 4; j++) |
@@ -186,8 +183,7 @@ parse_ipv4_specification (const char *routeList) | |||
186 | GNUNET_free (result); | 183 | GNUNET_free (result); |
187 | return NULL; | 184 | return NULL; |
188 | } | 185 | } |
189 | result[i].network.s_addr | 186 | result[i].network.s_addr = |
190 | = | ||
191 | htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + | 187 | htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + |
192 | temps[3]); | 188 | temps[3]); |
193 | result[i].netmask.s_addr = 0; | 189 | result[i].netmask.s_addr = 0; |
@@ -203,15 +199,15 @@ parse_ipv4_specification (const char *routeList) | |||
203 | i++; | 199 | i++; |
204 | continue; | 200 | continue; |
205 | } | 201 | } |
206 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 202 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid format for IP: `%s'\n"), |
207 | _("Invalid format for IP: `%s'\n"), &routeList[pos]); | 203 | &routeList[pos]); |
208 | GNUNET_free (result); | 204 | GNUNET_free (result); |
209 | return NULL; /* error */ | 205 | return NULL; /* error */ |
210 | } | 206 | } |
211 | if (pos < strlen (routeList)) | 207 | if (pos < strlen (routeList)) |
212 | { | 208 | { |
213 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 209 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid format for IP: `%s'\n"), |
214 | _("Invalid format for IP: `%s'\n"), &routeList[pos]); | 210 | &routeList[pos]); |
215 | GNUNET_free (result); | 211 | GNUNET_free (result); |
216 | return NULL; /* oops */ | 212 | return NULL; /* oops */ |
217 | } | 213 | } |
@@ -259,8 +255,7 @@ parse_ipv6_specification (const char *routeListX) | |||
259 | if (routeList[len - 1] != ';') | 255 | if (routeList[len - 1] != ';') |
260 | { | 256 | { |
261 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
262 | _ | 258 | _("Invalid network notation (does not end with ';': `%s')\n"), |
263 | ("Invalid network notation (does not end with ';': `%s')\n"), | ||
264 | routeList); | 259 | routeList); |
265 | GNUNET_free (routeList); | 260 | GNUNET_free (routeList); |
266 | return NULL; | 261 | return NULL; |
@@ -313,8 +308,8 @@ parse_ipv6_specification (const char *routeListX) | |||
313 | } | 308 | } |
314 | while (bits > 0) | 309 | while (bits > 0) |
315 | { | 310 | { |
316 | result[i].netmask.s6_addr[off] | 311 | result[i].netmask.s6_addr[off] = |
317 | = (result[i].netmask.s6_addr[off] >> 1) + 0x80; | 312 | (result[i].netmask.s6_addr[off] >> 1) + 0x80; |
318 | bits--; | 313 | bits--; |
319 | } | 314 | } |
320 | } | 315 | } |
@@ -550,16 +545,15 @@ write_test (void *cls, size_t size, void *buf) | |||
550 | * @param message the actual message | 545 | * @param message the actual message |
551 | */ | 546 | */ |
552 | static void | 547 | static void |
553 | handle_test (void *cls, | 548 | handle_test (void *cls, struct GNUNET_SERVER_Client *client, |
554 | struct GNUNET_SERVER_Client *client, | ||
555 | const struct GNUNET_MessageHeader *message) | 549 | const struct GNUNET_MessageHeader *message) |
556 | { | 550 | { |
557 | /* simply bounce message back to acknowledge */ | 551 | /* simply bounce message back to acknowledge */ |
558 | if (NULL == GNUNET_SERVER_notify_transmit_ready (client, | 552 | if (NULL == |
559 | sizeof (struct | 553 | GNUNET_SERVER_notify_transmit_ready (client, |
560 | GNUNET_MessageHeader), | 554 | sizeof (struct GNUNET_MessageHeader), |
561 | GNUNET_TIME_UNIT_FOREVER_REL, | 555 | GNUNET_TIME_UNIT_FOREVER_REL, |
562 | &write_test, client)) | 556 | &write_test, client)) |
563 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 557 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
564 | } | 558 | } |
565 | 559 | ||
@@ -591,8 +585,7 @@ static const struct GNUNET_SERVER_MessageHandler defhandlers[] = { | |||
591 | * for unknown address family (will be denied). | 585 | * for unknown address family (will be denied). |
592 | */ | 586 | */ |
593 | static int | 587 | static int |
594 | check_access (void *cls, | 588 | check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc, |
595 | const struct GNUNET_CONNECTION_Credentials *uc, | ||
596 | const struct sockaddr *addr, socklen_t addrlen) | 589 | const struct sockaddr *addr, socklen_t addrlen) |
597 | { | 590 | { |
598 | struct GNUNET_SERVICE_Context *sctx = cls; | 591 | struct GNUNET_SERVICE_Context *sctx = cls; |
@@ -606,19 +599,17 @@ check_access (void *cls, | |||
606 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in)); | 599 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in)); |
607 | i4 = (const struct sockaddr_in *) addr; | 600 | i4 = (const struct sockaddr_in *) addr; |
608 | ret = ((sctx->v4_allowed == NULL) || | 601 | ret = ((sctx->v4_allowed == NULL) || |
609 | (check_ipv4_listed (sctx->v4_allowed, | 602 | (check_ipv4_listed (sctx->v4_allowed, &i4->sin_addr))) && |
610 | &i4->sin_addr))) | 603 | ((sctx->v4_denied == NULL) || |
611 | && ((sctx->v4_denied == NULL) || | 604 | (!check_ipv4_listed (sctx->v4_denied, &i4->sin_addr))); |
612 | (!check_ipv4_listed (sctx->v4_denied, &i4->sin_addr))); | ||
613 | break; | 605 | break; |
614 | case AF_INET6: | 606 | case AF_INET6: |
615 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); | 607 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); |
616 | i6 = (const struct sockaddr_in6 *) addr; | 608 | i6 = (const struct sockaddr_in6 *) addr; |
617 | ret = ((sctx->v6_allowed == NULL) || | 609 | ret = ((sctx->v6_allowed == NULL) || |
618 | (check_ipv6_listed (sctx->v6_allowed, | 610 | (check_ipv6_listed (sctx->v6_allowed, &i6->sin6_addr))) && |
619 | &i6->sin6_addr))) | 611 | ((sctx->v6_denied == NULL) || |
620 | && ((sctx->v6_denied == NULL) || | 612 | (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr))); |
621 | (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr))); | ||
622 | break; | 613 | break; |
623 | #ifndef WINDOWS | 614 | #ifndef WINDOWS |
624 | case AF_UNIX: | 615 | case AF_UNIX: |
@@ -626,11 +617,10 @@ check_access (void *cls, | |||
626 | if ((sctx->match_uid == GNUNET_YES) || (sctx->match_gid == GNUNET_YES)) | 617 | if ((sctx->match_uid == GNUNET_YES) || (sctx->match_gid == GNUNET_YES)) |
627 | ret = GNUNET_NO; | 618 | ret = GNUNET_NO; |
628 | if ((uc != NULL) && | 619 | if ((uc != NULL) && |
629 | ((sctx->match_uid != GNUNET_YES) || | 620 | ((sctx->match_uid != GNUNET_YES) || (uc->uid == geteuid ()) || |
630 | (uc->uid == geteuid ()) || | 621 | (uc->uid == getuid ())) && ((sctx->match_gid != GNUNET_YES) || |
631 | (uc->uid == getuid ())) && | 622 | (uc->gid == getegid ()) || |
632 | ((sctx->match_gid != GNUNET_YES) || | 623 | (uc->gid == getgid ()))) |
633 | (uc->gid == getegid ()) || (uc->gid == getgid ()))) | ||
634 | ret = GNUNET_YES; | 624 | ret = GNUNET_YES; |
635 | else | 625 | else |
636 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 626 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -639,8 +629,8 @@ check_access (void *cls, | |||
639 | break; | 629 | break; |
640 | #endif | 630 | #endif |
641 | default: | 631 | default: |
642 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 632 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Unknown address family %d\n"), |
643 | _("Unknown address family %d\n"), addr->sa_family); | 633 | addr->sa_family); |
644 | return GNUNET_SYSERR; | 634 | return GNUNET_SYSERR; |
645 | } | 635 | } |
646 | if (ret != GNUNET_OK) | 636 | if (ret != GNUNET_OK) |
@@ -664,8 +654,7 @@ get_pid_file_name (struct GNUNET_SERVICE_Context *sctx) | |||
664 | char *pif; | 654 | char *pif; |
665 | 655 | ||
666 | if (GNUNET_OK != | 656 | if (GNUNET_OK != |
667 | GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, | 657 | GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->serviceName, |
668 | sctx->serviceName, | ||
669 | "PIDFILE", &pif)) | 658 | "PIDFILE", &pif)) |
670 | return NULL; | 659 | return NULL; |
671 | return pif; | 660 | return pif; |
@@ -676,8 +665,8 @@ get_pid_file_name (struct GNUNET_SERVICE_Context *sctx) | |||
676 | * Parse an IPv4 access control list. | 665 | * Parse an IPv4 access control list. |
677 | */ | 666 | */ |
678 | static int | 667 | static int |
679 | process_acl4 (struct IPv4NetworkSet **ret, | 668 | process_acl4 (struct IPv4NetworkSet **ret, struct GNUNET_SERVICE_Context *sctx, |
680 | struct GNUNET_SERVICE_Context *sctx, const char *option) | 669 | const char *option) |
681 | { | 670 | { |
682 | char *opt; | 671 | char *opt; |
683 | 672 | ||
@@ -705,8 +694,8 @@ process_acl4 (struct IPv4NetworkSet **ret, | |||
705 | * Parse an IPv4 access control list. | 694 | * Parse an IPv4 access control list. |
706 | */ | 695 | */ |
707 | static int | 696 | static int |
708 | process_acl6 (struct IPv6NetworkSet **ret, | 697 | process_acl6 (struct IPv6NetworkSet **ret, struct GNUNET_SERVICE_Context *sctx, |
709 | struct GNUNET_SERVICE_Context *sctx, const char *option) | 698 | const char *option) |
710 | { | 699 | { |
711 | char *opt; | 700 | char *opt; |
712 | 701 | ||
@@ -738,8 +727,8 @@ process_acl6 (struct IPv6NetworkSet **ret, | |||
738 | * @param unixpath path to add | 727 | * @param unixpath path to add |
739 | */ | 728 | */ |
740 | static void | 729 | static void |
741 | add_unixpath (struct sockaddr **saddrs, | 730 | add_unixpath (struct sockaddr **saddrs, socklen_t * saddrlens, |
742 | socklen_t * saddrlens, const char *unixpath) | 731 | const char *unixpath) |
743 | { | 732 | { |
744 | #ifdef AF_UNIX | 733 | #ifdef AF_UNIX |
745 | struct sockaddr_un *un; | 734 | struct sockaddr_un *un; |
@@ -816,9 +805,8 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
816 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "DISABLEV6")) | 805 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "DISABLEV6")) |
817 | { | 806 | { |
818 | if (GNUNET_SYSERR == | 807 | if (GNUNET_SYSERR == |
819 | (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg, | 808 | (disablev6 = |
820 | serviceName, | 809 | GNUNET_CONFIGURATION_get_value_yesno (cfg, serviceName, "DISABLEV6"))) |
821 | "DISABLEV6"))) | ||
822 | return GNUNET_SYSERR; | 810 | return GNUNET_SYSERR; |
823 | } | 811 | } |
824 | else | 812 | else |
@@ -830,8 +818,8 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
830 | desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); | 818 | desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); |
831 | if (NULL == desc) | 819 | if (NULL == desc) |
832 | { | 820 | { |
833 | if ((errno == ENOBUFS) || | 821 | if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || |
834 | (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) | 822 | (errno == EACCES)) |
835 | { | 823 | { |
836 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 824 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
837 | return GNUNET_SYSERR; | 825 | return GNUNET_SYSERR; |
@@ -853,8 +841,7 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
853 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT")) | 841 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT")) |
854 | { | 842 | { |
855 | GNUNET_break (GNUNET_OK == | 843 | GNUNET_break (GNUNET_OK == |
856 | GNUNET_CONFIGURATION_get_value_number (cfg, | 844 | GNUNET_CONFIGURATION_get_value_number (cfg, serviceName, |
857 | serviceName, | ||
858 | "PORT", &port)); | 845 | "PORT", &port)); |
859 | if (port > 65535) | 846 | if (port > 65535) |
860 | { | 847 | { |
@@ -869,8 +856,7 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
869 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "BINDTO")) | 856 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "BINDTO")) |
870 | { | 857 | { |
871 | GNUNET_break (GNUNET_OK == | 858 | GNUNET_break (GNUNET_OK == |
872 | GNUNET_CONFIGURATION_get_value_string (cfg, | 859 | GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, |
873 | serviceName, | ||
874 | "BINDTO", &hostname)); | 860 | "BINDTO", &hostname)); |
875 | } | 861 | } |
876 | else | 862 | else |
@@ -878,11 +864,11 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
878 | 864 | ||
879 | unixpath = NULL; | 865 | unixpath = NULL; |
880 | #ifdef AF_UNIX | 866 | #ifdef AF_UNIX |
881 | if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, | 867 | if ((GNUNET_YES == |
882 | serviceName, "UNIXPATH")) | 868 | GNUNET_CONFIGURATION_have_value (cfg, serviceName, "UNIXPATH")) && |
883 | && (GNUNET_OK == | 869 | (GNUNET_OK == |
884 | GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, "UNIXPATH", | 870 | GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, "UNIXPATH", |
885 | &unixpath)) && | 871 | &unixpath)) && |
886 | (0 < strlen (unixpath))) | 872 | (0 < strlen (unixpath))) |
887 | { | 873 | { |
888 | /* probe UNIX support */ | 874 | /* probe UNIX support */ |
@@ -901,8 +887,8 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
901 | desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); | 887 | desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); |
902 | if (NULL == desc) | 888 | if (NULL == desc) |
903 | { | 889 | { |
904 | if ((errno == ENOBUFS) || | 890 | if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || |
905 | (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) | 891 | (errno == EACCES)) |
906 | { | 892 | { |
907 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 893 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
908 | GNUNET_free_non_null (hostname); | 894 | GNUNET_free_non_null (hostname); |
@@ -955,11 +941,10 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
955 | memset (&hints, 0, sizeof (struct addrinfo)); | 941 | memset (&hints, 0, sizeof (struct addrinfo)); |
956 | if (disablev6) | 942 | if (disablev6) |
957 | hints.ai_family = AF_INET; | 943 | hints.ai_family = AF_INET; |
958 | if ((0 != (ret = getaddrinfo (hostname, | 944 | if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) || |
959 | NULL, &hints, &res))) || (res == NULL)) | 945 | (res == NULL)) |
960 | { | 946 | { |
961 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 947 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to resolve `%s': %s\n"), |
962 | _("Failed to resolve `%s': %s\n"), | ||
963 | hostname, gai_strerror (ret)); | 948 | hostname, gai_strerror (ret)); |
964 | GNUNET_free (hostname); | 949 | GNUNET_free (hostname); |
965 | GNUNET_free_non_null (unixpath); | 950 | GNUNET_free_non_null (unixpath); |
@@ -1006,8 +991,7 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
1006 | if ((pos->ai_socktype != SOCK_STREAM) && (pos->ai_socktype != 0)) | 991 | if ((pos->ai_socktype != SOCK_STREAM) && (pos->ai_socktype != 0)) |
1007 | continue; /* huh? */ | 992 | continue; /* huh? */ |
1008 | #if DEBUG_SERVICE | 993 | #if DEBUG_SERVICE |
1009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 994 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n", |
1010 | "Service `%s' will bind to `%s'\n", | ||
1011 | serviceName, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen)); | 995 | serviceName, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen)); |
1012 | #endif | 996 | #endif |
1013 | if (pos->ai_family == AF_INET) | 997 | if (pos->ai_family == AF_INET) |
@@ -1130,8 +1114,7 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) | |||
1130 | if (GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->serviceName, "TIMEOUT")) | 1114 | if (GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->serviceName, "TIMEOUT")) |
1131 | { | 1115 | { |
1132 | if (GNUNET_OK != | 1116 | if (GNUNET_OK != |
1133 | GNUNET_CONFIGURATION_get_value_time (sctx->cfg, | 1117 | GNUNET_CONFIGURATION_get_value_time (sctx->cfg, sctx->serviceName, |
1134 | sctx->serviceName, | ||
1135 | "TIMEOUT", &idleout)) | 1118 | "TIMEOUT", &idleout)) |
1136 | { | 1119 | { |
1137 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1120 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1144,13 +1127,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) | |||
1144 | else | 1127 | else |
1145 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 1128 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
1146 | 1129 | ||
1147 | if (GNUNET_CONFIGURATION_have_value (sctx->cfg, | 1130 | if (GNUNET_CONFIGURATION_have_value |
1148 | sctx->serviceName, "TOLERANT")) | 1131 | (sctx->cfg, sctx->serviceName, "TOLERANT")) |
1149 | { | 1132 | { |
1150 | if (GNUNET_SYSERR == | 1133 | if (GNUNET_SYSERR == |
1151 | (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, | 1134 | (tolerant = |
1152 | sctx->serviceName, | 1135 | GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName, |
1153 | "TOLERANT"))) | 1136 | "TOLERANT"))) |
1154 | { | 1137 | { |
1155 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1138 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1156 | _("Specified value for `%s' of service `%s' is invalid\n"), | 1139 | _("Specified value for `%s' of service `%s' is invalid\n"), |
@@ -1164,19 +1147,17 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) | |||
1164 | #ifndef MINGW | 1147 | #ifndef MINGW |
1165 | errno = 0; | 1148 | errno = 0; |
1166 | if ((NULL != (lpid = getenv ("LISTEN_PID"))) && | 1149 | if ((NULL != (lpid = getenv ("LISTEN_PID"))) && |
1167 | (1 == sscanf (lpid, "%u", &pid)) && | 1150 | (1 == sscanf (lpid, "%u", &pid)) && (getpid () == (pid_t) pid) && |
1168 | (getpid () == (pid_t) pid) && | ||
1169 | (NULL != (nfds = getenv ("LISTEN_FDS"))) && | 1151 | (NULL != (nfds = getenv ("LISTEN_FDS"))) && |
1170 | (1 == sscanf (nfds, "%u", &cnt)) && | 1152 | (1 == sscanf (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && |
1171 | (cnt > 0) && (cnt < FD_SETSIZE) && (cnt + 4 < FD_SETSIZE)) | 1153 | (cnt + 4 < FD_SETSIZE)) |
1172 | { | 1154 | { |
1173 | sctx->lsocks = | 1155 | sctx->lsocks = |
1174 | GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1)); | 1156 | GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1)); |
1175 | while (0 < cnt--) | 1157 | while (0 < cnt--) |
1176 | { | 1158 | { |
1177 | flags = fcntl (3 + cnt, F_GETFD); | 1159 | flags = fcntl (3 + cnt, F_GETFD); |
1178 | if ((flags < 0) || | 1160 | if ((flags < 0) || (0 != (flags & FD_CLOEXEC)) || |
1179 | (0 != (flags & FD_CLOEXEC)) || | ||
1180 | (NULL == | 1161 | (NULL == |
1181 | (sctx->lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt)))) | 1162 | (sctx->lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt)))) |
1182 | { | 1163 | { |
@@ -1199,17 +1180,16 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) | |||
1199 | 1180 | ||
1200 | if ((sctx->lsocks == NULL) && | 1181 | if ((sctx->lsocks == NULL) && |
1201 | (GNUNET_SYSERR == | 1182 | (GNUNET_SYSERR == |
1202 | GNUNET_SERVICE_get_server_addresses (sctx->serviceName, | 1183 | GNUNET_SERVICE_get_server_addresses (sctx->serviceName, sctx->cfg, |
1203 | sctx->cfg, | ||
1204 | &sctx->addrs, &sctx->addrlens))) | 1184 | &sctx->addrs, &sctx->addrlens))) |
1205 | return GNUNET_SYSERR; | 1185 | return GNUNET_SYSERR; |
1206 | sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES; | 1186 | sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES; |
1207 | sctx->match_uid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, | 1187 | sctx->match_uid = |
1208 | sctx->serviceName, | 1188 | GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName, |
1209 | "UNIX_MATCH_UID"); | 1189 | "UNIX_MATCH_UID"); |
1210 | sctx->match_gid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, | 1190 | sctx->match_gid = |
1211 | sctx->serviceName, | 1191 | GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName, |
1212 | "UNIX_MATCH_GID"); | 1192 | "UNIX_MATCH_GID"); |
1213 | process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM"); | 1193 | process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM"); |
1214 | process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM"); | 1194 | process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM"); |
1215 | process_acl6 (&sctx->v6_denied, sctx, "REJECT_FROM6"); | 1195 | process_acl6 (&sctx->v6_denied, sctx, "REJECT_FROM6"); |
@@ -1230,8 +1210,7 @@ get_user_name (struct GNUNET_SERVICE_Context *sctx) | |||
1230 | char *un; | 1210 | char *un; |
1231 | 1211 | ||
1232 | if (GNUNET_OK != | 1212 | if (GNUNET_OK != |
1233 | GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, | 1213 | GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->serviceName, |
1234 | sctx->serviceName, | ||
1235 | "USERNAME", &un)) | 1214 | "USERNAME", &un)) |
1236 | return NULL; | 1215 | return NULL; |
1237 | return un; | 1216 | return un; |
@@ -1319,17 +1298,13 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1319 | 1298 | ||
1320 | GNUNET_RESOLVER_connect (sctx->cfg); | 1299 | GNUNET_RESOLVER_connect (sctx->cfg); |
1321 | if (sctx->lsocks != NULL) | 1300 | if (sctx->lsocks != NULL) |
1322 | sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, | 1301 | sctx->server = |
1323 | sctx, | 1302 | GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks, |
1324 | sctx->lsocks, | 1303 | sctx->timeout, sctx->require_found); |
1325 | sctx->timeout, | ||
1326 | sctx->require_found); | ||
1327 | else | 1304 | else |
1328 | sctx->server = GNUNET_SERVER_create (&check_access, | 1305 | sctx->server = |
1329 | sctx, | 1306 | GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens, |
1330 | sctx->addrs, | 1307 | sctx->timeout, sctx->require_found); |
1331 | sctx->addrlens, | ||
1332 | sctx->timeout, sctx->require_found); | ||
1333 | if (sctx->server == NULL) | 1308 | if (sctx->server == NULL) |
1334 | { | 1309 | { |
1335 | if (sctx->addrs != NULL) | 1310 | if (sctx->addrs != NULL) |
@@ -1337,10 +1312,9 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1337 | i = 0; | 1312 | i = 0; |
1338 | while (sctx->addrs[i] != NULL) | 1313 | while (sctx->addrs[i] != NULL) |
1339 | { | 1314 | { |
1340 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1315 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Failed to start `%s' at `%s'\n"), |
1341 | _("Failed to start `%s' at `%s'\n"), | 1316 | sctx->serviceName, GNUNET_a2s (sctx->addrs[i], |
1342 | sctx->serviceName, | 1317 | sctx->addrlens[i])); |
1343 | GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i])); | ||
1344 | i++; | 1318 | i++; |
1345 | } | 1319 | } |
1346 | } | 1320 | } |
@@ -1351,8 +1325,8 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1351 | { | 1325 | { |
1352 | /* install a task that will kill the server | 1326 | /* install a task that will kill the server |
1353 | * process if the scheduler ever gets a shutdown signal */ | 1327 | * process if the scheduler ever gets a shutdown signal */ |
1354 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1328 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
1355 | &shutdown_task, sctx->server); | 1329 | sctx->server); |
1356 | } | 1330 | } |
1357 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); | 1331 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); |
1358 | memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); | 1332 | memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); |
@@ -1372,10 +1346,9 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1372 | i = 0; | 1346 | i = 0; |
1373 | while (sctx->addrs[i] != NULL) | 1347 | while (sctx->addrs[i] != NULL) |
1374 | { | 1348 | { |
1375 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1349 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Service `%s' runs at %s\n"), |
1376 | _("Service `%s' runs at %s\n"), | 1350 | sctx->serviceName, GNUNET_a2s (sctx->addrs[i], |
1377 | sctx->serviceName, | 1351 | sctx->addrlens[i])); |
1378 | GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i])); | ||
1379 | i++; | 1352 | i++; |
1380 | } | 1353 | } |
1381 | } | 1354 | } |
@@ -1480,8 +1453,8 @@ set_user_id (struct GNUNET_SERVICE_Context *sctx) | |||
1480 | if (pws == NULL) | 1453 | if (pws == NULL) |
1481 | { | 1454 | { |
1482 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1455 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1483 | _("Cannot obtain information about user `%s': %s\n"), | 1456 | _("Cannot obtain information about user `%s': %s\n"), user, |
1484 | user, errno == 0 ? _("No such user") : STRERROR (errno)); | 1457 | errno == 0 ? _("No such user") : STRERROR (errno)); |
1485 | GNUNET_free (user); | 1458 | GNUNET_free (user); |
1486 | return GNUNET_SYSERR; | 1459 | return GNUNET_SYSERR; |
1487 | } | 1460 | } |
@@ -1537,11 +1510,9 @@ pid_file_delete (struct GNUNET_SERVICE_Context *sctx) | |||
1537 | * if we shutdown nicely | 1510 | * if we shutdown nicely |
1538 | */ | 1511 | */ |
1539 | int | 1512 | int |
1540 | GNUNET_SERVICE_run (int argc, | 1513 | GNUNET_SERVICE_run (int argc, char *const *argv, const char *serviceName, |
1541 | char *const *argv, | 1514 | enum GNUNET_SERVICE_Options opt, GNUNET_SERVICE_Main task, |
1542 | const char *serviceName, | 1515 | void *task_cls) |
1543 | enum GNUNET_SERVICE_Options opt, | ||
1544 | GNUNET_SERVICE_Main task, void *task_cls) | ||
1545 | { | 1516 | { |
1546 | #define HANDLE_ERROR do { err = 1; GNUNET_break (0); goto shutdown; } while (0) | 1517 | #define HANDLE_ERROR do { err = 1; GNUNET_break (0); goto shutdown; } while (0) |
1547 | 1518 | ||
@@ -1583,8 +1554,8 @@ GNUNET_SERVICE_run (int argc, | |||
1583 | sctx.serviceName = serviceName; | 1554 | sctx.serviceName = serviceName; |
1584 | sctx.cfg = cfg = GNUNET_CONFIGURATION_create (); | 1555 | sctx.cfg = cfg = GNUNET_CONFIGURATION_create (); |
1585 | /* setup subsystems */ | 1556 | /* setup subsystems */ |
1586 | if (GNUNET_SYSERR == GNUNET_GETOPT_run (serviceName, service_options, argc, | 1557 | if (GNUNET_SYSERR == |
1587 | argv)) | 1558 | GNUNET_GETOPT_run (serviceName, service_options, argc, argv)) |
1588 | goto shutdown; | 1559 | goto shutdown; |
1589 | if (GNUNET_OK != GNUNET_log_setup (serviceName, loglev, logfile)) | 1560 | if (GNUNET_OK != GNUNET_log_setup (serviceName, loglev, logfile)) |
1590 | HANDLE_ERROR; | 1561 | HANDLE_ERROR; |
@@ -1598,8 +1569,8 @@ GNUNET_SERVICE_run (int argc, | |||
1598 | goto shutdown; | 1569 | goto shutdown; |
1599 | #if DEBUG_SERVICE | 1570 | #if DEBUG_SERVICE |
1600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1571 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1601 | "Service `%s' runs with configuration from `%s'\n", | 1572 | "Service `%s' runs with configuration from `%s'\n", serviceName, |
1602 | serviceName, cfg_fn); | 1573 | cfg_fn); |
1603 | #endif | 1574 | #endif |
1604 | if (GNUNET_OK == | 1575 | if (GNUNET_OK == |
1605 | GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "testing", "skew_offset", | 1576 | GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "testing", "skew_offset", |
@@ -1679,17 +1650,13 @@ GNUNET_SERVICE_start (const char *serviceName, | |||
1679 | return NULL; | 1650 | return NULL; |
1680 | } | 1651 | } |
1681 | if (sctx->lsocks != NULL) | 1652 | if (sctx->lsocks != NULL) |
1682 | sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, | 1653 | sctx->server = |
1683 | sctx, | 1654 | GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks, |
1684 | sctx->lsocks, | 1655 | sctx->timeout, sctx->require_found); |
1685 | sctx->timeout, | ||
1686 | sctx->require_found); | ||
1687 | else | 1656 | else |
1688 | sctx->server = GNUNET_SERVER_create (&check_access, | 1657 | sctx->server = |
1689 | sctx, | 1658 | GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens, |
1690 | sctx->addrs, | 1659 | sctx->timeout, sctx->require_found); |
1691 | sctx->addrlens, | ||
1692 | sctx->timeout, sctx->require_found); | ||
1693 | 1660 | ||
1694 | if (NULL == sctx->server) | 1661 | if (NULL == sctx->server) |
1695 | { | 1662 | { |
diff --git a/src/util/strings.c b/src/util/strings.c index a95981690..e2ca69e10 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -96,8 +96,8 @@ GNUNET_STRINGS_buffer_fill (char *buffer, size_t size, unsigned int count, ...) | |||
96 | * in the buffer, or 0 on error. | 96 | * in the buffer, or 0 on error. |
97 | */ | 97 | */ |
98 | unsigned int | 98 | unsigned int |
99 | GNUNET_STRINGS_buffer_tokenize (const char *buffer, | 99 | GNUNET_STRINGS_buffer_tokenize (const char *buffer, size_t size, |
100 | size_t size, unsigned int count, ...) | 100 | unsigned int count, ...) |
101 | { | 101 | { |
102 | unsigned int start; | 102 | unsigned int start; |
103 | unsigned int needed; | 103 | unsigned int needed; |
@@ -314,8 +314,7 @@ GNUNET_STRINGS_filename_expand (const char *fil) | |||
314 | } | 314 | } |
315 | n = strlen (fm) + 1 + strlen (fil_ptr) + 1; | 315 | n = strlen (fm) + 1 + strlen (fil_ptr) + 1; |
316 | buffer = GNUNET_malloc (n); | 316 | buffer = GNUNET_malloc (n); |
317 | GNUNET_snprintf (buffer, n, "%s%s%s", | 317 | GNUNET_snprintf (buffer, n, "%s%s%s", fm, |
318 | fm, | ||
319 | (fm[strlen (fm) - 1] == | 318 | (fm[strlen (fm) - 1] == |
320 | DIR_SEPARATOR) ? "" : DIR_SEPARATOR_STR, fil_ptr); | 319 | DIR_SEPARATOR) ? "" : DIR_SEPARATOR_STR, fil_ptr); |
321 | GNUNET_free (fm); | 320 | GNUNET_free (fm); |
diff --git a/src/util/test_client.c b/src/util/test_client.c index 9c2abb016..f9d961ab6 100644 --- a/src/util/test_client.c +++ b/src/util/test_client.c | |||
@@ -70,8 +70,7 @@ copy_msg (void *cls, size_t size, void *buf) | |||
70 | * Callback that just bounces the message back to the sender. | 70 | * Callback that just bounces the message back to the sender. |
71 | */ | 71 | */ |
72 | static void | 72 | static void |
73 | echo_cb (void *cls, | 73 | echo_cb (void *cls, struct GNUNET_SERVER_Client *client, |
74 | struct GNUNET_SERVER_Client *client, | ||
75 | const struct GNUNET_MessageHeader *message) | 74 | const struct GNUNET_MessageHeader *message) |
76 | { | 75 | { |
77 | struct CopyContext *cc; | 76 | struct CopyContext *cc; |
@@ -148,13 +147,10 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
148 | #endif | 147 | #endif |
149 | sa.sin_family = AF_INET; | 148 | sa.sin_family = AF_INET; |
150 | sa.sin_port = htons (PORT); | 149 | sa.sin_port = htons (PORT); |
151 | server = GNUNET_SERVER_create (NULL, | 150 | server = |
152 | NULL, | 151 | GNUNET_SERVER_create (NULL, NULL, sap, slens, |
153 | sap, | 152 | GNUNET_TIME_relative_multiply |
154 | slens, | 153 | (GNUNET_TIME_UNIT_MILLISECONDS, 10000), GNUNET_NO); |
155 | GNUNET_TIME_relative_multiply | ||
156 | (GNUNET_TIME_UNIT_MILLISECONDS, 10000), | ||
157 | GNUNET_NO); | ||
158 | GNUNET_assert (server != NULL); | 154 | GNUNET_assert (server != NULL); |
159 | handlers[0].callback_cls = cls; | 155 | handlers[0].callback_cls = cls; |
160 | handlers[1].callback_cls = cls; | 156 | handlers[1].callback_cls = cls; |
@@ -166,8 +162,8 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
166 | sizeof (struct | 162 | sizeof (struct |
167 | GNUNET_MessageHeader), | 163 | GNUNET_MessageHeader), |
168 | GNUNET_TIME_UNIT_SECONDS, | 164 | GNUNET_TIME_UNIT_SECONDS, |
169 | GNUNET_NO, | 165 | GNUNET_NO, &make_msg, |
170 | &make_msg, NULL)); | 166 | NULL)); |
171 | GNUNET_CLIENT_receive (client, &recv_bounce, cls, | 167 | GNUNET_CLIENT_receive (client, &recv_bounce, cls, |
172 | GNUNET_TIME_relative_multiply | 168 | GNUNET_TIME_relative_multiply |
173 | (GNUNET_TIME_UNIT_MILLISECONDS, 10000)); | 169 | (GNUNET_TIME_UNIT_MILLISECONDS, 10000)); |
@@ -186,8 +182,8 @@ check () | |||
186 | cfg = GNUNET_CONFIGURATION_create (); | 182 | cfg = GNUNET_CONFIGURATION_create (); |
187 | GNUNET_CONFIGURATION_set_value_number (cfg, MYNAME, "PORT", PORT); | 183 | GNUNET_CONFIGURATION_set_value_number (cfg, MYNAME, "PORT", PORT); |
188 | GNUNET_CONFIGURATION_set_value_string (cfg, MYNAME, "HOSTNAME", "localhost"); | 184 | GNUNET_CONFIGURATION_set_value_string (cfg, MYNAME, "HOSTNAME", "localhost"); |
189 | GNUNET_CONFIGURATION_set_value_string (cfg, | 185 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
190 | "resolver", "HOSTNAME", "localhost"); | 186 | "localhost"); |
191 | ok = 1; | 187 | ok = 1; |
192 | GNUNET_SCHEDULER_run (&task, &ok); | 188 | GNUNET_SCHEDULER_run (&task, &ok); |
193 | GNUNET_CONFIGURATION_destroy (cfg); | 189 | GNUNET_CONFIGURATION_destroy (cfg); |
diff --git a/src/util/test_common_endian.c b/src/util/test_common_endian.c index fb556c7f4..a709abec6 100644 --- a/src/util/test_common_endian.c +++ b/src/util/test_common_endian.c | |||
@@ -33,8 +33,8 @@ main (int argc, char *argv[]) | |||
33 | CHECK (1); | 33 | CHECK (1); |
34 | CHECK (0x12345678); | 34 | CHECK (0x12345678); |
35 | CHECK (123456789012345LL); | 35 | CHECK (123456789012345LL); |
36 | if ((0x1234567890ABCDEFLL != | 36 | if ((0x1234567890ABCDEFLL != GNUNET_htonll (0xEFCDAB9078563412LL)) && |
37 | GNUNET_htonll (0xEFCDAB9078563412LL)) && 42 != htonl (42)) | 37 | 42 != htonl (42)) |
38 | return 1; | 38 | return 1; |
39 | return 0; | 39 | return 0; |
40 | } | 40 | } |
diff --git a/src/util/test_common_logging.c b/src/util/test_common_logging.c index da200d62a..39ef58267 100644 --- a/src/util/test_common_logging.c +++ b/src/util/test_common_logging.c | |||
@@ -27,8 +27,8 @@ | |||
27 | #include "gnunet_common.h" | 27 | #include "gnunet_common.h" |
28 | 28 | ||
29 | static void | 29 | static void |
30 | my_log (void *ctx, enum GNUNET_ErrorType kind, | 30 | my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component, |
31 | const char *component, const char *date, const char *msg) | 31 | const char *date, const char *msg) |
32 | { | 32 | { |
33 | unsigned int *c = ctx; | 33 | unsigned int *c = ctx; |
34 | 34 | ||
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c index 8bad5b5d4..2737cb4f7 100644 --- a/src/util/test_configuration.c +++ b/src/util/test_configuration.c | |||
@@ -75,8 +75,8 @@ initDiffsCBData (struct DiffsCBData *cbData) | |||
75 | * and comparing configuration | 75 | * and comparing configuration |
76 | */ | 76 | */ |
77 | static void | 77 | static void |
78 | diffsCallBack (void *cls, | 78 | diffsCallBack (void *cls, const char *section, const char *option, |
79 | const char *section, const char *option, const char *value) | 79 | const char *value) |
80 | { | 80 | { |
81 | struct DiffsCBData *cbData = cls; | 81 | struct DiffsCBData *cbData = cls; |
82 | int cbOption = cbData->callBackOption; | 82 | int cbOption = cbData->callBackOption; |
@@ -90,15 +90,15 @@ diffsCallBack (void *cls, | |||
90 | { | 90 | { |
91 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, | 91 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, |
92 | "new-value"); | 92 | "new-value"); |
93 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, | 93 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option, |
94 | option, "new-value"); | 94 | "new-value"); |
95 | } | 95 | } |
96 | break; | 96 | break; |
97 | case EDIT_ALL: | 97 | case EDIT_ALL: |
98 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, | 98 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, |
99 | "new-value"); | 99 | "new-value"); |
100 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, | 100 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option, |
101 | option, "new-value"); | 101 | "new-value"); |
102 | break; | 102 | break; |
103 | case ADD_NEW_ENTRY: | 103 | case ADD_NEW_ENTRY: |
104 | { | 104 | { |
@@ -107,8 +107,8 @@ diffsCallBack (void *cls, | |||
107 | if (hit == 0) | 107 | if (hit == 0) |
108 | { | 108 | { |
109 | hit = 1; | 109 | hit = 1; |
110 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, | 110 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, "new-key", |
111 | "new-key", "new-value"); | 111 | "new-value"); |
112 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, | 112 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, |
113 | "new-key", "new-value"); | 113 | "new-key", "new-value"); |
114 | } | 114 | } |
@@ -183,8 +183,8 @@ editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, int option) | |||
183 | GNUNET_asprintf (&key, "key%d", i); | 183 | GNUNET_asprintf (&key, "key%d", i); |
184 | GNUNET_CONFIGURATION_set_value_string (cfg, "new-section", key, | 184 | GNUNET_CONFIGURATION_set_value_string (cfg, "new-section", key, |
185 | "new-value"); | 185 | "new-value"); |
186 | GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs, | 186 | GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs, "new-section", |
187 | "new-section", key, "new-value"); | 187 | key, "new-value"); |
188 | GNUNET_free (key); | 188 | GNUNET_free (key); |
189 | } | 189 | } |
190 | break; | 190 | break; |
@@ -282,8 +282,8 @@ testConfig () | |||
282 | return 2; | 282 | return 2; |
283 | } | 283 | } |
284 | GNUNET_free (c); | 284 | GNUNET_free (c); |
285 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, | 285 | if (GNUNET_OK != |
286 | "test", "five", &l)) | 286 | GNUNET_CONFIGURATION_get_value_number (cfg, "test", "five", &l)) |
287 | { | 287 | { |
288 | GNUNET_break (0); | 288 | GNUNET_break (0); |
289 | return 3; | 289 | return 3; |
@@ -364,9 +364,9 @@ testConfigFilenames () | |||
364 | int idx; | 364 | int idx; |
365 | 365 | ||
366 | idx = 0; | 366 | idx = 0; |
367 | if (3 != GNUNET_CONFIGURATION_iterate_value_filenames (cfg, | 367 | if (3 != |
368 | "FILENAMES", | 368 | GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test", |
369 | "test", &check, &idx)) | 369 | &check, &idx)) |
370 | { | 370 | { |
371 | GNUNET_break (0); | 371 | GNUNET_break (0); |
372 | return 8; | 372 | return 8; |
@@ -374,60 +374,54 @@ testConfigFilenames () | |||
374 | if (idx != 3) | 374 | if (idx != 3) |
375 | return 16; | 375 | return 16; |
376 | if (GNUNET_OK != | 376 | if (GNUNET_OK != |
377 | GNUNET_CONFIGURATION_remove_value_filename (cfg, | 377 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", |
378 | "FILENAMES", | 378 | "/File Name")) |
379 | "test", "/File Name")) | ||
380 | { | 379 | { |
381 | GNUNET_break (0); | 380 | GNUNET_break (0); |
382 | return 24; | 381 | return 24; |
383 | } | 382 | } |
384 | 383 | ||
385 | if (GNUNET_NO != | 384 | if (GNUNET_NO != |
386 | GNUNET_CONFIGURATION_remove_value_filename (cfg, | 385 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", |
387 | "FILENAMES", | 386 | "/File Name")) |
388 | "test", "/File Name")) | ||
389 | { | 387 | { |
390 | GNUNET_break (0); | 388 | GNUNET_break (0); |
391 | return 32; | 389 | return 32; |
392 | } | 390 | } |
393 | if (GNUNET_NO != | 391 | if (GNUNET_NO != |
394 | GNUNET_CONFIGURATION_remove_value_filename (cfg, | 392 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", |
395 | "FILENAMES", "test", "Stuff")) | 393 | "Stuff")) |
396 | { | 394 | { |
397 | GNUNET_break (0); | 395 | GNUNET_break (0); |
398 | return 40; | 396 | return 40; |
399 | } | 397 | } |
400 | 398 | ||
401 | if (GNUNET_NO != | 399 | if (GNUNET_NO != |
402 | GNUNET_CONFIGURATION_append_value_filename (cfg, | 400 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", |
403 | "FILENAMES", | 401 | "/Hello")) |
404 | "test", "/Hello")) | ||
405 | { | 402 | { |
406 | GNUNET_break (0); | 403 | GNUNET_break (0); |
407 | return 48; | 404 | return 48; |
408 | } | 405 | } |
409 | if (GNUNET_NO != | 406 | if (GNUNET_NO != |
410 | GNUNET_CONFIGURATION_append_value_filename (cfg, | 407 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", |
411 | "FILENAMES", | 408 | "/World")) |
412 | "test", "/World")) | ||
413 | { | 409 | { |
414 | GNUNET_break (0); | 410 | GNUNET_break (0); |
415 | return 56; | 411 | return 56; |
416 | } | 412 | } |
417 | 413 | ||
418 | if (GNUNET_YES != | 414 | if (GNUNET_YES != |
419 | GNUNET_CONFIGURATION_append_value_filename (cfg, | 415 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", |
420 | "FILENAMES", | 416 | "/File 1")) |
421 | "test", "/File 1")) | ||
422 | { | 417 | { |
423 | GNUNET_break (0); | 418 | GNUNET_break (0); |
424 | return 64; | 419 | return 64; |
425 | } | 420 | } |
426 | 421 | ||
427 | if (GNUNET_YES != | 422 | if (GNUNET_YES != |
428 | GNUNET_CONFIGURATION_append_value_filename (cfg, | 423 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", |
429 | "FILENAMES", | 424 | "/File 2")) |
430 | "test", "/File 2")) | ||
431 | { | 425 | { |
432 | GNUNET_break (0); | 426 | GNUNET_break (0); |
433 | return 72; | 427 | return 72; |
@@ -437,9 +431,9 @@ testConfigFilenames () | |||
437 | want[1] = "/World"; | 431 | want[1] = "/World"; |
438 | want[2] = "/File 1"; | 432 | want[2] = "/File 1"; |
439 | want[3] = "/File 2"; | 433 | want[3] = "/File 2"; |
440 | if (4 != GNUNET_CONFIGURATION_iterate_value_filenames (cfg, | 434 | if (4 != |
441 | "FILENAMES", | 435 | GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test", |
442 | "test", &check, &idx)) | 436 | &check, &idx)) |
443 | { | 437 | { |
444 | GNUNET_break (0); | 438 | GNUNET_break (0); |
445 | return 80; | 439 | return 80; |
diff --git a/src/util/test_connection.c b/src/util/test_connection.c index 3519522ef..cb69f4036 100644 --- a/src/util/test_connection.c +++ b/src/util/test_connection.c | |||
@@ -75,9 +75,7 @@ open_listen_socket () | |||
75 | } | 75 | } |
76 | 76 | ||
77 | static void | 77 | static void |
78 | receive_check (void *cls, | 78 | receive_check (void *cls, const void *buf, size_t available, |
79 | const void *buf, | ||
80 | size_t available, | ||
81 | const struct sockaddr *addr, socklen_t addrlen, int errCode) | 79 | const struct sockaddr *addr, socklen_t addrlen, int errCode) |
82 | { | 80 | { |
83 | int *ok = cls; | 81 | int *ok = cls; |
@@ -93,11 +91,10 @@ receive_check (void *cls, | |||
93 | #if VERBOSE | 91 | #if VERBOSE |
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive needs more data\n"); | 92 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive needs more data\n"); |
95 | #endif | 93 | #endif |
96 | GNUNET_CONNECTION_receive (asock, | 94 | GNUNET_CONNECTION_receive (asock, 1024, |
97 | 1024, | ||
98 | GNUNET_TIME_relative_multiply | 95 | GNUNET_TIME_relative_multiply |
99 | (GNUNET_TIME_UNIT_SECONDS, 5), | 96 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, |
100 | &receive_check, cls); | 97 | cls); |
101 | } | 98 | } |
102 | else | 99 | else |
103 | { | 100 | { |
@@ -127,8 +124,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 124 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
128 | "Test asks to receive on accepted socket\n"); | 125 | "Test asks to receive on accepted socket\n"); |
129 | #endif | 126 | #endif |
130 | GNUNET_CONNECTION_receive (asock, | 127 | GNUNET_CONNECTION_receive (asock, 1024, |
131 | 1024, | ||
132 | GNUNET_TIME_relative_multiply | 128 | GNUNET_TIME_relative_multiply |
133 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, | 129 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, |
134 | cls); | 130 | cls); |
@@ -162,15 +158,14 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks for write notification\n"); | 158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks for write notification\n"); |
163 | #endif | 159 | #endif |
164 | GNUNET_assert (NULL != | 160 | GNUNET_assert (NULL != |
165 | GNUNET_CONNECTION_notify_transmit_ready (csock, | 161 | GNUNET_CONNECTION_notify_transmit_ready (csock, 12, |
166 | 12, | ||
167 | GNUNET_TIME_UNIT_SECONDS, | 162 | GNUNET_TIME_UNIT_SECONDS, |
168 | &make_hello, NULL)); | 163 | &make_hello, NULL)); |
169 | #if VERBOSE | 164 | #if VERBOSE |
170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); | 165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); |
171 | #endif | 166 | #endif |
172 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 167 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, |
173 | ls, &run_accept, cls); | 168 | cls); |
174 | } | 169 | } |
175 | 170 | ||
176 | 171 | ||
@@ -185,8 +180,8 @@ check () | |||
185 | 180 | ||
186 | ok = 1; | 181 | ok = 1; |
187 | cfg = GNUNET_CONFIGURATION_create (); | 182 | cfg = GNUNET_CONFIGURATION_create (); |
188 | GNUNET_CONFIGURATION_set_value_string (cfg, | 183 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
189 | "resolver", "HOSTNAME", "localhost"); | 184 | "localhost"); |
190 | GNUNET_SCHEDULER_run (&task, &ok); | 185 | GNUNET_SCHEDULER_run (&task, &ok); |
191 | GNUNET_CONFIGURATION_destroy (cfg); | 186 | GNUNET_CONFIGURATION_destroy (cfg); |
192 | return ok; | 187 | return ok; |
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index 111894a36..2d08acc3c 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c | |||
@@ -67,9 +67,9 @@ open_listen_socket () | |||
67 | if (GNUNET_NETWORK_socket_setsockopt | 67 | if (GNUNET_NETWORK_socket_setsockopt |
68 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 68 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
70 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (desc, | 70 | if (GNUNET_OK != |
71 | (const struct sockaddr *) &sa, | 71 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
72 | sizeof (sa))) | 72 | sizeof (sa))) |
73 | { | 73 | { |
74 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 74 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
75 | "bind"); | 75 | "bind"); |
@@ -81,9 +81,7 @@ open_listen_socket () | |||
81 | 81 | ||
82 | 82 | ||
83 | static void | 83 | static void |
84 | receive_check (void *cls, | 84 | receive_check (void *cls, const void *buf, size_t available, |
85 | const void *buf, | ||
86 | size_t available, | ||
87 | const struct sockaddr *addr, socklen_t addrlen, int errCode) | 85 | const struct sockaddr *addr, socklen_t addrlen, int errCode) |
88 | { | 86 | { |
89 | int *ok = cls; | 87 | int *ok = cls; |
@@ -93,11 +91,10 @@ receive_check (void *cls, | |||
93 | sofar += available; | 91 | sofar += available; |
94 | if (sofar < 12) | 92 | if (sofar < 12) |
95 | { | 93 | { |
96 | GNUNET_CONNECTION_receive (asock, | 94 | GNUNET_CONNECTION_receive (asock, 1024, |
97 | 1024, | ||
98 | GNUNET_TIME_relative_multiply | 95 | GNUNET_TIME_relative_multiply |
99 | (GNUNET_TIME_UNIT_SECONDS, 5), | 96 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, |
100 | &receive_check, cls); | 97 | cls); |
101 | } | 98 | } |
102 | else | 99 | else |
103 | { | 100 | { |
@@ -132,8 +129,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
132 | GNUNET_assert (0 == memcmp (&expect, v4, alen)); | 129 | GNUNET_assert (0 == memcmp (&expect, v4, alen)); |
133 | GNUNET_free (addr); | 130 | GNUNET_free (addr); |
134 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); | 131 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); |
135 | GNUNET_CONNECTION_receive (asock, | 132 | GNUNET_CONNECTION_receive (asock, 1024, |
136 | 1024, | ||
137 | GNUNET_TIME_relative_multiply | 133 | GNUNET_TIME_relative_multiply |
138 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, | 134 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, |
139 | cls); | 135 | cls); |
@@ -162,18 +158,18 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
162 | v4.sin_family = AF_INET; | 158 | v4.sin_family = AF_INET; |
163 | v4.sin_port = htons (PORT); | 159 | v4.sin_port = htons (PORT); |
164 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 160 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
165 | csock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, | 161 | csock = |
166 | (const struct sockaddr | 162 | GNUNET_CONNECTION_create_from_sockaddr (AF_INET, |
167 | *) &v4, sizeof (v4)); | 163 | (const struct sockaddr *) &v4, |
164 | sizeof (v4)); | ||
168 | GNUNET_assert (csock != NULL); | 165 | GNUNET_assert (csock != NULL); |
169 | GNUNET_assert (NULL != | 166 | GNUNET_assert (NULL != |
170 | GNUNET_CONNECTION_notify_transmit_ready (csock, | 167 | GNUNET_CONNECTION_notify_transmit_ready (csock, 12, |
171 | 12, | ||
172 | GNUNET_TIME_UNIT_SECONDS, | 168 | GNUNET_TIME_UNIT_SECONDS, |
173 | &make_hello, NULL)); | 169 | &make_hello, NULL)); |
174 | GNUNET_CONNECTION_destroy (csock, GNUNET_YES); | 170 | GNUNET_CONNECTION_destroy (csock, GNUNET_YES); |
175 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 171 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, |
176 | ls, &run_accept, cls); | 172 | cls); |
177 | } | 173 | } |
178 | 174 | ||
179 | 175 | ||
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index d635f5742..aa1672455 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.c | |||
@@ -76,9 +76,7 @@ open_listen_socket () | |||
76 | 76 | ||
77 | 77 | ||
78 | static void | 78 | static void |
79 | dead_receive (void *cls, | 79 | dead_receive (void *cls, const void *buf, size_t available, |
80 | const void *buf, | ||
81 | size_t available, | ||
82 | const struct sockaddr *addr, socklen_t addrlen, int errCode) | 80 | const struct sockaddr *addr, socklen_t addrlen, int errCode) |
83 | { | 81 | { |
84 | GNUNET_assert (0); | 82 | GNUNET_assert (0); |
@@ -93,8 +91,7 @@ run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
93 | GNUNET_assert (asock != NULL); | 91 | GNUNET_assert (asock != NULL); |
94 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); | 92 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); |
95 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); | 93 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); |
96 | GNUNET_CONNECTION_receive (asock, | 94 | GNUNET_CONNECTION_receive (asock, 1024, |
97 | 1024, | ||
98 | GNUNET_TIME_relative_multiply | 95 | GNUNET_TIME_relative_multiply |
99 | (GNUNET_TIME_UNIT_SECONDS, 5), &dead_receive, cls); | 96 | (GNUNET_TIME_UNIT_SECONDS, 5), &dead_receive, cls); |
100 | } | 97 | } |
@@ -121,10 +118,10 @@ task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
121 | GNUNET_assert (lsock != NULL); | 118 | GNUNET_assert (lsock != NULL); |
122 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); | 119 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); |
123 | GNUNET_assert (csock != NULL); | 120 | GNUNET_assert (csock != NULL); |
124 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 121 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, |
125 | ls, &run_accept_cancel, cls); | 122 | &run_accept_cancel, cls); |
126 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 123 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &receive_cancel_task, |
127 | &receive_cancel_task, cls); | 124 | cls); |
128 | } | 125 | } |
129 | 126 | ||
130 | 127 | ||
@@ -139,8 +136,8 @@ check_receive_cancel () | |||
139 | 136 | ||
140 | ok = 1; | 137 | ok = 1; |
141 | cfg = GNUNET_CONFIGURATION_create (); | 138 | cfg = GNUNET_CONFIGURATION_create (); |
142 | GNUNET_CONFIGURATION_set_value_string (cfg, | 139 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
143 | "resolver", "HOSTNAME", "localhost"); | 140 | "localhost"); |
144 | GNUNET_SCHEDULER_run (&task_receive_cancel, &ok); | 141 | GNUNET_SCHEDULER_run (&task_receive_cancel, &ok); |
145 | GNUNET_CONFIGURATION_destroy (cfg); | 142 | GNUNET_CONFIGURATION_destroy (cfg); |
146 | return ok; | 143 | return ok; |
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c index 3989d654a..2338665cb 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c | |||
@@ -94,8 +94,7 @@ send_kilo (void *cls, size_t size, void *buf) | |||
94 | memset (buf, 42, 1024); | 94 | memset (buf, 42, 1024); |
95 | 95 | ||
96 | GNUNET_assert (NULL != | 96 | GNUNET_assert (NULL != |
97 | GNUNET_CONNECTION_notify_transmit_ready (csock, | 97 | GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, |
98 | 1024, | ||
99 | GNUNET_TIME_UNIT_SECONDS, | 98 | GNUNET_TIME_UNIT_SECONDS, |
100 | &send_kilo, cls)); | 99 | &send_kilo, cls)); |
101 | return 1024; | 100 | return 1024; |
@@ -112,8 +111,7 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
112 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); | 111 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); |
113 | GNUNET_assert (csock != NULL); | 112 | GNUNET_assert (csock != NULL); |
114 | GNUNET_assert (NULL != | 113 | GNUNET_assert (NULL != |
115 | GNUNET_CONNECTION_notify_transmit_ready (csock, | 114 | GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, |
116 | 1024, | ||
117 | GNUNET_TIME_UNIT_SECONDS, | 115 | GNUNET_TIME_UNIT_SECONDS, |
118 | &send_kilo, cls)); | 116 | &send_kilo, cls)); |
119 | } | 117 | } |
@@ -130,8 +128,8 @@ check_timeout () | |||
130 | 128 | ||
131 | ok = 1; | 129 | ok = 1; |
132 | cfg = GNUNET_CONFIGURATION_create (); | 130 | cfg = GNUNET_CONFIGURATION_create (); |
133 | GNUNET_CONFIGURATION_set_value_string (cfg, | 131 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
134 | "resolver", "HOSTNAME", "localhost"); | 132 | "localhost"); |
135 | GNUNET_SCHEDULER_run (&task_timeout, &ok); | 133 | GNUNET_SCHEDULER_run (&task_timeout, &ok); |
136 | GNUNET_CONFIGURATION_destroy (cfg); | 134 | GNUNET_CONFIGURATION_destroy (cfg); |
137 | return ok; | 135 | return ok; |
diff --git a/src/util/test_connection_timeout_no_connect.c b/src/util/test_connection_timeout_no_connect.c index ea4a32412..2e8f9be2e 100644 --- a/src/util/test_connection_timeout_no_connect.c +++ b/src/util/test_connection_timeout_no_connect.c | |||
@@ -57,8 +57,7 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
57 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); | 57 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); |
58 | GNUNET_assert (csock != NULL); | 58 | GNUNET_assert (csock != NULL); |
59 | GNUNET_assert (NULL != | 59 | GNUNET_assert (NULL != |
60 | GNUNET_CONNECTION_notify_transmit_ready (csock, | 60 | GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, |
61 | 1024, | ||
62 | GNUNET_TIME_UNIT_SECONDS, | 61 | GNUNET_TIME_UNIT_SECONDS, |
63 | &handle_timeout, | 62 | &handle_timeout, |
64 | cls)); | 63 | cls)); |
@@ -76,8 +75,8 @@ check_timeout () | |||
76 | 75 | ||
77 | ok = 1; | 76 | ok = 1; |
78 | cfg = GNUNET_CONFIGURATION_create (); | 77 | cfg = GNUNET_CONFIGURATION_create (); |
79 | GNUNET_CONFIGURATION_set_value_string (cfg, | 78 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
80 | "resolver", "HOSTNAME", "localhost"); | 79 | "localhost"); |
81 | GNUNET_SCHEDULER_run (&task_timeout, &ok); | 80 | GNUNET_SCHEDULER_run (&task_timeout, &ok); |
82 | GNUNET_CONFIGURATION_destroy (cfg); | 81 | GNUNET_CONFIGURATION_destroy (cfg); |
83 | return ok; | 82 | return ok; |
diff --git a/src/util/test_connection_transmit_cancel.c b/src/util/test_connection_transmit_cancel.c index 4280edf1d..d81c32a6c 100644 --- a/src/util/test_connection_transmit_cancel.c +++ b/src/util/test_connection_transmit_cancel.c | |||
@@ -51,8 +51,7 @@ task_transmit_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
51 | 51 | ||
52 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); | 52 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); |
53 | GNUNET_assert (csock != NULL); | 53 | GNUNET_assert (csock != NULL); |
54 | th = GNUNET_CONNECTION_notify_transmit_ready (csock, | 54 | th = GNUNET_CONNECTION_notify_transmit_ready (csock, 12, |
55 | 12, | ||
56 | GNUNET_TIME_UNIT_MINUTES, | 55 | GNUNET_TIME_UNIT_MINUTES, |
57 | ¬_run, cls); | 56 | ¬_run, cls); |
58 | GNUNET_assert (NULL != th); | 57 | GNUNET_assert (NULL != th); |
@@ -74,8 +73,8 @@ check_transmit_cancel () | |||
74 | 73 | ||
75 | ok = 1; | 74 | ok = 1; |
76 | cfg = GNUNET_CONFIGURATION_create (); | 75 | cfg = GNUNET_CONFIGURATION_create (); |
77 | GNUNET_CONFIGURATION_set_value_string (cfg, | 76 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
78 | "resolver", "HOSTNAME", "localhost"); | 77 | "localhost"); |
79 | GNUNET_SCHEDULER_run (&task_transmit_cancel, &ok); | 78 | GNUNET_SCHEDULER_run (&task_transmit_cancel, &ok); |
80 | GNUNET_CONFIGURATION_destroy (cfg); | 79 | GNUNET_CONFIGURATION_destroy (cfg); |
81 | return ok; | 80 | return ok; |
diff --git a/src/util/test_container_bloomfilter.c b/src/util/test_container_bloomfilter.c index 49cddac7c..c14adb075 100644 --- a/src/util/test_container_bloomfilter.c +++ b/src/util/test_container_bloomfilter.c | |||
@@ -127,8 +127,8 @@ main (int argc, char *argv[]) | |||
127 | 127 | ||
128 | if (ok2 != 200) | 128 | if (ok2 != 200) |
129 | { | 129 | { |
130 | printf ("Got %d elements out of 200 " | 130 | printf ("Got %d elements out of 200 " "expected after initialization.\n", |
131 | "expected after initialization.\n", ok2); | 131 | ok2); |
132 | GNUNET_CONTAINER_bloomfilter_free (bf); | 132 | GNUNET_CONTAINER_bloomfilter_free (bf); |
133 | GNUNET_CONTAINER_bloomfilter_free (bfi); | 133 | GNUNET_CONTAINER_bloomfilter_free (bfi); |
134 | return -1; | 134 | return -1; |
diff --git a/src/util/test_container_heap.c b/src/util/test_container_heap.c index 7b352241c..62d675bbb 100644 --- a/src/util/test_container_heap.c +++ b/src/util/test_container_heap.c | |||
@@ -29,8 +29,7 @@ | |||
29 | #include "gnunet_container_lib.h" | 29 | #include "gnunet_container_lib.h" |
30 | 30 | ||
31 | static int | 31 | static int |
32 | iterator_callback (void *cls, | 32 | iterator_callback (void *cls, struct GNUNET_CONTAINER_HeapNode *node, |
33 | struct GNUNET_CONTAINER_HeapNode *node, | ||
34 | void *element, GNUNET_CONTAINER_HeapCostType cost) | 33 | void *element, GNUNET_CONTAINER_HeapCostType cost) |
35 | { | 34 | { |
36 | return GNUNET_OK; | 35 | return GNUNET_OK; |
diff --git a/src/util/test_container_meta_data.c b/src/util/test_container_meta_data.c index cee550f96..fe1dd79c1 100644 --- a/src/util/test_container_meta_data.c +++ b/src/util/test_container_meta_data.c | |||
@@ -41,20 +41,17 @@ testMeta (int i) | |||
41 | 41 | ||
42 | m = GNUNET_CONTAINER_meta_data_create (); | 42 | m = GNUNET_CONTAINER_meta_data_create (); |
43 | if (GNUNET_OK != | 43 | if (GNUNET_OK != |
44 | GNUNET_CONTAINER_meta_data_insert (m, | 44 | GNUNET_CONTAINER_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE, |
45 | "<test>", | ||
46 | EXTRACTOR_METATYPE_TITLE, | ||
47 | EXTRACTOR_METAFORMAT_UTF8, | 45 | EXTRACTOR_METAFORMAT_UTF8, |
48 | "text/plain", | 46 | "text/plain", "TestTitle", |
49 | "TestTitle", strlen ("TestTitle") + 1)) | 47 | strlen ("TestTitle") + 1)) |
50 | ABORT (m); | 48 | ABORT (m); |
51 | if (GNUNET_OK != | 49 | if (GNUNET_OK != |
52 | GNUNET_CONTAINER_meta_data_insert (m, | 50 | GNUNET_CONTAINER_meta_data_insert (m, "<test>", |
53 | "<test>", | ||
54 | EXTRACTOR_METATYPE_AUTHOR_NAME, | 51 | EXTRACTOR_METATYPE_AUTHOR_NAME, |
55 | EXTRACTOR_METAFORMAT_UTF8, | 52 | EXTRACTOR_METAFORMAT_UTF8, |
56 | "text/plain", | 53 | "text/plain", "TestTitle", |
57 | "TestTitle", strlen ("TestTitle") + 1)) | 54 | strlen ("TestTitle") + 1)) |
58 | ABORT (m); | 55 | ABORT (m); |
59 | if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", "TestTitle", strlen ("TestTitle") + 1)) /* dup! */ | 56 | if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", "TestTitle", strlen ("TestTitle") + 1)) /* dup! */ |
60 | ABORT (m); | 57 | ABORT (m); |
@@ -63,8 +60,7 @@ testMeta (int i) | |||
63 | if (2 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL)) | 60 | if (2 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL)) |
64 | ABORT (m); | 61 | ABORT (m); |
65 | if (GNUNET_OK != | 62 | if (GNUNET_OK != |
66 | GNUNET_CONTAINER_meta_data_delete (m, | 63 | GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME, |
67 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
68 | "TestTitle", strlen ("TestTitle") + 1)) | 64 | "TestTitle", strlen ("TestTitle") + 1)) |
69 | ABORT (m); | 65 | ABORT (m); |
70 | if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME, "TestTitle", strlen ("TestTitle") + 1)) /* already gone */ | 66 | if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME, "TestTitle", strlen ("TestTitle") + 1)) /* already gone */ |
@@ -72,8 +68,7 @@ testMeta (int i) | |||
72 | if (1 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL)) | 68 | if (1 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL)) |
73 | ABORT (m); | 69 | ABORT (m); |
74 | if (GNUNET_OK != | 70 | if (GNUNET_OK != |
75 | GNUNET_CONTAINER_meta_data_delete (m, | 71 | GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE, |
76 | EXTRACTOR_METATYPE_TITLE, | ||
77 | "TestTitle", strlen ("TestTitle") + 1)) | 72 | "TestTitle", strlen ("TestTitle") + 1)) |
78 | ABORT (m); | 73 | ABORT (m); |
79 | if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE, "TestTitle", strlen ("TestTitle") + 1)) /* already gone */ | 74 | if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE, "TestTitle", strlen ("TestTitle") + 1)) /* already gone */ |
@@ -82,12 +77,10 @@ testMeta (int i) | |||
82 | ABORT (m); | 77 | ABORT (m); |
83 | for (j = 0; j < i; j++) | 78 | for (j = 0; j < i; j++) |
84 | { | 79 | { |
85 | GNUNET_snprintf (val, | 80 | GNUNET_snprintf (val, sizeof (val), "%s.%d", |
86 | sizeof (val), | 81 | "A teststring that should compress well.", j); |
87 | "%s.%d", "A teststring that should compress well.", j); | ||
88 | if (GNUNET_OK != | 82 | if (GNUNET_OK != |
89 | GNUNET_CONTAINER_meta_data_insert (m, | 83 | GNUNET_CONTAINER_meta_data_insert (m, "<test>", |
90 | "<test>", | ||
91 | EXTRACTOR_METATYPE_UNKNOWN, | 84 | EXTRACTOR_METATYPE_UNKNOWN, |
92 | EXTRACTOR_METAFORMAT_UTF8, | 85 | EXTRACTOR_METAFORMAT_UTF8, |
93 | "text/plain", val, strlen (val) + 1)) | 86 | "text/plain", val, strlen (val) + 1)) |
@@ -98,9 +91,9 @@ testMeta (int i) | |||
98 | 91 | ||
99 | size = GNUNET_CONTAINER_meta_data_get_serialized_size (m); | 92 | size = GNUNET_CONTAINER_meta_data_get_serialized_size (m); |
100 | sval = NULL; | 93 | sval = NULL; |
101 | if (size != GNUNET_CONTAINER_meta_data_serialize (m, | 94 | if (size != |
102 | &sval, size, | 95 | GNUNET_CONTAINER_meta_data_serialize (m, &sval, size, |
103 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) | 96 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) |
104 | { | 97 | { |
105 | GNUNET_free_non_null (sval); | 98 | GNUNET_free_non_null (sval); |
106 | ABORT (m); | 99 | ABORT (m); |
@@ -112,13 +105,11 @@ testMeta (int i) | |||
112 | ABORT (m); | 105 | ABORT (m); |
113 | for (j = 0; j < i; j++) | 106 | for (j = 0; j < i; j++) |
114 | { | 107 | { |
115 | GNUNET_snprintf (val, | 108 | GNUNET_snprintf (val, sizeof (val), "%s.%d", |
116 | sizeof (val), "%s.%d", | ||
117 | "A teststring that should compress well.", j); | 109 | "A teststring that should compress well.", j); |
118 | if (GNUNET_OK != | 110 | if (GNUNET_OK != |
119 | GNUNET_CONTAINER_meta_data_delete (m, | 111 | GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_UNKNOWN, val, |
120 | EXTRACTOR_METATYPE_UNKNOWN, | 112 | strlen (val) + 1)) |
121 | val, strlen (val) + 1)) | ||
122 | { | 113 | { |
123 | ABORT (m); | 114 | ABORT (m); |
124 | } | 115 | } |
@@ -142,17 +133,16 @@ testMetaMore (int i) | |||
142 | for (q = 0; q <= i; q++) | 133 | for (q = 0; q <= i; q++) |
143 | { | 134 | { |
144 | GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q); | 135 | GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q); |
145 | GNUNET_CONTAINER_meta_data_insert (meta, | 136 | GNUNET_CONTAINER_meta_data_insert (meta, "<test>", |
146 | "<test>", | ||
147 | q % EXTRACTOR_metatype_get_max (), | 137 | q % EXTRACTOR_metatype_get_max (), |
148 | EXTRACTOR_METAFORMAT_UTF8, | 138 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
149 | "text/plain", txt, strlen (txt) + 1); | 139 | txt, strlen (txt) + 1); |
150 | } | 140 | } |
151 | size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); | 141 | size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); |
152 | data = GNUNET_malloc (size * 4); | 142 | data = GNUNET_malloc (size * 4); |
153 | if (size != GNUNET_CONTAINER_meta_data_serialize (meta, | 143 | if (size != |
154 | &data, size * 4, | 144 | GNUNET_CONTAINER_meta_data_serialize (meta, &data, size * 4, |
155 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) | 145 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) |
156 | { | 146 | { |
157 | GNUNET_free (data); | 147 | GNUNET_free (data); |
158 | ABORT (meta); | 148 | ABORT (meta); |
@@ -171,25 +161,23 @@ testMetaLink () | |||
171 | 161 | ||
172 | m = GNUNET_CONTAINER_meta_data_create (); | 162 | m = GNUNET_CONTAINER_meta_data_create (); |
173 | if (GNUNET_OK != | 163 | if (GNUNET_OK != |
174 | GNUNET_CONTAINER_meta_data_insert (m, | 164 | GNUNET_CONTAINER_meta_data_insert (m, "<test>", |
175 | "<test>", | ||
176 | EXTRACTOR_METATYPE_UNKNOWN, | 165 | EXTRACTOR_METATYPE_UNKNOWN, |
177 | EXTRACTOR_METAFORMAT_UTF8, | 166 | EXTRACTOR_METAFORMAT_UTF8, |
178 | "text/plain", | 167 | "text/plain", "link", |
179 | "link", strlen ("link") + 1)) | 168 | strlen ("link") + 1)) |
180 | ABORT (m); | 169 | ABORT (m); |
181 | if (GNUNET_OK != | 170 | if (GNUNET_OK != |
182 | GNUNET_CONTAINER_meta_data_insert (m, | 171 | GNUNET_CONTAINER_meta_data_insert (m, "<test>", |
183 | "<test>", | ||
184 | EXTRACTOR_METATYPE_FILENAME, | 172 | EXTRACTOR_METATYPE_FILENAME, |
185 | EXTRACTOR_METAFORMAT_UTF8, | 173 | EXTRACTOR_METAFORMAT_UTF8, |
186 | "text/plain", | 174 | "text/plain", "lib-link.m4", |
187 | "lib-link.m4", | ||
188 | strlen ("lib-link.m4") + 1)) | 175 | strlen ("lib-link.m4") + 1)) |
189 | ABORT (m); | 176 | ABORT (m); |
190 | val = NULL; | 177 | val = NULL; |
191 | size = GNUNET_CONTAINER_meta_data_serialize (m, &val, (size_t) - 1, | 178 | size = |
192 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); | 179 | GNUNET_CONTAINER_meta_data_serialize (m, &val, (size_t) - 1, |
180 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); | ||
193 | GNUNET_CONTAINER_meta_data_destroy (m); | 181 | GNUNET_CONTAINER_meta_data_destroy (m); |
194 | m = GNUNET_CONTAINER_meta_data_deserialize (val, size); | 182 | m = GNUNET_CONTAINER_meta_data_deserialize (val, size); |
195 | GNUNET_free (val); | 183 | GNUNET_free (val); |
@@ -215,17 +203,13 @@ check () | |||
215 | for (q = 0; q <= i; q++) | 203 | for (q = 0; q <= i; q++) |
216 | { | 204 | { |
217 | GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q); | 205 | GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q); |
218 | GNUNET_CONTAINER_meta_data_insert (meta, | 206 | GNUNET_CONTAINER_meta_data_insert (meta, "<test>", |
219 | "<test>", | ||
220 | EXTRACTOR_METATYPE_UNKNOWN, | 207 | EXTRACTOR_METATYPE_UNKNOWN, |
221 | EXTRACTOR_METAFORMAT_UTF8, | 208 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
222 | "text/plain", | ||
223 | "TestTitle", strlen ("TestTitle") + 1); | 209 | "TestTitle", strlen ("TestTitle") + 1); |
224 | GNUNET_CONTAINER_meta_data_insert (meta2, | 210 | GNUNET_CONTAINER_meta_data_insert (meta2, "<test>", |
225 | "<test>", | ||
226 | EXTRACTOR_METATYPE_UNKNOWN, | 211 | EXTRACTOR_METATYPE_UNKNOWN, |
227 | EXTRACTOR_METAFORMAT_UTF8, | 212 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
228 | "text/plain", | ||
229 | "TestTitle", strlen ("TestTitle") + 1); | 213 | "TestTitle", strlen ("TestTitle") + 1); |
230 | } | 214 | } |
231 | 215 | ||
@@ -303,9 +287,10 @@ check () | |||
303 | } | 287 | } |
304 | 288 | ||
305 | //check meta_data_get_first_by_types | 289 | //check meta_data_get_first_by_types |
306 | str = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 290 | str = |
307 | EXTRACTOR_METATYPE_UNKNOWN, | 291 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
308 | -1); | 292 | EXTRACTOR_METATYPE_UNKNOWN, |
293 | -1); | ||
309 | GNUNET_assert (NULL != str); | 294 | GNUNET_assert (NULL != str); |
310 | if (str[0] != 'T') | 295 | if (str[0] != 'T') |
311 | { | 296 | { |
diff --git a/src/util/test_container_multihashmap.c b/src/util/test_container_multihashmap.c index c16b2df22..ba621c17e 100644 --- a/src/util/test_container_multihashmap.c +++ b/src/util/test_container_multihashmap.c | |||
@@ -54,27 +54,23 @@ testMap (int i) | |||
54 | CHECK (0 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); | 54 | CHECK (0 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); |
55 | CHECK (0 == GNUNET_CONTAINER_multihashmap_get_multiple (m, &k1, NULL, NULL)); | 55 | CHECK (0 == GNUNET_CONTAINER_multihashmap_get_multiple (m, &k1, NULL, NULL)); |
56 | 56 | ||
57 | CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, | 57 | CHECK (GNUNET_OK == |
58 | &k1, | 58 | GNUNET_CONTAINER_multihashmap_put (m, &k1, "v1", |
59 | "v1", | 59 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); |
60 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); | ||
61 | CHECK (1 == GNUNET_CONTAINER_multihashmap_size (m)); | 60 | CHECK (1 == GNUNET_CONTAINER_multihashmap_size (m)); |
62 | ret = GNUNET_CONTAINER_multihashmap_get (m, &k1); | 61 | ret = GNUNET_CONTAINER_multihashmap_get (m, &k1); |
63 | GNUNET_assert (ret != NULL); | 62 | GNUNET_assert (ret != NULL); |
64 | CHECK (0 == strcmp ("v1", ret)); | 63 | CHECK (0 == strcmp ("v1", ret)); |
65 | CHECK (GNUNET_NO == GNUNET_CONTAINER_multihashmap_put (m, | 64 | CHECK (GNUNET_NO == |
66 | &k1, | 65 | GNUNET_CONTAINER_multihashmap_put (m, &k1, "v1", |
67 | "v1", | 66 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); |
68 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); | ||
69 | CHECK (1 == GNUNET_CONTAINER_multihashmap_size (m)); | 67 | CHECK (1 == GNUNET_CONTAINER_multihashmap_size (m)); |
70 | CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, | 68 | CHECK (GNUNET_OK == |
71 | &k1, | 69 | GNUNET_CONTAINER_multihashmap_put (m, &k1, "v2", |
72 | "v2", | 70 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
73 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 71 | CHECK (GNUNET_OK == |
74 | CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, | 72 | GNUNET_CONTAINER_multihashmap_put (m, &k1, "v3", |
75 | &k1, | 73 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
76 | "v3", | ||
77 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | ||
78 | CHECK (3 == GNUNET_CONTAINER_multihashmap_size (m)); | 74 | CHECK (3 == GNUNET_CONTAINER_multihashmap_size (m)); |
79 | CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (m, &k1, "v3")); | 75 | CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (m, &k1, "v3")); |
80 | CHECK (2 == GNUNET_CONTAINER_multihashmap_size (m)); | 76 | CHECK (2 == GNUNET_CONTAINER_multihashmap_size (m)); |
@@ -85,10 +81,9 @@ testMap (int i) | |||
85 | CHECK (2 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); | 81 | CHECK (2 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); |
86 | CHECK (2 == GNUNET_CONTAINER_multihashmap_remove_all (m, &k1)); | 82 | CHECK (2 == GNUNET_CONTAINER_multihashmap_remove_all (m, &k1)); |
87 | for (j = 0; j < 1024; j++) | 83 | for (j = 0; j < 1024; j++) |
88 | CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, | 84 | CHECK (GNUNET_OK == |
89 | &k1, | 85 | GNUNET_CONTAINER_multihashmap_put (m, &k1, "v2", |
90 | "v2", | 86 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
91 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | ||
92 | GNUNET_CONTAINER_multihashmap_destroy (m); | 87 | GNUNET_CONTAINER_multihashmap_destroy (m); |
93 | return 0; | 88 | return 0; |
94 | } | 89 | } |
diff --git a/src/util/test_container_slist.c b/src/util/test_container_slist.c index 13c12bc5a..4a277dab5 100644 --- a/src/util/test_container_slist.c +++ b/src/util/test_container_slist.c | |||
@@ -46,8 +46,7 @@ main (int argc, char *argv[]) | |||
46 | GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0); | 46 | GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0); |
47 | 47 | ||
48 | for (i = 0; i < 100; i++) | 48 | for (i = 0; i < 100; i++) |
49 | GNUNET_CONTAINER_slist_add (l, | 49 | GNUNET_CONTAINER_slist_add (l, GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, |
50 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, | ||
51 | &i, sizeof (i)); | 50 | &i, sizeof (i)); |
52 | GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 100); | 51 | GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 100); |
53 | 52 | ||
@@ -105,8 +104,7 @@ main (int argc, char *argv[]) | |||
105 | GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0); | 104 | GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0); |
106 | 105 | ||
107 | for (i = 0; i < 100; i++) | 106 | for (i = 0; i < 100; i++) |
108 | GNUNET_CONTAINER_slist_add (l, | 107 | GNUNET_CONTAINER_slist_add (l, GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, |
109 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, | ||
110 | &i, sizeof (i)); | 108 | &i, sizeof (i)); |
111 | /*check slist_append */ | 109 | /*check slist_append */ |
112 | GNUNET_CONTAINER_slist_append (l, l); | 110 | GNUNET_CONTAINER_slist_append (l, l); |
@@ -145,8 +143,7 @@ main (int argc, char *argv[]) | |||
145 | { | 143 | { |
146 | ip = GNUNET_malloc (sizeof (int)); | 144 | ip = GNUNET_malloc (sizeof (int)); |
147 | *ip = i; | 145 | *ip = i; |
148 | GNUNET_CONTAINER_slist_add (l, | 146 | GNUNET_CONTAINER_slist_add (l, GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC, |
149 | GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC, | ||
150 | ip, sizeof (int)); | 147 | ip, sizeof (int)); |
151 | } | 148 | } |
152 | //creat_add | 149 | //creat_add |
diff --git a/src/util/test_crypto_aes.c b/src/util/test_crypto_aes.c index 968c7f40f..971e9afbe 100644 --- a/src/util/test_crypto_aes.c +++ b/src/util/test_crypto_aes.c | |||
@@ -39,22 +39,21 @@ testSymcipher () | |||
39 | char res[100]; | 39 | char res[100]; |
40 | 40 | ||
41 | GNUNET_CRYPTO_aes_create_session_key (&key); | 41 | GNUNET_CRYPTO_aes_create_session_key (&key); |
42 | size = GNUNET_CRYPTO_aes_encrypt (TESTSTRING, | 42 | size = |
43 | strlen (TESTSTRING) + 1, | 43 | GNUNET_CRYPTO_aes_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &key, |
44 | &key, | 44 | (const struct |
45 | (const struct | 45 | GNUNET_CRYPTO_AesInitializationVector *) |
46 | GNUNET_CRYPTO_AesInitializationVector *) | 46 | INITVALUE, result); |
47 | INITVALUE, result); | ||
48 | if (size == -1) | 47 | if (size == -1) |
49 | { | 48 | { |
50 | printf ("symciphertest failed: encryptBlock returned %d\n", size); | 49 | printf ("symciphertest failed: encryptBlock returned %d\n", size); |
51 | return 1; | 50 | return 1; |
52 | } | 51 | } |
53 | size = GNUNET_CRYPTO_aes_decrypt (result, size, | 52 | size = |
54 | &key, | 53 | GNUNET_CRYPTO_aes_decrypt (result, size, &key, |
55 | (const struct | 54 | (const struct |
56 | GNUNET_CRYPTO_AesInitializationVector *) | 55 | GNUNET_CRYPTO_AesInitializationVector *) |
57 | INITVALUE, res); | 56 | INITVALUE, res); |
58 | if (strlen (TESTSTRING) + 1 != size) | 57 | if (strlen (TESTSTRING) + 1 != size) |
59 | { | 58 | { |
60 | printf ("symciphertest failed: decryptBlock returned %d\n", size); | 59 | printf ("symciphertest failed: decryptBlock returned %d\n", size); |
@@ -101,17 +100,15 @@ verifyCrypto () | |||
101 | 100 | ||
102 | if (ntohl (key.crc32) != (unsigned int) 38125195LL) | 101 | if (ntohl (key.crc32) != (unsigned int) 38125195LL) |
103 | { | 102 | { |
104 | printf ("Static key has different CRC: %u - %u\n", | 103 | printf ("Static key has different CRC: %u - %u\n", ntohl (key.crc32), |
105 | ntohl (key.crc32), key.crc32); | 104 | key.crc32); |
106 | 105 | ||
107 | ret = 1; | 106 | ret = 1; |
108 | goto error; | 107 | goto error; |
109 | } | 108 | } |
110 | 109 | ||
111 | if (GNUNET_CRYPTO_AES_KEY_LENGTH != | 110 | if (GNUNET_CRYPTO_AES_KEY_LENGTH != |
112 | GNUNET_CRYPTO_aes_encrypt (plain, | 111 | GNUNET_CRYPTO_aes_encrypt (plain, GNUNET_CRYPTO_AES_KEY_LENGTH, &key, |
113 | GNUNET_CRYPTO_AES_KEY_LENGTH, | ||
114 | &key, | ||
115 | (const struct | 112 | (const struct |
116 | GNUNET_CRYPTO_AesInitializationVector *) | 113 | GNUNET_CRYPTO_AesInitializationVector *) |
117 | "testtesttesttest", result)) | 114 | "testtesttesttest", result)) |
@@ -131,9 +128,7 @@ verifyCrypto () | |||
131 | res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH); | 128 | res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH); |
132 | 129 | ||
133 | if (GNUNET_CRYPTO_AES_KEY_LENGTH != | 130 | if (GNUNET_CRYPTO_AES_KEY_LENGTH != |
134 | GNUNET_CRYPTO_aes_decrypt (result, | 131 | GNUNET_CRYPTO_aes_decrypt (result, GNUNET_CRYPTO_AES_KEY_LENGTH, &key, |
135 | GNUNET_CRYPTO_AES_KEY_LENGTH, | ||
136 | &key, | ||
137 | (const struct | 132 | (const struct |
138 | GNUNET_CRYPTO_AesInitializationVector *) | 133 | GNUNET_CRYPTO_AesInitializationVector *) |
139 | "testtesttesttest", res)) | 134 | "testtesttesttest", res)) |
diff --git a/src/util/test_crypto_aes_weak.c b/src/util/test_crypto_aes_weak.c index f54835b3d..a0161b575 100644 --- a/src/util/test_crypto_aes_weak.c +++ b/src/util/test_crypto_aes_weak.c | |||
@@ -94,9 +94,10 @@ testWeakKey () | |||
94 | weak_key.crc32 = | 94 | weak_key.crc32 = |
95 | htonl (GNUNET_CRYPTO_crc32_n (&weak_key, GNUNET_CRYPTO_AES_KEY_LENGTH)); | 95 | htonl (GNUNET_CRYPTO_crc32_n (&weak_key, GNUNET_CRYPTO_AES_KEY_LENGTH)); |
96 | 96 | ||
97 | size = GNUNET_CRYPTO_aes_encrypt (WEAK_KEY_TESTSTRING, | 97 | size = |
98 | strlen (WEAK_KEY_TESTSTRING) + 1, | 98 | GNUNET_CRYPTO_aes_encrypt (WEAK_KEY_TESTSTRING, |
99 | &weak_key, &INITVALUE, result); | 99 | strlen (WEAK_KEY_TESTSTRING) + 1, &weak_key, |
100 | &INITVALUE, result); | ||
100 | 101 | ||
101 | if (size == -1) | 102 | if (size == -1) |
102 | { | 103 | { |
@@ -139,8 +140,8 @@ getWeakKeys () | |||
139 | /*printf("Got to run number %d.\n", number_of_runs); */ | 140 | /*printf("Got to run number %d.\n", number_of_runs); */ |
140 | GNUNET_CRYPTO_aes_create_session_key (&sessionkey); | 141 | GNUNET_CRYPTO_aes_create_session_key (&sessionkey); |
141 | 142 | ||
142 | rc = gcry_cipher_open (&handle, | 143 | rc = gcry_cipher_open (&handle, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CFB, |
143 | GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CFB, 0); | 144 | 0); |
144 | 145 | ||
145 | if (rc) | 146 | if (rc) |
146 | { | 147 | { |
@@ -188,8 +189,8 @@ main (int argc, char *argv[]) | |||
188 | } | 189 | } |
189 | else | 190 | else |
190 | { | 191 | { |
191 | printf ("\n%d weak keys found in %d runs.\n", | 192 | printf ("\n%d weak keys found in %d runs.\n", weak_keys, |
192 | weak_keys, MAX_WEAK_KEY_TRIALS); | 193 | MAX_WEAK_KEY_TRIALS); |
193 | } | 194 | } |
194 | } | 195 | } |
195 | 196 | ||
diff --git a/src/util/test_crypto_hkdf.c b/src/util/test_crypto_hkdf.c index a9b742922..752116194 100644 --- a/src/util/test_crypto_hkdf.c +++ b/src/util/test_crypto_hkdf.c | |||
@@ -43,8 +43,8 @@ tc1 () | |||
43 | { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, | 43 | { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, |
44 | 0x0a, 0x0b, 0x0c | 44 | 0x0a, 0x0b, 0x0c |
45 | }; | 45 | }; |
46 | unsigned char | 46 | unsigned char info[10] = |
47 | info[10] = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }; | 47 | { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }; |
48 | unsigned char okm[42] = | 48 | unsigned char okm[42] = |
49 | { 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, 0x90, 0x43, | 49 | { 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, 0x90, 0x43, |
50 | 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a, 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, | 50 | 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a, 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, |
@@ -149,8 +149,8 @@ tc4 () | |||
149 | { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, | 149 | { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, |
150 | 0x0a, 0x0b, 0x0c | 150 | 0x0a, 0x0b, 0x0c |
151 | }; | 151 | }; |
152 | unsigned char | 152 | unsigned char info[10] = |
153 | info[10] = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }; | 153 | { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }; |
154 | unsigned char okm[42] = | 154 | unsigned char okm[42] = |
155 | { 0x08, 0x5a, 0x01, 0xea, 0x1b, 0x10, 0xf3, 0x69, 0x33, 0x06, | 155 | { 0x08, 0x5a, 0x01, 0xea, 0x1b, 0x10, 0xf3, 0x69, 0x33, 0x06, |
156 | 0x8b, 0x56, 0xef, 0xa5, 0xad, 0x81, 0xa4, 0xf1, 0x4b, 0x82, 0x2f, 0x5b, | 156 | 0x8b, 0x56, 0xef, 0xa5, 0xad, 0x81, 0xa4, 0xf1, 0x4b, 0x82, 0x2f, 0x5b, |
diff --git a/src/util/test_crypto_ksk.c b/src/util/test_crypto_ksk.c index 184f9f137..d4340f3ea 100644 --- a/src/util/test_crypto_ksk.c +++ b/src/util/test_crypto_ksk.c | |||
@@ -66,9 +66,8 @@ testCorrectKey () | |||
66 | snprintf (out, sizeof (out), "%02x", ((unsigned char *) &pkey)[i]); | 66 | snprintf (out, sizeof (out), "%02x", ((unsigned char *) &pkey)[i]); |
67 | if (0 != strncmp (out, &want[i * 2], 2)) | 67 | if (0 != strncmp (out, &want[i * 2], 2)) |
68 | { | 68 | { |
69 | fprintf (stderr, | 69 | fprintf (stderr, " Failed! Wanted %.2s but got %2s at %d\n", &want[i * 2], |
70 | " Failed! Wanted %.2s but got %2s at %d\n", | 70 | out, i); |
71 | &want[i * 2], out, i); | ||
72 | return GNUNET_SYSERR; | 71 | return GNUNET_SYSERR; |
73 | } | 72 | } |
74 | } | 73 | } |
@@ -144,17 +143,17 @@ testEncryptDecrypt (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
144 | for (i = 0; i < ITER; i++) | 143 | for (i = 0; i < ITER; i++) |
145 | { | 144 | { |
146 | fprintf (stderr, "."); | 145 | fprintf (stderr, "."); |
147 | if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, | 146 | if (GNUNET_SYSERR == |
148 | strlen (TESTSTRING) + 1, | 147 | GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &pkey, |
149 | &pkey, &target)) | 148 | &target)) |
150 | { | 149 | { |
151 | fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); | 150 | fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); |
152 | ok++; | 151 | ok++; |
153 | continue; | 152 | continue; |
154 | } | 153 | } |
155 | if (-1 == GNUNET_CRYPTO_rsa_decrypt (hostkey, | 154 | if (-1 == |
156 | &target, result, | 155 | GNUNET_CRYPTO_rsa_decrypt (hostkey, &target, result, |
157 | strlen (TESTSTRING) + 1)) | 156 | strlen (TESTSTRING) + 1)) |
158 | { | 157 | { |
159 | fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); | 158 | fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); |
160 | ok++; | 159 | ok++; |
@@ -162,16 +161,15 @@ testEncryptDecrypt (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
162 | } | 161 | } |
163 | if (strncmp (TESTSTRING, result, strlen (TESTSTRING)) != 0) | 162 | if (strncmp (TESTSTRING, result, strlen (TESTSTRING)) != 0) |
164 | { | 163 | { |
165 | printf ("%s != %.*s - testEncryptDecrypt failed!\n", | 164 | printf ("%s != %.*s - testEncryptDecrypt failed!\n", TESTSTRING, |
166 | TESTSTRING, MAX_TESTVAL, result); | 165 | MAX_TESTVAL, result); |
167 | ok++; | 166 | ok++; |
168 | continue; | 167 | continue; |
169 | } | 168 | } |
170 | } | 169 | } |
171 | printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", | 170 | printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", ITER, |
172 | ITER, | 171 | (unsigned long long) GNUNET_TIME_absolute_get_duration (start). |
173 | (unsigned long long) | 172 | rel_value, ok); |
174 | GNUNET_TIME_absolute_get_duration (start).rel_value, ok); | ||
175 | if (ok == 0) | 173 | if (ok == 0) |
176 | return GNUNET_OK; | 174 | return GNUNET_OK; |
177 | else | 175 | else |
@@ -203,26 +201,25 @@ testSignVerify (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
203 | continue; | 201 | continue; |
204 | } | 202 | } |
205 | if (GNUNET_SYSERR == | 203 | if (GNUNET_SYSERR == |
206 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, | 204 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, &purp, &sig, |
207 | &purp, &sig, &pkey)) | 205 | &pkey)) |
208 | { | 206 | { |
209 | printf ("GNUNET_CRYPTO_rsa_verify failed!\n"); | 207 | printf ("GNUNET_CRYPTO_rsa_verify failed!\n"); |
210 | ok = GNUNET_SYSERR; | 208 | ok = GNUNET_SYSERR; |
211 | continue; | 209 | continue; |
212 | } | 210 | } |
213 | if (GNUNET_SYSERR != | 211 | if (GNUNET_SYSERR != |
214 | GNUNET_CRYPTO_rsa_verify | 212 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, |
215 | (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, &purp, &sig, &pkey)) | 213 | &purp, &sig, &pkey)) |
216 | { | 214 | { |
217 | printf ("GNUNET_CRYPTO_rsa_verify failed to fail!\n"); | 215 | printf ("GNUNET_CRYPTO_rsa_verify failed to fail!\n"); |
218 | ok = GNUNET_SYSERR; | 216 | ok = GNUNET_SYSERR; |
219 | continue; | 217 | continue; |
220 | } | 218 | } |
221 | } | 219 | } |
222 | printf ("%d RSA sign/verify operations %llums\n", | 220 | printf ("%d RSA sign/verify operations %llums\n", ITER, |
223 | ITER, | 221 | (unsigned long long) GNUNET_TIME_absolute_get_duration (start). |
224 | (unsigned long long) | 222 | rel_value); |
225 | GNUNET_TIME_absolute_get_duration (start).rel_value); | ||
226 | return ok; | 223 | return ok; |
227 | } | 224 | } |
228 | 225 | ||
diff --git a/src/util/test_crypto_rsa.c b/src/util/test_crypto_rsa.c index d7c23731e..bf058d285 100644 --- a/src/util/test_crypto_rsa.c +++ b/src/util/test_crypto_rsa.c | |||
@@ -56,17 +56,17 @@ testEncryptDecrypt () | |||
56 | for (i = 0; i < ITER; i++) | 56 | for (i = 0; i < ITER; i++) |
57 | { | 57 | { |
58 | fprintf (stderr, "."); | 58 | fprintf (stderr, "."); |
59 | if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, | 59 | if (GNUNET_SYSERR == |
60 | strlen (TESTSTRING) + 1, | 60 | GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &pkey, |
61 | &pkey, &target)) | 61 | &target)) |
62 | { | 62 | { |
63 | fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); | 63 | fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); |
64 | ok++; | 64 | ok++; |
65 | continue; | 65 | continue; |
66 | } | 66 | } |
67 | if (-1 == GNUNET_CRYPTO_rsa_decrypt (hostkey, | 67 | if (-1 == |
68 | &target, result, | 68 | GNUNET_CRYPTO_rsa_decrypt (hostkey, &target, result, |
69 | strlen (TESTSTRING) + 1)) | 69 | strlen (TESTSTRING) + 1)) |
70 | { | 70 | { |
71 | fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); | 71 | fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); |
72 | ok++; | 72 | ok++; |
@@ -75,16 +75,15 @@ testEncryptDecrypt () | |||
75 | } | 75 | } |
76 | if (strncmp (TESTSTRING, result, strlen (TESTSTRING)) != 0) | 76 | if (strncmp (TESTSTRING, result, strlen (TESTSTRING)) != 0) |
77 | { | 77 | { |
78 | printf ("%s != %.*s - testEncryptDecrypt failed!\n", | 78 | printf ("%s != %.*s - testEncryptDecrypt failed!\n", TESTSTRING, |
79 | TESTSTRING, (int) MAX_TESTVAL, result); | 79 | (int) MAX_TESTVAL, result); |
80 | ok++; | 80 | ok++; |
81 | continue; | 81 | continue; |
82 | } | 82 | } |
83 | } | 83 | } |
84 | printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", | 84 | printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", ITER, |
85 | ITER, | 85 | (unsigned long long) GNUNET_TIME_absolute_get_duration (start). |
86 | (unsigned long long) | 86 | rel_value, ok); |
87 | GNUNET_TIME_absolute_get_duration (start).rel_value, ok); | ||
88 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 87 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
89 | if (ok == 0) | 88 | if (ok == 0) |
90 | return GNUNET_OK; | 89 | return GNUNET_OK; |
@@ -112,19 +111,18 @@ testEncryptPerformance () | |||
112 | for (i = 0; i < ITER; i++) | 111 | for (i = 0; i < ITER; i++) |
113 | { | 112 | { |
114 | fprintf (stderr, "."); | 113 | fprintf (stderr, "."); |
115 | if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, | 114 | if (GNUNET_SYSERR == |
116 | strlen (TESTSTRING) + 1, | 115 | GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &pkey, |
117 | &pkey, &target)) | 116 | &target)) |
118 | { | 117 | { |
119 | fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); | 118 | fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); |
120 | ok++; | 119 | ok++; |
121 | continue; | 120 | continue; |
122 | } | 121 | } |
123 | } | 122 | } |
124 | printf ("%d RSA encrypt operations %llu ms (%d failures)\n", | 123 | printf ("%d RSA encrypt operations %llu ms (%d failures)\n", ITER, |
125 | ITER, | 124 | (unsigned long long) GNUNET_TIME_absolute_get_duration (start). |
126 | (unsigned long long) | 125 | rel_value, ok); |
127 | GNUNET_TIME_absolute_get_duration (start).rel_value, ok); | ||
128 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 126 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
129 | if (ok != 0) | 127 | if (ok != 0) |
130 | return GNUNET_SYSERR; | 128 | return GNUNET_SYSERR; |
@@ -154,19 +152,18 @@ testEncryptDecryptSK () | |||
154 | { | 152 | { |
155 | fprintf (stderr, "."); | 153 | fprintf (stderr, "."); |
156 | GNUNET_CRYPTO_aes_create_session_key (&insk); | 154 | GNUNET_CRYPTO_aes_create_session_key (&insk); |
157 | if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (&insk, | 155 | if (GNUNET_SYSERR == |
158 | sizeof (struct | 156 | GNUNET_CRYPTO_rsa_encrypt (&insk, |
159 | GNUNET_CRYPTO_AesSessionKey), | 157 | sizeof (struct GNUNET_CRYPTO_AesSessionKey), |
160 | &pkey, &target)) | 158 | &pkey, &target)) |
161 | { | 159 | { |
162 | fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); | 160 | fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); |
163 | ok++; | 161 | ok++; |
164 | continue; | 162 | continue; |
165 | } | 163 | } |
166 | if (-1 == GNUNET_CRYPTO_rsa_decrypt (hostkey, | 164 | if (-1 == |
167 | &target, &outsk, | 165 | GNUNET_CRYPTO_rsa_decrypt (hostkey, &target, &outsk, |
168 | sizeof (struct | 166 | sizeof (struct GNUNET_CRYPTO_AesSessionKey))) |
169 | GNUNET_CRYPTO_AesSessionKey))) | ||
170 | { | 167 | { |
171 | fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); | 168 | fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); |
172 | ok++; | 169 | ok++; |
@@ -180,10 +177,9 @@ testEncryptDecryptSK () | |||
180 | continue; | 177 | continue; |
181 | } | 178 | } |
182 | } | 179 | } |
183 | printf ("%d RSA encrypt/decrypt SK operations %llums (%d failures)\n", | 180 | printf ("%d RSA encrypt/decrypt SK operations %llums (%d failures)\n", ITER, |
184 | ITER, | 181 | (unsigned long long) GNUNET_TIME_absolute_get_duration (start). |
185 | (unsigned long long) | 182 | rel_value, ok); |
186 | GNUNET_TIME_absolute_get_duration (start).rel_value, ok); | ||
187 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 183 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
188 | if (ok != 0) | 184 | if (ok != 0) |
189 | return GNUNET_SYSERR; | 185 | return GNUNET_SYSERR; |
@@ -219,26 +215,25 @@ testSignVerify () | |||
219 | continue; | 215 | continue; |
220 | } | 216 | } |
221 | if (GNUNET_SYSERR == | 217 | if (GNUNET_SYSERR == |
222 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, | 218 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, &purp, &sig, |
223 | &purp, &sig, &pkey)) | 219 | &pkey)) |
224 | { | 220 | { |
225 | printf ("GNUNET_CRYPTO_rsa_verify failed!\n"); | 221 | printf ("GNUNET_CRYPTO_rsa_verify failed!\n"); |
226 | ok = GNUNET_SYSERR; | 222 | ok = GNUNET_SYSERR; |
227 | continue; | 223 | continue; |
228 | } | 224 | } |
229 | if (GNUNET_SYSERR != | 225 | if (GNUNET_SYSERR != |
230 | GNUNET_CRYPTO_rsa_verify | 226 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, |
231 | (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, &purp, &sig, &pkey)) | 227 | &purp, &sig, &pkey)) |
232 | { | 228 | { |
233 | printf ("GNUNET_CRYPTO_rsa_verify failed to fail!\n"); | 229 | printf ("GNUNET_CRYPTO_rsa_verify failed to fail!\n"); |
234 | ok = GNUNET_SYSERR; | 230 | ok = GNUNET_SYSERR; |
235 | continue; | 231 | continue; |
236 | } | 232 | } |
237 | } | 233 | } |
238 | printf ("%d RSA sign/verify operations %llums\n", | 234 | printf ("%d RSA sign/verify operations %llums\n", ITER, |
239 | ITER, | 235 | (unsigned long long) GNUNET_TIME_absolute_get_duration (start). |
240 | (unsigned long long) | 236 | rel_value); |
241 | GNUNET_TIME_absolute_get_duration (start).rel_value); | ||
242 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 237 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
243 | return ok; | 238 | return ok; |
244 | } | 239 | } |
@@ -273,8 +268,8 @@ testSignPerformance () | |||
273 | } | 268 | } |
274 | } | 269 | } |
275 | printf ("%d RSA sign operations %llu ms\n", ITER, | 270 | printf ("%d RSA sign operations %llu ms\n", ITER, |
276 | (unsigned long long) | 271 | (unsigned long long) GNUNET_TIME_absolute_get_duration (start). |
277 | GNUNET_TIME_absolute_get_duration (start).rel_value); | 272 | rel_value); |
278 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 273 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
279 | return ok; | 274 | return ok; |
280 | } | 275 | } |
diff --git a/src/util/test_disk.c b/src/util/test_disk.c index d8d8021e5..91154a6f5 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c | |||
@@ -37,8 +37,7 @@ testReadWrite () | |||
37 | int ret; | 37 | int ret; |
38 | 38 | ||
39 | if (strlen (TESTSTRING) != | 39 | if (strlen (TESTSTRING) != |
40 | GNUNET_DISK_fn_write (".testfile", TESTSTRING, | 40 | GNUNET_DISK_fn_write (".testfile", TESTSTRING, strlen (TESTSTRING), |
41 | strlen (TESTSTRING), | ||
42 | GNUNET_DISK_PERM_USER_READ | | 41 | GNUNET_DISK_PERM_USER_READ | |
43 | GNUNET_DISK_PERM_USER_WRITE)) | 42 | GNUNET_DISK_PERM_USER_WRITE)) |
44 | return 1; | 43 | return 1; |
@@ -53,9 +52,8 @@ testReadWrite () | |||
53 | tmp[ret] = '\0'; | 52 | tmp[ret] = '\0'; |
54 | if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1)) | 53 | if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1)) |
55 | { | 54 | { |
56 | fprintf (stderr, | 55 | fprintf (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp, |
57 | "Error in testReadWrite: *%s* != *%s* for file %s\n", | 56 | TESTSTRING, ".testfile"); |
58 | tmp, TESTSTRING, ".testfile"); | ||
59 | return 1; | 57 | return 1; |
60 | } | 58 | } |
61 | GNUNET_DISK_file_copy (".testfile", ".testfile2"); | 59 | GNUNET_DISK_file_copy (".testfile", ".testfile2"); |
@@ -63,16 +61,15 @@ testReadWrite () | |||
63 | ret = GNUNET_DISK_fn_read (".testfile2", tmp, sizeof (tmp) - 1); | 61 | ret = GNUNET_DISK_fn_read (".testfile2", tmp, sizeof (tmp) - 1); |
64 | if (ret < 0) | 62 | if (ret < 0) |
65 | { | 63 | { |
66 | fprintf (stderr, | 64 | fprintf (stderr, "Error reading file `%s' in testReadWrite\n", |
67 | "Error reading file `%s' in testReadWrite\n", ".testfile2"); | 65 | ".testfile2"); |
68 | return 1; | 66 | return 1; |
69 | } | 67 | } |
70 | tmp[ret] = '\0'; | 68 | tmp[ret] = '\0'; |
71 | if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1)) | 69 | if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1)) |
72 | { | 70 | { |
73 | fprintf (stderr, | 71 | fprintf (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp, |
74 | "Error in testReadWrite: *%s* != *%s* for file %s\n", | 72 | TESTSTRING, ".testfile2"); |
75 | tmp, TESTSTRING, ".testfile2"); | ||
76 | return 1; | 73 | return 1; |
77 | } | 74 | } |
78 | 75 | ||
@@ -91,8 +88,9 @@ testOpenClose () | |||
91 | uint64_t size; | 88 | uint64_t size; |
92 | long avail; | 89 | long avail; |
93 | 90 | ||
94 | fh = GNUNET_DISK_file_open (".testfile", GNUNET_DISK_OPEN_READWRITE | 91 | fh = GNUNET_DISK_file_open (".testfile", |
95 | | GNUNET_DISK_OPEN_CREATE, | 92 | GNUNET_DISK_OPEN_READWRITE | |
93 | GNUNET_DISK_OPEN_CREATE, | ||
96 | GNUNET_DISK_PERM_USER_READ | | 94 | GNUNET_DISK_PERM_USER_READ | |
97 | GNUNET_DISK_PERM_USER_WRITE); | 95 | GNUNET_DISK_PERM_USER_WRITE); |
98 | GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh)); | 96 | GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh)); |
@@ -108,8 +106,9 @@ testOpenClose () | |||
108 | GNUNET_log_skip (1, GNUNET_NO); | 106 | GNUNET_log_skip (1, GNUNET_NO); |
109 | avail = GNUNET_DISK_get_blocks_available (".testfile"); | 107 | avail = GNUNET_DISK_get_blocks_available (".testfile"); |
110 | GNUNET_log_skip (0, GNUNET_NO); | 108 | GNUNET_log_skip (0, GNUNET_NO); |
111 | fh = GNUNET_DISK_file_open (".testfile", GNUNET_DISK_OPEN_READWRITE | 109 | fh = GNUNET_DISK_file_open (".testfile", |
112 | | GNUNET_DISK_OPEN_CREATE, | 110 | GNUNET_DISK_OPEN_READWRITE | |
111 | GNUNET_DISK_OPEN_CREATE, | ||
113 | GNUNET_DISK_PERM_USER_WRITE | | 112 | GNUNET_DISK_PERM_USER_WRITE | |
114 | GNUNET_DISK_PERM_USER_READ); | 113 | GNUNET_DISK_PERM_USER_READ); |
115 | GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh)); | 114 | GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh)); |
@@ -156,8 +155,7 @@ testDirScan () | |||
156 | } | 155 | } |
157 | 156 | ||
158 | static void | 157 | static void |
159 | iter_callback (void *cls, | 158 | iter_callback (void *cls, struct GNUNET_DISK_DirectoryIterator *di, |
160 | struct GNUNET_DISK_DirectoryIterator *di, | ||
161 | const char *filename, const char *dirname) | 159 | const char *filename, const char *dirname) |
162 | { | 160 | { |
163 | int *i = cls; | 161 | int *i = cls; |
diff --git a/src/util/test_os_network.c b/src/util/test_os_network.c index e92eba2c9..583a5fb82 100644 --- a/src/util/test_os_network.c +++ b/src/util/test_os_network.c | |||
@@ -34,9 +34,8 @@ | |||
34 | * (success). | 34 | * (success). |
35 | */ | 35 | */ |
36 | static int | 36 | static int |
37 | proc (void *cls, | 37 | proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr, |
38 | const char *name, | 38 | socklen_t addrlen) |
39 | int isDefault, const struct sockaddr *addr, socklen_t addrlen) | ||
40 | { | 39 | { |
41 | int *ok = cls; | 40 | int *ok = cls; |
42 | char buf[INET6_ADDRSTRLEN]; | 41 | char buf[INET6_ADDRSTRLEN]; |
@@ -45,9 +44,9 @@ proc (void *cls, | |||
45 | return GNUNET_OK; | 44 | return GNUNET_OK; |
46 | 45 | ||
47 | inet_ntop (addr->sa_family, | 46 | inet_ntop (addr->sa_family, |
48 | (addr->sa_family == AF_INET) ? | 47 | (addr->sa_family == |
49 | (void *) &((struct sockaddr_in *) addr)->sin_addr : | 48 | AF_INET) ? (void *) &((struct sockaddr_in *) addr)-> |
50 | (void *) &((struct sockaddr_in6 *) addr)->sin6_addr, | 49 | sin_addr : (void *) &((struct sockaddr_in6 *) addr)->sin6_addr, |
51 | buf, sizeof (buf)); | 50 | buf, sizeof (buf)); |
52 | if ((0 == strcmp ("::1", buf)) || (0 == strcmp ("127.0.0.1", buf))) | 51 | if ((0 == strcmp ("::1", buf)) || (0 == strcmp ("127.0.0.1", buf))) |
53 | *ok = 0; | 52 | *ok = 0; |
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index 4137118fa..36dd42a23 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c | |||
@@ -125,8 +125,9 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | proc = GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn, | 128 | proc = |
129 | "test_gnunet_echo_hello", "-", NULL); | 129 | GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn, |
130 | "test_gnunet_echo_hello", "-", NULL); | ||
130 | GNUNET_free (fn); | 131 | GNUNET_free (fn); |
131 | 132 | ||
132 | /* Close the write end of the read pipe */ | 133 | /* Close the write end of the read pipe */ |
diff --git a/src/util/test_program.c b/src/util/test_program.c index 9ea5b1510..faeb4e716 100644 --- a/src/util/test_program.c +++ b/src/util/test_program.c | |||
@@ -57,9 +57,8 @@ static struct GNUNET_GETOPT_CommandLineOption options4[] = { | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | static void | 59 | static void |
60 | runner (void *cls, | 60 | runner (void *cls, char *const *args, const char *cfgfile, |
61 | char *const *args, | 61 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
62 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
63 | { | 62 | { |
64 | int *ok = cls; | 63 | int *ok = cls; |
65 | 64 | ||
@@ -92,26 +91,18 @@ check () | |||
92 | }; | 91 | }; |
93 | 92 | ||
94 | GNUNET_assert (GNUNET_OK == | 93 | GNUNET_assert (GNUNET_OK == |
95 | GNUNET_PROGRAM_run (7, | 94 | GNUNET_PROGRAM_run (7, argv, "test_program", "A test", |
96 | argv, | 95 | options1, &runner, &ok)); |
97 | "test_program", | ||
98 | "A test", options1, &runner, &ok)); | ||
99 | 96 | ||
100 | GNUNET_assert (GNUNET_OK == | 97 | GNUNET_assert (GNUNET_OK == |
101 | GNUNET_PROGRAM_run (7, | 98 | GNUNET_PROGRAM_run (7, argv, "test_program", "A test", |
102 | argv, | 99 | options2, &runner, &ok)); |
103 | "test_program", | ||
104 | "A test", options2, &runner, &ok)); | ||
105 | GNUNET_assert (GNUNET_OK == | 100 | GNUNET_assert (GNUNET_OK == |
106 | GNUNET_PROGRAM_run (7, | 101 | GNUNET_PROGRAM_run (7, argv, "test_program", "A test", |
107 | argv, | 102 | options3, &runner, &ok)); |
108 | "test_program", | ||
109 | "A test", options3, &runner, &ok)); | ||
110 | GNUNET_assert (GNUNET_OK == | 103 | GNUNET_assert (GNUNET_OK == |
111 | GNUNET_PROGRAM_run (7, | 104 | GNUNET_PROGRAM_run (7, argv, "test_program", "A test", |
112 | argv, | 105 | options4, &runner, &ok)); |
113 | "test_program", | ||
114 | "A test", options4, &runner, &ok)); | ||
115 | 106 | ||
116 | return ok; | 107 | return ok; |
117 | } | 108 | } |
diff --git a/src/util/test_pseudonym.c b/src/util/test_pseudonym.c index dfdcbb1bb..20a3d3d96 100644 --- a/src/util/test_pseudonym.c +++ b/src/util/test_pseudonym.c | |||
@@ -38,15 +38,12 @@ static struct GNUNET_CONTAINER_MetaData *meta; | |||
38 | static GNUNET_HashCode id1; | 38 | static GNUNET_HashCode id1; |
39 | 39 | ||
40 | static int | 40 | static int |
41 | iter (void *cls, | 41 | iter (void *cls, const GNUNET_HashCode * pseudonym, |
42 | const GNUNET_HashCode * | 42 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
43 | pseudonym, const struct GNUNET_CONTAINER_MetaData *md, int rating) | ||
44 | { | 43 | { |
45 | int *ok = cls; | 44 | int *ok = cls; |
46 | 45 | ||
47 | if ((0 == memcmp (pseudonym, | 46 | if ((0 == memcmp (pseudonym, &id1, sizeof (GNUNET_HashCode))) && |
48 | &id1, | ||
49 | sizeof (GNUNET_HashCode))) && | ||
50 | (!GNUNET_CONTAINER_meta_data_test_equal (md, meta))) | 47 | (!GNUNET_CONTAINER_meta_data_test_equal (md, meta))) |
51 | { | 48 | { |
52 | *ok = GNUNET_NO; | 49 | *ok = GNUNET_NO; |
@@ -56,9 +53,7 @@ iter (void *cls, | |||
56 | } | 53 | } |
57 | 54 | ||
58 | static int | 55 | static int |
59 | noti_callback (void *cls, | 56 | noti_callback (void *cls, const GNUNET_HashCode * pseudonym, |
60 | const GNUNET_HashCode * | ||
61 | pseudonym, | ||
62 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 57 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
63 | { | 58 | { |
64 | int *ret = cls; | 59 | int *ret = cls; |
@@ -68,9 +63,7 @@ noti_callback (void *cls, | |||
68 | } | 63 | } |
69 | 64 | ||
70 | static int | 65 | static int |
71 | fake_noti_callback (void *cls, | 66 | fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, |
72 | const GNUNET_HashCode * | ||
73 | pseudonym, | ||
74 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 67 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
75 | { | 68 | { |
76 | int *ret = cls; | 69 | int *ret = cls; |
@@ -80,8 +73,7 @@ fake_noti_callback (void *cls, | |||
80 | } | 73 | } |
81 | 74 | ||
82 | static int | 75 | static int |
83 | false_callback (void *cls, | 76 | false_callback (void *cls, const GNUNET_HashCode * pseudonym, |
84 | const GNUNET_HashCode * pseudonym, | ||
85 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 77 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
86 | { | 78 | { |
87 | return GNUNET_OK; | 79 | return GNUNET_OK; |
@@ -125,8 +117,7 @@ main (int argc, char *argv[]) | |||
125 | notiCount = 0; | 117 | notiCount = 0; |
126 | fakenotiCount = 0; | 118 | fakenotiCount = 0; |
127 | count = 0; | 119 | count = 0; |
128 | GNUNET_PSEUDONYM_discovery_callback_register (cfg, | 120 | GNUNET_PSEUDONYM_discovery_callback_register (cfg, &fake_noti_callback, |
129 | &fake_noti_callback, | ||
130 | &fakenotiCount); | 121 | &fakenotiCount); |
131 | GNUNET_PSEUDONYM_discovery_callback_register (cfg, ¬i_callback, | 122 | GNUNET_PSEUDONYM_discovery_callback_register (cfg, ¬i_callback, |
132 | ¬iCount); | 123 | ¬iCount); |
@@ -137,11 +128,9 @@ main (int argc, char *argv[]) | |||
137 | /* ACTUAL TEST CODE */ | 128 | /* ACTUAL TEST CODE */ |
138 | old = GNUNET_PSEUDONYM_list_all (cfg, NULL, NULL); | 129 | old = GNUNET_PSEUDONYM_list_all (cfg, NULL, NULL); |
139 | meta = GNUNET_CONTAINER_meta_data_create (); | 130 | meta = GNUNET_CONTAINER_meta_data_create (); |
140 | GNUNET_CONTAINER_meta_data_insert (meta, | 131 | GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE, |
141 | "<test>", | 132 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
142 | EXTRACTOR_METATYPE_TITLE, | 133 | "test", strlen ("test") + 1); |
143 | EXTRACTOR_METAFORMAT_UTF8, | ||
144 | "text/plain", "test", strlen ("test") + 1); | ||
145 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id1); | 134 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id1); |
146 | GNUNET_PSEUDONYM_add (cfg, &id1, meta); | 135 | GNUNET_PSEUDONYM_add (cfg, &id1, meta); |
147 | CHECK (notiCount == 1); | 136 | CHECK (notiCount == 1); |
@@ -155,14 +144,12 @@ main (int argc, char *argv[]) | |||
155 | CHECK (notiCount == 3); | 144 | CHECK (notiCount == 3); |
156 | newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok); | 145 | newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok); |
157 | CHECK (old < newVal); | 146 | CHECK (old < newVal); |
158 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (meta, | 147 | GNUNET_assert (GNUNET_OK == |
159 | "<test>", | 148 | GNUNET_CONTAINER_meta_data_insert (meta, "<test>", |
160 | EXTRACTOR_METATYPE_COMMENT, | 149 | EXTRACTOR_METATYPE_COMMENT, |
161 | EXTRACTOR_METAFORMAT_UTF8, | 150 | EXTRACTOR_METAFORMAT_UTF8, |
162 | "text/plain", | 151 | "text/plain", m, |
163 | m, | 152 | strlen (m) + 1)); |
164 | strlen (m) + | ||
165 | 1)); | ||
166 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3); | 153 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3); |
167 | GNUNET_PSEUDONYM_add (cfg, &id3, meta); | 154 | GNUNET_PSEUDONYM_add (cfg, &id3, meta); |
168 | name3 = GNUNET_PSEUDONYM_id_to_name (cfg, &id3); | 155 | name3 = GNUNET_PSEUDONYM_id_to_name (cfg, &id3); |
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index 8058fa287..563f204eb 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c | |||
@@ -65,16 +65,16 @@ check_localhost_num (void *cls, const char *hostname) | |||
65 | if (0 == strcmp (hostname, "127.0.0.1")) | 65 | if (0 == strcmp (hostname, "127.0.0.1")) |
66 | { | 66 | { |
67 | #if DEBUG_RESOLVER | 67 | #if DEBUG_RESOLVER |
68 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 68 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct hostname `%s'.\n", |
69 | "Received correct hostname `%s'.\n", hostname); | 69 | hostname); |
70 | #endif | 70 | #endif |
71 | (*ok) &= ~4; | 71 | (*ok) &= ~4; |
72 | } | 72 | } |
73 | else | 73 | else |
74 | { | 74 | { |
75 | #if DEBUG_RESOLVER | 75 | #if DEBUG_RESOLVER |
76 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 76 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received invalid hostname `%s'.\n", |
77 | "Received invalid hostname `%s'.\n", hostname); | 77 | hostname); |
78 | #endif | 78 | #endif |
79 | GNUNET_break (0); | 79 | GNUNET_break (0); |
80 | } | 80 | } |
@@ -91,8 +91,8 @@ check_localhost (void *cls, const char *hostname) | |||
91 | if (0 == strcmp (hostname, "localhost")) | 91 | if (0 == strcmp (hostname, "localhost")) |
92 | { | 92 | { |
93 | #if DEBUG_RESOLVER | 93 | #if DEBUG_RESOLVER |
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct hostname `%s'.\n", |
95 | "Received correct hostname `%s'.\n", hostname); | 95 | hostname); |
96 | #endif | 96 | #endif |
97 | (*ok) &= ~2; | 97 | (*ok) &= ~2; |
98 | } | 98 | } |
@@ -139,20 +139,20 @@ check_local_fqdn (void *cls, const char *gnunet_fqdn) | |||
139 | 139 | ||
140 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) | 140 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) |
141 | { | 141 | { |
142 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | | 142 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
143 | GNUNET_ERROR_TYPE_BULK, "gethostname"); | 143 | "gethostname"); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | #if DEBUG_RESOLVER | 146 | #if DEBUG_RESOLVER |
147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our FQDN `%s'\n"), |
148 | _("Resolving our FQDN `%s'\n"), hostname); | 148 | hostname); |
149 | #endif | 149 | #endif |
150 | host = gethostbyname (hostname); | 150 | host = gethostbyname (hostname); |
151 | if (NULL == host) | 151 | if (NULL == host) |
152 | { | 152 | { |
153 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 153 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
154 | _("Could not resolve our FQDN : %s %u\n"), | 154 | _("Could not resolve our FQDN : %s %u\n"), hstrerror (h_errno), |
155 | hstrerror (h_errno), h_errno); | 155 | h_errno); |
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | 158 | ||
@@ -224,8 +224,8 @@ check_rootserver_name (void *cls, const char *hostname) | |||
224 | } | 224 | } |
225 | 225 | ||
226 | static void | 226 | static void |
227 | run (void *cls, char *const *args, | 227 | run (void *cls, char *const *args, const char *cfgfile, |
228 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | 228 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
229 | { | 229 | { |
230 | int *ok = cls; | 230 | int *ok = cls; |
231 | struct sockaddr_in sa; | 231 | struct sockaddr_in sa; |
@@ -283,8 +283,9 @@ run (void *cls, char *const *args, | |||
283 | } | 283 | } |
284 | 284 | ||
285 | /* Comparing to resolved address to the address the root name server should have */ | 285 | /* Comparing to resolved address to the address the root name server should have */ |
286 | if (strcmp (inet_ntoa (*(struct in_addr *) rootserver->h_addr_list[0]), | 286 | if (strcmp |
287 | ROOTSERVER_IP) != 0) | 287 | (inet_ntoa (*(struct in_addr *) rootserver->h_addr_list[0]), |
288 | ROOTSERVER_IP) != 0) | ||
288 | { | 289 | { |
289 | #if DEBUG_RESOLVER | 290 | #if DEBUG_RESOLVER |
290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -318,8 +319,8 @@ run (void *cls, char *const *args, | |||
318 | GNUNET_break (0); | 319 | GNUNET_break (0); |
319 | } | 320 | } |
320 | 321 | ||
321 | rootserver | 322 | rootserver = |
322 | = gethostbyaddr (&rootserver_addr, sizeof (rootserver_addr), AF_INET); | 323 | gethostbyaddr (&rootserver_addr, sizeof (rootserver_addr), AF_INET); |
323 | if (rootserver == NULL) | 324 | if (rootserver == NULL) |
324 | { | 325 | { |
325 | /* Error: resolving IP addresses does not work */ | 326 | /* Error: resolving IP addresses does not work */ |
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index d5a701692..3d8ae979c 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c | |||
@@ -50,8 +50,8 @@ task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
50 | GNUNET_assert (2 == *ok); | 50 | GNUNET_assert (2 == *ok); |
51 | (*ok) = 3; | 51 | (*ok) = 3; |
52 | /* t3 will go before t4: higher priority */ | 52 | /* t3 will go before t4: higher priority */ |
53 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, | 53 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task3, |
54 | &task3, cls); | 54 | cls); |
55 | } | 55 | } |
56 | 56 | ||
57 | static void | 57 | static void |
@@ -106,8 +106,8 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
106 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); | 106 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); |
107 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); | 107 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); |
108 | (*ok) = 8; | 108 | (*ok) = 8; |
109 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 109 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &taskLast, |
110 | &taskLast, cls); | 110 | cls); |
111 | GNUNET_SCHEDULER_shutdown (); | 111 | GNUNET_SCHEDULER_shutdown (); |
112 | } | 112 | } |
113 | 113 | ||
@@ -123,10 +123,10 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
123 | GNUNET_assert (NULL != p); | 123 | GNUNET_assert (NULL != p); |
124 | fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); | 124 | fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); |
125 | fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); | 125 | fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); |
126 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 126 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[0], &taskRd, |
127 | fds[0], &taskRd, cls); | 127 | cls); |
128 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, | 128 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[1], |
129 | fds[1], &taskWrt, cls); | 129 | &taskWrt, cls); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
@@ -225,8 +225,8 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
225 | 225 | ||
226 | GNUNET_assert (1 == *ok); | 226 | GNUNET_assert (1 == *ok); |
227 | *ok = 0; | 227 | *ok = 0; |
228 | GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, | 228 | GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after |
229 | &taskNeverRun, NULL)); | 229 | (GNUNET_SCHEDULER_NO_TASK, &taskNeverRun, NULL)); |
230 | } | 230 | } |
231 | 231 | ||
232 | 232 | ||
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c index b98e76eeb..8bcfa096e 100644 --- a/src/util/test_scheduler_delay.c +++ b/src/util/test_scheduler_delay.c | |||
@@ -66,8 +66,8 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
66 | return; | 66 | return; |
67 | } | 67 | } |
68 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 68 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
69 | (GNUNET_TIME_UNIT_MILLISECONDS, i), | 69 | (GNUNET_TIME_UNIT_MILLISECONDS, i), &test_task, |
70 | &test_task, NULL); | 70 | NULL); |
71 | i += INCR; | 71 | i += INCR; |
72 | } | 72 | } |
73 | 73 | ||
@@ -76,8 +76,8 @@ check () | |||
76 | { | 76 | { |
77 | target = GNUNET_TIME_absolute_get (); | 77 | target = GNUNET_TIME_absolute_get (); |
78 | GNUNET_SCHEDULER_run (&test_task, NULL); | 78 | GNUNET_SCHEDULER_run (&test_task, NULL); |
79 | FPRINTF (stdout, | 79 | FPRINTF (stdout, "Sleep precision: %llu ms. ", |
80 | "Sleep precision: %llu ms. ", cumDelta / 1000 / (MAXV / INCR)); | 80 | cumDelta / 1000 / (MAXV / INCR)); |
81 | if (cumDelta <= 10 * MAXV / INCR) | 81 | if (cumDelta <= 10 * MAXV / INCR) |
82 | fprintf (stdout, "Timer precision is excellent.\n"); | 82 | fprintf (stdout, "Timer precision is excellent.\n"); |
83 | else if (cumDelta <= 50 * MAXV / INCR) /* 50 ms average deviation */ | 83 | else if (cumDelta <= 50 * MAXV / INCR) /* 50 ms average deviation */ |
diff --git a/src/util/test_server.c b/src/util/test_server.c index 577a841ff..59bf8a2f4 100644 --- a/src/util/test_server.c +++ b/src/util/test_server.c | |||
@@ -60,8 +60,7 @@ finish_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
60 | 60 | ||
61 | 61 | ||
62 | static void | 62 | static void |
63 | recv_fin_cb (void *cls, | 63 | recv_fin_cb (void *cls, struct GNUNET_SERVER_Client *client, |
64 | struct GNUNET_SERVER_Client *client, | ||
65 | const struct GNUNET_MessageHeader *message) | 64 | const struct GNUNET_MessageHeader *message) |
66 | { | 65 | { |
67 | GNUNET_assert (ok == 5); | 66 | GNUNET_assert (ok == 5); |
@@ -98,8 +97,7 @@ reply_msg (void *cls, size_t size, void *buf) | |||
98 | 97 | ||
99 | 98 | ||
100 | static void | 99 | static void |
101 | recv_cb (void *cls, | 100 | recv_cb (void *cls, struct GNUNET_SERVER_Client *client, |
102 | struct GNUNET_SERVER_Client *client, | ||
103 | const struct GNUNET_MessageHeader *message) | 101 | const struct GNUNET_MessageHeader *message) |
104 | { | 102 | { |
105 | GNUNET_assert (ok == 2); | 103 | GNUNET_assert (ok == 2); |
@@ -111,8 +109,8 @@ recv_cb (void *cls, | |||
111 | GNUNET_assert (NULL != | 109 | GNUNET_assert (NULL != |
112 | GNUNET_SERVER_notify_transmit_ready (client, | 110 | GNUNET_SERVER_notify_transmit_ready (client, |
113 | ntohs (message->size), | 111 | ntohs (message->size), |
114 | TIMEOUT, | 112 | TIMEOUT, &reply_msg, |
115 | &reply_msg, NULL)); | 113 | NULL)); |
116 | } | 114 | } |
117 | 115 | ||
118 | 116 | ||
diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c index 03d57a222..8010695e8 100644 --- a/src/util/test_server_disconnect.c +++ b/src/util/test_server_disconnect.c | |||
@@ -80,8 +80,7 @@ server_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
80 | 80 | ||
81 | 81 | ||
82 | static void | 82 | static void |
83 | recv_cb (void *cls, | 83 | recv_cb (void *cls, struct GNUNET_SERVER_Client *client, |
84 | struct GNUNET_SERVER_Client *client, | ||
85 | const struct GNUNET_MessageHeader *message) | 84 | const struct GNUNET_MessageHeader *message) |
86 | { | 85 | { |
87 | GNUNET_assert (ok == 2); | 86 | GNUNET_assert (ok == 2); |
diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c index 4b9d84059..06a4b71d6 100644 --- a/src/util/test_server_with_client.c +++ b/src/util/test_server_with_client.c | |||
@@ -57,8 +57,7 @@ send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
57 | 57 | ||
58 | 58 | ||
59 | static void | 59 | static void |
60 | recv_cb (void *cls, | 60 | recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient, |
61 | struct GNUNET_SERVER_Client *argclient, | ||
62 | const struct GNUNET_MessageHeader *message) | 61 | const struct GNUNET_MessageHeader *message) |
63 | { | 62 | { |
64 | void *addr; | 63 | void *addr; |
@@ -169,13 +168,10 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
169 | #endif | 168 | #endif |
170 | sa.sin_family = AF_INET; | 169 | sa.sin_family = AF_INET; |
171 | sa.sin_port = htons (PORT); | 170 | sa.sin_port = htons (PORT); |
172 | server = GNUNET_SERVER_create (NULL, | 171 | server = |
173 | NULL, | 172 | GNUNET_SERVER_create (NULL, NULL, sap, slens, |
174 | sap, | 173 | GNUNET_TIME_relative_multiply |
175 | slens, | 174 | (GNUNET_TIME_UNIT_MILLISECONDS, 250), GNUNET_NO); |
176 | GNUNET_TIME_relative_multiply | ||
177 | (GNUNET_TIME_UNIT_MILLISECONDS, 250), | ||
178 | GNUNET_NO); | ||
179 | GNUNET_assert (server != NULL); | 175 | GNUNET_assert (server != NULL); |
180 | handlers[0].callback_cls = cls; | 176 | handlers[0].callback_cls = cls; |
181 | GNUNET_SERVER_add_handlers (server, handlers); | 177 | GNUNET_SERVER_add_handlers (server, handlers); |
@@ -187,8 +183,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
187 | "localhost"); | 183 | "localhost"); |
188 | client = GNUNET_CLIENT_connect ("test", cfg); | 184 | client = GNUNET_CLIENT_connect ("test", cfg); |
189 | GNUNET_assert (client != NULL); | 185 | GNUNET_assert (client != NULL); |
190 | GNUNET_CLIENT_notify_transmit_ready (client, | 186 | GNUNET_CLIENT_notify_transmit_ready (client, 256, |
191 | 256, | ||
192 | GNUNET_TIME_relative_multiply | 187 | GNUNET_TIME_relative_multiply |
193 | (GNUNET_TIME_UNIT_MILLISECONDS, 250), | 188 | (GNUNET_TIME_UNIT_MILLISECONDS, 250), |
194 | GNUNET_NO, ¬ify_ready, NULL); | 189 | GNUNET_NO, ¬ify_ready, NULL); |
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c index 00df21129..99af4e8c3 100644 --- a/src/util/test_server_with_client_unix.c +++ b/src/util/test_server_with_client_unix.c | |||
@@ -55,8 +55,7 @@ send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
55 | 55 | ||
56 | 56 | ||
57 | static void | 57 | static void |
58 | recv_cb (void *cls, | 58 | recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient, |
59 | struct GNUNET_SERVER_Client *argclient, | ||
60 | const struct GNUNET_MessageHeader *message) | 59 | const struct GNUNET_MessageHeader *message) |
61 | { | 60 | { |
62 | switch (ok) | 61 | switch (ok) |
@@ -156,13 +155,10 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
156 | slens[0] = sizeof (un); | 155 | slens[0] = sizeof (un); |
157 | sap[1] = NULL; | 156 | sap[1] = NULL; |
158 | slens[1] = 0; | 157 | slens[1] = 0; |
159 | server = GNUNET_SERVER_create (NULL, | 158 | server = |
160 | NULL, | 159 | GNUNET_SERVER_create (NULL, NULL, sap, slens, |
161 | sap, | 160 | GNUNET_TIME_relative_multiply |
162 | slens, | 161 | (GNUNET_TIME_UNIT_MILLISECONDS, 250), GNUNET_NO); |
163 | GNUNET_TIME_relative_multiply | ||
164 | (GNUNET_TIME_UNIT_MILLISECONDS, 250), | ||
165 | GNUNET_NO); | ||
166 | GNUNET_assert (server != NULL); | 162 | GNUNET_assert (server != NULL); |
167 | handlers[0].callback_cls = cls; | 163 | handlers[0].callback_cls = cls; |
168 | GNUNET_SERVER_add_handlers (server, handlers); | 164 | GNUNET_SERVER_add_handlers (server, handlers); |
@@ -175,8 +171,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
175 | 171 | ||
176 | client = GNUNET_CLIENT_connect ("test", cfg); | 172 | client = GNUNET_CLIENT_connect ("test", cfg); |
177 | GNUNET_assert (client != NULL); | 173 | GNUNET_assert (client != NULL); |
178 | GNUNET_CLIENT_notify_transmit_ready (client, | 174 | GNUNET_CLIENT_notify_transmit_ready (client, 256, |
179 | 256, | ||
180 | GNUNET_TIME_relative_multiply | 175 | GNUNET_TIME_relative_multiply |
181 | (GNUNET_TIME_UNIT_MILLISECONDS, 250), | 176 | (GNUNET_TIME_UNIT_MILLISECONDS, 250), |
182 | GNUNET_NO, ¬ify_ready, NULL); | 177 | GNUNET_NO, ¬ify_ready, NULL); |
diff --git a/src/util/test_service.c b/src/util/test_service.c index daafa6cd3..4d1608191 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -71,8 +71,8 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
71 | "Client connecting, waiting to transmit\n"); | 71 | "Client connecting, waiting to transmit\n"); |
72 | GNUNET_CLIENT_notify_transmit_ready (client, | 72 | GNUNET_CLIENT_notify_transmit_ready (client, |
73 | sizeof (struct GNUNET_MessageHeader), | 73 | sizeof (struct GNUNET_MessageHeader), |
74 | GNUNET_TIME_UNIT_SECONDS, | 74 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, |
75 | GNUNET_NO, &build_msg, client); | 75 | &build_msg, client); |
76 | } | 76 | } |
77 | 77 | ||
78 | static void | 78 | static void |
@@ -83,8 +83,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
83 | 83 | ||
84 | 84 | ||
85 | static void | 85 | static void |
86 | recv_cb (void *cls, | 86 | recv_cb (void *cls, struct GNUNET_SERVER_Client *client, |
87 | struct GNUNET_SERVER_Client *client, | ||
88 | const struct GNUNET_MessageHeader *message) | 87 | const struct GNUNET_MessageHeader *message) |
89 | { | 88 | { |
90 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); | 89 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); |
@@ -105,15 +104,13 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = { | |||
105 | 104 | ||
106 | 105 | ||
107 | static void | 106 | static void |
108 | runner (void *cls, | 107 | runner (void *cls, struct GNUNET_SERVER_Handle *server, |
109 | struct GNUNET_SERVER_Handle *server, | ||
110 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 108 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
111 | { | 109 | { |
112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); | 110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); |
113 | GNUNET_SERVER_add_handlers (server, myhandlers); | 111 | GNUNET_SERVER_add_handlers (server, myhandlers); |
114 | GNUNET_CLIENT_service_test ("test_service", | 112 | GNUNET_CLIENT_service_test ("test_service", cfg, GNUNET_TIME_UNIT_SECONDS, |
115 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready, | 113 | &ready, (void *) cfg); |
116 | (void *) cfg); | ||
117 | } | 114 | } |
118 | 115 | ||
119 | 116 | ||
@@ -139,9 +136,7 @@ check () | |||
139 | }; | 136 | }; |
140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service\n"); | 137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service\n"); |
141 | GNUNET_assert (GNUNET_OK == | 138 | GNUNET_assert (GNUNET_OK == |
142 | GNUNET_SERVICE_run (5, | 139 | GNUNET_SERVICE_run (5, argv, "test_service", |
143 | argv, | ||
144 | "test_service", | ||
145 | GNUNET_SERVICE_OPTION_NONE, &runner, &ok)); | 140 | GNUNET_SERVICE_OPTION_NONE, &runner, &ok)); |
146 | GNUNET_assert (0 == ok); | 141 | GNUNET_assert (0 == ok); |
147 | return ok; | 142 | return ok; |
@@ -160,20 +155,18 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); | 155 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); |
161 | GNUNET_CLIENT_notify_transmit_ready (client, | 156 | GNUNET_CLIENT_notify_transmit_ready (client, |
162 | sizeof (struct GNUNET_MessageHeader), | 157 | sizeof (struct GNUNET_MessageHeader), |
163 | GNUNET_TIME_UNIT_SECONDS, | 158 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, |
164 | GNUNET_NO, &build_msg, client); | 159 | &build_msg, client); |
165 | } | 160 | } |
166 | 161 | ||
167 | static void | 162 | static void |
168 | runner6 (void *cls, | 163 | runner6 (void *cls, struct GNUNET_SERVER_Handle *server, |
169 | struct GNUNET_SERVER_Handle *server, | ||
170 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 164 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
171 | { | 165 | { |
172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); | 166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); |
173 | GNUNET_SERVER_add_handlers (server, myhandlers); | 167 | GNUNET_SERVER_add_handlers (server, myhandlers); |
174 | GNUNET_CLIENT_service_test ("test_service6", | 168 | GNUNET_CLIENT_service_test ("test_service6", cfg, GNUNET_TIME_UNIT_SECONDS, |
175 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, | 169 | &ready6, (void *) cfg); |
176 | (void *) cfg); | ||
177 | } | 170 | } |
178 | 171 | ||
179 | /** | 172 | /** |
@@ -197,11 +190,9 @@ check6 () | |||
197 | }; | 190 | }; |
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n"); | 191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n"); |
199 | GNUNET_assert (GNUNET_OK == | 192 | GNUNET_assert (GNUNET_OK == |
200 | GNUNET_SERVICE_run (5, | 193 | GNUNET_SERVICE_run (5, argv, "test_service6", |
201 | argv, | 194 | GNUNET_SERVICE_OPTION_NONE, &runner6, |
202 | "test_service6", | 195 | &ok)); |
203 | GNUNET_SERVICE_OPTION_NONE, | ||
204 | &runner6, &ok)); | ||
205 | GNUNET_assert (0 == ok); | 196 | GNUNET_assert (0 == ok); |
206 | return ok; | 197 | return ok; |
207 | } | 198 | } |
@@ -209,9 +200,7 @@ check6 () | |||
209 | 200 | ||
210 | 201 | ||
211 | static void | 202 | static void |
212 | start_stop_main (void *cls, | 203 | start_stop_main (void *cls, char *const *args, const char *cfgfile, |
213 | char *const *args, | ||
214 | const char *cfgfile, | ||
215 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 204 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
216 | { | 205 | { |
217 | int *ret = cls; | 206 | int *ret = cls; |
@@ -245,10 +234,7 @@ check_start_stop () | |||
245 | int ret = 1; | 234 | int ret = 1; |
246 | 235 | ||
247 | GNUNET_assert (GNUNET_OK == | 236 | GNUNET_assert (GNUNET_OK == |
248 | GNUNET_PROGRAM_run (5, | 237 | GNUNET_PROGRAM_run (5, argv, "test-service-program", "no help", |
249 | argv, | ||
250 | "test-service-program", | ||
251 | "no help", | ||
252 | options, &start_stop_main, &ret)); | 238 | options, &start_stop_main, &ret)); |
253 | 239 | ||
254 | GNUNET_break (0 == ret); | 240 | GNUNET_break (0 == ret); |
@@ -278,8 +264,8 @@ main (int argc, char *argv[]) | |||
278 | #endif | 264 | #endif |
279 | if (NULL == s) | 265 | if (NULL == s) |
280 | { | 266 | { |
281 | if ((errno == ENOBUFS) || | 267 | if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || |
282 | (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) | 268 | (errno == EACCES)) |
283 | { | 269 | { |
284 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 270 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
285 | return 1; | 271 | return 1; |
diff --git a/src/util/test_time.c b/src/util/test_time.c index 788884fcc..6a05b698c 100644 --- a/src/util/test_time.c +++ b/src/util/test_time.c | |||
@@ -108,8 +108,8 @@ check () | |||
108 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value == | 108 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value == |
109 | 0); | 109 | 0); |
110 | 110 | ||
111 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).rel_value | 111 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever). |
112 | == forever.abs_value); | 112 | rel_value == forever.abs_value); |
113 | 113 | ||
114 | past.abs_value = now.abs_value - 1000000; | 114 | past.abs_value = now.abs_value - 1000000; |
115 | rel = GNUNET_TIME_absolute_get_duration (future); | 115 | rel = GNUNET_TIME_absolute_get_duration (future); |
@@ -153,7 +153,8 @@ check () | |||
153 | 153 | ||
154 | GNUNET_assert (forever.abs_value == | 154 | GNUNET_assert (forever.abs_value == |
155 | GNUNET_TIME_absolute_subtract (forever, | 155 | GNUNET_TIME_absolute_subtract (forever, |
156 | GNUNET_TIME_UNIT_MINUTES).abs_value); | 156 | GNUNET_TIME_UNIT_MINUTES). |
157 | abs_value); | ||
157 | /*check absolute subtract */ | 158 | /*check absolute subtract */ |
158 | now.abs_value = 50000; | 159 | now.abs_value = 50000; |
159 | rel.rel_value = 100000; | 160 | rel.rel_value = 100000; |
diff --git a/src/util/time.c b/src/util/time.c index f4d4c4070..34880b08b 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -145,9 +145,8 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) | |||
145 | * @return timestamp that is smaller | 145 | * @return timestamp that is smaller |
146 | */ | 146 | */ |
147 | struct GNUNET_TIME_Relative | 147 | struct GNUNET_TIME_Relative |
148 | GNUNET_TIME_relative_min (struct | 148 | GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1, |
149 | GNUNET_TIME_Relative | 149 | struct GNUNET_TIME_Relative t2) |
150 | t1, struct GNUNET_TIME_Relative t2) | ||
151 | { | 150 | { |
152 | return (t1.rel_value < t2.rel_value) ? t1 : t2; | 151 | return (t1.rel_value < t2.rel_value) ? t1 : t2; |
153 | } | 152 | } |
@@ -161,9 +160,8 @@ GNUNET_TIME_relative_min (struct | |||
161 | * @return timestamp that is larger | 160 | * @return timestamp that is larger |
162 | */ | 161 | */ |
163 | struct GNUNET_TIME_Relative | 162 | struct GNUNET_TIME_Relative |
164 | GNUNET_TIME_relative_max (struct | 163 | GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1, |
165 | GNUNET_TIME_Relative | 164 | struct GNUNET_TIME_Relative t2) |
166 | t1, struct GNUNET_TIME_Relative t2) | ||
167 | { | 165 | { |
168 | return (t1.rel_value > t2.rel_value) ? t1 : t2; | 166 | return (t1.rel_value > t2.rel_value) ? t1 : t2; |
169 | } | 167 | } |
@@ -178,9 +176,8 @@ GNUNET_TIME_relative_max (struct | |||
178 | * @return timestamp that is smaller | 176 | * @return timestamp that is smaller |
179 | */ | 177 | */ |
180 | struct GNUNET_TIME_Absolute | 178 | struct GNUNET_TIME_Absolute |
181 | GNUNET_TIME_absolute_min (struct | 179 | GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1, |
182 | GNUNET_TIME_Absolute | 180 | struct GNUNET_TIME_Absolute t2) |
183 | t1, struct GNUNET_TIME_Absolute t2) | ||
184 | { | 181 | { |
185 | return (t1.abs_value < t2.abs_value) ? t1 : t2; | 182 | return (t1.abs_value < t2.abs_value) ? t1 : t2; |
186 | } | 183 | } |
@@ -194,9 +191,8 @@ GNUNET_TIME_absolute_min (struct | |||
194 | * @return timestamp that is smaller | 191 | * @return timestamp that is smaller |
195 | */ | 192 | */ |
196 | struct GNUNET_TIME_Absolute | 193 | struct GNUNET_TIME_Absolute |
197 | GNUNET_TIME_absolute_max (struct | 194 | GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1, |
198 | GNUNET_TIME_Absolute | 195 | struct GNUNET_TIME_Absolute t2) |
199 | t1, struct GNUNET_TIME_Absolute t2) | ||
200 | { | 196 | { |
201 | return (t1.abs_value > t2.abs_value) ? t1 : t2; | 197 | return (t1.abs_value > t2.abs_value) ? t1 : t2; |
202 | } | 198 | } |
@@ -298,9 +294,8 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, | |||
298 | * @return ZERO if start <= duration, or FOREVER if start time is FOREVER; start-duration otherwise | 294 | * @return ZERO if start <= duration, or FOREVER if start time is FOREVER; start-duration otherwise |
299 | */ | 295 | */ |
300 | struct GNUNET_TIME_Absolute | 296 | struct GNUNET_TIME_Absolute |
301 | GNUNET_TIME_absolute_subtract (struct | 297 | GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, |
302 | GNUNET_TIME_Absolute | 298 | struct GNUNET_TIME_Relative duration) |
303 | start, struct GNUNET_TIME_Relative duration) | ||
304 | { | 299 | { |
305 | struct GNUNET_TIME_Absolute ret; | 300 | struct GNUNET_TIME_Absolute ret; |
306 | 301 | ||
@@ -368,8 +363,8 @@ GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, | |||
368 | * assuming it continues at the same speed | 363 | * assuming it continues at the same speed |
369 | */ | 364 | */ |
370 | struct GNUNET_TIME_Relative | 365 | struct GNUNET_TIME_Relative |
371 | GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, | 366 | GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished, |
372 | uint64_t finished, uint64_t total) | 367 | uint64_t total) |
373 | { | 368 | { |
374 | struct GNUNET_TIME_Relative dur; | 369 | struct GNUNET_TIME_Relative dur; |
375 | double exp; | 370 | double exp; |
diff --git a/src/util/winproc.c b/src/util/winproc.c index 4fa3ab484..9594c5d6f 100644 --- a/src/util/winproc.c +++ b/src/util/winproc.c | |||
@@ -100,8 +100,9 @@ GNInitWinEnv () | |||
100 | /* Function to get CPU usage under Win NT */ | 100 | /* Function to get CPU usage under Win NT */ |
101 | if (hNTDLL) | 101 | if (hNTDLL) |
102 | { | 102 | { |
103 | GNNtQuerySystemInformation = (TNtQuerySystemInformation) | 103 | GNNtQuerySystemInformation = |
104 | GetProcAddress (hNTDLL, "NtQuerySystemInformation"); | 104 | (TNtQuerySystemInformation) GetProcAddress (hNTDLL, |
105 | "NtQuerySystemInformation"); | ||
105 | } | 106 | } |
106 | else | 107 | else |
107 | { | 108 | { |
@@ -113,13 +114,13 @@ GNInitWinEnv () | |||
113 | if (hIphlpapi) | 114 | if (hIphlpapi) |
114 | { | 115 | { |
115 | GNGetIfEntry = (TGetIfEntry) GetProcAddress (hIphlpapi, "GetIfEntry"); | 116 | GNGetIfEntry = (TGetIfEntry) GetProcAddress (hIphlpapi, "GetIfEntry"); |
116 | GNGetIpAddrTable = (TGetIpAddrTable) GetProcAddress (hIphlpapi, | 117 | GNGetIpAddrTable = |
117 | "GetIpAddrTable"); | 118 | (TGetIpAddrTable) GetProcAddress (hIphlpapi, "GetIpAddrTable"); |
118 | GNGetIfTable = (TGetIfTable) GetProcAddress (hIphlpapi, "GetIfTable"); | 119 | GNGetIfTable = (TGetIfTable) GetProcAddress (hIphlpapi, "GetIfTable"); |
119 | GNGetBestInterface = (TGetBestInterface) GetProcAddress (hIphlpapi, | 120 | GNGetBestInterface = |
120 | "GetBestInterface"); | 121 | (TGetBestInterface) GetProcAddress (hIphlpapi, "GetBestInterface"); |
121 | GGetAdaptersInfo = (TGetAdaptersInfo) GetProcAddress (hIphlpapi, | 122 | GGetAdaptersInfo = |
122 | "GetAdaptersInfo"); | 123 | (TGetAdaptersInfo) GetProcAddress (hIphlpapi, "GetAdaptersInfo"); |
123 | } | 124 | } |
124 | else | 125 | else |
125 | { | 126 | { |
@@ -134,51 +135,57 @@ GNInitWinEnv () | |||
134 | hAdvapi = LoadLibrary ("advapi32.dll"); | 135 | hAdvapi = LoadLibrary ("advapi32.dll"); |
135 | if (hAdvapi) | 136 | if (hAdvapi) |
136 | { | 137 | { |
137 | GNOpenSCManager = (TOpenSCManager) | 138 | GNOpenSCManager = |
138 | GetProcAddress (hAdvapi, "OpenSCManagerA"); | 139 | (TOpenSCManager) GetProcAddress (hAdvapi, "OpenSCManagerA"); |
139 | GNCreateService = (TCreateService) | 140 | GNCreateService = |
140 | GetProcAddress (hAdvapi, "CreateServiceA"); | 141 | (TCreateService) GetProcAddress (hAdvapi, "CreateServiceA"); |
141 | GNCloseServiceHandle = (TCloseServiceHandle) | 142 | GNCloseServiceHandle = |
142 | GetProcAddress (hAdvapi, "CloseServiceHandle"); | 143 | (TCloseServiceHandle) GetProcAddress (hAdvapi, "CloseServiceHandle"); |
143 | GNDeleteService = (TDeleteService) | 144 | GNDeleteService = |
144 | GetProcAddress (hAdvapi, "DeleteService"); | 145 | (TDeleteService) GetProcAddress (hAdvapi, "DeleteService"); |
145 | GNRegisterServiceCtrlHandler = (TRegisterServiceCtrlHandler) | 146 | GNRegisterServiceCtrlHandler = |
146 | GetProcAddress (hAdvapi, "RegisterServiceCtrlHandlerA"); | 147 | (TRegisterServiceCtrlHandler) GetProcAddress (hAdvapi, |
147 | GNSetServiceStatus = (TSetServiceStatus) | 148 | "RegisterServiceCtrlHandlerA"); |
148 | GetProcAddress (hAdvapi, "SetServiceStatus"); | 149 | GNSetServiceStatus = |
149 | GNStartServiceCtrlDispatcher = (TStartServiceCtrlDispatcher) | 150 | (TSetServiceStatus) GetProcAddress (hAdvapi, "SetServiceStatus"); |
150 | GetProcAddress (hAdvapi, "StartServiceCtrlDispatcherA"); | 151 | GNStartServiceCtrlDispatcher = |
151 | GNControlService = (TControlService) | 152 | (TStartServiceCtrlDispatcher) GetProcAddress (hAdvapi, |
152 | GetProcAddress (hAdvapi, "ControlService"); | 153 | "StartServiceCtrlDispatcherA"); |
154 | GNControlService = | ||
155 | (TControlService) GetProcAddress (hAdvapi, "ControlService"); | ||
153 | GNOpenService = (TOpenService) GetProcAddress (hAdvapi, "OpenServiceA"); | 156 | GNOpenService = (TOpenService) GetProcAddress (hAdvapi, "OpenServiceA"); |
154 | 157 | ||
155 | GNLsaOpenPolicy = (TLsaOpenPolicy) | 158 | GNLsaOpenPolicy = |
156 | GetProcAddress (hAdvapi, "LsaOpenPolicy"); | 159 | (TLsaOpenPolicy) GetProcAddress (hAdvapi, "LsaOpenPolicy"); |
157 | GNLsaAddAccountRights = (TLsaAddAccountRights) | 160 | GNLsaAddAccountRights = |
158 | GetProcAddress (hAdvapi, "LsaAddAccountRights"); | 161 | (TLsaAddAccountRights) GetProcAddress (hAdvapi, "LsaAddAccountRights"); |
159 | GNLsaRemoveAccountRights = (TLsaRemoveAccountRights) | 162 | GNLsaRemoveAccountRights = |
160 | GetProcAddress (hAdvapi, "LsaRemoveAccountRights"); | 163 | (TLsaRemoveAccountRights) GetProcAddress (hAdvapi, |
164 | "LsaRemoveAccountRights"); | ||
161 | GNLsaClose = (TLsaClose) GetProcAddress (hAdvapi, "LsaClose"); | 165 | GNLsaClose = (TLsaClose) GetProcAddress (hAdvapi, "LsaClose"); |
162 | GNLookupAccountName = (TLookupAccountName) | 166 | GNLookupAccountName = |
163 | GetProcAddress (hAdvapi, "LookupAccountNameA"); | 167 | (TLookupAccountName) GetProcAddress (hAdvapi, "LookupAccountNameA"); |
164 | 168 | ||
165 | GNGetFileSecurity = (TGetFileSecurity) | 169 | GNGetFileSecurity = |
166 | GetProcAddress (hAdvapi, "GetFileSecurityA"); | 170 | (TGetFileSecurity) GetProcAddress (hAdvapi, "GetFileSecurityA"); |
167 | GNInitializeSecurityDescriptor = (TInitializeSecurityDescriptor) | 171 | GNInitializeSecurityDescriptor = |
168 | GetProcAddress (hAdvapi, "InitializeSecurityDescriptor"); | 172 | (TInitializeSecurityDescriptor) GetProcAddress (hAdvapi, |
169 | GNGetSecurityDescriptorDacl = (TGetSecurityDescriptorDacl) | 173 | "InitializeSecurityDescriptor"); |
170 | GetProcAddress (hAdvapi, "GetSecurityDescriptorDacl"); | 174 | GNGetSecurityDescriptorDacl = |
171 | GNGetAclInformation = (TGetAclInformation) | 175 | (TGetSecurityDescriptorDacl) GetProcAddress (hAdvapi, |
172 | GetProcAddress (hAdvapi, "GetAclInformation"); | 176 | "GetSecurityDescriptorDacl"); |
173 | GNInitializeAcl = (TInitializeAcl) | 177 | GNGetAclInformation = |
174 | GetProcAddress (hAdvapi, "InitializeAcl"); | 178 | (TGetAclInformation) GetProcAddress (hAdvapi, "GetAclInformation"); |
179 | GNInitializeAcl = | ||
180 | (TInitializeAcl) GetProcAddress (hAdvapi, "InitializeAcl"); | ||
175 | GNGetAce = (TGetAce) GetProcAddress (hAdvapi, "GetAce"); | 181 | GNGetAce = (TGetAce) GetProcAddress (hAdvapi, "GetAce"); |
176 | GNEqualSid = (TEqualSid) GetProcAddress (hAdvapi, "EqualSid"); | 182 | GNEqualSid = (TEqualSid) GetProcAddress (hAdvapi, "EqualSid"); |
177 | GNAddAce = (TAddAce) GetProcAddress (hAdvapi, "AddAce"); | 183 | GNAddAce = (TAddAce) GetProcAddress (hAdvapi, "AddAce"); |
178 | GNAddAccessAllowedAce = (TAddAccessAllowedAce) | 184 | GNAddAccessAllowedAce = |
179 | GetProcAddress (hAdvapi, "AddAccessAllowedAce"); | 185 | (TAddAccessAllowedAce) GetProcAddress (hAdvapi, "AddAccessAllowedAce"); |
180 | GNSetNamedSecurityInfo = (TSetNamedSecurityInfo) | 186 | GNSetNamedSecurityInfo = |
181 | GetProcAddress (hAdvapi, "SetNamedSecurityInfoA"); | 187 | (TSetNamedSecurityInfo) GetProcAddress (hAdvapi, |
188 | "SetNamedSecurityInfoA"); | ||
182 | } | 189 | } |
183 | else | 190 | else |
184 | { | 191 | { |
@@ -215,8 +222,8 @@ GNInitWinEnv () | |||
215 | if (hNetapi) | 222 | if (hNetapi) |
216 | { | 223 | { |
217 | GNNetUserAdd = (TNetUserAdd) GetProcAddress (hNetapi, "NetUserAdd"); | 224 | GNNetUserAdd = (TNetUserAdd) GetProcAddress (hNetapi, "NetUserAdd"); |
218 | GNNetUserSetInfo = (TNetUserSetInfo) | 225 | GNNetUserSetInfo = |
219 | GetProcAddress (hNetapi, "NetUserSetInfo"); | 226 | (TNetUserSetInfo) GetProcAddress (hNetapi, "NetUserSetInfo"); |
220 | } | 227 | } |
221 | else | 228 | else |
222 | { | 229 | { |