]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lwapp.c
Handle very large -f files by rejecting them.
[tcpdump] / print-lwapp.c
index ffd67690a071383fb49cef2153bc1326dc8b44c2..bab3219f10ec4e6e3fe788bdfd3edc943524c28c 100644 (file)
  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * FOR A PARTICULAR PURPOSE.
  *
- * Support for the Light Weight Access Point Protocol as per draft-ohara-capwap-lwapp-04
- *
  * Original code by Carles Kishimoto <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: Light Weight Access Point Protocol (LWAPP) printer */
+
+/* specification: RFC 5412 */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
 
  */
 
 struct lwapp_transport_header {
-    u_int8_t  version;
-    u_int8_t  frag_id;
-    u_int8_t  length[2];
-    u_int16_t status;
+    uint8_t  version;
+    uint8_t  frag_id;
+    uint8_t  length[2];
+    uint16_t status;
 };
 
 /*
@@ -61,10 +62,10 @@ struct lwapp_transport_header {
  */
 
 struct lwapp_control_header {
-    u_int8_t  msg_type;
-    u_int8_t  seq_num;
-    u_int8_t  len[2];
-    u_int8_t  session_id[4];
+    uint8_t  msg_type;
+    uint8_t  seq_num;
+    uint8_t  len[2];
+    uint8_t  session_id[4];
 };
 
 #define LWAPP_VERSION 0
@@ -156,14 +157,14 @@ static const struct tok lwapp_msg_type_values[] = {
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lwapp_message_header {
-    u_int8_t type;
-    u_int8_t length[2];
+    uint8_t type;
+    uint8_t length[2];
 };
 
 void
 lwapp_control_print(netdissect_options *ndo,
-                    const u_char *pptr, u_int len, int has_ap_ident) {
-
+                    const u_char *pptr, u_int len, int has_ap_ident)
+{
     const struct lwapp_transport_header *lwapp_trans_header;
     const struct lwapp_control_header *lwapp_control_header;
     const u_char *tptr;
@@ -174,8 +175,7 @@ lwapp_control_print(netdissect_options *ndo,
 
     if (has_ap_ident) {
         /* check if enough bytes for AP identity */
-        if (!ND_TTEST2(*tptr, 6))
-            goto trunc;
+        ND_TCHECK2(*tptr, 6);
         lwapp_trans_header = (const struct lwapp_transport_header *)(pptr+6);
     } else {
         lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
@@ -222,8 +222,7 @@ lwapp_control_print(netdissect_options *ndo,
     while(tlen>0) {
 
         /* did we capture enough for fully decoding the object header ? */
-        if (!ND_TTEST2(*tptr, sizeof(struct lwapp_control_header)))
-            goto trunc;
+        ND_TCHECK2(*tptr, sizeof(struct lwapp_control_header));
 
         lwapp_control_header = (const struct lwapp_control_header *)tptr;
        msg_tlen = EXTRACT_16BITS(lwapp_control_header->len);
@@ -237,8 +236,7 @@ lwapp_control_print(netdissect_options *ndo,
                EXTRACT_32BITS(lwapp_control_header->session_id)));
 
         /* did we capture enough for fully decoding the message */
-        if (!ND_TTEST2(*tptr, msg_tlen))
-            goto trunc;
+        ND_TCHECK2(*tptr, msg_tlen);
 
        /* XXX - Decode sub messages for each message */
         switch(lwapp_control_header->msg_type) {
@@ -288,8 +286,8 @@ lwapp_control_print(netdissect_options *ndo,
 
 void
 lwapp_data_print(netdissect_options *ndo,
-                 const u_char *pptr, u_int len) {
-
+                 const u_char *pptr, u_int len)
+{
     const struct lwapp_transport_header *lwapp_trans_header;
     const u_char *tptr;
     int tlen;
@@ -297,8 +295,7 @@ lwapp_data_print(netdissect_options *ndo,
     tptr=pptr;
 
     /* check if enough bytes for AP identity */
-    if (!ND_TTEST2(*tptr, 6))
-        goto trunc;
+    ND_TCHECK2(*tptr, 6);
     lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
     ND_TCHECK(*lwapp_trans_header);