diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-10 13:47:33 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-10 13:47:33 +0000 |
commit | 215714314289a4753be984cccb68fb8fc97ccbd1 (patch) | |
tree | 4480f14db7ba6e65400bc92ba5b37e8c9636aead /src/mesh/mesh_api.c | |
parent | ce2f5fa9e8dd91ccd9647d38e86d33bdc0a7001c (diff) | |
download | gnunet-215714314289a4753be984cccb68fb8fc97ccbd1.tar.gz gnunet-215714314289a4753be984cccb68fb8fc97ccbd1.zip |
use LOG macro in mesh_api.c
Diffstat (limited to 'src/mesh/mesh_api.c')
-rw-r--r-- | src/mesh/mesh_api.c | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 9c2af545b..871318755 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <gnunet_container_lib.h> | 32 | #include <gnunet_container_lib.h> |
33 | #include <gnunet_applications.h> | 33 | #include <gnunet_applications.h> |
34 | 34 | ||
35 | #define LOG(kind,...) GNUNET_log_from (kind, "mesh-api",__VA_ARGS__) | ||
36 | |||
35 | struct tunnel_id | 37 | struct tunnel_id |
36 | { | 38 | { |
37 | uint32_t id GNUNET_PACKED; | 39 | uint32_t id GNUNET_PACKED; |
@@ -196,7 +198,7 @@ send_hello_message (void *cls, size_t size, void *buf) | |||
196 | if (cls == NULL) | 198 | if (cls == NULL) |
197 | return 0; | 199 | return 0; |
198 | 200 | ||
199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending hello\n"); | 201 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending hello\n"); |
200 | 202 | ||
201 | struct peer_list_element *element = cls; | 203 | struct peer_list_element *element = cls; |
202 | struct GNUNET_MESH_Handle *handle = element->handle; | 204 | struct GNUNET_MESH_Handle *handle = element->handle; |
@@ -256,8 +258,8 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
256 | { | 258 | { |
257 | struct GNUNET_MESH_Handle *handle = cls; | 259 | struct GNUNET_MESH_Handle *handle = cls; |
258 | 260 | ||
259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 261 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Core tells us we are connected to peer %s\n", |
260 | "Core tells us we are connected to peer %s\n", GNUNET_i2s (peer)); | 262 | GNUNET_i2s (peer)); |
261 | 263 | ||
262 | /* put the new peer into the list of connected peers */ | 264 | /* put the new peer into the list of connected peers */ |
263 | struct peer_list_element *element = | 265 | struct peer_list_element *element = |
@@ -312,9 +314,9 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
312 | { | 314 | { |
313 | struct GNUNET_MESH_Handle *handle = cls; | 315 | struct GNUNET_MESH_Handle *handle = cls; |
314 | 316 | ||
315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 317 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
316 | "Core tells us we are no longer connected to peer %s\n", | 318 | "Core tells us we are no longer connected to peer %s\n", |
317 | GNUNET_i2s (peer)); | 319 | GNUNET_i2s (peer)); |
318 | 320 | ||
319 | struct peer_list_element *element = handle->connected_peers.head; | 321 | struct peer_list_element *element = handle->connected_peers.head; |
320 | 322 | ||
@@ -389,9 +391,9 @@ receive_hello (void *cls, const struct GNUNET_PeerIdentity *other, | |||
389 | (GNUNET_MESH_ApplicationType *) (num + 1); | 391 | (GNUNET_MESH_ApplicationType *) (num + 1); |
390 | unsigned int i; | 392 | unsigned int i; |
391 | 393 | ||
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 394 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
393 | "The peer %s tells us he supports %d application-types.\n", | 395 | "The peer %s tells us he supports %d application-types.\n", |
394 | GNUNET_i2s (other), ntohs (*num)); | 396 | GNUNET_i2s (other), ntohs (*num)); |
395 | 397 | ||
396 | struct peer_list_element *element = handle->connected_peers.head; | 398 | struct peer_list_element *element = handle->connected_peers.head; |
397 | 399 | ||
@@ -407,9 +409,9 @@ receive_hello (void *cls, const struct GNUNET_PeerIdentity *other, | |||
407 | 409 | ||
408 | for (i = 0; i < ntohs (*num); i++) | 410 | for (i = 0; i < ntohs (*num); i++) |
409 | { | 411 | { |
410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 412 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
411 | "The peer %s newly supports the application-type %d\n", | 413 | "The peer %s newly supports the application-type %d\n", |
412 | GNUNET_i2s (other), ntohs (ports[i])); | 414 | GNUNET_i2s (other), ntohs (ports[i])); |
413 | if (GNUNET_APPLICATION_TYPE_END == ntohs (ports[i])) | 415 | if (GNUNET_APPLICATION_TYPE_END == ntohs (ports[i])) |
414 | continue; | 416 | continue; |
415 | struct type_list_element *new_type = GNUNET_malloc (sizeof *new_type); | 417 | struct type_list_element *new_type = GNUNET_malloc (sizeof *new_type); |
@@ -423,9 +425,9 @@ receive_hello (void *cls, const struct GNUNET_PeerIdentity *other, | |||
423 | 425 | ||
424 | for (type = element->type_head; type != NULL; type = type->next) | 426 | for (type = element->type_head; type != NULL; type = type->next) |
425 | { | 427 | { |
426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 428 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
427 | "The peer %s supports the application-type %d\n", | 429 | "The peer %s supports the application-type %d\n", GNUNET_i2s (other), |
428 | GNUNET_i2s (other), type->type); | 430 | type->type); |
429 | } | 431 | } |
430 | 432 | ||
431 | struct tunnel_list_element *tunnel = handle->pending_by_type_tunnels.head; | 433 | struct tunnel_list_element *tunnel = handle->pending_by_type_tunnels.head; |
@@ -491,9 +493,9 @@ core_receive (void *cls, const struct GNUNET_PeerIdentity *other, | |||
491 | /* If no handler was found, drop the message but keep the channel open */ | 493 | /* If no handler was found, drop the message but keep the channel open */ |
492 | if (handler->callback == NULL) | 494 | if (handler->callback == NULL) |
493 | { | 495 | { |
494 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 496 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
495 | "Received message of type %d from peer %s; dropping it.\n", | 497 | "Received message of type %d from peer %s; dropping it.\n", |
496 | ntohs (rmessage->type), GNUNET_i2s (other)); | 498 | ntohs (rmessage->type), GNUNET_i2s (other)); |
497 | return GNUNET_OK; | 499 | return GNUNET_OK; |
498 | } | 500 | } |
499 | 501 | ||
@@ -515,9 +517,9 @@ core_receive (void *cls, const struct GNUNET_PeerIdentity *other, | |||
515 | /* if no tunnel was found: create a new inbound tunnel */ | 517 | /* if no tunnel was found: create a new inbound tunnel */ |
516 | if (tunnel == NULL) | 518 | if (tunnel == NULL) |
517 | { | 519 | { |
518 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 520 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
519 | "New inbound tunnel from peer %s; first message has type %d.\n", | 521 | "New inbound tunnel from peer %s; first message has type %d.\n", |
520 | GNUNET_i2s (other), ntohs (rmessage->type)); | 522 | GNUNET_i2s (other), ntohs (rmessage->type)); |
521 | tunnel = GNUNET_malloc (sizeof (struct tunnel_list_element)); | 523 | tunnel = GNUNET_malloc (sizeof (struct tunnel_list_element)); |
522 | tunnel->tunnel.connect_handler = NULL; | 524 | tunnel->tunnel.connect_handler = NULL; |
523 | tunnel->tunnel.disconnect_handler = NULL; | 525 | tunnel->tunnel.disconnect_handler = NULL; |
@@ -533,9 +535,8 @@ core_receive (void *cls, const struct GNUNET_PeerIdentity *other, | |||
533 | tunnel); | 535 | tunnel); |
534 | } | 536 | } |
535 | else | 537 | else |
536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 538 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Inbound message from peer %s; type %d.\n", |
537 | "Inbound message from peer %s; type %d.\n", GNUNET_i2s (other), | 539 | GNUNET_i2s (other), ntohs (rmessage->type)); |
538 | ntohs (rmessage->type)); | ||
539 | 540 | ||
540 | return handler->callback (handle->cls, &tunnel->tunnel, &tunnel->tunnel.ctx, | 541 | return handler->callback (handle->cls, &tunnel->tunnel, &tunnel->tunnel.ctx, |
541 | other, rmessage, atsi); | 542 | other, rmessage, atsi); |
@@ -568,8 +569,8 @@ GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Handle *handle, | |||
568 | element = element->next; | 569 | element = element->next; |
569 | } | 570 | } |
570 | 571 | ||
571 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect by tupe %d.\n", | 572 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect by tupe %d.\n", |
572 | application_type); | 573 | application_type); |
573 | 574 | ||
574 | /* Put into pending list */ | 575 | /* Put into pending list */ |
575 | struct tunnel_list_element *tunnel = | 576 | struct tunnel_list_element *tunnel = |
@@ -809,7 +810,7 @@ build_hello_message (struct GNUNET_MESH_Handle *handle, | |||
809 | 810 | ||
810 | for (t = stypes; *t != GNUNET_APPLICATION_TYPE_END; t++, num++) ; | 811 | for (t = stypes; *t != GNUNET_APPLICATION_TYPE_END; t++, num++) ; |
811 | 812 | ||
812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I can handle %d app-types.\n", num); | 813 | LOG (GNUNET_ERROR_TYPE_DEBUG, "I can handle %d app-types.\n", num); |
813 | 814 | ||
814 | handle->hello_message_size = sizeof (uint16_t) + /* For the number of types */ | 815 | handle->hello_message_size = sizeof (uint16_t) + /* For the number of types */ |
815 | num * sizeof (GNUNET_MESH_ApplicationType); /* For the types */ | 816 | num * sizeof (GNUNET_MESH_ApplicationType); /* For the types */ |
@@ -824,8 +825,7 @@ build_hello_message (struct GNUNET_MESH_Handle *handle, | |||
824 | 825 | ||
825 | for (i = 0; i < num; i++) | 826 | for (i = 0; i < num; i++) |
826 | { | 827 | { |
827 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I can handle the app-type %d\n", | 828 | LOG (GNUNET_ERROR_TYPE_DEBUG, "I can handle the app-type %d\n", stypes[i]); |
828 | stypes[i]); | ||
829 | types[i] = htons (stypes[i]); | 829 | types[i] = htons (stypes[i]); |
830 | } | 830 | } |
831 | 831 | ||
@@ -872,10 +872,9 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, | |||
872 | 872 | ||
873 | ret->core = | 873 | ret->core = |
874 | GNUNET_CORE_connect (cfg, 42, ret, &core_startup, &core_connect, | 874 | GNUNET_CORE_connect (cfg, 42, ret, &core_startup, &core_connect, |
875 | &core_disconnect, NULL, GNUNET_NO, NULL, | 875 | &core_disconnect, NULL, GNUNET_NO, NULL, GNUNET_NO, |
876 | GNUNET_NO, core_handlers); | 876 | core_handlers); |
877 | ret->transport = | 877 | ret->transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); |
878 | GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); | ||
879 | return ret; | 878 | return ret; |
880 | } | 879 | } |
881 | 880 | ||