aboutsummaryrefslogtreecommitdiff
path: root/src/pt/gnunet-daemon-pt.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-16 21:11:18 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-16 21:11:18 +0000
commitf23b3b053cd53b0af73dc02d5986581d9750a02e (patch)
tree642f021d245f668d538863abe6e33ad4691cb33f /src/pt/gnunet-daemon-pt.c
parent0ccdd3775b7d005251dc40610d5f92f37f016b4b (diff)
downloadgnunet-f23b3b053cd53b0af73dc02d5986581d9750a02e.tar.gz
gnunet-f23b3b053cd53b0af73dc02d5986581d9750a02e.zip
implemented new protocol translation daemon (#2063)
Diffstat (limited to 'src/pt/gnunet-daemon-pt.c')
-rw-r--r--src/pt/gnunet-daemon-pt.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c
index bbe9477a8..3d9128379 100644
--- a/src/pt/gnunet-daemon-pt.c
+++ b/src/pt/gnunet-daemon-pt.c
@@ -22,11 +22,6 @@
22 * @file pt/gnunet-daemon-pt.c 22 * @file pt/gnunet-daemon-pt.c
23 * @brief tool to manipulate DNS and VPN services to perform protocol translation (IPvX over GNUnet) 23 * @brief tool to manipulate DNS and VPN services to perform protocol translation (IPvX over GNUnet)
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 *
26 * TODO:
27 * - add statistics
28 * - add logging?
29 * - figure out how/where/when/who tunnels DNS over mesh when necessary!
30 */ 25 */
31#include "platform.h" 26#include "platform.h"
32#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
@@ -43,6 +38,16 @@
43 38
44 39
45/** 40/**
41 * How many bytes of payload do we allow at most for a DNS reply?
42 * Given that this is pretty much limited to loopback, we can be
43 * pretty high (Linux loopback defaults to 16k, most local UDP packets
44 * should survive up to 9k (NFS), so 8k should be pretty safe in
45 * general).
46 */
47#define MAX_DNS_SIZE (8 * 1024)
48
49
50/**
46 * Which group of DNS records are we currently processing? 51 * Which group of DNS records are we currently processing?
47 */ 52 */
48enum RequestGroup 53enum RequestGroup
@@ -61,6 +66,7 @@ enum RequestGroup
61 * DNS additional records 66 * DNS additional records
62 */ 67 */
63 ADDITIONAL_RECORDS = 2, 68 ADDITIONAL_RECORDS = 2,
69
64 /** 70 /**
65 * We're done processing. 71 * We're done processing.
66 */ 72 */
@@ -151,7 +157,7 @@ finish_request (struct RequestContext *rc)
151 157
152 if (GNUNET_SYSERR == 158 if (GNUNET_SYSERR ==
153 GNUNET_DNSPARSER_pack (rc->dns, 159 GNUNET_DNSPARSER_pack (rc->dns,
154 16 * 1024, 160 MAX_DNS_SIZE,
155 &buf, 161 &buf,
156 &buf_len)) 162 &buf_len))
157 { 163 {
@@ -161,6 +167,9 @@ finish_request (struct RequestContext *rc)
161 } 167 }
162 else 168 else
163 { 169 {
170 GNUNET_STATISTICS_update (stats,
171 gettext_noop ("# DNS requests mapped to VPN"),
172 1, GNUNET_NO);
164 GNUNET_DNS_request_answer (rc->rh, 173 GNUNET_DNS_request_answer (rc->rh,
165 buf_len, buf); 174 buf_len, buf);
166 GNUNET_free (buf); 175 GNUNET_free (buf);
@@ -211,8 +220,11 @@ vpn_allocation_callback (void *cls,
211 GNUNET_free (rc); 220 GNUNET_free (rc);
212 return; 221 return;
213 } 222 }
223 GNUNET_STATISTICS_update (stats,
224 gettext_noop ("# DNS records modified"),
225 1, GNUNET_NO);
214 switch (rc->rec->type) 226 switch (rc->rec->type)
215 { 227 {
216 case GNUNET_DNSPARSER_TYPE_A: 228 case GNUNET_DNSPARSER_TYPE_A:
217 GNUNET_assert (AF_INET == af); 229 GNUNET_assert (AF_INET == af);
218 memcpy (rc->rec->data.raw.data, address, sizeof (struct in_addr)); 230 memcpy (rc->rec->data.raw.data, address, sizeof (struct in_addr));
@@ -397,6 +409,9 @@ dns_request_handler (void *cls,
397 struct RequestContext *rc; 409 struct RequestContext *rc;
398 int work; 410 int work;
399 411
412 GNUNET_STATISTICS_update (stats,
413 gettext_noop ("# DNS requests intercepted"),
414 1, GNUNET_NO);
400 dns = GNUNET_DNSPARSER_parse (request, request_length); 415 dns = GNUNET_DNSPARSER_parse (request, request_length);
401 if (NULL == dns) 416 if (NULL == dns)
402 { 417 {
@@ -431,7 +446,7 @@ cleanup (void *cls GNUNET_UNUSED,
431 const struct GNUNET_SCHEDULER_TaskContext *tskctx) 446 const struct GNUNET_SCHEDULER_TaskContext *tskctx)
432{ 447{
433 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
434 "Pt service is shutting down now\n"); 449 "Protocol translation daemon is shutting down now\n");
435 if (vpn_handle != NULL) 450 if (vpn_handle != NULL)
436 { 451 {
437 GNUNET_VPN_disconnect (vpn_handle); 452 GNUNET_VPN_disconnect (vpn_handle);