aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-10-18 09:42:41 +0000
committerChristian Grothoff <christian@grothoff.org>2012-10-18 09:42:41 +0000
commit188988276482b3795b89da6c3814cefb4234abc6 (patch)
tree3bd16b509b05004a9418ded51c7d962c8dc0264e /src
parent50f76ab44c5cb28c0aa92a2a54f50d9ba10a46ee (diff)
downloadgnunet-188988276482b3795b89da6c3814cefb4234abc6.tar.gz
gnunet-188988276482b3795b89da6c3814cefb4234abc6.zip
-more logging
Diffstat (limited to 'src')
-rw-r--r--src/dns/gnunet-service-dns.c90
1 files changed, 63 insertions, 27 deletions
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c
index 37cc5afec..aaa5f3dd1 100644
--- a/src/dns/gnunet-service-dns.c
+++ b/src/dns/gnunet-service-dns.c
@@ -52,6 +52,13 @@
52 52
53 53
54/** 54/**
55 * Generic logging shorthand
56 */
57#define LOG(kind, ...) \
58 GNUNET_log_from (kind, "dns", __VA_ARGS__);
59
60
61/**
55 * Phases each request goes through. 62 * Phases each request goes through.
56 */ 63 */
57enum RequestPhase 64enum RequestPhase
@@ -370,10 +377,16 @@ request_done (struct RequestRecord *rr)
370 if (RP_RESPONSE_MONITOR != rr->phase) 377 if (RP_RESPONSE_MONITOR != rr->phase)
371 { 378 {
372 /* no response, drop */ 379 /* no response, drop */
380 LOG (GNUNET_ERROR_TYPE_DEBUG,
381 "Got no response for request %llu, dropping\n",
382 (unsigned long long) rr->request_id);
373 cleanup_rr (rr); 383 cleanup_rr (rr);
374 return; 384 return;
375 } 385 }
376 386
387 LOG (GNUNET_ERROR_TYPE_DEBUG,
388 "Transmitting response for request %llu\n",
389 (unsigned long long) rr->request_id);
377 /* send response via hijacker */ 390 /* send response via hijacker */
378 reply_len = sizeof (struct GNUNET_MessageHeader); 391 reply_len = sizeof (struct GNUNET_MessageHeader);
379 reply_len += sizeof (struct GNUNET_TUN_Layer2PacketHeader); 392 reply_len += sizeof (struct GNUNET_TUN_Layer2PacketHeader);
@@ -524,6 +537,9 @@ send_request_to_client (struct RequestRecord *rr,
524 cleanup_rr (rr); 537 cleanup_rr (rr);
525 return; 538 return;
526 } 539 }
540 LOG (GNUNET_ERROR_TYPE_DEBUG,
541 "Sending information about request %llu to local client\n",
542 (unsigned long long) rr->request_id);
527 req = (struct GNUNET_DNS_Request*) buf; 543 req = (struct GNUNET_DNS_Request*) buf;
528 req->header.type = htons (GNUNET_MESSAGE_TYPE_DNS_CLIENT_REQUEST); 544 req->header.type = htons (GNUNET_MESSAGE_TYPE_DNS_CLIENT_REQUEST);
529 req->header.size = htons (sizeof (buf)); 545 req->header.size = htons (sizeof (buf));
@@ -588,6 +604,10 @@ next_phase (struct RequestRecord *rr)
588 return; 604 return;
589 } 605 }
590 /* done with current phase, advance! */ 606 /* done with current phase, advance! */
607 LOG (GNUNET_ERROR_TYPE_DEBUG,
608 "Request %llu now in phase %d\n",
609 rr->request_id,
610 rr->phase);
591 switch (rr->phase) 611 switch (rr->phase)
592 { 612 {
593 case RP_INIT: 613 case RP_INIT:
@@ -785,7 +805,9 @@ process_dns_result (void *cls,
785{ 805{
786 struct RequestRecord *rr; 806 struct RequestRecord *rr;
787 struct TunnelState *ts; 807 struct TunnelState *ts;
788 808
809 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
810 "Processing DNS result from stub resolver\n");
789 GNUNET_assert (NULL == cls); 811 GNUNET_assert (NULL == cls);
790 /* Handle case that this is a reply to a request from a MESH DNS tunnel */ 812 /* Handle case that this is a reply to a request from a MESH DNS tunnel */
791 ts = tunnels[dns->id]; 813 ts = tunnels[dns->id];
@@ -793,36 +815,43 @@ process_dns_result (void *cls,
793 (ts->rs != rs) ) 815 (ts->rs != rs) )
794 ts = NULL; /* DNS responder address missmatch */ 816 ts = NULL; /* DNS responder address missmatch */
795 if (NULL != ts) 817 if (NULL != ts)
796 { 818 {
797 tunnels[dns->id] = NULL; 819 LOG (GNUNET_ERROR_TYPE_DEBUG,
798 GNUNET_free_non_null (ts->reply); 820 "Got a response from the stub resolver for DNS request received via MESH!\n");
799 ts->reply = GNUNET_malloc (r); 821 tunnels[dns->id] = NULL;
800 ts->reply_length = r; 822 GNUNET_free_non_null (ts->reply);
801 memcpy (ts->reply, dns, r); 823 ts->reply = GNUNET_malloc (r);
802 if (ts->th != NULL) 824 ts->reply_length = r;
803 GNUNET_MESH_notify_transmit_ready_cancel (ts->th); 825 memcpy (ts->reply, dns, r);
804 ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel, 826 if (NULL != ts->th)
805 GNUNET_NO, 827 GNUNET_MESH_notify_transmit_ready_cancel (ts->th);
806 GNUNET_TIME_UNIT_FOREVER_REL, 828 ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel,
807 NULL, 829 GNUNET_NO,
808 sizeof (struct GNUNET_MessageHeader) + r, 830 GNUNET_TIME_UNIT_FOREVER_REL,
809 &transmit_reply_to_mesh, 831 NULL,
810 ts); 832 sizeof (struct GNUNET_MessageHeader) + r,
811 } 833 &transmit_reply_to_mesh,
834 ts);
835 }
812 /* Handle case that this is a reply to a local request (intercepted from TUN interface) */ 836 /* Handle case that this is a reply to a local request (intercepted from TUN interface) */
813 rr = &requests[dns->id]; 837 rr = &requests[dns->id];
814 if ( (rr->phase != RP_INTERNET_DNS) || 838 if ( (rr->phase != RP_INTERNET_DNS) ||
815 (rr->rs != rs) ) 839 (rr->rs != rs) )
840 {
841 if (NULL == ts)
816 { 842 {
817 if (NULL == ts) 843 /* unexpected / bogus reply */
818 { 844 GNUNET_STATISTICS_update (stats,
819 /* unexpected / bogus reply */ 845 gettext_noop ("# External DNS response discarded (no matching request)"),
820 GNUNET_STATISTICS_update (stats, 846 1, GNUNET_NO);
821 gettext_noop ("# External DNS response discarded (no matching request)"),
822 1, GNUNET_NO);
823 }
824 return;
825 } 847 }
848 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
849 "Received DNS reply that does not match any pending request. Dropping.\n");
850 return;
851 }
852 LOG (GNUNET_ERROR_TYPE_DEBUG,
853 "Got a response from the stub resolver for DNS request %llu intercepted locally!\n",
854 (unsigned long long) rr->request_id);
826 GNUNET_free_non_null (rr->payload); 855 GNUNET_free_non_null (rr->payload);
827 rr->payload = GNUNET_malloc (r); 856 rr->payload = GNUNET_malloc (r);
828 memcpy (rr->payload, dns, r); 857 memcpy (rr->payload, dns, r);
@@ -886,6 +915,9 @@ handle_client_response (void *cls GNUNET_UNUSED,
886 resp = (const struct GNUNET_DNS_Response*) message; 915 resp = (const struct GNUNET_DNS_Response*) message;
887 off = (uint16_t) resp->request_id; 916 off = (uint16_t) resp->request_id;
888 rr = &requests[off]; 917 rr = &requests[off];
918 LOG (GNUNET_ERROR_TYPE_DEBUG,
919 "Received DNS response with ID %llu from local client!\n",
920 (unsigned long long) resp->request_id);
889 if (rr->request_id != resp->request_id) 921 if (rr->request_id != resp->request_id)
890 { 922 {
891 GNUNET_STATISTICS_update (stats, 923 GNUNET_STATISTICS_update (stats,
@@ -979,6 +1011,8 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
979 struct sockaddr_in *dsta4; 1011 struct sockaddr_in *dsta4;
980 struct sockaddr_in6 *dsta6; 1012 struct sockaddr_in6 *dsta6;
981 1013
1014 LOG (GNUNET_ERROR_TYPE_DEBUG,
1015 "Intercepted message via DNS hijacker\n");
982 msize = ntohs (message->size); 1016 msize = ntohs (message->size);
983 if (msize < sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader) + sizeof (struct GNUNET_TUN_IPv4Header)) 1017 if (msize < sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader) + sizeof (struct GNUNET_TUN_IPv4Header))
984 { 1018 {
@@ -1099,7 +1133,9 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
1099 memcpy (rr->payload, dns, msize); 1133 memcpy (rr->payload, dns, msize);
1100 rr->request_id = dns->id | (request_id_gen << 16); 1134 rr->request_id = dns->id | (request_id_gen << 16);
1101 request_id_gen++; 1135 request_id_gen++;
1102 1136 LOG (GNUNET_ERROR_TYPE_DEBUG,
1137 "Creating new DNS request %llu\n",
1138 (unsigned long long) rr->request_id);
1103 GNUNET_STATISTICS_update (stats, 1139 GNUNET_STATISTICS_update (stats,
1104 gettext_noop ("# DNS requests received via TUN interface"), 1140 gettext_noop ("# DNS requests received via TUN interface"),
1105 1, GNUNET_NO); 1141 1, GNUNET_NO);