]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-esp.c
document SIGUSR1 in manual page
[tcpdump] / print-esp.c
index 241030204b293743acc50e8c53f68451202ebb67..8e267d45cdf9381d0eff7f70dbbaee8eaefeb0e0 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <string.h>
-
 #include <tcpdump-stdinc.h>
 
+#include <string.h>
 #include <stdlib.h>
 
 /* Any code in this file that depends on HAVE_LIBCRYPTO depends on
 #endif
 #endif
 
-#include <stdio.h>
-
 #include "ip.h"
 #ifdef INET6
 #include "ip6.h"
 #endif
 
-#include "netdissect.h"
-#include "addrtoname.h"
+#include "interface.h"
 #include "extract.h"
 
 /*
@@ -88,8 +85,8 @@
  */
 
 struct newesp {
-       u_int32_t       esp_spi;        /* ESP */
-       u_int32_t       esp_seq;        /* Sequence number */
+       uint32_t        esp_spi;        /* ESP */
+       uint32_t        esp_seq;        /* Sequence number */
        /*variable size*/               /* (IV and) Payload data */
        /*variable size*/               /* padding */
        /*8bit*/                        /* pad size */
@@ -109,7 +106,7 @@ struct sa_list {
        struct sa_list  *next;
        u_int           daddr_version;
        union inaddr_u  daddr;
-       u_int32_t       spi;          /* if == 0, then IKEv2 */
+       uint32_t        spi;          /* if == 0, then IKEv2 */
        int             initiator;
        u_char          spii[8];      /* for IKEv2 */
        u_char          spir[8];
@@ -468,7 +465,7 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
        if (spikey) {
 
                char *spistr, *foo;
-               u_int32_t spino;
+               uint32_t spino;
 
                spistr = strsep(&spikey, "@");
 
@@ -597,12 +594,12 @@ esp_print(netdissect_options *ndo,
        ep = ndo->ndo_snapend;
 
        if ((u_char *)(esp + 1) >= ep) {
-               fputs("[|ESP]", stdout);
+               ND_PRINT((ndo, "[|ESP]"));
                goto fail;
        }
-       (*ndo->ndo_printf)(ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi));
-       (*ndo->ndo_printf)(ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq));
-        (*ndo->ndo_printf)(ndo, ", length %u", length);
+       ND_PRINT((ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi)));
+       ND_PRINT((ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq)));
+       ND_PRINT((ndo, ", length %u", length));
 
 #ifndef HAVE_LIBCRYPTO
        goto fail;
@@ -633,7 +630,7 @@ esp_print(netdissect_options *ndo,
                for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
                        if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
                            sa->daddr_version == 6 &&
-                           unaligned_memcmp(&sa->daddr.in6, &ip6->ip6_dst,
+                           UNALIGNED_MEMCMP(&sa->daddr.in6, &ip6->ip6_dst,
                                   sizeof(struct in6_addr)) == 0) {
                                break;
                        }
@@ -650,7 +647,7 @@ esp_print(netdissect_options *ndo,
                for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
                        if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
                            sa->daddr_version == 4 &&
-                           unaligned_memcmp(&sa->daddr.in4, &ip->ip_dst,
+                           UNALIGNED_MEMCMP(&sa->daddr.in4, &ip->ip_dst,
                                   sizeof(struct in_addr)) == 0) {
                                break;
                        }
@@ -706,7 +703,7 @@ esp_print(netdissect_options *ndo,
        if (nhdr)
                *nhdr = *(ep - 1);
 
-       (ndo->ndo_printf)(ndo, ": ");
+       ND_PRINT((ndo, ": "));
        return advance;
 #endif