diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-05 16:23:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-05 16:23:58 +0000 |
commit | 64584845b3207ade2038bca6ed9821da760e8219 (patch) | |
tree | 8ac1a170b25eade7d912d0d4eb96b85e0e7d7978 /src/dns | |
parent | 60ee943bc43ebb8b6a6c35eff2ca0df6618d12ea (diff) | |
download | gnunet-64584845b3207ade2038bca6ed9821da760e8219.tar.gz gnunet-64584845b3207ade2038bca6ed9821da760e8219.zip |
-addressing FIXMEs and adding statistics
Diffstat (limited to 'src/dns')
-rw-r--r-- | src/dns/gnunet-service-dns_new.c | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/src/dns/gnunet-service-dns_new.c b/src/dns/gnunet-service-dns_new.c index 60b3d9384..a74bccabd 100644 --- a/src/dns/gnunet-service-dns_new.c +++ b/src/dns/gnunet-service-dns_new.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_signatures.h" | 29 | #include "gnunet_signatures.h" |
30 | #include "dns_new.h" | 30 | #include "dns_new.h" |
31 | #include "gnunet_dns_service-new.h" | 31 | #include "gnunet_dns_service-new.h" |
32 | #include "gnunet_statistics_service.h" | ||
32 | 33 | ||
33 | /* see http://www.iana.org/assignments/ethernet-numbers */ | 34 | /* see http://www.iana.org/assignments/ethernet-numbers */ |
34 | #ifndef ETH_P_IPV4 | 35 | #ifndef ETH_P_IPV4 |
@@ -279,6 +280,11 @@ static uint16_t dnsoutport; | |||
279 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 280 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
280 | 281 | ||
281 | /** | 282 | /** |
283 | * Statistics. | ||
284 | */ | ||
285 | static struct GNUNET_STATISTICS_Handle *stats; | ||
286 | |||
287 | /** | ||
282 | * Handle to DNS hijacker helper process ("gnunet-helper-dns"). | 288 | * Handle to DNS hijacker helper process ("gnunet-helper-dns"). |
283 | */ | 289 | */ |
284 | static struct GNUNET_HELPER_Handle *hijacker; | 290 | static struct GNUNET_HELPER_Handle *hijacker; |
@@ -371,6 +377,11 @@ cleanup_task (void *cls GNUNET_UNUSED, | |||
371 | cleanup_rr (&requests[i]); | 377 | cleanup_rr (&requests[i]); |
372 | GNUNET_SERVER_notification_context_destroy (nc); | 378 | GNUNET_SERVER_notification_context_destroy (nc); |
373 | nc = NULL; | 379 | nc = NULL; |
380 | if (stats != NULL) | ||
381 | { | ||
382 | GNUNET_STATISTICS_destroy (stats, GNUNET_YES); | ||
383 | stats = NULL; | ||
384 | } | ||
374 | } | 385 | } |
375 | 386 | ||
376 | 387 | ||
@@ -561,6 +572,9 @@ request_done (struct RequestRecord *rr) | |||
561 | hdr, | 572 | hdr, |
562 | GNUNET_YES, | 573 | GNUNET_YES, |
563 | NULL, NULL); | 574 | NULL, NULL); |
575 | GNUNET_STATISTICS_update (stats, | ||
576 | gettext_noop ("# DNS requests answered via TUN interface"), | ||
577 | 1, GNUNET_NO); | ||
564 | } | 578 | } |
565 | /* clean up, we're done */ | 579 | /* clean up, we're done */ |
566 | cleanup_rr (rr); | 580 | cleanup_rr (rr); |
@@ -678,7 +692,9 @@ next_phase (struct RequestRecord *rr) | |||
678 | } | 692 | } |
679 | if (NULL == dnsout) | 693 | if (NULL == dnsout) |
680 | { | 694 | { |
681 | /* fail, FIXME: case for statistics! */ | 695 | GNUNET_STATISTICS_update (stats, |
696 | gettext_noop ("# DNS exit failed (address family not supported)"), | ||
697 | 1, GNUNET_NO); | ||
682 | cleanup_rr (rr); | 698 | cleanup_rr (rr); |
683 | return; | 699 | return; |
684 | } | 700 | } |
@@ -842,8 +858,10 @@ read_response (void *cls, | |||
842 | rr = &requests[dns->id]; | 858 | rr = &requests[dns->id]; |
843 | if (rr->phase != RP_INTERNET_DNS) | 859 | if (rr->phase != RP_INTERNET_DNS) |
844 | { | 860 | { |
845 | /* FIXME: case for statistics */ | ||
846 | /* unexpected / bogus reply */ | 861 | /* unexpected / bogus reply */ |
862 | GNUNET_STATISTICS_update (stats, | ||
863 | gettext_noop ("# External DNS response discarded (no matching request)"), | ||
864 | 1, GNUNET_NO); | ||
847 | return; | 865 | return; |
848 | } | 866 | } |
849 | GNUNET_free_non_null (rr->payload); | 867 | GNUNET_free_non_null (rr->payload); |
@@ -1028,9 +1046,9 @@ handle_client_response (void *cls GNUNET_UNUSED, | |||
1028 | rr = &requests[off]; | 1046 | rr = &requests[off]; |
1029 | if (rr->request_id != resp->request_id) | 1047 | if (rr->request_id != resp->request_id) |
1030 | { | 1048 | { |
1031 | // FIXME: this is a case for calling statistics... | 1049 | GNUNET_STATISTICS_update (stats, |
1032 | // (client is answering a request that we've lost | 1050 | gettext_noop ("# Client response discarded (no matching request)"), |
1033 | // track of -- more than 64k requests ago or so...) | 1051 | 1, GNUNET_NO); |
1034 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1052 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1035 | return; | 1053 | return; |
1036 | } | 1054 | } |
@@ -1132,8 +1150,8 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, | |||
1132 | (ip4->protocol != IPPROTO_UDP) ) | 1150 | (ip4->protocol != IPPROTO_UDP) ) |
1133 | { | 1151 | { |
1134 | /* non-IP/UDP packet received on TUN (or with options) */ | 1152 | /* non-IP/UDP packet received on TUN (or with options) */ |
1135 | // FIXME: maybe just log with stats? | 1153 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1136 | GNUNET_break (0); | 1154 | _("Received malformed IPv4-UDP packet on TUN interface.\n")); |
1137 | return; | 1155 | return; |
1138 | } | 1156 | } |
1139 | udp = (const struct udp_packet*) &ip4[1]; | 1157 | udp = (const struct udp_packet*) &ip4[1]; |
@@ -1147,8 +1165,8 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, | |||
1147 | (ip6->next_header != IPPROTO_UDP) ) | 1165 | (ip6->next_header != IPPROTO_UDP) ) |
1148 | { | 1166 | { |
1149 | /* non-IP/UDP packet received on TUN (or with extensions) */ | 1167 | /* non-IP/UDP packet received on TUN (or with extensions) */ |
1150 | // FIXME: maybe just log with stats? | 1168 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1151 | GNUNET_break (0); | 1169 | _("Received malformed IPv6-UDP packet on TUN interface.\n")); |
1152 | return; | 1170 | return; |
1153 | } | 1171 | } |
1154 | udp = (const struct udp_packet*) &ip6[1]; | 1172 | udp = (const struct udp_packet*) &ip6[1]; |
@@ -1156,17 +1174,18 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, | |||
1156 | break; | 1174 | break; |
1157 | default: | 1175 | default: |
1158 | /* non-IP packet received on TUN!? */ | 1176 | /* non-IP packet received on TUN!? */ |
1159 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1177 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1160 | _("Got packet with %u bytes and protocol %u from TUN\n"), | 1178 | _("Got non-IP packet with %u bytes and protocol %u from TUN\n"), |
1161 | (unsigned int) msize, | 1179 | (unsigned int) msize, |
1162 | ntohs (tun->proto)); | 1180 | ntohs (tun->proto)); |
1163 | GNUNET_break (0); | ||
1164 | return; | 1181 | return; |
1165 | } | 1182 | } |
1166 | if (msize <= sizeof (struct udp_packet) + sizeof (struct dns_header)) | 1183 | if (msize <= sizeof (struct udp_packet) + sizeof (struct dns_header)) |
1167 | { | 1184 | { |
1168 | /* non-DNS packet received on TUN, ignore */ | 1185 | /* non-DNS packet received on TUN, ignore */ |
1169 | /* FIXME: case for statistics... */ | 1186 | GNUNET_STATISTICS_update (stats, |
1187 | gettext_noop ("# Non-DNS UDP packet received via TUN interface"), | ||
1188 | 1, GNUNET_NO); | ||
1170 | return; | 1189 | return; |
1171 | } | 1190 | } |
1172 | msize -= sizeof (struct udp_packet); | 1191 | msize -= sizeof (struct udp_packet); |
@@ -1194,7 +1213,10 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, | |||
1194 | dsta4->sin_addr = ip4->destination_address; | 1213 | dsta4->sin_addr = ip4->destination_address; |
1195 | srca4->sin_port = udp->spt; | 1214 | srca4->sin_port = udp->spt; |
1196 | dsta4->sin_port = udp->dpt; | 1215 | dsta4->sin_port = udp->dpt; |
1197 | /* FIXME: bother with FreeBSD sin_len crap? */ | 1216 | #if HAVE_SOCKADDR_IN_SIN_LEN |
1217 | srca4->sin_len = sizeof (sizeof (struct sockaddr_in)); | ||
1218 | dsta4->sin_len = sizeof (sizeof (struct sockaddr_in)); | ||
1219 | #endif | ||
1198 | } | 1220 | } |
1199 | else /* ipv6 */ | 1221 | else /* ipv6 */ |
1200 | { | 1222 | { |
@@ -1208,7 +1230,10 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, | |||
1208 | dsta6->sin6_addr = ip6->destination_address; | 1230 | dsta6->sin6_addr = ip6->destination_address; |
1209 | srca6->sin6_port = udp->spt; | 1231 | srca6->sin6_port = udp->spt; |
1210 | dsta6->sin6_port = udp->dpt; | 1232 | dsta6->sin6_port = udp->dpt; |
1211 | /* FIXME: bother with FreeBSD sin_len crap? */ | 1233 | #if HAVE_SOCKADDR_IN_SIN_LEN |
1234 | srca6->sin_len = sizeof (sizeof (struct sockaddr_in6)); | ||
1235 | dsta6->sin_len = sizeof (sizeof (struct sockaddr_in6)); | ||
1236 | #endif | ||
1212 | } | 1237 | } |
1213 | rr->payload = GNUNET_malloc (msize); | 1238 | rr->payload = GNUNET_malloc (msize); |
1214 | rr->payload_length = msize; | 1239 | rr->payload_length = msize; |
@@ -1216,7 +1241,9 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, | |||
1216 | rr->request_id = dns->id | (request_id_gen << 16); | 1241 | rr->request_id = dns->id | (request_id_gen << 16); |
1217 | request_id_gen++; | 1242 | request_id_gen++; |
1218 | 1243 | ||
1219 | /* FIXME: case for statistics... */ | 1244 | GNUNET_STATISTICS_update (stats, |
1245 | gettext_noop ("# DNS requests received via TUN interface"), | ||
1246 | 1, GNUNET_NO); | ||
1220 | /* start request processing state machine */ | 1247 | /* start request processing state machine */ |
1221 | next_phase (rr); | 1248 | next_phase (rr); |
1222 | } | 1249 | } |
@@ -1246,6 +1273,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1246 | char *ipv6prefix; | 1273 | char *ipv6prefix; |
1247 | 1274 | ||
1248 | cfg = cfg_; | 1275 | cfg = cfg_; |
1276 | stats = GNUNET_STATISTICS_create ("dns", cfg); | ||
1249 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 1277 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
1250 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, | 1278 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, |
1251 | cls); | 1279 | cls); |