]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-esp.c
Don't require IPv6 library support in order to support IPv6 addresses.
[tcpdump] / print-esp.c
index 426aa845eca017fae411488ccdcb0112ef58258d..50cc2d1f7b72a3abfc1e59872134adfdf14022dc 100644 (file)
 #endif
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 
 #include "netdissect.h"
+#include "strtoaddr.h"
 #include "extract.h"
 
 #include "ascii_strcasecmp.h"
@@ -99,9 +98,7 @@ struct newesp {
 #ifdef HAVE_LIBCRYPTO
 union inaddr_u {
        struct in_addr in4;
-#ifdef INET6
        struct in6_addr in6;
-#endif
 };
 struct sa_list {
        struct sa_list  *next;
@@ -478,17 +475,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
 
                sa1.spi = spino;
 
-#ifdef INET6
-               if (inet_pton(AF_INET6, spikey, &sa1.daddr.in6) == 1) {
+               if (strtoaddr6(spikey, &sa1.daddr.in6) == 1) {
                        sa1.daddr_version = 6;
-               } else
-#endif
-                       if (inet_pton(AF_INET, spikey, &sa1.daddr.in4) == 1) {
-                               sa1.daddr_version = 4;
-                       } else {
-                               (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
-                               return;
-                       }
+               } else if (strtoaddr(spikey, &sa1.daddr.in4) == 1) {
+                       sa1.daddr_version = 4;
+               } else {
+                       (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
+                       return;
+               }
        }
 
        if (decode) {
@@ -567,9 +561,7 @@ esp_print(netdissect_options *ndo,
 #ifdef HAVE_LIBCRYPTO
        const struct ip *ip;
        struct sa_list *sa = NULL;
-#ifdef INET6
        const struct ip6_hdr *ip6 = NULL;
-#endif
        int advance;
        int len;
        u_char *secret;
@@ -618,7 +610,6 @@ esp_print(netdissect_options *ndo,
 
        ip = (const struct ip *)bp2;
        switch (IP_V(ip)) {
-#ifdef INET6
        case 6:
                ip6 = (const struct ip6_hdr *)bp2;
                /* we do not attempt to decrypt jumbograms */
@@ -637,7 +628,6 @@ esp_print(netdissect_options *ndo,
                        }
                }
                break;
-#endif /*INET6*/
        case 4:
                /* nexthdr & padding are in the last fragment */
                if (EXTRACT_16BITS(&ip->ip_off) & IP_MF)