]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lwres.c
Handle very large -f files by rejecting them.
[tcpdump] / print-lwres.c
index d78c9a9068597db5c9143012f12e4228f22b0dd7..ae352807d006b2399e222b718eabf3dbfd24bbc2 100644 (file)
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: BIND9 Lightweight Resolver protocol printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
 #include "nameser.h"
 
 #include <stdio.h>
 #include <string.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
-#include "extract.h"                    /* must come after interface.h */
+#include "extract.h"
 
 /* BIND9 lib/lwres/include/lwres */
 typedef uint32_t lwres_uint32_t;
@@ -250,7 +251,7 @@ lwres_printbinlen(netdissect_options *ndo,
 
 static int
 lwres_printaddr(netdissect_options *ndo,
-                lwres_addr_t *ap)
+                const lwres_addr_t *ap)
 {
        uint16_t l;
        const char *p;
@@ -269,14 +270,12 @@ lwres_printaddr(netdissect_options *ndo,
                ND_PRINT((ndo, " %s", ipaddr_string(ndo, p)));
                p += sizeof(struct in_addr);
                break;
-#ifdef INET6
        case 2: /* IPv6 */
                if (l < 16)
                        return -1;
                ND_PRINT((ndo, " %s", ip6addr_string(ndo, p)));
                p += sizeof(struct in6_addr);
                break;
-#endif
        default:
                ND_PRINT((ndo, " %u/", EXTRACT_32BITS(&ap->family)));
                for (i = 0; i < l; i++)
@@ -343,9 +342,9 @@ lwres_print(netdissect_options *ndo,
                /*
                 * queries
                 */
-               lwres_gabnrequest_t *gabn;
-               lwres_gnbarequest_t *gnba;
-               lwres_grbnrequest_t *grbn;
+               const lwres_gabnrequest_t *gabn;
+               const lwres_gnbarequest_t *gnba;
+               const lwres_grbnrequest_t *grbn;
                uint32_t l;
 
                gabn = NULL;
@@ -356,7 +355,7 @@ lwres_print(netdissect_options *ndo,
                case LWRES_OPCODE_NOOP:
                        break;
                case LWRES_OPCODE_GETADDRSBYNAME:
-                       gabn = (lwres_gabnrequest_t *)(np + 1);
+                       gabn = (const lwres_gabnrequest_t *)(np + 1);
                        ND_TCHECK(gabn->namelen);
                        /* XXX gabn points to packed struct */
                        s = (const char *)&gabn->namelen +
@@ -390,7 +389,7 @@ lwres_print(netdissect_options *ndo,
                        s += advance;
                        break;
                case LWRES_OPCODE_GETNAMEBYADDR:
-                       gnba = (lwres_gnbarequest_t *)(np + 1);
+                       gnba = (const lwres_gnbarequest_t *)(np + 1);
                        ND_TCHECK(gnba->addr);
 
                        /* BIND910: not used */
@@ -408,7 +407,7 @@ lwres_print(netdissect_options *ndo,
                        break;
                case LWRES_OPCODE_GETRDATABYNAME:
                        /* XXX no trace, not tested */
-                       grbn = (lwres_grbnrequest_t *)(np + 1);
+                       grbn = (const lwres_grbnrequest_t *)(np + 1);
                        ND_TCHECK(grbn->namelen);
 
                        /* BIND910: not used */
@@ -442,9 +441,9 @@ lwres_print(netdissect_options *ndo,
                /*
                 * responses
                 */
-               lwres_gabnresponse_t *gabn;
-               lwres_gnbaresponse_t *gnba;
-               lwres_grbnresponse_t *grbn;
+               const lwres_gabnresponse_t *gabn;
+               const lwres_gnbaresponse_t *gnba;
+               const lwres_grbnresponse_t *grbn;
                uint32_t l, na;
                uint32_t i;
 
@@ -456,7 +455,7 @@ lwres_print(netdissect_options *ndo,
                case LWRES_OPCODE_NOOP:
                        break;
                case LWRES_OPCODE_GETADDRSBYNAME:
-                       gabn = (lwres_gabnresponse_t *)(np + 1);
+                       gabn = (const lwres_gabnresponse_t *)(np + 1);
                        ND_TCHECK(gabn->realnamelen);
                        /* XXX gabn points to packed struct */
                        s = (const char *)&gabn->realnamelen +
@@ -489,14 +488,14 @@ lwres_print(netdissect_options *ndo,
                        /* addrs */
                        na = EXTRACT_16BITS(&gabn->naddrs);
                        for (i = 0; i < na; i++) {
-                               advance = lwres_printaddr(ndo, (lwres_addr_t *)s);
+                               advance = lwres_printaddr(ndo, (const lwres_addr_t *)s);
                                if (advance < 0)
                                        goto trunc;
                                s += advance;
                        }
                        break;
                case LWRES_OPCODE_GETNAMEBYADDR:
-                       gnba = (lwres_gnbaresponse_t *)(np + 1);
+                       gnba = (const lwres_gnbaresponse_t *)(np + 1);
                        ND_TCHECK(gnba->realnamelen);
                        /* XXX gnba points to packed struct */
                        s = (const char *)&gnba->realnamelen +
@@ -527,7 +526,7 @@ lwres_print(netdissect_options *ndo,
                        break;
                case LWRES_OPCODE_GETRDATABYNAME:
                        /* XXX no trace, not tested */
-                       grbn = (lwres_grbnresponse_t *)(np + 1);
+                       grbn = (const lwres_grbnresponse_t *)(np + 1);
                        ND_TCHECK(grbn->nsigs);
 
                        /* BIND910: not used */
@@ -543,7 +542,7 @@ lwres_print(netdissect_options *ndo,
                                    EXTRACT_16BITS(&grbn->rdclass))));
                        }
                        ND_PRINT((ndo, " TTL "));
-                       relts_print(ndo, EXTRACT_32BITS(&grbn->ttl));
+                       unsigned_relts_print(ndo, EXTRACT_32BITS(&grbn->ttl));
                        ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
                            EXTRACT_16BITS(&grbn->nsigs)));