]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-medsa.c
Translate UDP/1700 as RADIUS
[tcpdump] / print-medsa.c
index 8eedfaa8dee76be263e48daab37ab2b5a0aa2971..a29bf4a056b7e71009aef2e6b89892a172e16c93 100644 (file)
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "ether.h"
 #include "ethertype.h"
-#include "extract.h"                   /* must come after interface.h */
+#include "extract.h"
 
 static const char tstr[] = "[|MEDSA]";
 
@@ -80,9 +80,10 @@ static const struct tok code_values[] = {
        { 0, NULL },
 };
 
-static void medsa_print_full(netdissect_options *ndo,
-                           const struct medsa_pkthdr *medsa,
-                           u_int caplen)
+static void
+medsa_print_full(netdissect_options *ndo,
+                const struct medsa_pkthdr *medsa,
+                u_int caplen)
 {
        u_char tag = TAG(medsa);
 
@@ -134,7 +135,7 @@ static void medsa_print_full(netdissect_options *ndo,
 
 void
 medsa_print(netdissect_options *ndo,
-          const u_char *bp, u_int length, u_int caplen)
+           const u_char *bp, u_int length, u_int caplen)
 {
        register const struct ether_header *ep;
        const struct medsa_pkthdr *medsa;
@@ -157,9 +158,11 @@ medsa_print(netdissect_options *ndo,
        ether_type = EXTRACT_16BITS(&medsa->ether_type);
        if (ether_type <= ETHERMTU) {
                /* Try to print the LLC-layer header & higher layers */
-               if (llc_print(ndo, bp, length, caplen, ESRC(ep), EDST(ep)) < 0)
-                       /* ether_type not known, print raw packet */
-                       ND_DEFAULTPRINT(bp, caplen);
+               if (llc_print(ndo, bp, length, caplen, ESRC(ep), EDST(ep)) < 0) {
+                       /* packet type not known, print raw packet */
+                       if (!ndo->ndo_suppress_default_print)
+                               ND_DEFAULTPRINT(bp, caplen);
+               }
        } else {
                if (ndo->ndo_eflag)
                        ND_PRINT((ndo, "ethertype %s (0x%04x) ",
@@ -167,7 +170,17 @@ medsa_print(netdissect_options *ndo,
                                          ether_type),
                                  ether_type));
 
-               ethertype_print(ndo, ether_type, bp, length, caplen);
+               if (ethertype_print(ndo, ether_type, bp, length, caplen) == 0) {
+                       /* ether_type not known, print raw packet */
+                       if (!ndo->ndo_eflag)
+                               ND_PRINT((ndo, "ethertype %s (0x%04x) ",
+                                         tok2str(ethertype_values, "Unknown",
+                                                 ether_type),
+                                         ether_type));
+
+                       if (!ndo->ndo_suppress_default_print)
+                               ND_DEFAULTPRINT(bp, caplen);
+               }
        }
        return;
 trunc: