]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lisp.c
CHANGES: Add/move change(s) backported to 4.99
[tcpdump] / print-lisp.c
index 5c6825ae6d974bdcde9d4ec16f519cca3b7bdb87..da131226579765cd44548515c98dea7cd91c55cb 100644 (file)
  *  +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 #include "netdissect.h"
-#include <string.h>
-#include <stdlib.h>
 
 #include "ip.h"
 #include "ip6.h"
@@ -131,12 +127,12 @@ enum {
 };
 
 static const struct tok lisp_type [] = {
-       { 0, "LISP-Reserved"                    },
-       { 1, "LISP-Map-Request"                 },
-       { 2, "LISP-Map-Reply"                   },
-       { 3, "LISP-Map-Register"                },
-       { 4, "LISP-Map-Notify"                  },
-       { 8, "LISP-Encapsulated-Contol-Message" },
+       { 0, "LISP-Reserved"                     },
+       { 1, "LISP-Map-Request"                  },
+       { 2, "LISP-Map-Reply"                    },
+       { 3, "LISP-Map-Register"                 },
+       { 4, "LISP-Map-Notify"                   },
+       { 8, "LISP-Encapsulated-Control-Message" },
        { 0, NULL }
 };
 
@@ -285,8 +281,8 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                goto invalid;
 
        /* Print all the EID records */
-       while ((length > packet_offset) && (record_count--)) {
-
+       while ((length > packet_offset) && (record_count != 0)) {
+               record_count--;
                ND_TCHECK_LEN(packet_iterator + packet_offset,
                              MAP_REGISTER_EID_LEN);
                ND_PRINT("\n");
@@ -307,15 +303,15 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
 
                switch (eid_afi) {
                case IPv4_AFI:
-                       ND_TCHECK_4(packet_iterator + packet_offset);
-                       ND_PRINT(" EID %s/%u,", ipaddr_string(ndo,
-                               packet_iterator + packet_offset), mask_len);
+                       ND_PRINT(" EID %s/%u,",
+                               GET_IPADDR_STRING(packet_iterator + packet_offset),
+                               mask_len);
                        packet_offset += 4;
                        break;
                case IPv6_AFI:
-                       ND_TCHECK_16(packet_iterator + packet_offset);
-                       ND_PRINT(" EID %s/%u,", ip6addr_string(ndo,
-                               packet_iterator + packet_offset), mask_len);
+                       ND_PRINT(" EID %s/%u,",
+                               GET_IP6ADDR_STRING(packet_iterator + packet_offset),
+                               mask_len);
                        packet_offset += 16;
                        break;
                default:
@@ -328,7 +324,8 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
 
                ND_PRINT(" %u locator(s)", loc_count);
 
-               while (loc_count--) {
+               while (loc_count != 0) {
+                       loc_count--;
                        ND_TCHECK_LEN(packet_iterator + packet_offset,
                                      MAP_REGISTER_LOC_LEN);
                        lisp_loc = (const lisp_map_register_loc *) (packet_iterator + packet_offset);
@@ -342,12 +339,12 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                        switch (loc_afi) {
                        case IPv4_AFI:
                                ND_TCHECK_4(packet_iterator + packet_offset);
-                               ND_PRINT(" LOC %s", ipaddr_string(ndo, loc_ip_pointer));
+                               ND_PRINT(" LOC %s", GET_IPADDR_STRING(loc_ip_pointer));
                                packet_offset += 4;
                                break;
                        case IPv6_AFI:
                                ND_TCHECK_16(packet_iterator + packet_offset);
-                               ND_PRINT(" LOC %s", ip6addr_string(ndo, loc_ip_pointer));
+                               ND_PRINT(" LOC %s", GET_IP6ADDR_STRING(loc_ip_pointer));
                                packet_offset += 16;
                                break;
                        default:
@@ -374,14 +371,14 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
        if (xtr_present) {
                if (!ND_TTEST_LEN(packet_iterator + packet_offset, 24))
                        goto invalid;
-               hex_print_with_offset(ndo, "\n    xTR-ID: ", packet_iterator + packet_offset, 16, 0);
+               hex_print(ndo, "\n    xTR-ID: ", packet_iterator + packet_offset, 16);
                ND_PRINT("\n    SITE-ID: %" PRIu64,
                        GET_BE_U_8(packet_iterator + packet_offset + 16));
        } else {
                /* Check if packet isn't over yet */
                if (packet_iterator + packet_offset < ndo->ndo_snapend) {
-                       hex_print_with_offset(ndo, "\n    Data: ", packet_iterator + packet_offset,
-                               ND_BYTES_AVAILABLE_AFTER(packet_iterator + packet_offset), 0);
+                       hex_print(ndo, "\n    Data: ", packet_iterator + packet_offset,
+                               ND_BYTES_AVAILABLE_AFTER(packet_iterator + packet_offset));
                }
        }
        return;
@@ -390,7 +387,6 @@ trunc:
        return;
 invalid:
        nd_print_invalid(ndo);
-       return;
 }
 
 static uint8_t
@@ -430,8 +426,6 @@ static void lisp_hdr_flag(netdissect_options *ndo, const lisp_map_register_hdr *
                ND_PRINT(" flags [%s],", bittok2str(map_notify_hdr_flag,
                         "none", GET_BE_U_4(lisp_hdr)));
        }
-
-       return;
 }
 
 static void action_flag(netdissect_options *ndo, uint8_t act_auth_inc_res)