diff options
author | Philipp Tölke <toelke@in.tum.de> | 2010-09-07 13:37:27 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2010-09-07 13:37:27 +0000 |
commit | 35769f281f4faa7117fe18ca7c2a0c422d5078f7 (patch) | |
tree | 941395525e2a8b6719e53a0157e29deb2e7190a0 /src | |
parent | 626c304ecedf52caf96834caddeaf95d22e55bbe (diff) | |
download | gnunet-35769f281f4faa7117fe18ca7c2a0c422d5078f7.tar.gz gnunet-35769f281f4faa7117fe18ca7c2a0c422d5078f7.zip |
prepare the dns-pretty-printing for the service-dns
Diffstat (limited to 'src')
-rw-r--r-- | src/vpn/gnunet-vpn-pretty-print.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/vpn/gnunet-vpn-pretty-print.c b/src/vpn/gnunet-vpn-pretty-print.c index ea5936074..ba842602a 100644 --- a/src/vpn/gnunet-vpn-pretty-print.c +++ b/src/vpn/gnunet-vpn-pretty-print.c | |||
@@ -254,17 +254,17 @@ static char* dns_classes(short class) {{{ | |||
254 | return 0; | 254 | return 0; |
255 | }}} | 255 | }}} |
256 | 256 | ||
257 | void pkt_printf_dns(struct udp_dns* pkt) {{{ | 257 | void pkt_printf_dns(struct dns_pkt* pkt) {{{ |
258 | printf("DNS-Packet:\n"); | 258 | printf("DNS-Packet:\n"); |
259 | printf("\tid: %d\n", ntohs(pkt->data.id)); | 259 | printf("\tid: %d\n", ntohs(pkt->id)); |
260 | printf("\t%d: %s\n", pkt->data.qr, pkt->data.qr == 0 ? "query" : "response"); | 260 | printf("\t%d: %s\n", pkt->qr, pkt->qr == 0 ? "query" : "response"); |
261 | printf("\top: %s\n", (char*[]){"query", "inverse q.", "status", "inval"}[pkt->data.op]); | 261 | printf("\top: %s\n", (char*[]){"query", "inverse q.", "status", "inval"}[pkt->op]); |
262 | printf("\trecursion is%s desired\n", pkt->data.rd == 0 ? " not" : ""); | 262 | printf("\trecursion is%s desired\n", pkt->rd == 0 ? " not" : ""); |
263 | unsigned short qdcount = ntohs(pkt->data.qdcount); | 263 | unsigned short qdcount = ntohs(pkt->qdcount); |
264 | printf("\t#qd: %d\n", qdcount); | 264 | printf("\t#qd: %d\n", qdcount); |
265 | printf("\t#an: %d\n", ntohs(pkt->data.ancount)); | 265 | printf("\t#an: %d\n", ntohs(pkt->ancount)); |
266 | printf("\t#ns: %d\n", ntohs(pkt->data.nscount)); | 266 | printf("\t#ns: %d\n", ntohs(pkt->nscount)); |
267 | printf("\t#ar: %d\n", ntohs(pkt->data.arcount)); | 267 | printf("\t#ar: %d\n", ntohs(pkt->arcount)); |
268 | 268 | ||
269 | struct dns_query** queries = alloca(qdcount*sizeof(struct dns_query*)); | 269 | struct dns_query** queries = alloca(qdcount*sizeof(struct dns_query*)); |
270 | unsigned int idx = 0; | 270 | unsigned int idx = 0; |
@@ -274,29 +274,33 @@ void pkt_printf_dns(struct udp_dns* pkt) {{{ | |||
274 | queries[i] = alloca(sizeof(struct dns_query)); | 274 | queries[i] = alloca(sizeof(struct dns_query)); |
275 | queries[i]->name = alloca(255); // see RFC1035 | 275 | queries[i]->name = alloca(255); // see RFC1035 |
276 | unsigned char* name = queries[i]->name; | 276 | unsigned char* name = queries[i]->name; |
277 | int len = pkt->data.data[idx++]; | 277 | int len = pkt->data[idx++]; |
278 | while (len != 0) { | 278 | while (len != 0) { |
279 | memcpy(name, pkt->data.data+idx, len); | 279 | memcpy(name, pkt->data+idx, len); |
280 | idx += len; | 280 | idx += len; |
281 | name += len; | 281 | name += len; |
282 | *name = '.'; | 282 | *name = '.'; |
283 | name++; | 283 | name++; |
284 | len = pkt->data.data[idx++]; | 284 | len = pkt->data[idx++]; |
285 | }; | 285 | }; |
286 | printf("%d\n", idx); | 286 | printf("%d\n", idx); |
287 | *name = 0; | 287 | *name = 0; |
288 | queries[i]->qtype = *((unsigned short*)(pkt->data.data+idx)); | 288 | queries[i]->qtype = *((unsigned short*)(pkt->data+idx)); |
289 | idx += 2; | 289 | idx += 2; |
290 | queries[i]->qclass = *((unsigned short*)(pkt->data.data+idx)); | 290 | queries[i]->qclass = *((unsigned short*)(pkt->data+idx)); |
291 | idx += 2; | 291 | idx += 2; |
292 | printf("query for %s type=%d (%s) class=%d (%s)\n", queries[i]->name, ntohs(queries[i]->qtype), dns_types(ntohs(queries[i]->qtype)), ntohs(queries[i]->qclass), dns_classes(ntohs(queries[i]->qclass))); | 292 | printf("query for %s type=%d (%s) class=%d (%s)\n", queries[i]->name, ntohs(queries[i]->qtype), dns_types(ntohs(queries[i]->qtype)), ntohs(queries[i]->qclass), dns_classes(ntohs(queries[i]->qclass))); |
293 | } | 293 | } |
294 | }}} | 294 | }}} |
295 | 295 | ||
296 | void pkt_printf_udp_dns(struct udp_dns* pkt) {{{ | ||
297 | pkt_printf_dns(&pkt->data); | ||
298 | }}} | ||
299 | |||
296 | void pkt_printf_ip6dns(struct ip6_udp_dns* pkt) {{{ | 300 | void pkt_printf_ip6dns(struct ip6_udp_dns* pkt) {{{ |
297 | pkt_printf_dns(&pkt->udp_dns); | 301 | pkt_printf_udp_dns(&pkt->udp_dns); |
298 | }}} | 302 | }}} |
299 | 303 | ||
300 | void pkt_printf_ipdns(struct ip_udp_dns* pkt) {{{ | 304 | void pkt_printf_ipdns(struct ip_udp_dns* pkt) {{{ |
301 | pkt_printf_dns(&pkt->udp_dns); | 305 | pkt_printf_udp_dns(&pkt->udp_dns); |
302 | }}} | 306 | }}} |