diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/gnunet-service-core.c | 14 | ||||
-rw-r--r-- | src/core/test_core_api.c | 10 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist.c | 11 | ||||
-rw-r--r-- | src/testing/testing.c | 42 |
4 files changed, 43 insertions, 34 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 71771905e..0f4a3c3b9 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -2880,16 +2880,18 @@ handle_encrypted_message (struct Neighbour *n, | |||
2880 | * Function called by the transport for each received message. | 2880 | * Function called by the transport for each received message. |
2881 | * | 2881 | * |
2882 | * @param cls closure | 2882 | * @param cls closure |
2883 | * @param latency estimated latency for communicating with the | ||
2884 | * given peer | ||
2885 | * @param peer (claimed) identity of the other peer | 2883 | * @param peer (claimed) identity of the other peer |
2886 | * @param message the message | 2884 | * @param message the message |
2885 | * @param latency estimated latency for communicating with the | ||
2886 | * given peer (round-trip) | ||
2887 | * @param distance in overlay hops, as given by transport plugin | ||
2887 | */ | 2888 | */ |
2888 | static void | 2889 | static void |
2889 | handle_transport_receive (void *cls, | 2890 | handle_transport_receive (void *cls, |
2890 | struct GNUNET_TIME_Relative latency, | ||
2891 | const struct GNUNET_PeerIdentity *peer, | 2891 | const struct GNUNET_PeerIdentity *peer, |
2892 | const struct GNUNET_MessageHeader *message) | 2892 | const struct GNUNET_MessageHeader *message, |
2893 | struct GNUNET_TIME_Relative latency, | ||
2894 | unsigned int distance) | ||
2893 | { | 2895 | { |
2894 | struct Neighbour *n; | 2896 | struct Neighbour *n; |
2895 | struct GNUNET_TIME_Absolute now; | 2897 | struct GNUNET_TIME_Absolute now; |
@@ -3073,11 +3075,13 @@ neighbour_quota_update (void *cls, | |||
3073 | * @param cls closure | 3075 | * @param cls closure |
3074 | * @param peer the peer that connected | 3076 | * @param peer the peer that connected |
3075 | * @param latency current latency of the connection | 3077 | * @param latency current latency of the connection |
3078 | * @param distance in overlay hops, as given by transport plugin | ||
3076 | */ | 3079 | */ |
3077 | static void | 3080 | static void |
3078 | handle_transport_notify_connect (void *cls, | 3081 | handle_transport_notify_connect (void *cls, |
3079 | const struct GNUNET_PeerIdentity *peer, | 3082 | const struct GNUNET_PeerIdentity *peer, |
3080 | struct GNUNET_TIME_Relative latency) | 3083 | struct GNUNET_TIME_Relative latency, |
3084 | unsigned int distance) | ||
3081 | { | 3085 | { |
3082 | struct Neighbour *n; | 3086 | struct Neighbour *n; |
3083 | struct GNUNET_TIME_Absolute now; | 3087 | struct GNUNET_TIME_Absolute now; |
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index acece6545..7cb5e245c 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -243,16 +243,14 @@ init_notify (void *cls, | |||
243 | 243 | ||
244 | static void | 244 | static void |
245 | process_hello (void *cls, | 245 | process_hello (void *cls, |
246 | struct GNUNET_TIME_Relative latency, | ||
247 | const struct GNUNET_PeerIdentity *peer, | ||
248 | const struct GNUNET_MessageHeader *message) | 246 | const struct GNUNET_MessageHeader *message) |
249 | { | 247 | { |
250 | struct PeerContext *p = cls; | 248 | struct PeerContext *p = cls; |
251 | 249 | ||
252 | GNUNET_assert (peer != NULL); | 250 | GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p); |
253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
254 | "Received (my) `%s' from transport service of `%4s'\n", | 252 | "Received (my) `%s' from transport service\n", |
255 | "HELLO", GNUNET_i2s (peer)); | 253 | "HELLO"); |
256 | GNUNET_assert (message != NULL); | 254 | GNUNET_assert (message != NULL); |
257 | p->hello = GNUNET_malloc (ntohs (message->size)); | 255 | p->hello = GNUNET_malloc (ntohs (message->size)); |
258 | memcpy (p->hello, message, ntohs (message->size)); | 256 | memcpy (p->hello, message, ntohs (message->size)); |
@@ -285,7 +283,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
285 | GNUNET_ARM_start_services (p->cfg, sched, "core", NULL); | 283 | GNUNET_ARM_start_services (p->cfg, sched, "core", NULL); |
286 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL); | 284 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL); |
287 | GNUNET_assert (p->th != NULL); | 285 | GNUNET_assert (p->th != NULL); |
288 | GNUNET_TRANSPORT_get_hello (p->th, TIMEOUT, &process_hello, p); | 286 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); |
289 | } | 287 | } |
290 | 288 | ||
291 | 289 | ||
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 904990a83..f9d2e9169 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c | |||
@@ -95,11 +95,13 @@ timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
95 | * @param cls closure | 95 | * @param cls closure |
96 | * @param peer the peer that connected | 96 | * @param peer the peer that connected |
97 | * @param latency current latency of the connection | 97 | * @param latency current latency of the connection |
98 | * @param distance in overlay hops, as given by transport plugin | ||
98 | */ | 99 | */ |
99 | static void | 100 | static void |
100 | notify_connect (void *cls, | 101 | notify_connect (void *cls, |
101 | const struct GNUNET_PeerIdentity * peer, | 102 | const struct GNUNET_PeerIdentity * peer, |
102 | struct GNUNET_TIME_Relative latency) | 103 | struct GNUNET_TIME_Relative latency, |
104 | unsigned int distance) | ||
103 | { | 105 | { |
104 | if (peer == NULL) | 106 | if (peer == NULL) |
105 | return; | 107 | return; |
@@ -120,14 +122,11 @@ notify_connect (void *cls, | |||
120 | 122 | ||
121 | static void | 123 | static void |
122 | process_hello (void *cls, | 124 | process_hello (void *cls, |
123 | struct GNUNET_TIME_Relative latency, | ||
124 | const struct GNUNET_PeerIdentity *peer, | ||
125 | const struct GNUNET_MessageHeader *message) | 125 | const struct GNUNET_MessageHeader *message) |
126 | { | 126 | { |
127 | struct PeerContext *p = cls; | 127 | struct PeerContext *p = cls; |
128 | 128 | ||
129 | if (message == NULL) | 129 | GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p); |
130 | return; | ||
131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
132 | "Received HELLO, starting hostlist service.\n"); | 131 | "Received HELLO, starting hostlist service.\n"); |
133 | GNUNET_ARM_start_services (p->cfg, sched, "hostlist", NULL); | 132 | GNUNET_ARM_start_services (p->cfg, sched, "hostlist", NULL); |
@@ -151,7 +150,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
151 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, | 150 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, |
152 | ¬ify_connect, NULL); | 151 | ¬ify_connect, NULL); |
153 | GNUNET_assert (p->th != NULL); | 152 | GNUNET_assert (p->th != NULL); |
154 | GNUNET_TRANSPORT_get_hello (p->th, TIMEOUT, &process_hello, p); | 153 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); |
155 | } | 154 | } |
156 | 155 | ||
157 | 156 | ||
diff --git a/src/testing/testing.c b/src/testing/testing.c index 489252411..628856b21 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -973,34 +973,41 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
973 | } | 973 | } |
974 | 974 | ||
975 | 975 | ||
976 | #if 0 | ||
977 | static void | ||
978 | timeout_hello_task (void *cls, | ||
979 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
980 | { | ||
981 | GNUNET_TRANSPORT_get_hello_cancel (ctx->d1th, | ||
982 | &process_hello, | ||
983 | ctx); | ||
984 | GNUNET_TRANSPORT_disconnect (ctx->d1th); | ||
985 | GNUNET_TRANSPORT_disconnect (ctx->d2th); | ||
986 | if (NULL != ctx->cb) | ||
987 | ctx->cb (ctx->cb_cls, | ||
988 | _("Failed to receive `HELLO' from peer\n")); | ||
989 | GNUNET_free (ctx); | ||
990 | } | ||
991 | #endif | ||
992 | |||
993 | |||
976 | /** | 994 | /** |
977 | * Receive the HELLO from one peer, give it to the other | 995 | * Receive the HELLO from one peer, give it to the other |
978 | * and ask them to connect. | 996 | * and ask them to connect. |
979 | * | 997 | * |
980 | * @param cls "struct ConnectContext" | 998 | * @param cls "struct ConnectContext" |
981 | * @param latency how fast is the connection | ||
982 | * @param peer ID of peer giving us the HELLO | ||
983 | * @param message HELLO message of peer | 999 | * @param message HELLO message of peer |
984 | */ | 1000 | */ |
985 | static void | 1001 | static void |
986 | process_hello (void *cls, | 1002 | process_hello (void *cls, |
987 | struct GNUNET_TIME_Relative latency, | ||
988 | const struct GNUNET_PeerIdentity *peer, | ||
989 | const struct GNUNET_MessageHeader *message) | 1003 | const struct GNUNET_MessageHeader *message) |
990 | { | 1004 | { |
991 | struct ConnectContext *ctx = cls; | 1005 | struct ConnectContext *ctx = cls; |
992 | 1006 | ||
993 | if (peer == NULL) | 1007 | /* first of all, stop the notification stuff */ |
994 | { | 1008 | GNUNET_TRANSPORT_get_hello_cancel (ctx->d1th, |
995 | /* signal error */ | 1009 | &process_hello, |
996 | GNUNET_TRANSPORT_disconnect (ctx->d1th); | 1010 | ctx); |
997 | GNUNET_TRANSPORT_disconnect (ctx->d2th); | ||
998 | if (NULL != ctx->cb) | ||
999 | ctx->cb (ctx->cb_cls, | ||
1000 | _("Failed to receive `HELLO' from peer\n")); | ||
1001 | GNUNET_free (ctx); | ||
1002 | return; | ||
1003 | } | ||
1004 | #if DEBUG_TESTING | 1011 | #if DEBUG_TESTING |
1005 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1012 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1006 | "Received `%s' from transport service of `%4s'\n", | 1013 | "Received `%s' from transport service of `%4s'\n", |
@@ -1071,9 +1078,10 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
1071 | if (NULL != cb) | 1078 | if (NULL != cb) |
1072 | cb (cb_cls, _("Failed to connect to transport service!\n")); | 1079 | cb (cb_cls, _("Failed to connect to transport service!\n")); |
1073 | return; | 1080 | return; |
1074 | } | 1081 | } |
1082 | /* FIXME: need to handle timeout: start timeout task | ||
1083 | as well here! (use 'timeout_hello_task') */ | ||
1075 | GNUNET_TRANSPORT_get_hello (ctx->d1th, | 1084 | GNUNET_TRANSPORT_get_hello (ctx->d1th, |
1076 | timeout, | ||
1077 | &process_hello, | 1085 | &process_hello, |
1078 | ctx); | 1086 | ctx); |
1079 | } | 1087 | } |