dnstap-read.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
* Portions of this code were adapted from dnstap-ldns:
*
* Copyright (c) 2014 by Farsight Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <config.h>
#include <stdlib.h>
#include <isc/commandline.h>
#include <dns/fixedname.h>
#include <dns/masterdump.h>
const char *program = "dnstap-read";
if (result != ISC_R_SUCCESS) { \
isc_result_totext(result)); \
goto cleanup; \
} \
} while (0)
ISC_PLATFORM_NORETURN_PRE static void
static void
exit(1);
}
static void
usage(void) {
}
static void
print_yaml(dns_dtdata_t *d) {
return;
if (frame->has_identity)
if (frame->has_version)
return;
printf("message:\n");
m->type);
return;
if (!isc_time_isepoch(&d->qtime)) {
char buf[100];
}
if (!isc_time_isepoch(&d->rtime)) {
char buf[100];
}
if (m->has_socket_family) {
const ProtobufCEnumValue *type =
m->socket_family);
}
if (m->has_query_address) {
char buf[100];
}
if (m->has_response_address) {
char buf[100];
}
if (m->has_query_port)
if (m->has_response_port)
if (m->has_query_zone) {
isc_buffer_t b;
if (result == ISC_R_SUCCESS) {
printf(" query_zone: ");
printf("\n");
}
}
? "query_message" : "response_message");
};
int
isc_buffer_t *b = NULL;
switch (ch) {
case 'm':
break;
case 'p':
break;
case 'y':
dns_master_indentstr = " ";
break;
default:
usage();
exit(1);
}
}
if (argc < 1)
fatal("no file specified");
"dns_dt_openfile");
for (;;) {
if (result == ISC_R_NOMORE)
break;
else
if (b != NULL)
isc_buffer_free(&b);
if (b == NULL)
fatal("out of memory");
if (result != ISC_R_SUCCESS) {
isc_buffer_free(&b);
continue;
}
if (yaml)
print_yaml(dt);
else {
(char *) isc_buffer_base(b));
}
isc_buffer_clear(b);
for (;;) {
isc_buffer_reserve(&b, textlen);
if (b == NULL)
fatal("out of memory");
0, b);
if (result == ISC_R_NOSPACE) {
textlen *= 2;
continue;
} else if (result == ISC_R_SUCCESS) {
printf("%.*s",
(int) isc_buffer_usedlength(b),
(char *) isc_buffer_base(b));
isc_buffer_free(&b);
} else {
isc_buffer_free(&b);
}
break;
}
}
if (yaml)
printf("---\n");
}
if (b != NULL)
isc_buffer_free(&b);
}