#include "platform.h"
#include "gnunet_util_lib.h"
-#include "gnunet_dns_service-new.h"
+#include "gnunet_dns_service.h"
#include "gnunet_dnsparser_lib.h"
/**
static struct GNUNET_DNS_Handle *handle;
/**
- * Option -s.
+ * Option -i.
*/
-static int benchmark_send;
+static int inbound_only;
+
+/**
+ * Option -o.
+ */
+static int outbound_only;
/**
* Global return value (0 success).
/**
- * Output the given DNS query to stdout.
+ * Output the given DNS record to stdout.
*
- * @param query query to display.
+ * @param record record to display.
*/
static void
display_record (const struct GNUNET_DNSPARSER_Record *record)
switch (record->type)
{
case GNUNET_DNSPARSER_TYPE_A:
- if (record->data_len != sizeof (struct in_addr))
+ if (record->data.raw.data_len != sizeof (struct in_addr))
format = "<invalid>";
else
- format = inet_ntop (AF_INET, record->data.raw, buf, sizeof (buf));
+ format = inet_ntop (AF_INET, record->data.raw.data, buf, sizeof (buf));
break;
case GNUNET_DNSPARSER_TYPE_AAAA:
- if (record->data_len != sizeof (struct in6_addr))
+ if (record->data.raw.data_len != sizeof (struct in6_addr))
format = "<invalid>";
else
- format = inet_ntop (AF_INET6, record->data.raw, buf, sizeof (buf));
+ format = inet_ntop (AF_INET6, record->data.raw.data, buf, sizeof (buf));
break;
case GNUNET_DNSPARSER_TYPE_NS:
case GNUNET_DNSPARSER_TYPE_CNAME:
case GNUNET_DNSPARSER_TYPE_TXT:
GNUNET_asprintf (&tmp,
"%.*s",
- (unsigned int) record->data_len,
- record->data.raw);
+ (unsigned int) record->data.raw.data_len,
+ record->data.raw.data);
format = tmp;
break;
default:
break;
}
fprintf (stdout,
- "\t\t%s %s: %s = %s (%u bytes, %u s)\n",
+ "\t\t%s %s: %s = %s (%u s)\n",
get_class (record->class),
get_type (record->type),
record->name,
format,
- (unsigned int) record->data_len,
(unsigned int) (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value / 1000));
GNUNET_free_non_null (tmp);
}
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
+ enum GNUNET_DNS_Flags flags;
+
+ flags = GNUNET_DNS_FLAG_REQUEST_MONITOR | GNUNET_DNS_FLAG_RESPONSE_MONITOR;
+ if (inbound_only | outbound_only)
+ flags = 0;
+ if (inbound_only)
+ flags |= GNUNET_DNS_FLAG_REQUEST_MONITOR;
+ if (outbound_only)
+ flags |= GNUNET_DNS_FLAG_RESPONSE_MONITOR;
handle =
GNUNET_DNS_connect (cfg,
- GNUNET_DNS_FLAG_REQUEST_MONITOR | GNUNET_DNS_FLAG_RESPONSE_MONITOR,
+ flags,
&display_request,
NULL);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
main (int argc, char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'s', "testoption", NULL,
- gettext_noop ("not useful"),
- 0, &GNUNET_GETOPT_set_one, &benchmark_send},
+ {'i', "inbound-only", NULL,
+ gettext_noop ("only monitor DNS queries"),
+ 0, &GNUNET_GETOPT_set_one, &inbound_only},
+ {'o', "outbound-only", NULL,
+ gettext_noop ("only monitor DNS replies"),
+ 0, &GNUNET_GETOPT_set_one, &outbound_only},
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};