* Type of messages for wlan
*/
+/**
+ * Type of messages to query the local service-dns
+ */
+#define GNUNET_MESSAGE_TYPE_LOCAL_QUERY_DNS 205
+/**
+ * Type of messages the local service-dns responds with
+ */
+#define GNUNET_MESSAGE_TYPE_LOCAL_RESPONSE_DNS 206
/**
#include "gnunet_common.h"
#include "gnunet_protocols.h"
#include "gnunet_server_lib.h"
+#include "gnunet-service-dns-p.h"
+#include "gnunet_client_lib.h"
/**
* Final status code.
struct GNUNET_SCHEDULER_Handle *sched;
+ struct GNUNET_CLIENT_Connection *dns_connection;
+
pid_t helper_pid;
};
} else if (ntohs(pkt_tun->tun.type) == 0x0800) {
struct ip_pkt *pkt = (struct ip_pkt*) message;
struct ip_udp *udp = (struct ip_udp*) message;
- fprintf(stderr, "IPv4\n");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "IPv4\n");
if (pkt->ip_hdr.proto == 0x11 && ntohl(udp->ip_hdr.dadr) == 0x0a0a0a02 && ntohs(udp->udp_hdr.dpt) == 53 ) {
pkt_printf_ipdns((struct ip_udp_dns*)udp);
+ struct query_packet* query = alloca((sizeof query) + ntohs(udp->udp_hdr.len) - 7); /* 7 = 8 for the udp-header - 1 for the unsigned char data[1]; */
+ query->hdr.type = htons(GNUNET_MESSAGE_TYPE_LOCAL_QUERY_DNS);
+ query->hdr.size = htons((sizeof query) + ntohs(udp->udp_hdr.len) - 7);
+ query->orig_to = pkt->ip_hdr.dadr;
+ query->orig_from = pkt->ip_hdr.sadr;
+ query->src_port = udp->udp_hdr.spt;
+ memcpy(query->data, udp->data, ntohs(udp->udp_hdr.len) - 8);
}
}
{
mycls.sched = sched;
mycls.mst = GNUNET_SERVER_mst_create(&message_token, NULL);
+
+ mycls.dns_connection = GNUNET_CLIENT_connect (sched, "gnunet-service-dns", cfg);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connection: %x\n", mycls.dns_connection);
+
GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls);
start_helper_and_schedule(mycls);
}
--- /dev/null
+#ifndef GN_DNS_SERVICE_P_H
+#define GN_DNS_SERVICE_P_H
+
+#include "gnunet_common.h"
+
+struct query_packet {
+ struct GNUNET_MessageHeader hdr;
+
+ unsigned orig_to:32 GNUNET_PACKED; /* The IP-Address, this query was originally sent to */
+ unsigned orig_from:32 GNUNET_PACKED;
+ unsigned src_port:16 GNUNET_PACKED;
+
+ unsigned char data[1]; /* The DNS-Packet */
+
+};
+
+#endif
#include "gnunet_service_lib.h"
#include "gnunet_network_lib.h"
#include "gnunet_os_lib.h"
+#include "gnunet-service-dns-p.h"
+#include "gnunet_protocols.h"
struct dns_cls {
struct GNUNET_SCHEDULER_Handle *sched;
GNUNET_OS_start_process(NULL, NULL, "gnunet-helper-hijack-dns", "gnunet-hijack-dns", "-d", port_s, NULL);
}
+void receive_query(void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message)
+{
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received query!\n");
+}
+
/**
* Task run during shutdown.
*
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
+ /* callback, cls, type, size */
+ {&receive_query, NULL, GNUNET_MESSAGE_TYPE_LOCAL_QUERY_DNS, 0},
{NULL, NULL, 0, 0}
};