From 92a5921b90299a78bda882b612f1816d309942cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philipp=20T=C3=B6lke?= Date: Tue, 5 Oct 2010 18:20:21 +0000 Subject: [PATCH] Make the packet-pretty-printing more usable (concise) --- src/vpn/gnunet-dns-parser.c | 4 ++-- src/vpn/gnunet-vpn-pretty-print.c | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/vpn/gnunet-dns-parser.c b/src/vpn/gnunet-dns-parser.c index be4770e24..ae0e24044 100644 --- a/src/vpn/gnunet-dns-parser.c +++ b/src/vpn/gnunet-dns-parser.c @@ -52,7 +52,7 @@ unsigned short parse_dns_record(unsigned char* data, struct dns_record** dst, un return idx; }/*}}}*/ -struct dns_pkt_parsed* parse_dns_packet(struct dns_pkt* pkt) { +struct dns_pkt_parsed* parse_dns_packet(struct dns_pkt* pkt) {/*{{{*/ struct dns_pkt_parsed* ppkt = GNUNET_malloc(sizeof(struct dns_pkt_parsed)); memcpy(&ppkt->s, &pkt->s, sizeof pkt->s); @@ -90,4 +90,4 @@ struct dns_pkt_parsed* parse_dns_packet(struct dns_pkt* pkt) { idx = parse_dns_record(pkt->data, ppkt->nameservers, nscount, idx); idx = parse_dns_record(pkt->data, ppkt->additional, arcount, idx); return ppkt; -} +}/*}}}*/ diff --git a/src/vpn/gnunet-vpn-pretty-print.c b/src/vpn/gnunet-vpn-pretty-print.c index 0d165a650..9ea5297cd 100644 --- a/src/vpn/gnunet-vpn-pretty-print.c +++ b/src/vpn/gnunet-vpn-pretty-print.c @@ -263,19 +263,22 @@ static char* dns_classes(short class) { /* {{{ */ void pkt_printf_dns(struct dns_pkt* upkt) {{{ struct dns_pkt_parsed* pkt = parse_dns_packet(upkt); - printf("DNS-Packet:\n"); - printf("\tid: %d\n", ntohs(pkt->s.id)); - printf("\t%d: %s\n", pkt->s.qr, pkt->s.qr == 0 ? "query" : "response"); - printf("\top: %s\n", (char*[]){"query", "inverse q.", "status", "inval"}[pkt->s.op]); - printf("\trecursion is%s desired\n", pkt->s.rd == 0 ? " not" : ""); + printf("\nDNS-Packet: "); + printf("\tid: %5d ", ntohs(pkt->s.id)); + printf("\t%d: %s ", pkt->s.qr, pkt->s.qr == 0 ? "query " : "response"); + printf("\top: %s ", (char*[]){ "query ", + "inverse q.", + "status ", + "inval "}[pkt->s.op]); + printf("\trecursion is%s desired ", pkt->s.rd == 0 ? " not" : " "); unsigned short qdcount = ntohs(pkt->s.qdcount); unsigned short ancount = ntohs(pkt->s.ancount); unsigned short nscount = ntohs(pkt->s.nscount); unsigned short arcount = ntohs(pkt->s.arcount); - printf("\t#qd: %d\n", qdcount); - printf("\t#an: %d\n", ancount); - printf("\t#ns: %d\n", nscount); - printf("\t#ar: %d\n", arcount); + printf("\t#qd: %5d ", qdcount); + printf("\t#an: %5d ", ancount); + printf("\t#ns: %5d ", nscount); + printf("\t#ar: %5d\n", arcount); int i; for (i = 0; i < qdcount; i++) { /*{{{*/ -- 2.25.1