]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-zep.c
the failed/passed count was not kept in the right place
[tcpdump] / print-zep.c
index 37ebcce49c3c8645fe9c34742e420b8420cd2434..f6be3a64ce26ef85c0d2ff183928536f8b84fd64 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+/* \summary: ZigBee Encapsulation Protocol (ZEP) printer */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #include "netdissect.h"
 
@@ -66,9 +67,9 @@ static void zep_print_ts(netdissect_options *ndo, const u_char *p)
        uint32_t uf;
        uint32_t f;
        float ff;
-       
-       i = EXTRACT_BE_U_4(p);
-       uf = EXTRACT_BE_U_4(p + 4);
+
+       i = GET_BE_U_4(p);
+       uf = GET_BE_U_4(p + 4);
        ff = (float) uf;
        if (ff < 0.0)           /* some compilers are buggy */
                ff += FMAXINT;
@@ -76,7 +77,7 @@ static void zep_print_ts(netdissect_options *ndo, const u_char *p)
        f = (uint32_t) (ff * 1000000000.0);  /* treat fraction as parts per
                                                billion */
        ND_PRINT("%u.%09d", i, f);
-       
+
 #ifdef HAVE_STRFTIME
        /*
         * print the time in human-readable format.
@@ -85,7 +86,7 @@ static void zep_print_ts(netdissect_options *ndo, const u_char *p)
                time_t seconds = i - JAN_1970;
                struct tm *tm;
                char time_buf[128];
-               
+
                tm = localtime(&seconds);
                strftime(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S", tm);
                ND_PRINT(" (%s)", time_buf);
@@ -103,38 +104,38 @@ zep_print(netdissect_options *ndo,
 {
        uint8_t version, inner_len;
        uint32_t seq_no;
-       
-       ndo->ndo_protocol ="ZEP";
 
-       ND_PRINT("ZEP");
-       
+       ndo->ndo_protocol = "zep";
+
+       nd_print_protocol_caps(ndo);
+
        ND_TCHECK_LEN(bp, 8);
-       
-       if (EXTRACT_U_1(bp) != 'E' || EXTRACT_U_1(bp + 1) != 'X')
+
+       if (GET_U_1(bp) != 'E' || GET_U_1(bp + 1) != 'X')
                goto trunc;
-       
-       version = EXTRACT_U_1(bp + 2);
+
+       version = GET_U_1(bp + 2);
        ND_PRINT("v%d ", version);
-       
+
        if (version == 1) {
                /* ZEP v1 packet. */
                ND_TCHECK_LEN(bp, 16);
                ND_PRINT("Channel ID %d, Device ID 0x%04x, ",
-                        EXTRACT_U_1(bp + 3), EXTRACT_BE_U_2(bp + 4));
-               if (EXTRACT_U_1(bp + 6))
+                        GET_U_1(bp + 3), GET_BE_U_2(bp + 4));
+               if (GET_U_1(bp + 6))
                        ND_PRINT("CRC, ");
                else
-                       ND_PRINT("LQI %d, ", EXTRACT_U_1(bp + 7));
-               inner_len = EXTRACT_U_1(bp + 15);
+                       ND_PRINT("LQI %d, ", GET_U_1(bp + 7));
+               inner_len = GET_U_1(bp + 15);
                ND_PRINT("inner len = %d", inner_len);
-               
+
                bp += 16;
                len -= 16;
        } else {
                /* ZEP v2 packet. */
-               if (EXTRACT_U_1(bp + 3) == 2) {
+               if (GET_U_1(bp + 3) == 2) {
                        /* ZEP v2 ack. */
-                       seq_no = EXTRACT_BE_U_4(bp + 4);
+                       seq_no = GET_BE_U_4(bp + 4);
                        ND_PRINT("ACK, seq# = %d", seq_no);
                        inner_len = 0;
                        bp += 8;
@@ -142,25 +143,25 @@ zep_print(netdissect_options *ndo,
                } else {
                        /* ZEP v2 data, or some other. */
                        ND_TCHECK_LEN(bp, 32);
-                       
+
                        ND_PRINT("Type %d, Channel ID %d, Device ID 0x%04x, ",
-                                EXTRACT_U_1(bp + 3), EXTRACT_U_1(bp + 4),
-                                EXTRACT_BE_U_2(bp + 5));
-                       if (EXTRACT_U_1(bp + 7))
+                                GET_U_1(bp + 3), GET_U_1(bp + 4),
+                                GET_BE_U_2(bp + 5));
+                       if (GET_U_1(bp + 7))
                                ND_PRINT("CRC, ");
                        else
-                               ND_PRINT("LQI %d, ", EXTRACT_U_1(bp + 8));
-                       
+                               ND_PRINT("LQI %d, ", GET_U_1(bp + 8));
+
                        zep_print_ts(ndo, bp + 9);
-                       seq_no = EXTRACT_BE_U_4(bp + 17);
-                       inner_len = EXTRACT_U_1(bp + 31);
+                       seq_no = GET_BE_U_4(bp + 17);
+                       inner_len = GET_U_1(bp + 31);
                        ND_PRINT(", seq# = %d, inner len = %d",
                                 seq_no, inner_len);
                        bp += 32;
                        len -= 32;
                }
        }
-       
+
        if (inner_len != 0) {
                /* Call 802.15.4 dissector. */
                ND_PRINT("\n\t");
@@ -169,18 +170,11 @@ zep_print(netdissect_options *ndo,
                        len = 0;
                }
        }
-       
+
        if (!ndo->ndo_suppress_default_print)
                ND_DEFAULTPRINT(bp, len);
-       
-       return;    
+
+       return;
  trunc:
-       ND_PRINT(" [|ZEP]");
+       nd_print_trunc(ndo);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */