aboutsummaryrefslogtreecommitdiff
path: root/src/hello/hello.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/hello/hello.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/hello/hello.c')
-rw-r--r--src/hello/hello.c78
1 files changed, 34 insertions, 44 deletions
diff --git a/src/hello/hello.c b/src/hello/hello.c
index 0df888c21..5d64d8f5a 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -77,8 +77,8 @@ struct GNUNET_HELLO_Message
77size_t 77size_t
78GNUNET_HELLO_add_address (const char *tname, 78GNUNET_HELLO_add_address (const char *tname,
79 struct GNUNET_TIME_Absolute expiration, 79 struct GNUNET_TIME_Absolute expiration,
80 const void *addr, 80 const void *addr, uint16_t addr_len, char *target,
81 uint16_t addr_len, char *target, size_t max) 81 size_t max)
82{ 82{
83 uint16_t alen; 83 uint16_t alen;
84 size_t slen; 84 size_t slen;
@@ -245,9 +245,9 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg,
245 memcpy (&expire, 245 memcpy (&expire,
246 &inptr[esize - alen - sizeof (struct GNUNET_TIME_AbsoluteNBO)], 246 &inptr[esize - alen - sizeof (struct GNUNET_TIME_AbsoluteNBO)],
247 sizeof (struct GNUNET_TIME_AbsoluteNBO)); 247 sizeof (struct GNUNET_TIME_AbsoluteNBO));
248 iret = it (it_cls, 248 iret =
249 inptr, 249 it (it_cls, inptr, GNUNET_TIME_absolute_ntoh (expire),
250 GNUNET_TIME_absolute_ntoh (expire), &inptr[esize - alen], alen); 250 &inptr[esize - alen], alen);
251 if (iret == GNUNET_SYSERR) 251 if (iret == GNUNET_SYSERR)
252 { 252 {
253 if (ret != NULL) 253 if (ret != NULL)
@@ -280,15 +280,13 @@ struct ExpireContext
280 280
281 281
282static int 282static int
283get_match_exp (void *cls, 283get_match_exp (void *cls, const char *tname,
284 const char *tname, 284 struct GNUNET_TIME_Absolute expiration, const void *addr,
285 struct GNUNET_TIME_Absolute expiration, 285 uint16_t addrlen)
286 const void *addr, uint16_t addrlen)
287{ 286{
288 struct ExpireContext *ec = cls; 287 struct ExpireContext *ec = cls;
289 288
290 if ((addrlen == ec->addrlen) && 289 if ((addrlen == ec->addrlen) && (0 == memcmp (addr, ec->addr, addrlen)) &&
291 (0 == memcmp (addr, ec->addr, addrlen)) &&
292 (0 == strcmp (tname, ec->tname))) 290 (0 == strcmp (tname, ec->tname)))
293 { 291 {
294 ec->found = GNUNET_YES; 292 ec->found = GNUNET_YES;
@@ -313,10 +311,9 @@ struct MergeContext
313 311
314 312
315static int 313static int
316copy_latest (void *cls, 314copy_latest (void *cls, const char *tname,
317 const char *tname, 315 struct GNUNET_TIME_Absolute expiration, const void *addr,
318 struct GNUNET_TIME_Absolute expiration, 316 uint16_t addrlen)
319 const void *addr, uint16_t addrlen)
320{ 317{
321 struct MergeContext *mc = cls; 318 struct MergeContext *mc = cls;
322 struct ExpireContext ec; 319 struct ExpireContext ec;
@@ -331,11 +328,9 @@ copy_latest (void *cls,
331 ((ec.expiration.abs_value == expiration.abs_value) && 328 ((ec.expiration.abs_value == expiration.abs_value) &&
332 (mc->take_equal == GNUNET_YES))) 329 (mc->take_equal == GNUNET_YES)))
333 { 330 {
334 mc->ret += GNUNET_HELLO_add_address (tname, 331 mc->ret +=
335 expiration, 332 GNUNET_HELLO_add_address (tname, expiration, addr, addrlen,
336 addr, 333 &mc->buf[mc->ret], mc->max - mc->ret);
337 addrlen,
338 &mc->buf[mc->ret], mc->max - mc->ret);
339 } 334 }
340 return GNUNET_OK; 335 return GNUNET_OK;
341} 336}
@@ -394,10 +389,9 @@ struct DeltaContext
394 389
395 390
396static int 391static int
397delta_match (void *cls, 392delta_match (void *cls, const char *tname,
398 const char *tname, 393 struct GNUNET_TIME_Absolute expiration, const void *addr,
399 struct GNUNET_TIME_Absolute expiration, 394 uint16_t addrlen)
400 const void *addr, uint16_t addrlen)
401{ 395{
402 struct DeltaContext *dc = cls; 396 struct DeltaContext *dc = cls;
403 int ret; 397 int ret;
@@ -407,8 +401,8 @@ delta_match (void *cls,
407 ec.addrlen = addrlen; 401 ec.addrlen = addrlen;
408 ec.found = GNUNET_NO; 402 ec.found = GNUNET_NO;
409 ec.tname = tname; 403 ec.tname = tname;
410 GNUNET_HELLO_iterate_addresses (dc->old_hello, 404 GNUNET_HELLO_iterate_addresses (dc->old_hello, GNUNET_NO, &get_match_exp,
411 GNUNET_NO, &get_match_exp, &ec); 405 &ec);
412 if ((ec.found == GNUNET_YES) && 406 if ((ec.found == GNUNET_YES) &&
413 ((ec.expiration.abs_value > expiration.abs_value) || 407 ((ec.expiration.abs_value > expiration.abs_value) ||
414 (ec.expiration.abs_value >= dc->expiration_limit.abs_value))) 408 (ec.expiration.abs_value >= dc->expiration_limit.abs_value)))
@@ -553,18 +547,16 @@ struct EqualsContext
553 547
554 548
555static int 549static int
556find_other_matching (void *cls, 550find_other_matching (void *cls, const char *tname,
557 const char *tname, 551 struct GNUNET_TIME_Absolute expiration, const void *addr,
558 struct GNUNET_TIME_Absolute expiration, 552 uint16_t addrlen)
559 const void *addr, uint16_t addrlen)
560{ 553{
561 struct EqualsContext *ec = cls; 554 struct EqualsContext *ec = cls;
562 555
563 if (expiration.abs_value < ec->expiration_limit.abs_value) 556 if (expiration.abs_value < ec->expiration_limit.abs_value)
564 return GNUNET_YES; 557 return GNUNET_YES;
565 if ((addrlen == ec->addrlen) && 558 if ((addrlen == ec->addrlen) && (0 == strcmp (tname, ec->tname)) &&
566 (0 == strcmp (tname, 559 (0 == memcmp (addr, ec->addr, addrlen)))
567 ec->tname)) && (0 == memcmp (addr, ec->addr, addrlen)))
568 { 560 {
569 ec->found = GNUNET_YES; 561 ec->found = GNUNET_YES;
570 if (expiration.abs_value < ec->expiration.abs_value) 562 if (expiration.abs_value < ec->expiration.abs_value)
@@ -576,10 +568,9 @@ find_other_matching (void *cls,
576 568
577 569
578static int 570static int
579find_matching (void *cls, 571find_matching (void *cls, const char *tname,
580 const char *tname, 572 struct GNUNET_TIME_Absolute expiration, const void *addr,
581 struct GNUNET_TIME_Absolute expiration, 573 uint16_t addrlen)
582 const void *addr, uint16_t addrlen)
583{ 574{
584 struct EqualsContext *ec = cls; 575 struct EqualsContext *ec = cls;
585 576
@@ -616,16 +607,15 @@ find_matching (void *cls,
616 * do not match at all 607 * do not match at all
617 */ 608 */
618struct GNUNET_TIME_Absolute 609struct GNUNET_TIME_Absolute
619GNUNET_HELLO_equals (const struct 610GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
620 GNUNET_HELLO_Message *h1, 611 const struct GNUNET_HELLO_Message *h2,
621 const struct 612 struct GNUNET_TIME_Absolute now)
622 GNUNET_HELLO_Message *h2, struct GNUNET_TIME_Absolute now)
623{ 613{
624 struct EqualsContext ec; 614 struct EqualsContext ec;
625 615
626 if (0 != memcmp (&h1->publicKey, 616 if (0 !=
627 &h2->publicKey, 617 memcmp (&h1->publicKey, &h2->publicKey,
628 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) 618 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))
629 return GNUNET_TIME_UNIT_ZERO_ABS; 619 return GNUNET_TIME_UNIT_ZERO_ABS;
630 ec.expiration_limit = now; 620 ec.expiration_limit = now;
631 ec.result = GNUNET_TIME_UNIT_FOREVER_ABS; 621 ec.result = GNUNET_TIME_UNIT_FOREVER_ABS;