X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/69128db28ea1e61902d8eddc1cc2c0cda031350e..246ca110d152b6483fd8c1c176a570858307f76b:/print-isakmp.c?ds=sidebyside diff --git a/print-isakmp.c b/print-isakmp.c index e85f64f8..21ca9027 100644 --- a/print-isakmp.c +++ b/print-isakmp.c @@ -47,6 +47,8 @@ #include +#include "netdissect-ctype.h" + #include "netdissect.h" #include "addrtoname.h" #include "extract.h" @@ -635,8 +637,8 @@ ikev1_print(netdissect_options *ndo, #define MAXINITIATORS 20 static int ninitiator = 0; union inaddr_u { - struct in_addr in4; - struct in6_addr in6; + nd_ipv4 in4; + nd_ipv6 in6; }; static struct { cookie_t initiator; @@ -1390,7 +1392,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, if (len < 4) ND_PRINT(" len=%u [bad: < 4]", len); else - ND_PRINT(" len=%u %s", len, ipaddr_string(ndo, data)); + ND_PRINT(" len=%u %s", len, GET_IPADDR_STRING(data)); len = 0; break; case IPSECDOI_ID_FQDN: @@ -1411,7 +1413,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, else { mask = data + sizeof(nd_ipv4); ND_PRINT(" len=%u %s/%u.%u.%u.%u", len, - ipaddr_string(ndo, data), + GET_IPADDR_STRING(data), GET_U_1(mask), GET_U_1(mask + 1), GET_U_1(mask + 2), GET_U_1(mask + 3)); @@ -1423,7 +1425,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, if (len < 16) ND_PRINT(" len=%u [bad: < 16]", len); else - ND_PRINT(" len=%u %s", len, ip6addr_string(ndo, data)); + ND_PRINT(" len=%u %s", len, GET_IP6ADDR_STRING(data)); len = 0; break; case IPSECDOI_ID_IPV6_ADDR_SUBNET: @@ -1435,7 +1437,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, mask = (const u_char *)(data + sizeof(nd_ipv6)); /*XXX*/ ND_PRINT(" len=%u %s/0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", len, - ip6addr_string(ndo, data), + GET_IP6ADDR_STRING(data), GET_U_1(mask), GET_U_1(mask + 1), GET_U_1(mask + 2), GET_U_1(mask + 3), @@ -1460,8 +1462,8 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, ND_PRINT(" len=%u [bad: < 8]", len); else { ND_PRINT(" len=%u %s-%s", len, - ipaddr_string(ndo, data), - ipaddr_string(ndo, data + sizeof(nd_ipv4))); + GET_IPADDR_STRING(data), + GET_IPADDR_STRING(data + sizeof(nd_ipv4))); } len = 0; break; @@ -1470,8 +1472,8 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, ND_PRINT(" len=%u [bad: < 32]", len); else { ND_PRINT(" len=%u %s-%s", len, - ip6addr_string(ndo, data), - ip6addr_string(ndo, data + sizeof(nd_ipv6))); + GET_IP6ADDR_STRING(data), + GET_IP6ADDR_STRING(data + sizeof(nd_ipv6))); } len = 0; break; @@ -2267,7 +2269,7 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay, if(dumpascii) { ND_TCHECK_LEN(typedata, idtype_len); for(i=0; indo_snapend, phase, doi, proto, depth+1); + + /* + * esp_print_decrypt_buffer_by_ikev2 pushed information + * on the buffer stack; we're done with the buffer, so + * pop it (which frees the buffer) + */ + nd_pop_packet_info(ndo); } #endif @@ -2813,7 +2822,7 @@ static char * numstr(u_int x) { static char buf[20]; - nd_snprintf(buf, sizeof(buf), "#%u", x); + snprintf(buf, sizeof(buf), "#%u", x); return buf; } @@ -3099,7 +3108,7 @@ isakmp_print(netdissect_options *ndo, void isakmp_rfc3948_print(netdissect_options *ndo, const u_char *bp, u_int length, - const u_char *bp2) + const u_char *bp2, int ver, int fragmented, u_int ttl_hl) { ndo->ndo_protocol = "isakmp_rfc3948"; ND_TCHECK_1(bp); @@ -3124,20 +3133,16 @@ isakmp_rfc3948_print(netdissect_options *ndo, /* must be an ESP packet */ { - u_int nh, enh, padlen; - int advance; - ND_PRINT("UDP-encap: "); - advance = esp_print(ndo, bp, length, bp2, &enh, &padlen); - if(advance <= 0) - return; - - bp += advance; - length -= advance + padlen; - nh = enh & 0xff; + esp_print(ndo, bp, length, bp2, ver, fragmented, ttl_hl); - ip_inner_print(ndo, bp, length, nh, bp2); + /* + * Either this has decrypted the payload and + * printed it, in which case there's nothing more + * to do, or it hasn't, in which case there's + * nothing more to do. + */ return; }