]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lwapp.c
Makefile.in: don't remove configure and config.h.in in make distclean.
[tcpdump] / print-lwapp.c
index 516b85bed392db87e8da8a83277ba1eb9694105f..10a2e0bed04315222331655ad8b025502495ebe0 100644 (file)
 /* specification: RFC 5412 */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
 
+
 /*
  * LWAPP transport (common) header
  *      0                   1                   2                   3
@@ -172,6 +173,7 @@ lwapp_control_print(netdissect_options *ndo,
     u_int tlen;
     u_int msg_type, msg_tlen;
 
+    ndo->ndo_protocol = "lwapp_control";
     tptr=pptr;
 
     if (has_ap_ident) {
@@ -181,41 +183,41 @@ lwapp_control_print(netdissect_options *ndo,
     } else {
         lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
     }
-    ND_TCHECK(*lwapp_trans_header);
-    version = EXTRACT_U_1(lwapp_trans_header->version);
+    ND_TCHECK_SIZE(lwapp_trans_header);
+    version = GET_U_1(lwapp_trans_header->version);
 
     /*
      * Sanity checking of the header.
      */
     if (LWAPP_EXTRACT_VERSION(version) != LWAPP_VERSION) {
-       ND_PRINT((ndo, "LWAPP version %u packet not supported",
-               LWAPP_EXTRACT_VERSION(version)));
+       ND_PRINT("LWAPP version %u packet not supported",
+               LWAPP_EXTRACT_VERSION(version));
        return;
     }
 
     /* non-verbose */
     if (ndo->ndo_vflag < 1) {
-        ND_PRINT((ndo, "LWAPPv%u, %s frame, Flags [%s], length %u",
+        ND_PRINT("LWAPPv%u, %s frame, Flags [%s], length %u",
                LWAPP_EXTRACT_VERSION(version),
                LWAPP_EXTRACT_CONTROL_BIT(version) ? "Control" : "Data",
                bittok2str(lwapp_header_bits_values,"none",version&0x07),
-               len));
+               len);
         return;
     }
 
     /* ok they seem to want to know everything - lets fully decode it */
-    tlen=EXTRACT_BE_U_2(lwapp_trans_header->length);
+    tlen=GET_BE_U_2(lwapp_trans_header->length);
 
-    ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
+    ND_PRINT("LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
            LWAPP_EXTRACT_VERSION(version),
            LWAPP_EXTRACT_CONTROL_BIT(version) ? "Control" : "Data",
            LWAPP_EXTRACT_RID(version),
            bittok2str(lwapp_header_bits_values,"none",version&0x07),
-          EXTRACT_U_1(lwapp_trans_header->frag_id),
-          tlen));
+          GET_U_1(lwapp_trans_header->frag_id),
+          tlen);
 
     if (has_ap_ident) {
-        ND_PRINT((ndo, "\n\tAP identity: %s", etheraddr_string(ndo, tptr)));
+        ND_PRINT("\n\tAP identity: %s", GET_ETHERADDR_STRING(tptr));
         tptr+=sizeof(struct lwapp_transport_header)+6;
     } else {
         tptr+=sizeof(struct lwapp_transport_header);
@@ -226,25 +228,25 @@ lwapp_control_print(netdissect_options *ndo,
         /* did we capture enough for fully decoding the object header ? */
         ND_TCHECK_LEN(tptr, sizeof(struct lwapp_control_header));
         if (tlen < sizeof(struct lwapp_control_header)) {
-            ND_PRINT((ndo, "\n\t  Msg goes past end of PDU"));
+            ND_PRINT("\n\t  Msg goes past end of PDU");
             break;
         }
 
         lwapp_control_header = (const struct lwapp_control_header *)tptr;
-       msg_tlen = EXTRACT_BE_U_2(lwapp_control_header->len);
+       msg_tlen = GET_BE_U_2(lwapp_control_header->len);
         if (tlen < sizeof(struct lwapp_control_header) + msg_tlen) {
-            ND_PRINT((ndo, "\n\t  Msg goes past end of PDU"));
+            ND_PRINT("\n\t  Msg goes past end of PDU");
             break;
         }
 
        /* print message header */
-       msg_type = EXTRACT_U_1(lwapp_control_header->msg_type);
-        ND_PRINT((ndo, "\n\t  Msg type: %s (%u), Seqnum: %u, Msg len: %u, Session: 0x%08x",
+       msg_type = GET_U_1(lwapp_control_header->msg_type);
+        ND_PRINT("\n\t  Msg type: %s (%u), Seqnum: %u, Msg len: %u, Session: 0x%08x",
                tok2str(lwapp_msg_type_values,"Unknown",msg_type),
                msg_type,
-               EXTRACT_U_1(lwapp_control_header->seq_num),
+               GET_U_1(lwapp_control_header->seq_num),
                msg_tlen,
-               EXTRACT_BE_U_4(lwapp_control_header->session_id)));
+               GET_BE_U_4(lwapp_control_header->session_id));
 
         /* did we capture enough for fully decoding the message */
         ND_TCHECK_LEN(tptr, msg_tlen);
@@ -291,8 +293,8 @@ lwapp_control_print(netdissect_options *ndo,
     }
     return;
 
- trunc:
-    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+trunc:
+    nd_print_trunc(ndo);
 }
 
 void
@@ -304,52 +306,53 @@ lwapp_data_print(netdissect_options *ndo,
     u_int tlen;
     u_int version;
 
+    ndo->ndo_protocol = "lwapp_data";
     tptr=pptr;
 
     /* check if enough bytes for AP identity */
     ND_TCHECK_6(tptr);
     lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
-    ND_TCHECK(*lwapp_trans_header);
-    version = EXTRACT_U_1(lwapp_trans_header->version);
+    ND_TCHECK_SIZE(lwapp_trans_header);
+    version = GET_U_1(lwapp_trans_header->version);
 
     /*
      * Sanity checking of the header.
      */
     if (LWAPP_EXTRACT_VERSION(version) != LWAPP_VERSION) {
-        ND_PRINT((ndo, "LWAPP version %u packet not supported",
-               LWAPP_EXTRACT_VERSION(version)));
+        ND_PRINT("LWAPP version %u packet not supported",
+               LWAPP_EXTRACT_VERSION(version));
         return;
     }
 
     /* non-verbose */
     if (ndo->ndo_vflag < 1) {
-        ND_PRINT((ndo, "LWAPPv%u, %s frame, Flags [%s], length %u",
+        ND_PRINT("LWAPPv%u, %s frame, Flags [%s], length %u",
                LWAPP_EXTRACT_VERSION(version),
                LWAPP_EXTRACT_CONTROL_BIT(version) ? "Control" : "Data",
                bittok2str(lwapp_header_bits_values,"none",version&0x07),
-               len));
+               len);
         return;
     }
 
     /* ok they seem to want to know everything - lets fully decode it */
-    tlen=EXTRACT_BE_U_2(lwapp_trans_header->length);
+    tlen=GET_BE_U_2(lwapp_trans_header->length);
     if (tlen < sizeof(struct lwapp_transport_header)) {
-        ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id  %u, Flags [%s], length %u < transport header length",
+        ND_PRINT("LWAPPv%u, %s frame, Radio-id  %u, Flags [%s], length %u < transport header length",
                LWAPP_EXTRACT_VERSION(version),
                LWAPP_EXTRACT_CONTROL_BIT(version) ? "Control" : "Data",
                LWAPP_EXTRACT_RID(version),
                bittok2str(lwapp_header_bits_values,"none",version&0x07),
-               tlen));
+               tlen);
         return;
     }
 
-    ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id  %u, Flags [%s], Frag-id  %u, length %u",
+    ND_PRINT("LWAPPv%u, %s frame, Radio-id  %u, Flags [%s], Frag-id  %u, length %u",
            LWAPP_EXTRACT_VERSION(version),
            LWAPP_EXTRACT_CONTROL_BIT(version) ? "Control" : "Data",
            LWAPP_EXTRACT_RID(version),
            bittok2str(lwapp_header_bits_values,"none",version&0x07),
-           EXTRACT_U_1(lwapp_trans_header->frag_id),
-           tlen));
+           GET_U_1(lwapp_trans_header->frag_id),
+           tlen);
 
     tptr+=sizeof(struct lwapp_transport_header);
     tlen-=sizeof(struct lwapp_transport_header);
@@ -359,13 +362,6 @@ lwapp_data_print(netdissect_options *ndo,
 
     return;
 
- trunc:
-    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+trunc:
+    nd_print_trunc(ndo);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */