diff options
-rw-r--r-- | src/pt/Makefile.am | 1 | ||||
-rwxr-xr-x | src/pt/gnunet-daemon-pt | 4 | ||||
-rw-r--r-- | src/pt/gnunet-daemon-pt.c | 52 |
3 files changed, 55 insertions, 2 deletions
diff --git a/src/pt/Makefile.am b/src/pt/Makefile.am index c43787133..8e33b45c2 100644 --- a/src/pt/Makefile.am +++ b/src/pt/Makefile.am | |||
@@ -23,6 +23,7 @@ gnunet_daemon_pt_SOURCES = \ | |||
23 | gnunet_daemon_pt_LDADD = \ | 23 | gnunet_daemon_pt_LDADD = \ |
24 | $(top_builddir)/src/vpn/libgnunetvpn.la \ | 24 | $(top_builddir)/src/vpn/libgnunetvpn.la \ |
25 | $(top_builddir)/src/dns/libgnunetdns.la \ | 25 | $(top_builddir)/src/dns/libgnunetdns.la \ |
26 | $(top_builddir)/src/dns/libgnunetdnsparser.la \ | ||
26 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 27 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
27 | $(top_builddir)/src/util/libgnunetutil.la \ | 28 | $(top_builddir)/src/util/libgnunetutil.la \ |
28 | $(top_builddir)/src/mesh/libgnunetmesh.la \ | 29 | $(top_builddir)/src/mesh/libgnunetmesh.la \ |
diff --git a/src/pt/gnunet-daemon-pt b/src/pt/gnunet-daemon-pt index d729865e3..84ebead21 100755 --- a/src/pt/gnunet-daemon-pt +++ b/src/pt/gnunet-daemon-pt | |||
@@ -32,13 +32,13 @@ DUALCASE=1; export DUALCASE # for MKS sh | |||
32 | # if CDPATH is set. | 32 | # if CDPATH is set. |
33 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH | 33 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH |
34 | 34 | ||
35 | relink_command="(cd /home/grothoff/svn/gnunet/src/pt; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; LD_LIBRARY_PATH=/usr/lib/debug:/home/grothoff/lib; export LD_LIBRARY_PATH; PATH=/opt/jdk1.6.0_22/bin:/usr/lib/jvm/java-6-sun//bin:.:/home/grothoff/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games; export PATH; gcc -fno-strict-aliasing -Wall -g -Wall -Werror -O0 -I/home/grothoff//include -o \$progdir/\$file gnunet-daemon-pt.o -L/home/grothoff//lib ../../src/vpn/.libs/libgnunetvpn.so ../../src/dns/.libs/libgnunetdns.so ../../src/statistics/.libs/libgnunetstatistics.so ../../src/util/.libs/libgnunetutil.so ../../src/mesh/.libs/libgnunetmesh.so -ldl -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/vpn/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/dns/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/statistics/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/util/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/mesh/.libs -Wl,-rpath -Wl,/home/grothoff/lib)" | 35 | relink_command="(cd /home/grothoff/svn/gnunet/src/pt; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; LD_LIBRARY_PATH=/usr/lib/debug:/home/grothoff/lib; export LD_LIBRARY_PATH; PATH=/opt/jdk1.6.0_22/bin:/usr/lib/jvm/java-6-sun//bin:.:/home/grothoff/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games; export PATH; gcc -fno-strict-aliasing -Wall -g -Wall -Werror -O0 -I/home/grothoff//include -o \$progdir/\$file gnunet-daemon-pt.o -L/home/grothoff//lib ../../src/vpn/.libs/libgnunetvpn.so ../../src/dns/.libs/libgnunetdns.so ../../src/dns/.libs/libgnunetdnsparser.so ../../src/statistics/.libs/libgnunetstatistics.so ../../src/util/.libs/libgnunetutil.so ../../src/mesh/.libs/libgnunetmesh.so -ldl -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/vpn/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/dns/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/statistics/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/util/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/mesh/.libs -Wl,-rpath -Wl,/home/grothoff/lib)" |
36 | 36 | ||
37 | # This environment variable determines our operation mode. | 37 | # This environment variable determines our operation mode. |
38 | if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then | 38 | if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then |
39 | # install mode needs the following variables: | 39 | # install mode needs the following variables: |
40 | generated_by_libtool_version='2.2.6b' | 40 | generated_by_libtool_version='2.2.6b' |
41 | notinst_deplibs=' ../../src/vpn/libgnunetvpn.la ../../src/dns/libgnunetdns.la ../../src/statistics/libgnunetstatistics.la ../../src/util/libgnunetutil.la ../../src/mesh/libgnunetmesh.la' | 41 | notinst_deplibs=' ../../src/vpn/libgnunetvpn.la ../../src/dns/libgnunetdns.la ../../src/dns/libgnunetdnsparser.la ../../src/statistics/libgnunetstatistics.la ../../src/util/libgnunetutil.la ../../src/mesh/libgnunetmesh.la' |
42 | else | 42 | else |
43 | # When we are sourced in execute mode, $file and $ECHO are already set. | 43 | # When we are sourced in execute mode, $file and $ECHO are already set. |
44 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then | 44 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then |
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c index f8d83237a..762df276e 100644 --- a/src/pt/gnunet-daemon-pt.c +++ b/src/pt/gnunet-daemon-pt.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_dns_service.h" | 29 | #include "gnunet_dns_service.h" |
30 | #include "gnunet_dnsparser_lib.h" | ||
30 | #include "gnunet_vpn_service.h" | 31 | #include "gnunet_vpn_service.h" |
31 | #include "gnunet_statistics_service.h" | 32 | #include "gnunet_statistics_service.h" |
32 | 33 | ||
@@ -62,6 +63,36 @@ static int ipv4_pt; | |||
62 | static int ipv6_pt; | 63 | static int ipv6_pt; |
63 | 64 | ||
64 | 65 | ||
66 | /** | ||
67 | * Test if any of the given records need protocol-translation work. | ||
68 | * | ||
69 | * @param ra array of records | ||
70 | * @param ra_len number of entries in ra | ||
71 | * @return GNUNET_YES if any of the given records require protocol-translation | ||
72 | */ | ||
73 | static int | ||
74 | work_test (const struct GNUNET_DNSPARSER_Record *ra, | ||
75 | unsigned int ra_len) | ||
76 | { | ||
77 | unsigned int i; | ||
78 | |||
79 | for (i=0;i<ra_len;i++) | ||
80 | { | ||
81 | switch (ra[i].type) | ||
82 | { | ||
83 | case GNUNET_DNSPARSER_TYPE_A: | ||
84 | if (ipv4_pt) | ||
85 | return GNUNET_YES; | ||
86 | break; | ||
87 | case GNUNET_DNSPARSER_TYPE_AAAA: | ||
88 | if (ipv6_pt) | ||
89 | return GNUNET_YES; | ||
90 | break; | ||
91 | } | ||
92 | } | ||
93 | return GNUNET_NO; | ||
94 | } | ||
95 | |||
65 | 96 | ||
66 | /** | 97 | /** |
67 | * Signature of a function that is called whenever the DNS service | 98 | * Signature of a function that is called whenever the DNS service |
@@ -92,6 +123,27 @@ dns_request_handler (void *cls, | |||
92 | size_t request_length, | 123 | size_t request_length, |
93 | const char *request) | 124 | const char *request) |
94 | { | 125 | { |
126 | struct GNUNET_DNSPARSER_Packet *dns; | ||
127 | int work; | ||
128 | |||
129 | dns = GNUNET_DNSPARSER_parse (request, request_length); | ||
130 | if (NULL == dns) | ||
131 | { | ||
132 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
133 | _("Failed to parse DNS request. Dropping.\n")); | ||
134 | GNUNET_DNS_request_drop (rh); | ||
135 | return; | ||
136 | } | ||
137 | work = GNUNET_NO; | ||
138 | work |= work_test (dns->answers, dns->num_answers); | ||
139 | work |= work_test (dns->authority_records, dns->num_authority_records); | ||
140 | work |= work_test (dns->additional_records, dns->num_additional_records); | ||
141 | if (! work) | ||
142 | { | ||
143 | GNUNET_DNS_request_forward (rh); | ||
144 | return; | ||
145 | } | ||
146 | /* FIXME: translate A/AAAA records using VPN! */ | ||
95 | } | 147 | } |
96 | 148 | ||
97 | 149 | ||