]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print.c
Refine INSTALL.txt. [skip ci]
[tcpdump] / print.c
diff --git a/print.c b/print.c
index 823cea6ad54c414f1e3f8e54e710c219c3b8831c..265eee7b8a4cd15b0f5c27a7242a6bfc90d50a58 100644 (file)
--- a/print.c
+++ b/print.c
@@ -246,21 +246,6 @@ static const struct printer printers[] = {
        { NULL,                 0 },
 };
 
-static void    ndo_default_print(netdissect_options *ndo, const u_char *bp,
-                   u_int length);
-
-static void NORETURN ndo_error(netdissect_options *ndo,
-                    status_exit_codes_t status,
-                    FORMAT_STRING(const char *fmt), ...)
-                    PRINTFLIKE(3, 4);
-static void    ndo_warning(netdissect_options *ndo,
-                   FORMAT_STRING(const char *fmt), ...)
-                   PRINTFLIKE(2, 3);
-
-static int     ndo_printf(netdissect_options *ndo,
-                    FORMAT_STRING(const char *fmt), ...)
-                    PRINTFLIKE(2, 3);
-
 void
 init_print(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
 {
@@ -386,7 +371,16 @@ pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h,
         * bigger lengths.
         */
 
-       ts_print(ndo, &h->ts);
+       /*
+        * The header /usr/include/pcap/pcap.h in OpenBSD declares h->ts as
+        * struct bpf_timeval, not struct timeval. The former comes from
+        * /usr/include/net/bpf.h and uses 32-bit unsigned types instead of
+        * the types used in struct timeval.
+        */
+       struct timeval tvbuf;
+       tvbuf.tv_sec = h->ts.tv_sec;
+       tvbuf.tv_usec = h->ts.tv_usec;
+       ts_print(ndo, &tvbuf);
 
        /*
         * Printers must check that they're not walking off the end of
@@ -395,6 +389,7 @@ pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h,
         * of the netdissect_options structure.
         */
        ndo->ndo_snapend = sp + h->caplen;
+       ndo->ndo_packetp = sp;
 
        ndo->ndo_protocol = "";
        ndo->ndo_ll_hdr_len = 0;
@@ -497,9 +492,9 @@ ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
 }
 
 /* VARARGS */
-static void
+static void NORETURN PRINTFLIKE(3, 4)
 ndo_error(netdissect_options *ndo, status_exit_codes_t status,
-         const char *fmt, ...)
+          FORMAT_STRING(const char *fmt), ...)
 {
        va_list ap;
 
@@ -519,8 +514,8 @@ ndo_error(netdissect_options *ndo, status_exit_codes_t status,
 }
 
 /* VARARGS */
-static void
-ndo_warning(netdissect_options *ndo, const char *fmt, ...)
+static void PRINTFLIKE(2, 3)
+ndo_warning(netdissect_options *ndo, FORMAT_STRING(const char *fmt), ...)
 {
        va_list ap;
 
@@ -537,8 +532,9 @@ ndo_warning(netdissect_options *ndo, const char *fmt, ...)
        }
 }
 
-static int
-ndo_printf(netdissect_options *ndo, const char *fmt, ...)
+/* VARARGS */
+static int PRINTFLIKE(2, 3)
+ndo_printf(netdissect_options *ndo, FORMAT_STRING(const char *fmt), ...)
 {
        va_list args;
        int ret;