Add the option to call RLC dissector for LCID 1&2.
authormartinm <martinm@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 10 Sep 2009 22:53:57 +0000 (22:53 +0000)
committermartinm <martinm@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 10 Sep 2009 22:53:57 +0000 (22:53 +0000)
These should be srb1 & srb2 (AM).

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29852 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-mac-lte.c
epan/dissectors/packet-rlc-lte.c

index faf557ba936b265742b8bead8b3b44da8874066b..448639546cf5026d5cce6cd72132100d3c992ff1 100644 (file)
@@ -31,6 +31,7 @@
 #include <epan/tap.h>
 
 #include "packet-mac-lte.h"
+#include "packet-rlc-lte.h"
 
 
 /* Described in:
@@ -383,8 +384,12 @@ static gboolean global_mac_lte_decode_rar_ul_grant = TRUE;
 /* Whether should attempt to dissect frames failing CRC check */
 static gboolean global_mac_lte_dissect_crc_failures = FALSE;
 
+/* Whether should attempt to decode lcid 1&2 SDUs as srb1/2 (i.e. AM RLC) */
+static gboolean global_mac_lte_attempt_srb_decode = FALSE;
 
 
+extern int proto_rlc_lte;
+
 /***************************************************************/
 /* Keeping track of Msg3 bodies so they can be compared with   */
 /* Contention Resolution bodies.                               */
@@ -1433,6 +1438,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
             break;
         }
 
+        /* Work out length */
         data_length = (pdu_lengths[n] == -1) ?
                             tvb_length_remaining(tvb, offset) :
                             pdu_lengths[n];
@@ -1493,6 +1499,51 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
             ENDTRY
         }
 
+        /* LCID 1 and 2 can be assumed to be srb1&2, so can dissect as RLC AM */
+        if (((lcids[n] == 1) || (lcids[n] == 2)) && global_mac_lte_attempt_srb_decode) {
+            tvbuff_t *srb_tvb = tvb_new_subset(tvb, offset, data_length, data_length);
+            struct rlc_lte_info *p_rlc_lte_info;
+
+            /* Get RLC dissector handle */
+            volatile dissector_handle_t protocol_handle = find_dissector("rlc-lte");
+
+            /* Resuse or create RLC info */
+            p_rlc_lte_info = p_get_proto_data(pinfo->fd, proto_rlc_lte);
+            if (p_rlc_lte_info == NULL) {
+                p_rlc_lte_info = se_alloc0(sizeof(struct rlc_lte_info));
+            }
+
+            /* Fill in struct details for srb channels */
+            p_rlc_lte_info->rlcMode = RLC_AM_MODE;
+            p_rlc_lte_info->direction = p_mac_lte_info->direction;
+            p_rlc_lte_info->priority = 0; /* ?? */
+            p_rlc_lte_info->ueid = p_mac_lte_info->ueid;
+            p_rlc_lte_info->channelType = CHANNEL_TYPE_SRB;
+            p_rlc_lte_info->channelId = lcids[n];
+            p_rlc_lte_info->pduLength = data_length;
+            p_rlc_lte_info->UMSequenceNumberLength = 0;
+
+            /* Store info in packet */
+            p_add_proto_data(pinfo->fd, proto_rlc_lte, p_rlc_lte_info);
+
+            /* Hide raw view of bytes */
+            PROTO_ITEM_SET_HIDDEN(sdu_ti);
+
+            /* Don't want these columns replaced */
+            col_set_writable(pinfo->cinfo, FALSE);
+
+            /* Call it (catch exceptions so that stats will be updated) */
+            TRY {
+                call_dissector_only(protocol_handle, srb_tvb, pinfo, tree);
+            }
+            CATCH_ALL {
+            }
+            ENDTRY
+
+            col_set_writable(pinfo->cinfo, TRUE);
+        }
+
+
         offset += data_length;
 
         /* Update tap byte count for this channel */
@@ -2233,6 +2284,12 @@ void proto_register_mac_lte(void)
         "UDP framing",
         &global_mac_lte_heur);
 
+    prefs_register_bool_preference(mac_lte_module, "attempt_to_dissect_srb_sdus",
+        "Attempt to dissect LCID 1&2 as srb1&2",
+        "Will call LTE RLC dissector with standard settings as per RRC spec",
+        &global_mac_lte_attempt_srb_decode);
+
+
     register_init_routine(&mac_lte_init_protocol);
 }
 
index 1d1e6b2ed8fcbb4dec56239a2665b74bd23ad297..e7800df2462977f5192ce37ae3ae80b2746183c2 100644 (file)
@@ -268,13 +268,13 @@ static int dissect_rlc_lte_extension_header(tvbuff_t *tvb, packet_info *pinfo,
 
         /* Read next extension */
         proto_tree_add_bits_ret_val(extension_part_tree, hf_rlc_lte_extension_e, tvb,
-                                   (offset*8) + ((isOdd) ? 4 : 0),
+                                    (offset*8) + ((isOdd) ? 4 : 0),
                                     1,
                                     &extension, FALSE);
 
         /* Read length field */
         proto_tree_add_bits_ret_val(extension_part_tree, hf_rlc_lte_extension_li, tvb,
-                                   (offset*8) + ((isOdd) ? 5 : 1),
+                                    (offset*8) + ((isOdd) ? 5 : 1),
                                     11,
                                     &length, FALSE);
 
@@ -286,7 +286,7 @@ static int dissect_rlc_lte_extension_header(tvbuff_t *tvb, packet_info *pinfo,
         } else {
             offset++;
         }
-
         s_lengths[s_number_of_extensions++] = (guint16)length;
     }
 
@@ -1002,6 +1002,7 @@ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo,
 void dissect_rlc_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
     proto_tree             *rlc_lte_tree;
+    proto_item             *top_ti;
     proto_item             *ti;
     proto_item             *mode_ti;
     gint                   offset = 0;
@@ -1011,8 +1012,8 @@ void dissect_rlc_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     col_set_str(pinfo->cinfo, COL_PROTOCOL, "RLC-LTE");
 
     /* Create protocol tree. */
-    ti = proto_tree_add_item(tree, proto_rlc_lte, tvb, offset, -1, FALSE);
-    rlc_lte_tree = proto_item_add_subtree(ti, ett_rlc_lte);
+    top_ti = proto_tree_add_item(tree, proto_rlc_lte, tvb, offset, -1, FALSE);
+    rlc_lte_tree = proto_item_add_subtree(top_ti, ett_rlc_lte);
 
 
     /* Look for packet info! */
@@ -1070,6 +1071,17 @@ void dissect_rlc_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         PROTO_ITEM_SET_GENERATED(ti);
     }
 
+    /* Append channel info to top-level item */
+    if (p_rlc_lte_info->channelId == 0) {
+        proto_item_append_text(top_ti, " (%s)",
+                               val_to_str(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"));
+    }
+    else {
+        proto_item_append_text(top_ti, " (%s:%u)",
+                               val_to_str(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"),
+                               p_rlc_lte_info->channelId);
+    }
+                     
 
     /* Append context highlights to info column */
     col_add_fstr(pinfo->cinfo, COL_INFO,