diff options
Diffstat (limited to 'src/mesh/gnunet-service-mesh_peer.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 142 |
1 files changed, 83 insertions, 59 deletions
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index 0de74bb12..22887f012 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #include "gnunet_core_service.h" | 25 | #include "gnunet_core_service.h" |
26 | 26 | ||
27 | #include "mesh_protocol_enc.h" | ||
28 | |||
27 | #include "gnunet-service-mesh_peer.h" | 29 | #include "gnunet-service-mesh_peer.h" |
28 | #include "gnunet-service-mesh_dht.h" | 30 | #include "gnunet-service-mesh_dht.h" |
29 | #include "gnunet-service-mesh_connection.h" | 31 | #include "gnunet-service-mesh_connection.h" |
@@ -154,6 +156,7 @@ notify_broken (void *cls, | |||
154 | return GNUNET_YES; | 156 | return GNUNET_YES; |
155 | } | 157 | } |
156 | 158 | ||
159 | |||
157 | /** | 160 | /** |
158 | * Method called whenever a given peer connects. | 161 | * Method called whenever a given peer connects. |
159 | * | 162 | * |
@@ -171,12 +174,12 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
171 | pi = peer_get (peer); | 174 | pi = peer_get (peer); |
172 | if (myid == pi->id) | 175 | if (myid == pi->id) |
173 | { | 176 | { |
174 | DEBUG_CONN (" (self)\n"); | 177 | LOG (" (self)\n"); |
175 | path = path_new (1); | 178 | path = path_new (1); |
176 | } | 179 | } |
177 | else | 180 | else |
178 | { | 181 | { |
179 | DEBUG_CONN (" %s\n", GNUNET_i2s (peer)); | 182 | LOG (" %s\n", GNUNET_i2s (peer)); |
180 | path = path_new (2); | 183 | path = path_new (2); |
181 | path->peers[1] = pi->id; | 184 | path->peers[1] = pi->id; |
182 | GNUNET_PEER_change_rc (pi->id, 1); | 185 | GNUNET_PEER_change_rc (pi->id, 1); |
@@ -202,7 +205,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
202 | { | 205 | { |
203 | struct MeshPeer *pi; | 206 | struct MeshPeer *pi; |
204 | 207 | ||
205 | DEBUG_CONN ("Peer disconnected\n"); | 208 | LOG ("Peer disconnected\n"); |
206 | pi = GNUNET_CONTAINER_multipeermap_get (peers, peer); | 209 | pi = GNUNET_CONTAINER_multipeermap_get (peers, peer); |
207 | if (NULL == pi) | 210 | if (NULL == pi) |
208 | { | 211 | { |
@@ -220,7 +223,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
220 | } | 223 | } |
221 | if (myid == pi->id) | 224 | if (myid == pi->id) |
222 | { | 225 | { |
223 | DEBUG_CONN (" (self)\n"); | 226 | LOG (" (self)\n"); |
224 | } | 227 | } |
225 | GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO); | 228 | GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO); |
226 | 229 | ||
@@ -228,6 +231,31 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
228 | } | 231 | } |
229 | 232 | ||
230 | 233 | ||
234 | /** | ||
235 | * Functions to handle messages from core | ||
236 | */ | ||
237 | static struct GNUNET_CORE_MessageHandler core_handlers[] = { | ||
238 | {&GMC_handle_create, GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE, | ||
239 | 0}, | ||
240 | {&GMC_handle_confirm, GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK, | ||
241 | sizeof (struct GNUNET_MESH_ConnectionACK)}, | ||
242 | {&GMC_handle_broken, GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN, | ||
243 | sizeof (struct GNUNET_MESH_ConnectionBroken)}, | ||
244 | {&GMC_handle_destroy, GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY, | ||
245 | sizeof (struct GNUNET_MESH_ConnectionDestroy)}, | ||
246 | {&GMC_handle_keepalive, GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE, | ||
247 | sizeof (struct GNUNET_MESH_ConnectionKeepAlive)}, | ||
248 | {&GMC_handle_keepalive, GNUNET_MESSAGE_TYPE_MESH_BCK_KEEPALIVE, | ||
249 | sizeof (struct GNUNET_MESH_ConnectionKeepAlive)}, | ||
250 | {&GMC_handle_ack, GNUNET_MESSAGE_TYPE_MESH_ACK, | ||
251 | sizeof (struct GNUNET_MESH_ACK)}, | ||
252 | {&GMC_handle_poll, GNUNET_MESSAGE_TYPE_MESH_POLL, | ||
253 | sizeof (struct GNUNET_MESH_Poll)}, | ||
254 | {&GMC_handle_fwd, GNUNET_MESSAGE_TYPE_MESH_FWD, 0}, | ||
255 | {&GMC_handle_bck, GNUNET_MESSAGE_TYPE_MESH_BCK, 0}, | ||
256 | {NULL, 0, 0} | ||
257 | }; | ||
258 | |||
231 | 259 | ||
232 | /** | 260 | /** |
233 | * To be called on core init/fail. | 261 | * To be called on core init/fail. |
@@ -242,16 +270,12 @@ core_init (void *cls, | |||
242 | const struct GNUNET_CONFIGURATION_Handle *c = cls; | 270 | const struct GNUNET_CONFIGURATION_Handle *c = cls; |
243 | static int i = 0; | 271 | static int i = 0; |
244 | 272 | ||
245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core init\n"); | 273 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Core init\n"); |
246 | if (0 != memcmp (identity, &my_full_id, sizeof (my_full_id))) | 274 | if (0 != memcmp (identity, &my_full_id, sizeof (my_full_id))) |
247 | { | 275 | { |
248 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Wrong CORE service\n")); | 276 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Wrong CORE service\n")); |
249 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 277 | LOG (GNUNET_ERROR_TYPE_ERROR, " core id %s\n", GNUNET_i2s (identity)); |
250 | " core id %s\n", | 278 | LOG (GNUNET_ERROR_TYPE_ERROR, " my id %s\n", GNUNET_i2s (&my_full_id)); |
251 | GNUNET_i2s (identity)); | ||
252 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
253 | " my id %s\n", | ||
254 | GNUNET_i2s (&my_full_id)); | ||
255 | GNUNET_CORE_disconnect (core_handle); | 279 | GNUNET_CORE_disconnect (core_handle); |
256 | core_handle = GNUNET_CORE_connect (c, /* Main configuration */ | 280 | core_handle = GNUNET_CORE_connect (c, /* Main configuration */ |
257 | NULL, /* Closure passed to MESH functions */ | 281 | NULL, /* Closure passed to MESH functions */ |
@@ -316,7 +340,7 @@ send_core_connection_create (struct MeshConnection *c, size_t size, void *buf) | |||
316 | size_t size_needed; | 340 | size_t size_needed; |
317 | int i; | 341 | int i; |
318 | 342 | ||
319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION CREATE...\n"); | 343 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION CREATE...\n"); |
320 | size_needed = | 344 | size_needed = |
321 | sizeof (struct GNUNET_MESH_ConnectionCreate) + | 345 | sizeof (struct GNUNET_MESH_ConnectionCreate) + |
322 | p->length * sizeof (struct GNUNET_PeerIdentity); | 346 | p->length * sizeof (struct GNUNET_PeerIdentity); |
@@ -337,7 +361,7 @@ send_core_connection_create (struct MeshConnection *c, size_t size, void *buf) | |||
337 | GNUNET_PEER_resolve (p->peers[i], peer_ptr++); | 361 | GNUNET_PEER_resolve (p->peers[i], peer_ptr++); |
338 | } | 362 | } |
339 | 363 | ||
340 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 364 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
341 | "CONNECTION CREATE (%u bytes long) sent!\n", size_needed); | 365 | "CONNECTION CREATE (%u bytes long) sent!\n", size_needed); |
342 | return size_needed; | 366 | return size_needed; |
343 | } | 367 | } |
@@ -358,7 +382,7 @@ send_core_connection_ack (struct MeshConnection *c, size_t size, void *buf) | |||
358 | struct GNUNET_MESH_ConnectionACK *msg = buf; | 382 | struct GNUNET_MESH_ConnectionACK *msg = buf; |
359 | struct MeshTunnel2 *t = c->t; | 383 | struct MeshTunnel2 *t = c->t; |
360 | 384 | ||
361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION ACK...\n"); | 385 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION ACK...\n"); |
362 | GNUNET_assert (NULL != t); | 386 | GNUNET_assert (NULL != t); |
363 | if (sizeof (struct GNUNET_MESH_ConnectionACK) > size) | 387 | if (sizeof (struct GNUNET_MESH_ConnectionACK) > size) |
364 | { | 388 | { |
@@ -372,7 +396,7 @@ send_core_connection_ack (struct MeshConnection *c, size_t size, void *buf) | |||
372 | 396 | ||
373 | /* TODO add signature */ | 397 | /* TODO add signature */ |
374 | 398 | ||
375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECTION ACK sent!\n"); | 399 | LOG (GNUNET_ERROR_TYPE_DEBUG, "CONNECTION ACK sent!\n"); |
376 | return sizeof (struct GNUNET_MESH_ConnectionACK); | 400 | return sizeof (struct GNUNET_MESH_ConnectionACK); |
377 | } | 401 | } |
378 | 402 | ||
@@ -426,7 +450,7 @@ peer_destroy (struct MeshPeer *peer) | |||
426 | GNUNET_CONTAINER_multipeermap_remove (peers, &id, peer)) | 450 | GNUNET_CONTAINER_multipeermap_remove (peers, &id, peer)) |
427 | { | 451 | { |
428 | GNUNET_break (0); | 452 | GNUNET_break (0); |
429 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 453 | LOG (GNUNET_ERROR_TYPE_WARNING, |
430 | "removing peer %s, not in peermap\n", GNUNET_i2s (&id)); | 454 | "removing peer %s, not in peermap\n", GNUNET_i2s (&id)); |
431 | } | 455 | } |
432 | if (NULL != peer->search_h) | 456 | if (NULL != peer->search_h) |
@@ -703,7 +727,7 @@ peer_add_path (struct MeshPeer *peer_info, struct MeshPeerPath *path, | |||
703 | { | 727 | { |
704 | if (path->peers[l] == myid) | 728 | if (path->peers[l] == myid) |
705 | { | 729 | { |
706 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shortening path by %u\n", l); | 730 | LOG (GNUNET_ERROR_TYPE_DEBUG, "shortening path by %u\n", l); |
707 | for (l2 = 0; l2 < path->length - l; l2++) | 731 | for (l2 = 0; l2 < path->length - l; l2++) |
708 | { | 732 | { |
709 | path->peers[l2] = path->peers[l + l2]; | 733 | path->peers[l2] = path->peers[l + l2]; |
@@ -715,7 +739,7 @@ peer_add_path (struct MeshPeer *peer_info, struct MeshPeerPath *path, | |||
715 | } | 739 | } |
716 | } | 740 | } |
717 | 741 | ||
718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n", | 742 | LOG (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n", |
719 | path->length, peer2s (peer_info)); | 743 | path->length, peer2s (peer_info)); |
720 | 744 | ||
721 | l = path_get_length (path); | 745 | l = path_get_length (path); |
@@ -823,7 +847,7 @@ search_handler (void *cls, struct MeshPeerPath *path) | |||
823 | 847 | ||
824 | if (peer->tunnel->state == MESH_TUNNEL_SEARCHING) | 848 | if (peer->tunnel->state == MESH_TUNNEL_SEARCHING) |
825 | { | 849 | { |
826 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n"); | 850 | LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n"); |
827 | GMP_connect (peer); | 851 | GMP_connect (peer); |
828 | } | 852 | } |
829 | return; | 853 | return; |
@@ -856,11 +880,11 @@ queue_send (void *cls, size_t size, void *buf) | |||
856 | int fwd; | 880 | int fwd; |
857 | 881 | ||
858 | peer->core_transmit = NULL; | 882 | peer->core_transmit = NULL; |
859 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Queue send (max %u)\n", size); | 883 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Queue send (max %u)\n", size); |
860 | 884 | ||
861 | if (NULL == buf || 0 == size) | 885 | if (NULL == buf || 0 == size) |
862 | { | 886 | { |
863 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Buffer size 0.\n"); | 887 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Buffer size 0.\n"); |
864 | return 0; | 888 | return 0; |
865 | } | 889 | } |
866 | 890 | ||
@@ -876,11 +900,11 @@ queue_send (void *cls, size_t size, void *buf) | |||
876 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 900 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
877 | 901 | ||
878 | dst_id = GNUNET_PEER_resolve2 (peer->id); | 902 | dst_id = GNUNET_PEER_resolve2 (peer->id); |
879 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* towards %s\n", GNUNET_i2s (dst_id)); | 903 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* towards %s\n", GNUNET_i2s (dst_id)); |
880 | /* Check if buffer size is enough for the message */ | 904 | /* Check if buffer size is enough for the message */ |
881 | if (queue->size > size) | 905 | if (queue->size > size) |
882 | { | 906 | { |
883 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* not enough room, reissue\n"); | 907 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* not enough room, reissue\n"); |
884 | peer->core_transmit = | 908 | peer->core_transmit = |
885 | GNUNET_CORE_notify_transmit_ready (core_handle, | 909 | GNUNET_CORE_notify_transmit_ready (core_handle, |
886 | GNUNET_NO, | 910 | GNUNET_NO, |
@@ -892,7 +916,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
892 | peer); | 916 | peer); |
893 | return 0; | 917 | return 0; |
894 | } | 918 | } |
895 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* size %u ok\n", queue->size); | 919 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* size %u ok\n", queue->size); |
896 | 920 | ||
897 | t = (NULL != c) ? c->t : NULL; | 921 | t = (NULL != c) ? c->t : NULL; |
898 | type = 0; | 922 | type = 0; |
@@ -907,7 +931,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
907 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | 931 | case GNUNET_MESSAGE_TYPE_MESH_BCK: |
908 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | 932 | case GNUNET_MESSAGE_TYPE_MESH_ACK: |
909 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 933 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
910 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 934 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
911 | "* raw: %s\n", | 935 | "* raw: %s\n", |
912 | GNUNET_MESH_DEBUG_M2S (queue->type)); | 936 | GNUNET_MESH_DEBUG_M2S (queue->type)); |
913 | data_size = send_core_data_raw (queue->cls, size, buf); | 937 | data_size = send_core_data_raw (queue->cls, size, buf); |
@@ -915,14 +939,14 @@ queue_send (void *cls, size_t size, void *buf) | |||
915 | type = ntohs (msg->type); | 939 | type = ntohs (msg->type); |
916 | break; | 940 | break; |
917 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE: | 941 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE: |
918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* path create\n"); | 942 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* path create\n"); |
919 | if (GMC_is_origin (c, GNUNET_YES)) | 943 | if (GMC_is_origin (c, GNUNET_YES)) |
920 | data_size = send_core_connection_create (queue->c, size, buf); | 944 | data_size = send_core_connection_create (queue->c, size, buf); |
921 | else | 945 | else |
922 | data_size = send_core_data_raw (queue->cls, size, buf); | 946 | data_size = send_core_data_raw (queue->cls, size, buf); |
923 | break; | 947 | break; |
924 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: | 948 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: |
925 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* path ack\n"); | 949 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* path ack\n"); |
926 | if (GMC_is_origin (c, GNUNET_NO) || | 950 | if (GMC_is_origin (c, GNUNET_NO) || |
927 | GMC_is_origin (c, GNUNET_YES)) | 951 | GMC_is_origin (c, GNUNET_YES)) |
928 | data_size = send_core_connection_ack (queue->c, size, buf); | 952 | data_size = send_core_connection_ack (queue->c, size, buf); |
@@ -938,7 +962,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
938 | break; | 962 | break; |
939 | default: | 963 | default: |
940 | GNUNET_break (0); | 964 | GNUNET_break (0); |
941 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "* type unknown: %u\n", | 965 | LOG (GNUNET_ERROR_TYPE_WARNING, "* type unknown: %u\n", |
942 | queue->type); | 966 | queue->type); |
943 | data_size = 0; | 967 | data_size = 0; |
944 | } | 968 | } |
@@ -946,7 +970,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
946 | if (0 < drop_percent && | 970 | if (0 < drop_percent && |
947 | GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent) | 971 | GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent) |
948 | { | 972 | { |
949 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 973 | LOG (GNUNET_ERROR_TYPE_WARNING, |
950 | "Dropping message of type %s\n", | 974 | "Dropping message of type %s\n", |
951 | GNUNET_MESH_DEBUG_M2S (queue->type)); | 975 | GNUNET_MESH_DEBUG_M2S (queue->type)); |
952 | data_size = 0; | 976 | data_size = 0; |
@@ -962,7 +986,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
962 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | 986 | case GNUNET_MESSAGE_TYPE_MESH_FWD: |
963 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | 987 | case GNUNET_MESSAGE_TYPE_MESH_BCK: |
964 | pid = ntohl ( ((struct GNUNET_MESH_Encrypted *) buf)->pid ); | 988 | pid = ntohl ( ((struct GNUNET_MESH_Encrypted *) buf)->pid ); |
965 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* accounting pid %u\n", pid); | 989 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* accounting pid %u\n", pid); |
966 | fc->last_pid_sent = pid; | 990 | fc->last_pid_sent = pid; |
967 | send_ack (c, ch, fwd); | 991 | send_ack (c, ch, fwd); |
968 | break; | 992 | break; |
@@ -974,7 +998,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
974 | queue = peer_get_first_message (peer); | 998 | queue = peer_get_first_message (peer); |
975 | if (NULL != queue) | 999 | if (NULL != queue) |
976 | { | 1000 | { |
977 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* more data!\n"); | 1001 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* more data!\n"); |
978 | if (NULL == peer->core_transmit) { | 1002 | if (NULL == peer->core_transmit) { |
979 | peer->core_transmit = | 1003 | peer->core_transmit = |
980 | GNUNET_CORE_notify_transmit_ready(core_handle, | 1004 | GNUNET_CORE_notify_transmit_ready(core_handle, |
@@ -988,12 +1012,12 @@ queue_send (void *cls, size_t size, void *buf) | |||
988 | } | 1012 | } |
989 | else | 1013 | else |
990 | { | 1014 | { |
991 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1015 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
992 | "* tmt rdy called somewhere else\n"); | 1016 | "* tmt rdy called somewhere else\n"); |
993 | } | 1017 | } |
994 | if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task) | 1018 | if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task) |
995 | { | 1019 | { |
996 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* starting poll timeout\n"); | 1020 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* starting poll timeout\n"); |
997 | fc->poll_task = | 1021 | fc->poll_task = |
998 | GNUNET_SCHEDULER_add_delayed (fc->poll_time, &connection_poll, fc); | 1022 | GNUNET_SCHEDULER_add_delayed (fc->poll_time, &connection_poll, fc); |
999 | } | 1023 | } |
@@ -1011,7 +1035,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
1011 | c->pending_messages--; | 1035 | c->pending_messages--; |
1012 | if (GNUNET_YES == c->destroy && 0 == c->pending_messages) | 1036 | if (GNUNET_YES == c->destroy && 0 == c->pending_messages) |
1013 | { | 1037 | { |
1014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* destroying connection!\n"); | 1038 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* destroying connection!\n"); |
1015 | GMC_destroy (c); | 1039 | GMC_destroy (c); |
1016 | } | 1040 | } |
1017 | } | 1041 | } |
@@ -1021,11 +1045,11 @@ queue_send (void *cls, size_t size, void *buf) | |||
1021 | t->pending_messages--; | 1045 | t->pending_messages--; |
1022 | if (GNUNET_YES == t->destroy && 0 == t->pending_messages) | 1046 | if (GNUNET_YES == t->destroy && 0 == t->pending_messages) |
1023 | { | 1047 | { |
1024 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* destroying tunnel!\n"); | 1048 | // LOG (GNUNET_ERROR_TYPE_DEBUG, "* destroying tunnel!\n"); |
1025 | tunnel_destroy (t); | 1049 | tunnel_destroy (t); |
1026 | } | 1050 | } |
1027 | } | 1051 | } |
1028 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Return %d\n", data_size); | 1052 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Return %d\n", data_size); |
1029 | return data_size; | 1053 | return data_size; |
1030 | } | 1054 | } |
1031 | 1055 | ||
@@ -1101,13 +1125,13 @@ GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | |||
1101 | 1125 | ||
1102 | if (GNUNET_YES == clear_cls) | 1126 | if (GNUNET_YES == clear_cls) |
1103 | { | 1127 | { |
1104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " queue destroy type %s\n", | 1128 | LOG (GNUNET_ERROR_TYPE_DEBUG, " queue destroy type %s\n", |
1105 | GNUNET_MESH_DEBUG_M2S (queue->type)); | 1129 | GNUNET_MESH_DEBUG_M2S (queue->type)); |
1106 | switch (queue->type) | 1130 | switch (queue->type) |
1107 | { | 1131 | { |
1108 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY: | 1132 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY: |
1109 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: | 1133 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: |
1110 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "destroying a DESTROY message\n"); | 1134 | LOG (GNUNET_ERROR_TYPE_INFO, "destroying a DESTROY message\n"); |
1111 | GNUNET_break (GNUNET_YES == queue->c->destroy); | 1135 | GNUNET_break (GNUNET_YES == queue->c->destroy); |
1112 | /* fall through */ | 1136 | /* fall through */ |
1113 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | 1137 | case GNUNET_MESSAGE_TYPE_MESH_FWD: |
@@ -1117,13 +1141,13 @@ GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | |||
1117 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: | 1141 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: |
1118 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE: | 1142 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE: |
1119 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: | 1143 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: |
1120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " prebuilt message\n");; | 1144 | LOG (GNUNET_ERROR_TYPE_DEBUG, " prebuilt message\n");; |
1121 | GNUNET_free_non_null (queue->cls); | 1145 | GNUNET_free_non_null (queue->cls); |
1122 | break; | 1146 | break; |
1123 | 1147 | ||
1124 | default: | 1148 | default: |
1125 | GNUNET_break (0); | 1149 | GNUNET_break (0); |
1126 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " type %s unknown!\n", | 1150 | LOG (GNUNET_ERROR_TYPE_ERROR, " type %s unknown!\n", |
1127 | GNUNET_MESH_DEBUG_M2S (queue->type)); | 1151 | GNUNET_MESH_DEBUG_M2S (queue->type)); |
1128 | } | 1152 | } |
1129 | 1153 | ||
@@ -1133,7 +1157,7 @@ GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | |||
1133 | if (queue->type != GNUNET_MESSAGE_TYPE_MESH_ACK && | 1157 | if (queue->type != GNUNET_MESSAGE_TYPE_MESH_ACK && |
1134 | queue->type != GNUNET_MESSAGE_TYPE_MESH_POLL) | 1158 | queue->type != GNUNET_MESSAGE_TYPE_MESH_POLL) |
1135 | { | 1159 | { |
1136 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Q_N- %p %u\n", fc, fc->queue_n); | 1160 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Q_N- %p %u\n", fc, fc->queue_n); |
1137 | fc->queue_n--; | 1161 | fc->queue_n--; |
1138 | peer->queue_n--; | 1162 | peer->queue_n--; |
1139 | } | 1163 | } |
@@ -1173,7 +1197,7 @@ GMP_queue_add (void *cls, uint16_t type, size_t size, | |||
1173 | int priority; | 1197 | int priority; |
1174 | int call_core; | 1198 | int call_core; |
1175 | 1199 | ||
1176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1200 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1177 | "queue add %s %s (%u) on c %p, ch %p\n", | 1201 | "queue add %s %s (%u) on c %p, ch %p\n", |
1178 | fwd ? "FWD" : "BCK", GNUNET_MESH_DEBUG_M2S (type), size, c, ch); | 1202 | fwd ? "FWD" : "BCK", GNUNET_MESH_DEBUG_M2S (type), size, c, ch); |
1179 | GNUNET_assert (NULL != c); | 1203 | GNUNET_assert (NULL != c); |
@@ -1202,28 +1226,28 @@ GMP_queue_add (void *cls, uint16_t type, size_t size, | |||
1202 | priority = 100; | 1226 | priority = 100; |
1203 | } | 1227 | } |
1204 | 1228 | ||
1205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority); | 1229 | LOG (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority); |
1206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "fc %p\n", fc); | 1230 | LOG (GNUNET_ERROR_TYPE_DEBUG, "fc %p\n", fc); |
1207 | if (fc->queue_n >= fc->queue_max && 0 == priority) | 1231 | if (fc->queue_n >= fc->queue_max && 0 == priority) |
1208 | { | 1232 | { |
1209 | GNUNET_STATISTICS_update (stats, "# messages dropped (buffer full)", | 1233 | GNUNET_STATISTICS_update (stats, "# messages dropped (buffer full)", |
1210 | 1, GNUNET_NO); | 1234 | 1, GNUNET_NO); |
1211 | GNUNET_break (0); | 1235 | GNUNET_break (0); |
1212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1236 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1213 | "queue full: %u/%u\n", | 1237 | "queue full: %u/%u\n", |
1214 | fc->queue_n, fc->queue_max); | 1238 | fc->queue_n, fc->queue_max); |
1215 | return; /* Drop this message */ | 1239 | return; /* Drop this message */ |
1216 | } | 1240 | } |
1217 | 1241 | ||
1218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "last pid %u\n", fc->last_pid_sent); | 1242 | LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid %u\n", fc->last_pid_sent); |
1219 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ack %u\n", fc->last_ack_recv); | 1243 | LOG (GNUNET_ERROR_TYPE_DEBUG, " ack %u\n", fc->last_ack_recv); |
1220 | if (GMC_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv)) | 1244 | if (GMC_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv)) |
1221 | { | 1245 | { |
1222 | call_core = GNUNET_NO; | 1246 | call_core = GNUNET_NO; |
1223 | if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task && | 1247 | if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task && |
1224 | GNUNET_MESSAGE_TYPE_MESH_POLL != type) | 1248 | GNUNET_MESSAGE_TYPE_MESH_POLL != type) |
1225 | { | 1249 | { |
1226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1250 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1227 | "no buffer space (%u > %u): starting poll\n", | 1251 | "no buffer space (%u > %u): starting poll\n", |
1228 | fc->last_pid_sent + 1, fc->last_ack_recv); | 1252 | fc->last_pid_sent + 1, fc->last_ack_recv); |
1229 | fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, | 1253 | fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, |
@@ -1260,14 +1284,14 @@ GMP_queue_add (void *cls, uint16_t type, size_t size, | |||
1260 | else | 1284 | else |
1261 | { | 1285 | { |
1262 | GNUNET_CONTAINER_DLL_insert_tail (peer->queue_head, peer->queue_tail, queue); | 1286 | GNUNET_CONTAINER_DLL_insert_tail (peer->queue_head, peer->queue_tail, queue); |
1263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Q_N+ %p %u\n", fc, fc->queue_n); | 1287 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Q_N+ %p %u\n", fc, fc->queue_n); |
1264 | fc->queue_n++; | 1288 | fc->queue_n++; |
1265 | peer->queue_n++; | 1289 | peer->queue_n++; |
1266 | } | 1290 | } |
1267 | 1291 | ||
1268 | if (NULL == peer->core_transmit && GNUNET_YES == call_core) | 1292 | if (NULL == peer->core_transmit && GNUNET_YES == call_core) |
1269 | { | 1293 | { |
1270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1294 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1271 | "calling core tmt rdy towards %s for %u bytes\n", | 1295 | "calling core tmt rdy towards %s for %u bytes\n", |
1272 | peer2s (peer), size); | 1296 | peer2s (peer), size); |
1273 | peer->core_transmit = | 1297 | peer->core_transmit = |
@@ -1282,7 +1306,7 @@ GMP_queue_add (void *cls, uint16_t type, size_t size, | |||
1282 | } | 1306 | } |
1283 | else | 1307 | else |
1284 | { | 1308 | { |
1285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1309 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1286 | "core tmt rdy towards %s already called\n", | 1310 | "core tmt rdy towards %s already called\n", |
1287 | peer2s (peer)); | 1311 | peer2s (peer)); |
1288 | 1312 | ||
@@ -1310,7 +1334,7 @@ GMP_init (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1310 | GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_PEERS", | 1334 | GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_PEERS", |
1311 | &max_peers)) | 1335 | &max_peers)) |
1312 | { | 1336 | { |
1313 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, | 1337 | LOG_config_invalid (GNUNET_ERROR_TYPE_WARNING, |
1314 | "MESH", "MAX_PEERS", "USING DEFAULT"); | 1338 | "MESH", "MAX_PEERS", "USING DEFAULT"); |
1315 | max_peers = 1000; | 1339 | max_peers = 1000; |
1316 | } | 1340 | } |
@@ -1323,7 +1347,7 @@ GMP_init (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1323 | } | 1347 | } |
1324 | else | 1348 | else |
1325 | { | 1349 | { |
1326 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1350 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1327 | "\n***************************************\n" | 1351 | "\n***************************************\n" |
1328 | "Mesh is running with drop mode enabled.\n" | 1352 | "Mesh is running with drop mode enabled.\n" |
1329 | "This is NOT a good idea!\n" | 1353 | "This is NOT a good idea!\n" |
@@ -1374,7 +1398,7 @@ GMP_connect (struct MeshPeer *peer) | |||
1374 | struct MeshConnection *c; | 1398 | struct MeshConnection *c; |
1375 | int rerun_search; | 1399 | int rerun_search; |
1376 | 1400 | ||
1377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1401 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1378 | "peer_connect towards %s\n", | 1402 | "peer_connect towards %s\n", |
1379 | peer2s (peer)); | 1403 | peer2s (peer)); |
1380 | t = peer->tunnel; | 1404 | t = peer->tunnel; |
@@ -1383,11 +1407,11 @@ GMP_connect (struct MeshPeer *peer) | |||
1383 | 1407 | ||
1384 | if (NULL != peer->path_head) | 1408 | if (NULL != peer->path_head) |
1385 | { | 1409 | { |
1386 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "path exists\n"); | 1410 | LOG (GNUNET_ERROR_TYPE_DEBUG, "path exists\n"); |
1387 | p = peer_get_best_path (peer); | 1411 | p = peer_get_best_path (peer); |
1388 | if (NULL != p) | 1412 | if (NULL != p) |
1389 | { | 1413 | { |
1390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u hops\n", p->length); | 1414 | LOG (GNUNET_ERROR_TYPE_DEBUG, " %u hops\n", p->length); |
1391 | c = tunnel_use_path (t, p); | 1415 | c = tunnel_use_path (t, p); |
1392 | if (NULL == c) | 1416 | if (NULL == c) |
1393 | { | 1417 | { |
@@ -1418,7 +1442,7 @@ GMP_connect (struct MeshPeer *peer) | |||
1418 | { | 1442 | { |
1419 | GMD_search_stop (peer->search_h); | 1443 | GMD_search_stop (peer->search_h); |
1420 | peer->search_h = NULL; | 1444 | peer->search_h = NULL; |
1421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1445 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1422 | " Stopping DHT GET for peer %s\n", peer2s (peer)); | 1446 | " Stopping DHT GET for peer %s\n", peer2s (peer)); |
1423 | } | 1447 | } |
1424 | 1448 | ||
@@ -1427,7 +1451,7 @@ GMP_connect (struct MeshPeer *peer) | |||
1427 | const struct GNUNET_PeerIdentity *id; | 1451 | const struct GNUNET_PeerIdentity *id; |
1428 | 1452 | ||
1429 | id = GNUNET_PEER_resolve2 (peer->id); | 1453 | id = GNUNET_PEER_resolve2 (peer->id); |
1430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1454 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1431 | " Starting DHT GET for peer %s\n", peer2s (peer)); | 1455 | " Starting DHT GET for peer %s\n", peer2s (peer)); |
1432 | peer->search_h = GMD_search (id, &search_handler, peer); | 1456 | peer->search_h = GMD_search (id, &search_handler, peer); |
1433 | if (MESH_TUNNEL_NEW == t->state) | 1457 | if (MESH_TUNNEL_NEW == t->state) |