]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-isakmp.c
CMake: Fix the comment about versions. [skip ci]
[tcpdump] / print-isakmp.c
index f3cb34289e98c587cd55f96e709a924cd385fcdb..e6be3c8e1ce8257d87e9098175e142b699876a16 100644 (file)
 
 /* specification: RFC 2407, RFC 2408, RFC 5996 */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
-
-/* The functions from print-esp.c used in this file are only defined when both
- * OpenSSL and evp.h are detected. Employ the same preprocessor device here.
- */
-#ifndef HAVE_OPENSSL_EVP_H
-#undef HAVE_LIBCRYPTO
-#endif
 
 #include "netdissect-stdinc.h"
 
@@ -122,9 +113,9 @@ struct isakmp {
 #define ISAKMP_FLAG_extra 0x04
 
 /* IKEv2 */
-#define ISAKMP_FLAG_I (1 << 3)  /* (I)nitiator */
-#define ISAKMP_FLAG_V (1 << 4)  /* (V)ersion   */
-#define ISAKMP_FLAG_R (1 << 5)  /* (R)esponse  */
+#define ISAKMP_FLAG_I (1 << 3)  /* Initiator */
+#define ISAKMP_FLAG_V (1 << 4)  /* Version   */
+#define ISAKMP_FLAG_R (1 << 5)  /* Response  */
 
 
 /* 3.2 Payload Generic Header
@@ -741,10 +732,10 @@ static const char *etypestr[] = {
                ? npfunc[(x)] : NULL)
 
 static int
-iszero(const u_char *p, size_t l)
+iszero(netdissect_options *ndo, const u_char *p, size_t l)
 {
        while (l != 0) {
-               if (*p)
+               if (GET_U_1(p))
                        return 0;
                p++;
                l--;
@@ -1828,14 +1819,16 @@ ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
        ND_PRINT(" spilen=%u", spi_size);
        num_spi = GET_BE_U_2(p->num_spi);
        ND_PRINT(" nspi=%u", num_spi);
-       ND_PRINT(" spi=");
        q = (const uint8_t *)(p + 1);
-       for (i = 0; i < num_spi; i++) {
-               if (i != 0)
-                       ND_PRINT(",");
-               if (!rawprint(ndo, (const uint8_t *)q, spi_size))
-                       goto trunc;
-               q += spi_size;
+       if (spi_size) {
+               ND_PRINT(" spi=");
+               for (i = 0; i < num_spi; i++) {
+                       if (i != 0)
+                               ND_PRINT(",");
+                       if (!rawprint(ndo, (const uint8_t *)q, spi_size))
+                               goto trunc;
+                       q += spi_size;
+               }
        }
        return q;
 trunc:
@@ -2841,7 +2834,7 @@ ikev1_print(netdissect_options *ndo,
 
        i = cookie_find(&base->i_ck);
        if (i < 0) {
-               if (iszero((const u_char *)&base->r_ck, sizeof(base->r_ck))) {
+               if (iszero(ndo, base->r_ck, sizeof(base->r_ck))) {
                        /* the first packet */
                        ND_PRINT(" I");
                        if (bp2)