From sangaran:
authorAnders Broman <anders.broman@ericsson.com>
Thu, 1 Apr 2010 20:49:07 +0000 (20:49 -0000)
committerAnders Broman <anders.broman@ericsson.com>
Thu, 1 Apr 2010 20:49:07 +0000 (20:49 -0000)
8-bit Bit Flag decoder method needed in wimaxasncp plugin dissecto.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4608

svn path=/trunk/; revision=32356

plugins/wimaxasncp/packet-wimaxasncp.c
plugins/wimaxasncp/wimaxasncp_dict.h
plugins/wimaxasncp/wimaxasncp_dict.l
wimaxasncp/dictionary.xml

index bbb5b47ae936bc0c7901c984d2c919634b21962a..cd6a81cf51c0c7791873974a74b16471984f52f0 100644 (file)
@@ -81,6 +81,7 @@ static int hf_wimaxasncp_tlv                    = -1;
 static int hf_wimaxasncp_tlv_type               = -1;
 static int hf_wimaxasncp_tlv_length             = -1;
 static int hf_wimaxasncp_tlv_value_bytes        = -1;
+static int hf_wimaxasncp_tlv_value_bitflags8    = -1;
 static int hf_wimaxasncp_tlv_value_bitflags16   = -1;
 static int hf_wimaxasncp_tlv_value_bitflags32   = -1;
 static int hf_wimaxasncp_tlv_value_protocol     = -1;
@@ -99,6 +100,7 @@ static guint global_wimaxasncp_udp_port = WIMAXASNCP_DEF_UDP_PORT;
 static gint ett_wimaxasncp                                       = -1;
 static gint ett_wimaxasncp_flags                                 = -1;
 static gint ett_wimaxasncp_tlv                                   = -1;
+static gint ett_wimaxasncp_tlv_value_bitflags8                   = -1;
 static gint ett_wimaxasncp_tlv_value_bitflags16                  = -1;
 static gint ett_wimaxasncp_tlv_value_bitflags32                  = -1;
 static gint ett_wimaxasncp_tlv_protocol_list                     = -1;
@@ -438,6 +440,7 @@ static const value_string wimaxasncp_decode_type_vals[] =
   { WIMAXASNCP_TLV_ETHER,               "WIMAXASNCP_TLV_ETHER"},
   { WIMAXASNCP_TLV_ASCII_STRING,        "WIMAXASNCP_TLV_ASCII_STRING"},
   { WIMAXASNCP_TLV_FLAG0,               "WIMAXASNCP_TLV_FLAG0"},
+  { WIMAXASNCP_TLV_BITFLAGS8,           "WIMAXASNCP_TLV_BITFLAGS8"},  
   { WIMAXASNCP_TLV_BITFLAGS16,          "WIMAXASNCP_TLV_BITFLAGS16"},
   { WIMAXASNCP_TLV_BITFLAGS32,          "WIMAXASNCP_TLV_BITFLAGS32"},
   { WIMAXASNCP_TLV_ID,                  "WIMAXASNCP_TLV_ID"},
@@ -741,6 +744,63 @@ static void wimaxasncp_dissect_tlv_value(
 
         return;
     }
