X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/99c91c3aec40b691641374f58e798bd8d6b657bd..refs/pull/482/head:/print-esp.c diff --git a/print-esp.c b/print-esp.c index 426aa845..50cc2d1f 100644 --- a/print-esp.c +++ b/print-esp.c @@ -43,11 +43,10 @@ #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)