]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-msdp.c
Fix spaces
[tcpdump] / print-msdp.c
index 68bb315939435af08d6f4f736c0cfe69a2cd348d..004818362968745f10a9413967bf6a30268de461 100644 (file)
 /* \summary: Multicast Source Discovery Protocol (MSDP) printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #include "netdissect.h"
 #include "addrtoname.h"
@@ -35,6 +35,7 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
 {
        unsigned int type, len;
 
+       ndo->ndo_protocol = "msdp";
        ND_TCHECK_3(sp);
        /* See if we think we're at the beginning of a compound packet */
        type = EXTRACT_U_1(sp);
@@ -42,7 +43,7 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
        if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX)
                goto trunc;     /* not really truncated, but still not decodable */
        ND_PRINT(" msdp:");
-       while (length > 0) {
+       while (length != 0) {
                ND_TCHECK_3(sp);
                type = EXTRACT_U_1(sp);
                len = EXTRACT_BE_U_2(sp + 1);
@@ -50,6 +51,8 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
                        ND_PRINT(" [len %u]", len);
                if (len < 3)
                        goto trunc;
+               if (length < len)
+                       goto trunc;
                sp += 3;
                length -= 3;
                switch (type) {
@@ -79,13 +82,13 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
                case 4:
                        ND_PRINT(" Keepalive");
                        if (len != 3)
-                               ND_PRINT("[len=%d] ", len);
+                               ND_PRINT("[len=%u] ", len);
                        break;
                case 5:
                        ND_PRINT(" Notification");
                        break;
                default:
-                       ND_PRINT(" [type=%d len=%d]", type, len);
+                       ND_PRINT(" [type=%u len=%u]", type, len);
                        break;
                }
                sp += (len - 3);
@@ -93,12 +96,5 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
        }
        return;
 trunc:
-       ND_PRINT(" [|msdp]");
+       nd_print_trunc(ndo);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */