diff options
author | Philipp Tölke <toelke@in.tum.de> | 2010-09-07 13:37:28 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2010-09-07 13:37:28 +0000 |
commit | 2a2509d66f5a7d670fbecb2b62498f1cab180161 (patch) | |
tree | 30629adff10f0aa3f357ae9f11e56402739fa12a /src | |
parent | 87bd42c5d90b9f4cce4e095a1dd52bad8bdfab89 (diff) | |
download | gnunet-2a2509d66f5a7d670fbecb2b62498f1cab180161.tar.gz gnunet-2a2509d66f5a7d670fbecb2b62498f1cab180161.zip |
send dns-queries to the service-dns and pretty-print them
Diffstat (limited to 'src')
-rw-r--r-- | src/vpn/Makefile.am | 6 | ||||
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.c | 9 | ||||
-rw-r--r-- | src/vpn/gnunet-service-dns.c | 5 | ||||
-rw-r--r-- | src/vpn/gnunet-vpn-pretty-print.h | 2 |
4 files changed, 17 insertions, 5 deletions
diff --git a/src/vpn/Makefile.am b/src/vpn/Makefile.am index 370528772..ca8f6c1af 100644 --- a/src/vpn/Makefile.am +++ b/src/vpn/Makefile.am | |||
@@ -34,7 +34,8 @@ gnunet_helper_hijack_dns_SOURCES = \ | |||
34 | gnunet-helper-hijack-dns.c | 34 | gnunet-helper-hijack-dns.c |
35 | 35 | ||
36 | gnunet_daemon_vpn_SOURCES = \ | 36 | gnunet_daemon_vpn_SOURCES = \ |
37 | gnunet-daemon-vpn.c gnunet-vpn-pretty-print.c | 37 | gnunet-daemon-vpn.c \ |
38 | gnunet-vpn-pretty-print.c | ||
38 | gnunet_daemon_vpn_LDADD = \ | 39 | gnunet_daemon_vpn_LDADD = \ |
39 | $(top_builddir)/src/core/libgnunetcore.la \ | 40 | $(top_builddir)/src/core/libgnunetcore.la \ |
40 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 41 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
@@ -42,7 +43,8 @@ gnunet_daemon_vpn_LDADD = \ | |||
42 | $(GN_LIBINTL) | 43 | $(GN_LIBINTL) |
43 | 44 | ||
44 | gnunet_service_dns_SOURCES = \ | 45 | gnunet_service_dns_SOURCES = \ |
45 | gnunet-service-dns.c | 46 | gnunet-service-dns.c \ |
47 | gnunet-vpn-pretty-print.c | ||
46 | gnunet_service_dns_LDADD = \ | 48 | gnunet_service_dns_LDADD = \ |
47 | $(top_builddir)/src/core/libgnunetcore.la \ | 49 | $(top_builddir)/src/core/libgnunetcore.la \ |
48 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 50 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 6eb3ea9a0..147983f5c 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c | |||
@@ -149,7 +149,7 @@ static void message_token(void *cls, void *client, const struct GNUNET_MessageHe | |||
149 | struct ip_pkt *pkt = (struct ip_pkt*) message; | 149 | struct ip_pkt *pkt = (struct ip_pkt*) message; |
150 | struct ip_udp *udp = (struct ip_udp*) message; | 150 | struct ip_udp *udp = (struct ip_udp*) message; |
151 | if (pkt->ip_hdr.proto == 0x11 && udp->ip_hdr.dadr == 0x020a0a0a && ntohs(udp->udp_hdr.dpt) == 53 ) { | 151 | if (pkt->ip_hdr.proto == 0x11 && udp->ip_hdr.dadr == 0x020a0a0a && ntohs(udp->udp_hdr.dpt) == 53 ) { |
152 | size_t len = sizeof(struct query_packet*) + ntohs(udp->udp_hdr.len) - 7; /* 7 = 8 for the udp-header - 1 for the unsigned char data[1]; */ | 152 | size_t len = sizeof(struct query_packet) + ntohs(udp->udp_hdr.len) - 9; /* 7 = 8 for the udp-header + 1 for the unsigned char data[1]; */ |
153 | struct query_packet* query = GNUNET_malloc(len); | 153 | struct query_packet* query = GNUNET_malloc(len); |
154 | query->hdr.type = htons(GNUNET_MESSAGE_TYPE_LOCAL_QUERY_DNS); | 154 | query->hdr.type = htons(GNUNET_MESSAGE_TYPE_LOCAL_QUERY_DNS); |
155 | query->hdr.size = htons(len); | 155 | query->hdr.size = htons(len); |
@@ -157,8 +157,11 @@ static void message_token(void *cls, void *client, const struct GNUNET_MessageHe | |||
157 | query->orig_from = pkt->ip_hdr.sadr; | 157 | query->orig_from = pkt->ip_hdr.sadr; |
158 | query->src_port = udp->udp_hdr.spt; | 158 | query->src_port = udp->udp_hdr.spt; |
159 | memcpy(query->data, udp->data, ntohs(udp->udp_hdr.len) - 8); | 159 | memcpy(query->data, udp->data, ntohs(udp->udp_hdr.len) - 8); |
160 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Queued sending\n"); | 160 | struct GNUNET_CLIENT_TransmitHandle* th = GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, len, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, query); |
161 | GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, len, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, query); | 161 | if (th != NULL) |
162 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Queued sending of %d bytes.\n", len); | ||
163 | else | ||
164 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Already queued!\n"); | ||
162 | } | 165 | } |
163 | } | 166 | } |
164 | 167 | ||
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index 90e789010..c85ba0027 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c | |||
@@ -29,6 +29,8 @@ | |||
29 | #include "gnunet_os_lib.h" | 29 | #include "gnunet_os_lib.h" |
30 | #include "gnunet-service-dns-p.h" | 30 | #include "gnunet-service-dns-p.h" |
31 | #include "gnunet_protocols.h" | 31 | #include "gnunet_protocols.h" |
32 | #include "gnunet-vpn-packet.h" | ||
33 | #include "gnunet-vpn-pretty-print.h" | ||
32 | 34 | ||
33 | struct dns_cls { | 35 | struct dns_cls { |
34 | struct GNUNET_SCHEDULER_Handle *sched; | 36 | struct GNUNET_SCHEDULER_Handle *sched; |
@@ -58,6 +60,9 @@ void receive_query(void *cls, struct GNUNET_SERVER_Client *client, const struct | |||
58 | { | 60 | { |
59 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received query!\n"); | 61 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received query!\n"); |
60 | struct query_packet* pkt = (struct query_packet*)message; | 62 | struct query_packet* pkt = (struct query_packet*)message; |
63 | struct dns_pkt* dns = (struct dns_pkt*)pkt->data; | ||
64 | |||
65 | pkt_printf_dns(dns); | ||
61 | 66 | ||
62 | GNUNET_SERVER_receive_done(client, GNUNET_OK); | 67 | GNUNET_SERVER_receive_done(client, GNUNET_OK); |
63 | } | 68 | } |
diff --git a/src/vpn/gnunet-vpn-pretty-print.h b/src/vpn/gnunet-vpn-pretty-print.h index 8e5ff66c2..26f651fac 100644 --- a/src/vpn/gnunet-vpn-pretty-print.h +++ b/src/vpn/gnunet-vpn-pretty-print.h | |||
@@ -7,6 +7,8 @@ extern void pp_write_header(char* dest, struct ip6_pkt* pkt); | |||
7 | 7 | ||
8 | extern void pkt_printf(struct ip6_pkt* pkt); | 8 | extern void pkt_printf(struct ip6_pkt* pkt); |
9 | 9 | ||
10 | void pkt_printf_dns(struct dns_pkt* pkt); | ||
11 | |||
10 | void pkt_printf_ip6tcp(struct ip6_tcp* pkt); | 12 | void pkt_printf_ip6tcp(struct ip6_tcp* pkt); |
11 | void pkt_printf_ip6udp(struct ip6_udp* pkt); | 13 | void pkt_printf_ip6udp(struct ip6_udp* pkt); |
12 | void pkt_printf_ip6dns(struct ip6_udp_dns* pkt); | 14 | void pkt_printf_ip6dns(struct ip6_udp_dns* pkt); |