+    case WIMAXASNCP_TLV_BITFLAGS8:
+    {
+        if (length != 1)
+        {
+            /* encoding error */
+            break;
+        }
+
+        if (tlv_info->enums == NULL)
+        {
+            /* enum values missing */
+        }
+
+        if (tree)
+        {
+            proto_tree *flags_tree;
+            proto_item *item;
+            guint8 value;
+            guint i;
+
+            value = tvb_get_guint8(tvb, offset);
+
+            item = proto_tree_add_uint_format(
+                tree, tlv_info->hf_value,
+                tvb, offset, length, value,
+                "Value: %s",
+               decode_numeric_bitfield(value, 0xff, 8, "0x%02x"));
+
+            proto_item_append_text(tlv_item, " - 0x%02x", value);
+
+            if (value != 0)
+            {
+                flags_tree = proto_item_add_subtree(
+                    item, ett_wimaxasncp_tlv_value_bitflags8);
+
+                for (i = 0; i < 8; ++i)
+                {
+                    guint8 mask;
+                    mask = 1 << (7 - i);
+
+                    if (value & mask)
+                    {
+                        const gchar *s;
+                           
+                        s = wimaxasncp_get_enum_name(tlv_info, value & mask);
+
+                        proto_tree_add_uint_format(
+                            flags_tree, hf_wimaxasncp_tlv_value_bitflags8,
+                            tvb, offset, length, value,
+                            "Bit #%u is set: %s", i, s);
+                    }
+                }
+            }
+        }
+  
+       return;
+    }    
     case WIMAXASNCP_TLV_BITFLAGS16:
     {
         if (length != 2)
@@ -2420,6 +2480,11 @@ static void add_tlv_reg_info(
         add_reg_info(
             &tlv->hf_value, name, abbrev, FT_STRING, BASE_NONE, blurb);
         break;
+    
+    case WIMAXASNCP_TLV_BITFLAGS8:
+        add_reg_info(
+            &tlv->hf_value, name, abbrev, FT_UINT8, BASE_HEX, blurb);
+        break;
 
     case WIMAXASNCP_TLV_BITFLAGS16:
         add_reg_info(
@@ -2987,6 +3052,19 @@ register_wimaxasncp_fields(const char* unused _U_)
                     HFILL
                 }
             },
+            {
+                &hf_wimaxasncp_tlv_value_bitflags8,
+                {
+                    "Value",
+                    "wimaxasncp.tlv_value_bitflags8",
+                    FT_UINT8,
+                    BASE_HEX,
+                    NULL,
+                    0xff,
+                    NULL,
+                    HFILL
+                }
+            },         
             {
                 &hf_wimaxasncp_tlv_value_bitflags16,
                 {
@@ -3050,6 +3128,7 @@ register_wimaxasncp_fields(const char* unused _U_)
             &ett_wimaxasncp,
             &ett_wimaxasncp_flags,
             &ett_wimaxasncp_tlv,
+            &ett_wimaxasncp_tlv_value_bitflags8,           
             &ett_wimaxasncp_tlv_value_bitflags16,
             &ett_wimaxasncp_tlv_value_bitflags32,
             &ett_wimaxasncp_tlv_protocol_list,
index a4747362c6f753aaedca066065096f695451fae5..054cfe93367b15ec56608418e888eb331a01cfe9 100644 (file)
@@ -41,6 +41,7 @@ enum
     WIMAXASNCP_TLV_ETHER,
     WIMAXASNCP_TLV_ASCII_STRING,
     WIMAXASNCP_TLV_FLAG0,
+    WIMAXASNCP_TLV_BITFLAGS8,  
     WIMAXASNCP_TLV_BITFLAGS16,
     WIMAXASNCP_TLV_BITFLAGS32,
     WIMAXASNCP_TLV_ID,
index eaece6185ee938b79458c900076679ae6b6c5d41..7b4e1274bab7643227e26e974d865688591df96f 100644 (file)
@@ -482,6 +482,7 @@ static const value_string wimaxasncp_decode_type_vals[] =
   { WIMAXASNCP_TLV_ETHER,               "WIMAXASNCP_TLV_ETHER"},
   { WIMAXASNCP_TLV_ASCII_STRING,        "WIMAXASNCP_TLV_ASCII_STRING"},
   { WIMAXASNCP_TLV_FLAG0,               "WIMAXASNCP_TLV_FLAG0"},
+  { WIMAXASNCP_TLV_BITFLAGS8,           "WIMAXASNCP_TLV_BITFLAGS8"},  
   { WIMAXASNCP_TLV_BITFLAGS16,          "WIMAXASNCP_TLV_BITFLAGS16"},
   { WIMAXASNCP_TLV_BITFLAGS32,          "WIMAXASNCP_TLV_BITFLAGS32"},
   { WIMAXASNCP_TLV_ID,                  "WIMAXASNCP_TLV_ID"},
index 65a000233edf9e63d57a120e12079be663c26902..2c5dbdb96df2e6ffcfe3663a318f84f6205ab9f8 100644 (file)
 
     <tlv name="Authorization Policy"
          type="21"
-         decoder="WIMAXASNCP_TLV_ENUM8">
+         decoder="WIMAXASNCP_TLV_BITFLAGS8">
 
         <enum name="RSA authorization"
-              code="0x01"/>
+              code="WIMAXASNCP_BIT8(7)"/>
 
         <enum name="EAP authorization"
-              code="0x02"/>
+              code="WIMAXASNCP_BIT8(6)"/>
 
         <enum name="Authenticated-EAP authorization"
-              code="0x04"/>
+              code="WIMAXASNCP_BIT8(5)"/>
 
         <enum name="HMAC supported"
-              code="0x08"/>
+              code="WIMAXASNCP_BIT8(4)"/>
 
         <enum name="RSA Authentication at Re-entry"
-              code="0x10"/>
+              code="WIMAXASNCP_BIT8(3)"/>
 
         <enum name="EAP Authentication at Re-entry"
-              code="0x20"/>
+              code="WIMAXASNCP_BIT8(2)"/>
 
         <enum name="Authenticated EAP-based authorization at reentry"
-              code="0x30"/>
+              code="WIMAXASNCP_BIT8(1)"/>
+             
+        <enum name="Reserved"
+              code="WIMAXASNCP_BIT8(0)"/>      
     </tlv>
 
     <!-- ****************************************************************** -->