diff options
-rw-r--r-- | src/hello/gnunet-hello.c | 4 | ||||
-rw-r--r-- | src/hello/hello.c | 55 | ||||
-rw-r--r-- | src/hello/test_friend_hello.c | 4 | ||||
-rw-r--r-- | src/hello/test_hello.c | 4 | ||||
-rw-r--r-- | src/include/gnunet_hello_lib.h | 4 | ||||
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 1 | ||||
-rw-r--r-- | src/peerinfo/perf_peerinfo_api.c | 6 | ||||
-rw-r--r-- | src/peerinfo/test_peerinfo_api.c | 6 | ||||
-rw-r--r-- | src/peerinfo/test_peerinfo_api_friend_only.c | 6 | ||||
-rw-r--r-- | src/peerinfo/test_peerinfo_api_notify_friend_only.c | 292 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_hello.c | 11 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 6 |
12 files changed, 206 insertions, 193 deletions
diff --git a/src/hello/gnunet-hello.c b/src/hello/gnunet-hello.c index e857bde26..93eaeef2b 100644 --- a/src/hello/gnunet-hello.c +++ b/src/hello/gnunet-hello.c | |||
@@ -85,14 +85,14 @@ add_to_buf (void *cls, const struct GNUNET_HELLO_Address *address, | |||
85 | * @param buf where to add the addresses | 85 | * @param buf where to add the addresses |
86 | * @return number of bytes added, 0 to terminate | 86 | * @return number of bytes added, 0 to terminate |
87 | */ | 87 | */ |
88 | static size_t | 88 | static ssize_t |
89 | add_from_hello (void *cls, size_t max, void *buf) | 89 | add_from_hello (void *cls, size_t max, void *buf) |
90 | { | 90 | { |
91 | struct GNUNET_HELLO_Message **orig = cls; | 91 | struct GNUNET_HELLO_Message **orig = cls; |
92 | struct AddContext ac; | 92 | struct AddContext ac; |
93 | 93 | ||
94 | if (NULL == *orig) | 94 | if (NULL == *orig) |
95 | return 0; /* already done */ | 95 | return GNUNET_SYSERR; /* already done */ |
96 | ac.buf = buf; | 96 | ac.buf = buf; |
97 | ac.max = max; | 97 | ac.max = max; |
98 | ac.ret = 0; | 98 | ac.ret = 0; |
diff --git a/src/hello/hello.c b/src/hello/hello.c index 4b7036125..1f9ef0f7e 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c | |||
@@ -22,6 +22,7 @@ | |||
22 | * @file hello/hello.c | 22 | * @file hello/hello.c |
23 | * @brief helper library for handling HELLOs | 23 | * @brief helper library for handling HELLOs |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * @author Matthias Wachs | ||
25 | */ | 26 | */ |
26 | #include "platform.h" | 27 | #include "platform.h" |
27 | #include "gnunet_hello_lib.h" | 28 | #include "gnunet_hello_lib.h" |
@@ -98,6 +99,17 @@ struct GNUNET_HELLO_ParseUriContext | |||
98 | int ret; | 99 | int ret; |
99 | 100 | ||
100 | /** | 101 | /** |
102 | * Counter | ||
103 | */ | ||
104 | unsigned int counter_total; | ||
105 | |||
106 | /** | ||
107 | * Counter skipped addresses | ||
108 | */ | ||
109 | unsigned int counter_added; | ||
110 | |||
111 | |||
112 | /** | ||
101 | * Function for finding transport plugins by name. | 113 | * Function for finding transport plugins by name. |
102 | */ | 114 | */ |
103 | GNUNET_HELLO_TransportPluginsFind plugins_find; | 115 | GNUNET_HELLO_TransportPluginsFind plugins_find; |
@@ -237,7 +249,7 @@ GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *publicKey, | |||
237 | used = 0; | 249 | used = 0; |
238 | if (addrgen != NULL) | 250 | if (addrgen != NULL) |
239 | { | 251 | { |
240 | while (0 != (ret = addrgen (addrgen_cls, max, &buffer[used]))) | 252 | while (GNUNET_SYSERR != (ret = addrgen (addrgen_cls, max, &buffer[used]))) |
241 | { | 253 | { |
242 | max -= ret; | 254 | max -= ret; |
243 | used += ret; | 255 | used += ret; |
@@ -395,13 +407,13 @@ copy_latest (void *cls, const struct GNUNET_HELLO_Address *address, | |||
395 | } | 407 | } |
396 | 408 | ||
397 | 409 | ||
398 | static size_t | 410 | static ssize_t |
399 | merge_addr (void *cls, size_t max, void *buf) | 411 | merge_addr (void *cls, size_t max, void *buf) |
400 | { | 412 | { |
401 | struct MergeContext *mc = cls; | 413 | struct MergeContext *mc = cls; |
402 | 414 | ||
403 | if (mc->h1 == NULL) | 415 | if (mc->h1 == NULL) |
404 | return 0; | 416 | return GNUNET_SYSERR; /* Stop iteration */ |
405 | mc->ret = 0; | 417 | mc->ret = 0; |
406 | mc->max = max; | 418 | mc->max = max; |
407 | mc->buf = buf; | 419 | mc->buf = buf; |
@@ -433,11 +445,11 @@ GNUNET_HELLO_merge (const struct GNUNET_HELLO_Message *h1, | |||
433 | int friend_only; | 445 | int friend_only; |
434 | 446 | ||
435 | if (h1->friend_only != h2->friend_only) | 447 | if (h1->friend_only != h2->friend_only) |
436 | friend_only = GNUNET_YES; /* One of the HELLOs is friend only */ | 448 | friend_only = GNUNET_YES; /* One of the HELLOs is friend only */ |
437 | else | 449 | else |
438 | friend_only = ntohl (h1->friend_only); /* Both HELLO's have the same type */ | 450 | friend_only = ntohl (h1->friend_only); /* Both HELLO's have the same type */ |
439 | 451 | ||
440 | return GNUNET_HELLO_create (&h1->publicKey, &merge_addr, &mc, friend_only); | 452 | return GNUNET_HELLO_create (&h1->publicKey, &merge_addr, &mc, friend_only); |
441 | } | 453 | } |
442 | 454 | ||
443 | 455 | ||
@@ -895,9 +907,9 @@ GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello, | |||
895 | * @param cls the 'struct GNUNET_HELLO_AddressParsingContext' | 907 | * @param cls the 'struct GNUNET_HELLO_AddressParsingContext' |
896 | * @param max number of bytes available for HELLO construction | 908 | * @param max number of bytes available for HELLO construction |
897 | * @param buffer where to copy the next address (in binary format) | 909 | * @param buffer where to copy the next address (in binary format) |
898 | * @return number of bytes added to buffer | 910 | * @return number of bytes added to buffer, GNUNET_SYSERR on error |
899 | */ | 911 | */ |
900 | static size_t | 912 | static ssize_t |
901 | add_address_to_hello (void *cls, size_t max, void *buffer) | 913 | add_address_to_hello (void *cls, size_t max, void *buffer) |
902 | { | 914 | { |
903 | struct GNUNET_HELLO_ParseUriContext *ctx = cls; | 915 | struct GNUNET_HELLO_ParseUriContext *ctx = cls; |
@@ -914,15 +926,16 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
914 | void *addr; | 926 | void *addr; |
915 | size_t addr_len; | 927 | size_t addr_len; |
916 | struct GNUNET_HELLO_Address haddr; | 928 | struct GNUNET_HELLO_Address haddr; |
917 | size_t ret; | 929 | ssize_t ret; |
930 | |||
918 | 931 | ||
919 | if (NULL == ctx->pos) | 932 | if (NULL == ctx->pos) |
920 | return 0; | 933 | return GNUNET_SYSERR; |
921 | if ('!' != ctx->pos[0]) | 934 | if ('!' != ctx->pos[0]) |
922 | { | 935 | { |
923 | ctx->ret = GNUNET_SYSERR; | 936 | ctx->ret = GNUNET_SYSERR; |
924 | GNUNET_break (0); | 937 | GNUNET_break (0); |
925 | return 0; | 938 | return GNUNET_SYSERR; |
926 | } | 939 | } |
927 | ctx->pos++; | 940 | ctx->pos++; |
928 | 941 | ||
@@ -943,7 +956,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
943 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 956 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
944 | _("Failed to parse HELLO message: missing expiration time\n")); | 957 | _("Failed to parse HELLO message: missing expiration time\n")); |
945 | GNUNET_break (0); | 958 | GNUNET_break (0); |
946 | return 0; | 959 | return GNUNET_SYSERR; |
947 | } | 960 | } |
948 | 961 | ||
949 | expiration_seconds = mktime (&expiration_time); | 962 | expiration_seconds = mktime (&expiration_time); |
@@ -953,7 +966,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
953 | _("Failed to parse HELLO message: invalid expiration time\n")); | 966 | _("Failed to parse HELLO message: invalid expiration time\n")); |
954 | ctx->ret = GNUNET_SYSERR; | 967 | ctx->ret = GNUNET_SYSERR; |
955 | GNUNET_break (0); | 968 | GNUNET_break (0); |
956 | return 0; | 969 | return GNUNET_SYSERR; |
957 | } | 970 | } |
958 | expire.abs_value_us = expiration_seconds * 1000LL * 1000LL; | 971 | expire.abs_value_us = expiration_seconds * 1000LL * 1000LL; |
959 | } | 972 | } |
@@ -963,7 +976,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
963 | _("Failed to parse HELLO message: malformed\n")); | 976 | _("Failed to parse HELLO message: malformed\n")); |
964 | ctx->ret = GNUNET_SYSERR; | 977 | ctx->ret = GNUNET_SYSERR; |
965 | GNUNET_break (0); | 978 | GNUNET_break (0); |
966 | return 0; | 979 | return GNUNET_SYSERR; |
967 | } | 980 | } |
968 | tname++; | 981 | tname++; |
969 | address = strchr (tname, (int) '!'); | 982 | address = strchr (tname, (int) '!'); |
@@ -973,11 +986,12 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
973 | _("Failed to parse HELLO message: missing transport plugin\n")); | 986 | _("Failed to parse HELLO message: missing transport plugin\n")); |
974 | ctx->ret = GNUNET_SYSERR; | 987 | ctx->ret = GNUNET_SYSERR; |
975 | GNUNET_break (0); | 988 | GNUNET_break (0); |
976 | return 0; | 989 | return GNUNET_SYSERR; |
977 | } | 990 | } |
978 | address++; | 991 | address++; |
979 | end = strchr (address, (int) '!'); | 992 | end = strchr (address, (int) '!'); |
980 | ctx->pos = end; | 993 | ctx->pos = end; |
994 | ctx->counter_total ++; | ||
981 | plugin_name = GNUNET_strndup (tname, address - (tname+1)); | 995 | plugin_name = GNUNET_strndup (tname, address - (tname+1)); |
982 | papi = ctx->plugins_find (plugin_name); | 996 | papi = ctx->plugins_find (plugin_name); |
983 | if (NULL == papi) | 997 | if (NULL == papi) |
@@ -986,7 +1000,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
986 | * Skip this part, advance to the next one and recurse. | 1000 | * Skip this part, advance to the next one and recurse. |
987 | * But only if this is not the end of string. | 1001 | * But only if this is not the end of string. |
988 | */ | 1002 | */ |
989 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1003 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
990 | _("Plugin `%s' not found, skipping address\n"), | 1004 | _("Plugin `%s' not found, skipping address\n"), |
991 | plugin_name); | 1005 | plugin_name); |
992 | GNUNET_free (plugin_name); | 1006 | GNUNET_free (plugin_name); |
@@ -994,7 +1008,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
994 | } | 1008 | } |
995 | if (NULL == papi->string_to_address) | 1009 | if (NULL == papi->string_to_address) |
996 | { | 1010 | { |
997 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1011 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
998 | _("Plugin `%s' does not support URIs yet\n"), | 1012 | _("Plugin `%s' does not support URIs yet\n"), |
999 | plugin_name); | 1013 | plugin_name); |
1000 | GNUNET_free (plugin_name); | 1014 | GNUNET_free (plugin_name); |
@@ -1027,6 +1041,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
1027 | haddr.address = addr; | 1041 | haddr.address = addr; |
1028 | haddr.transport_name = plugin_name; | 1042 | haddr.transport_name = plugin_name; |
1029 | ret = GNUNET_HELLO_add_address (&haddr, expire, buffer, max); | 1043 | ret = GNUNET_HELLO_add_address (&haddr, expire, buffer, max); |
1044 | ctx->counter_added ++; | ||
1030 | GNUNET_free (addr); | 1045 | GNUNET_free (addr); |
1031 | GNUNET_free (plugin_name); | 1046 | GNUNET_free (plugin_name); |
1032 | return ret; | 1047 | return ret; |
@@ -1080,9 +1095,15 @@ GNUNET_HELLO_parse_uri (const char *uri, | |||
1080 | 1095 | ||
1081 | ctx.pos = exc; | 1096 | ctx.pos = exc; |
1082 | ctx.ret = GNUNET_OK; | 1097 | ctx.ret = GNUNET_OK; |
1098 | ctx.counter_total = 0; | ||
1099 | ctx.counter_added = 0; | ||
1083 | ctx.plugins_find = plugins_find; | 1100 | ctx.plugins_find = plugins_find; |
1084 | *hello = GNUNET_HELLO_create (pubkey, &add_address_to_hello, &ctx, friend_only); | 1101 | *hello = GNUNET_HELLO_create (pubkey, &add_address_to_hello, &ctx, friend_only); |
1085 | 1102 | ||
1103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1104 | _("HELLO URI contained %u addresses, added %u addresses\n"), | ||
1105 | ctx.counter_total, ctx.counter_added); | ||
1106 | |||
1086 | return ctx.ret; | 1107 | return ctx.ret; |
1087 | } | 1108 | } |
1088 | 1109 | ||
diff --git a/src/hello/test_friend_hello.c b/src/hello/test_friend_hello.c index 019bf4b9a..79a55925c 100644 --- a/src/hello/test_friend_hello.c +++ b/src/hello/test_friend_hello.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_hello_lib.h" | 26 | #include "gnunet_hello_lib.h" |
27 | 27 | ||
28 | static size_t | 28 | static ssize_t |
29 | my_addr_gen (void *cls, size_t max, void *buf) | 29 | my_addr_gen (void *cls, size_t max, void *buf) |
30 | { | 30 | { |
31 | unsigned int *i = cls; | 31 | unsigned int *i = cls; |
@@ -35,7 +35,7 @@ my_addr_gen (void *cls, size_t max, void *buf) | |||
35 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 35 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
36 | "DEBUG: my_addr_gen called with i = %d\n", *i); | 36 | "DEBUG: my_addr_gen called with i = %d\n", *i); |
37 | if (0 == *i) | 37 | if (0 == *i) |
38 | return 0; | 38 | return GNUNET_SYSERR; /* Stop iteration */ |
39 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); | 39 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); |
40 | address.address = "address_information"; | 40 | address.address = "address_information"; |
41 | address.transport_name = "test"; | 41 | address.transport_name = "test"; |
diff --git a/src/hello/test_hello.c b/src/hello/test_hello.c index ff80f1889..d5d30fa1c 100644 --- a/src/hello/test_hello.c +++ b/src/hello/test_hello.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_hello_lib.h" | 26 | #include "gnunet_hello_lib.h" |
27 | 27 | ||
28 | static size_t | 28 | static ssize_t |
29 | my_addr_gen (void *cls, size_t max, void *buf) | 29 | my_addr_gen (void *cls, size_t max, void *buf) |
30 | { | 30 | { |
31 | unsigned int *i = cls; | 31 | unsigned int *i = cls; |
@@ -35,7 +35,7 @@ my_addr_gen (void *cls, size_t max, void *buf) | |||
35 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 35 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
36 | "DEBUG: my_addr_gen called with i = %d\n", *i); | 36 | "DEBUG: my_addr_gen called with i = %d\n", *i); |
37 | if (0 == *i) | 37 | if (0 == *i) |
38 | return 0; | 38 | return GNUNET_SYSERR; |
39 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); | 39 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); |
40 | address.address = "address_information"; | 40 | address.address = "address_information"; |
41 | address.transport_name = "test"; | 41 | address.transport_name = "test"; |
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index 8e96b5879..a88a3f9ac 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h | |||
@@ -231,10 +231,10 @@ GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, | |||
231 | * @param cls closure | 231 | * @param cls closure |
232 | * @param max maximum number of bytes that can be written to @a buf | 232 | * @param max maximum number of bytes that can be written to @a buf |
233 | * @param buf where to write the address information | 233 | * @param buf where to write the address information |
234 | * @return number of bytes written, 0 to signal the | 234 | * @return number of bytes written or 0, GNUNET_SYSERR to signal the |
235 | * end of the iteration. | 235 | * end of the iteration. |
236 | */ | 236 | */ |
237 | typedef size_t | 237 | typedef ssize_t |
238 | (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, | 238 | (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, |
239 | size_t max, | 239 | size_t max, |
240 | void *buf); | 240 | void *buf); |
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 05d8c3545..9c5f1953a 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -22,6 +22,7 @@ | |||
22 | * @file peerinfo-tool/gnunet-peerinfo.c | 22 | * @file peerinfo-tool/gnunet-peerinfo.c |
23 | * @brief Print information about other known peers. | 23 | * @brief Print information about other known peers. |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * @author Matthias Wachs | ||
25 | */ | 26 | */ |
26 | #include "platform.h" | 27 | #include "platform.h" |
27 | #include "gnunet_crypto_lib.h" | 28 | #include "gnunet_crypto_lib.h" |
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index 4eb84e8c2..3a3213350 100644 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c | |||
@@ -53,16 +53,16 @@ check_it (void *cls, const struct GNUNET_HELLO_Address *address, | |||
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | static size_t | 56 | static ssize_t |
57 | address_generator (void *cls, size_t max, void *buf) | 57 | address_generator (void *cls, size_t max, void *buf) |
58 | { | 58 | { |
59 | size_t *agc = cls; | 59 | size_t *agc = cls; |
60 | size_t ret; | 60 | ssize_t ret; |
61 | char *caddress; | 61 | char *caddress; |
62 | struct GNUNET_HELLO_Address address; | 62 | struct GNUNET_HELLO_Address address; |
63 | 63 | ||
64 | if (*agc == 0) | 64 | if (*agc == 0) |
65 | return 0; | 65 | return GNUNET_SYSERR; /* Done */ |
66 | 66 | ||
67 | GNUNET_asprintf (&caddress, "Address%d", *agc); | 67 | GNUNET_asprintf (&caddress, "Address%d", *agc); |
68 | address.peer = pid; | 68 | address.peer = pid; |
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index d69456e0c..b0d120869 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c | |||
@@ -60,15 +60,15 @@ check_it (void *cls, const struct GNUNET_HELLO_Address *address, | |||
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | static size_t | 63 | static ssize_t |
64 | address_generator (void *cls, size_t max, void *buf) | 64 | address_generator (void *cls, size_t max, void *buf) |
65 | { | 65 | { |
66 | size_t *agc = cls; | 66 | size_t *agc = cls; |
67 | size_t ret; | 67 | ssize_t ret; |
68 | struct GNUNET_HELLO_Address address; | 68 | struct GNUNET_HELLO_Address address; |
69 | 69 | ||
70 | if (0 == *agc) | 70 | if (0 == *agc) |
71 | return 0; | 71 | return GNUNET_SYSERR; /* Done */ |
72 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); | 72 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); |
73 | address.address = "Address"; | 73 | address.address = "Address"; |
74 | address.transport_name = "peerinfotest"; | 74 | address.transport_name = "peerinfotest"; |
diff --git a/src/peerinfo/test_peerinfo_api_friend_only.c b/src/peerinfo/test_peerinfo_api_friend_only.c index e2c4ec574..3b4eeb8f5 100644 --- a/src/peerinfo/test_peerinfo_api_friend_only.c +++ b/src/peerinfo/test_peerinfo_api_friend_only.c | |||
@@ -42,15 +42,15 @@ static unsigned int retries; | |||
42 | 42 | ||
43 | static int global_ret; | 43 | static int global_ret; |
44 | 44 | ||
45 | static size_t | 45 | static ssize_t |
46 | address_generator (void *cls, size_t max, void *buf) | 46 | address_generator (void *cls, size_t max, void *buf) |
47 | { | 47 | { |
48 | size_t *agc = cls; | 48 | size_t *agc = cls; |
49 | size_t ret; | 49 | ssize_t ret; |
50 | struct GNUNET_HELLO_Address address; | 50 | struct GNUNET_HELLO_Address address; |
51 | 51 | ||
52 | if (0 == *agc) | 52 | if (0 == *agc) |
53 | return 0; | 53 | return GNUNET_SYSERR; /* Done */ |
54 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); | 54 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); |
55 | address.address = "Address"; | 55 | address.address = "Address"; |
56 | address.transport_name = "peerinfotest"; | 56 | address.transport_name = "peerinfotest"; |
diff --git a/src/peerinfo/test_peerinfo_api_notify_friend_only.c b/src/peerinfo/test_peerinfo_api_notify_friend_only.c index f37107898..c47fe6387 100644 --- a/src/peerinfo/test_peerinfo_api_notify_friend_only.c +++ b/src/peerinfo/test_peerinfo_api_notify_friend_only.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2004, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2004, 2009 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation; either version 3, or (at your |
8 | option) any later version. | 8 | option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with GNUnet; see the file COPYING. If not, write to the |
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file peerinfo/test_peerinfo_api_notify_friend_only.c | 22 | * @file peerinfo/test_peerinfo_api_notify_friend_only.c |
@@ -42,7 +42,6 @@ static struct GNUNET_PEERINFO_NotifyContext *pnc_wo_fo; | |||
42 | 42 | ||
43 | static const struct GNUNET_CONFIGURATION_Handle *mycfg; | 43 | static const struct GNUNET_CONFIGURATION_Handle *mycfg; |
44 | 44 | ||
45 | |||
46 | static int global_ret; | 45 | static int global_ret; |
47 | 46 | ||
48 | /** | 47 | /** |
@@ -61,169 +60,164 @@ struct GNUNET_PeerIdentity pid; | |||
61 | 60 | ||
62 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 61 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; |
63 | 62 | ||
64 | |||
65 | static void | 63 | static void |
66 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 64 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
67 | { | 65 | { |
68 | timeout_task = GNUNET_SCHEDULER_NO_TASK; | 66 | timeout_task = GNUNET_SCHEDULER_NO_TASK; |
69 | GNUNET_break (0); | 67 | GNUNET_break(0); |
70 | if (NULL != pnc_wo_fo) | 68 | if (NULL != pnc_wo_fo) |
71 | { | 69 | { |
72 | GNUNET_PEERINFO_notify_cancel (pnc_wo_fo); | 70 | GNUNET_PEERINFO_notify_cancel (pnc_wo_fo); |
73 | pnc_wo_fo = NULL; | 71 | pnc_wo_fo = NULL; |
74 | } | 72 | } |
75 | if (NULL != pnc_w_fo) | 73 | if (NULL != pnc_w_fo) |
76 | { | 74 | { |
77 | GNUNET_PEERINFO_notify_cancel (pnc_w_fo); | 75 | GNUNET_PEERINFO_notify_cancel (pnc_w_fo); |
78 | pnc_w_fo = NULL; | 76 | pnc_w_fo = NULL; |
79 | } | 77 | } |
80 | if (NULL != h) | 78 | if (NULL != h) |
81 | { | 79 | { |
82 | GNUNET_PEERINFO_disconnect (h); | 80 | GNUNET_PEERINFO_disconnect (h); |
83 | h = NULL; | 81 | h = NULL; |
84 | } | 82 | } |
85 | global_ret = 255; | 83 | global_ret = 255; |
86 | } | 84 | } |
87 | 85 | ||
88 | static void | 86 | static void |
89 | done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 87 | done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
90 | { | 88 | { |
91 | if (NULL != pnc_w_fo) | 89 | if (NULL != pnc_w_fo) |
92 | GNUNET_PEERINFO_notify_cancel (pnc_w_fo); | 90 | GNUNET_PEERINFO_notify_cancel (pnc_w_fo); |
93 | pnc_w_fo = NULL; | 91 | pnc_w_fo = NULL; |
94 | if (NULL != pnc_wo_fo) | 92 | if (NULL != pnc_wo_fo) |
95 | GNUNET_PEERINFO_notify_cancel (pnc_wo_fo); | 93 | GNUNET_PEERINFO_notify_cancel (pnc_wo_fo); |
96 | pnc_wo_fo = NULL; | 94 | pnc_wo_fo = NULL; |
97 | GNUNET_PEERINFO_disconnect (h); | 95 | GNUNET_PEERINFO_disconnect (h); |
98 | h = NULL; | 96 | h = NULL; |
99 | 97 | ||
100 | if (GNUNET_SCHEDULER_NO_TASK != timeout_task) | 98 | if (GNUNET_SCHEDULER_NO_TASK != timeout_task) |
101 | { | 99 | { |
102 | GNUNET_SCHEDULER_cancel (timeout_task); | 100 | GNUNET_SCHEDULER_cancel (timeout_task); |
103 | timeout_task = GNUNET_SCHEDULER_NO_TASK; | 101 | timeout_task = GNUNET_SCHEDULER_NO_TASK; |
104 | } | 102 | } |
105 | 103 | ||
106 | if ((GNUNET_YES == res_cb_w_fo) && (GNUNET_NO == res_cb_wo_fo)) | 104 | if ((GNUNET_YES == res_cb_w_fo) && (GNUNET_NO == res_cb_wo_fo)) |
107 | global_ret = 0; | 105 | global_ret = 0; |
108 | else | 106 | else |
109 | GNUNET_break (0); | 107 | GNUNET_break(0); |
110 | } | 108 | } |
111 | 109 | ||
112 | static size_t | 110 | static ssize_t |
113 | address_generator (void *cls, size_t max, void *buf) | 111 | address_generator (void *cls, size_t max, void *buf) |
114 | { | 112 | { |
115 | size_t *agc = cls; | 113 | size_t *agc = cls; |
116 | size_t ret; | 114 | ssize_t ret; |
117 | struct GNUNET_HELLO_Address address; | 115 | struct GNUNET_HELLO_Address address; |
118 | 116 | ||
119 | if (0 == *agc) | 117 | if (0 == *agc) |
120 | return 0; | 118 | return GNUNET_SYSERR; /* Done */ |
121 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); | 119 | memset (&address.peer, 0, sizeof(struct GNUNET_PeerIdentity)); |
122 | address.address = "Address"; | 120 | address.address = "Address"; |
123 | address.transport_name = "peerinfotest"; | 121 | address.transport_name = "peerinfotest"; |
124 | address.address_length = *agc; | 122 | address.address_length = *agc; |
125 | ret = | 123 | ret = GNUNET_HELLO_add_address (&address, |
126 | GNUNET_HELLO_add_address (&address, | 124 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS), buf, max); |
127 | GNUNET_TIME_relative_to_absolute | ||
128 | (GNUNET_TIME_UNIT_HOURS), buf, max); | ||
129 | (*agc)--; | 125 | (*agc)--; |
130 | return ret; | 126 | return ret; |
131 | } | 127 | } |
132 | 128 | ||
133 | static void | 129 | static void |
134 | process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | 130 | process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer, |
135 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 131 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
136 | { | 132 | { |
137 | if (err_msg != NULL) | 133 | if (err_msg != NULL ) |
138 | { | 134 | { |
139 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 135 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
140 | _("Error in communication with PEERINFO service\n")); | 136 | _("Error in communication with PEERINFO service\n")); |
141 | GNUNET_SCHEDULER_add_now(&done, NULL); | 137 | GNUNET_SCHEDULER_add_now (&done, NULL ); |
142 | return; | 138 | return; |
143 | } | 139 | } |
144 | 140 | ||
145 | if (NULL != peer) | 141 | if (NULL != peer) |
146 | { | 142 | { |
147 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received callback for peer `%s' %s HELLO\n", | 143 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
148 | GNUNET_i2s (peer), | 144 | "Received callback for peer `%s' %s HELLO\n", GNUNET_i2s (peer), |
149 | (NULL != hello) ? "with" : "without"); | 145 | (NULL != hello) ? "with" : "without"); |
150 | 146 | ||
151 | if (NULL == hello) | 147 | if (NULL == hello) |
152 | return; | 148 | return; |
153 | 149 | ||
154 | if (GNUNET_NO == GNUNET_HELLO_is_friend_only(hello)) | 150 | if (GNUNET_NO == GNUNET_HELLO_is_friend_only (hello)) |
155 | { | 151 | { |
156 | GNUNET_break (0); | 152 | GNUNET_break(0); |
157 | return; | 153 | return; |
158 | } | 154 | } |
159 | 155 | ||
160 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO for peer `%s'\n", | 156 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Received %s HELLO for peer `%s'\n", |
161 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public", | 157 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public", |
162 | GNUNET_i2s (peer)); | 158 | GNUNET_i2s (peer)); |
163 | if (0 == memcmp (&pid, peer, sizeof (pid))) | 159 | if (0 == memcmp (&pid, peer, sizeof(pid))) |
164 | { | 160 | { |
165 | res_cb_w_fo = GNUNET_YES; | 161 | res_cb_w_fo = GNUNET_YES; |
166 | GNUNET_SCHEDULER_add_now(&done, NULL); | 162 | GNUNET_SCHEDULER_add_now (&done, NULL ); |
167 | } | 163 | } |
168 | return; | 164 | return; |
169 | } | 165 | } |
170 | } | 166 | } |
171 | 167 | ||
172 | static void | 168 | static void |
173 | process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | 169 | process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer, |
174 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 170 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
175 | { | 171 | { |
176 | if (err_msg != NULL) | 172 | if (err_msg != NULL ) |
177 | { | 173 | { |
178 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 174 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
179 | _("Error in communication with PEERINFO service\n")); | 175 | _("Error in communication with PEERINFO service\n")); |
180 | GNUNET_SCHEDULER_add_now(&done, NULL); | 176 | GNUNET_SCHEDULER_add_now (&done, NULL ); |
181 | return; | 177 | return; |
182 | } | 178 | } |
183 | 179 | ||
184 | if (NULL != peer) | 180 | if (NULL != peer) |
185 | { | 181 | { |
186 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received callback for peer `%s' %s HELLO\n", | 182 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
187 | GNUNET_i2s (peer), | 183 | "Received callback for peer `%s' %s HELLO\n", GNUNET_i2s (peer), |
188 | (NULL != hello) ? "with" : "without"); | 184 | (NULL != hello) ? "with" : "without"); |
189 | 185 | ||
190 | if (NULL == hello) | 186 | if (NULL == hello) |
191 | return; | 187 | return; |
192 | 188 | ||
193 | if (GNUNET_YES == GNUNET_HELLO_is_friend_only(hello)) | 189 | if (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) |
194 | { | 190 | { |
195 | GNUNET_break (0); | 191 | GNUNET_break(0); |
196 | return; | 192 | return; |
197 | } | 193 | } |
198 | 194 | ||
199 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO for peer `%s'\n", | 195 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Received %s HELLO for peer `%s'\n", |
200 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public", | 196 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public", |
201 | GNUNET_i2s (peer)); | 197 | GNUNET_i2s (peer)); |
202 | if (0 == memcmp (&pid, peer, sizeof (pid))) | 198 | if (0 == memcmp (&pid, peer, sizeof(pid))) |
203 | { | 199 | { |
204 | GNUNET_break (0); | 200 | GNUNET_break(0); |
205 | res_cb_wo_fo = GNUNET_YES; | 201 | res_cb_wo_fo = GNUNET_YES; |
206 | } | 202 | } |
207 | } | 203 | } |
208 | } | 204 | } |
209 | 205 | ||
210 | static void | 206 | static void |
211 | add_peer_done (void *cls, const char *emsg) | 207 | add_peer_done (void *cls, const char *emsg) |
212 | { | 208 | { |
213 | if (NULL == emsg) | 209 | if (NULL == emsg) |
214 | { | 210 | { |
215 | return; | 211 | return; |
216 | } | 212 | } |
217 | else | 213 | else |
218 | { | 214 | { |
219 | GNUNET_break (0); | 215 | GNUNET_break(0); |
220 | GNUNET_SCHEDULER_cancel (timeout_task); | 216 | GNUNET_SCHEDULER_cancel (timeout_task); |
221 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 217 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL ); |
222 | } | 218 | } |
223 | } | 219 | } |
224 | 220 | ||
225 | |||
226 | |||
227 | static void | 221 | static void |
228 | add_peer () | 222 | add_peer () |
229 | { | 223 | { |
@@ -231,40 +225,36 @@ add_peer () | |||
231 | size_t agc; | 225 | size_t agc; |
232 | 226 | ||
233 | agc = 2; | 227 | agc = 2; |
234 | memset (&pid, 32, sizeof (pid)); | 228 | memset (&pid, 32, sizeof(pid)); |
235 | h2 = GNUNET_HELLO_create (&pid.public_key, &address_generator, &agc, GNUNET_YES); | 229 | h2 = GNUNET_HELLO_create (&pid.public_key, &address_generator, &agc, |
236 | GNUNET_PEERINFO_add_peer (h, h2, &add_peer_done, NULL); | 230 | GNUNET_YES); |
237 | GNUNET_free (h2); | 231 | GNUNET_PEERINFO_add_peer (h, h2, &add_peer_done, NULL ); |
232 | GNUNET_free(h2); | ||
238 | 233 | ||
239 | } | 234 | } |
240 | 235 | ||
241 | |||
242 | |||
243 | static void | 236 | static void |
244 | run (void *cls, | 237 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, |
245 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 238 | struct GNUNET_TESTING_Peer *peer) |
246 | struct GNUNET_TESTING_Peer *peer) | ||
247 | { | 239 | { |
248 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 240 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL ); |
249 | mycfg = cfg; | 241 | mycfg = cfg; |
250 | pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL); | 242 | pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL ); |
251 | pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL); | 243 | pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL ); |
252 | h = GNUNET_PEERINFO_connect (cfg); | 244 | h = GNUNET_PEERINFO_connect (cfg); |
253 | GNUNET_assert (NULL != h); | 245 | GNUNET_assert(NULL != h); |
254 | add_peer (); | 246 | add_peer (); |
255 | } | 247 | } |
256 | 248 | ||
257 | |||
258 | int | 249 | int |
259 | main (int argc, char *argv[]) | 250 | main (int argc, char *argv[]) |
260 | { | 251 | { |
261 | res_cb_w_fo = GNUNET_NO; | 252 | res_cb_w_fo = GNUNET_NO; |
262 | res_cb_wo_fo = GNUNET_NO; | 253 | res_cb_wo_fo = GNUNET_NO; |
263 | global_ret = 3; | 254 | global_ret = 3; |
264 | if (0 != GNUNET_TESTING_service_run ("test-peerinfo-api-friend-only", | 255 | if (0 |
265 | "peerinfo", | 256 | != GNUNET_TESTING_service_run ("test-peerinfo-api-friend-only", |
266 | "test_peerinfo_api_data.conf", | 257 | "peerinfo", "test_peerinfo_api_data.conf", &run, NULL )) |
267 | &run, NULL)) | ||
268 | return 1; | 258 | return 1; |
269 | return global_ret; | 259 | return global_ret; |
270 | } | 260 | } |
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index 626be54c1..49992222d 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c | |||
@@ -133,17 +133,18 @@ struct GeneratorContext | |||
133 | * @param cls the 'struct GeneratorContext' | 133 | * @param cls the 'struct GeneratorContext' |
134 | * @param max maximum number of bytes left | 134 | * @param max maximum number of bytes left |
135 | * @param buf where to write the address | 135 | * @param buf where to write the address |
136 | * @return bytes written or GNUNET_SYSERR to signal the | ||
137 | * end of the iteration. | ||
136 | */ | 138 | */ |
137 | static size_t | 139 | static ssize_t |
138 | address_generator (void *cls, size_t max, void *buf) | 140 | address_generator (void *cls, size_t max, void *buf) |
139 | { | 141 | { |
140 | struct GeneratorContext *gc = cls; | 142 | struct GeneratorContext *gc = cls; |
141 | size_t ret; | 143 | ssize_t ret; |
142 | 144 | ||
143 | if (NULL == gc->addr_pos) | 145 | if (NULL == gc->addr_pos) |
144 | return 0; | 146 | return GNUNET_SYSERR; /* Done */ |
145 | ret = | 147 | ret = GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration, buf, |
146 | GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration, buf, | ||
147 | max); | 148 | max); |
148 | gc->addr_pos = gc->addr_pos->next; | 149 | gc->addr_pos = gc->addr_pos->next; |
149 | return ret; | 150 | return ret; |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index eb3f4c07d..7c2675df3 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -1280,16 +1280,16 @@ validate_address_iterator (void *cls, | |||
1280 | * @param cls the 'struct ValidationEntry' with the validated address | 1280 | * @param cls the 'struct ValidationEntry' with the validated address |
1281 | * @param max space in buf | 1281 | * @param max space in buf |
1282 | * @param buf where to add the address | 1282 | * @param buf where to add the address |
1283 | * @return number of bytes written, 0 to signal the | 1283 | * @return number of bytes written, GNUNET_SYSERR to signal the |
1284 | * end of the iteration. | 1284 | * end of the iteration. |
1285 | */ | 1285 | */ |
1286 | static size_t | 1286 | static ssize_t |
1287 | add_valid_peer_address (void *cls, size_t max, void *buf) | 1287 | add_valid_peer_address (void *cls, size_t max, void *buf) |
1288 | { | 1288 | { |
1289 | struct ValidationEntry *ve = cls; | 1289 | struct ValidationEntry *ve = cls; |
1290 | 1290 | ||
1291 | if (GNUNET_YES == ve->copied) | 1291 | if (GNUNET_YES == ve->copied) |
1292 | return 0; /* terminate */ | 1292 | return GNUNET_SYSERR; /* Done */ |
1293 | ve->copied = GNUNET_YES; | 1293 | ve->copied = GNUNET_YES; |
1294 | return GNUNET_HELLO_add_address (ve->address, ve->valid_until, buf, max); | 1294 | return GNUNET_HELLO_add_address (ve->address, ve->valid_until, buf, max); |
1295 | } | 1295 | } |