Wireshark-bugs: [Wireshark-bugs] [Bug 4508] Add new GSMTAP dissector
Date: Sat, 20 Feb 2010 02:41:49 -0800 (PST)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4508

Anders Broman <anders.broman@xxxxxxxxxxxx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anders.broman@xxxxxxxxxxxx

--- Comment #1 from Anders Broman <anders.broman@xxxxxxxxxxxx> 2010-02-20 02:41:45 PST ---
Hi,
+    u_int8_t version, hdr_len, type, ts, noise_db, signal_db;
And alike please use the glib types guint8 etc.

+    if (check_col(pinfo->cinfo, COL_INFO)) {
No longer needed


+static const char *gsmtap_bursts[] = {
+    [GSMTAP_BURST_UNKNOWN]        = "UNKNOWN",
+    [GSMTAP_BURST_FCCH]        = "FCCH",
+    [GSMTAP_BURST_PARTIAL_SCH]    = "PARTIAL_SCH",
+    [GSMTAP_BURST_SCH]        = "SCH",
+    [GSMTAP_BURST_CTS_SCH]        = "CTS_SCH",
+    [GSMTAP_BURST_COMPACT_SCH]    = "COMPACT_SCH",
+    [GSMTAP_BURST_NORMAL]        = "NORMAL",
+    [GSMTAP_BURST_DUMMY]        = "DUMMY",
+    [GSMTAP_BURST_ACCESS]        = "ACCESS",
+};
+
+static const char *gsmtap_get_burst(unsigned int burst_type)
+{
+    const char *desc = "UNSUPPORTED";
+
+    if (burst_type >= sizeof(gsmtap_bursts)/sizeof(const char *))
+        return desc;
+    if (gsmtap_bursts[burst_type] == NULL)
+        return desc;
+
+    return gsmtap_bursts[burst_type];
+}
+
+static const char *gsmtap_get_type(int type)
+{
+    const char *desc;
+
+    switch (type) {
+        case GSMTAP_TYPE_UM:
+            desc = "GSM Um (MS<->BTS)";
+            break;
+        case GSMTAP_TYPE_ABIS:
+            desc = "GSM Abis (BTS<->BSC)";
+            break;
+        case GSMTAP_TYPE_UM_BURST:
+            desc = "GSM Um burst (BTS<->BSC)";
+            break;
+        default:
+            desc = "<unknown type>";
+            break;
+    }
+
+    return desc;
+}
And
+    type = tvb_get_guint8(tvb, offset + 2);
:
+    burst_type = tvb_get_guint8(tvb, offset + 12);
:
+        proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_type,
+                       tvb, offset+2, 1, type,
+                       "Type: %s (0x%02x)",
+                       gsmtap_get_type(type), type);
+        proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_burst_type,
+                       tvb, offset+12, 1, burst_type,
+                       "Burst: %s",
+                       gsmtap_get_burst(burst_type));

Could all be replaced by using a value_string and proto_tree_add_item()

In general getting the values with tvb_get.. and adding them to the tree
with special proto_tree_add.. functions should be avoided if possible.

The .h file could be ditched as this file isn't exporting any thing.

Regards
Anders

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.