PDCP NR: add a framing option to indicate MAC-I presence in user plane PDU (CID 1435480)
authorPascal Quantin <pascal.quantin@gmail.com>
Thu, 24 May 2018 15:07:18 +0000 (17:07 +0200)
committerPascal Quantin <pascal.quantin@gmail.com>
Thu, 24 May 2018 17:44:12 +0000 (17:44 +0000)
Change-Id: I155e4fad0c42c4b2b10cf3a2cb71c0927190b8db
Reviewed-on: https://code.wireshark.org/review/27780
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
epan/dissectors/packet-pdcp-nr.c
epan/dissectors/packet-pdcp-nr.h

index 53f6e3c2c21417945fa65ca6cc74060f90341f3d..f079f55f02930c39e7ab6e64a09a5d7a31e5994b 100644 (file)
@@ -884,6 +884,9 @@ static gboolean dissect_pdcp_nr_heur(tvbuff_t *tvb, packet_info *pinfo,
                     p_pdcp_nr_info->rohc.profile = tvb_get_ntohs(tvb, offset);
                     offset += 2;
                     break;
+                case PDCP_NR_MACI_PRES_TAG:
+                    p_pdcp_nr_info->maci_present = TRUE;
+                    break;
 
                 case PDCP_NR_PAYLOAD_TAG:
                     /* Have reached data, so get out of loop */
@@ -927,14 +930,12 @@ static gboolean dissect_pdcp_nr_heur(tvbuff_t *tvb, packet_info *pinfo,
 static int dissect_pdcp_nr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
 {
     const char           *mode;
-    proto_tree           *pdcp_tree           = NULL;
-    proto_item           *root_ti             = NULL;
+    proto_tree           *pdcp_tree          = NULL;
+    proto_item           *root_ti            = NULL;
     proto_item           *ti;
     gint                 offset              = 0;
     struct pdcp_nr_info  *p_pdcp_info;
-    tvbuff_t             *rohc_tvb            = NULL;
-    gboolean             mac_included = FALSE;
-    guint32              mac_offset = 0;
+    tvbuff_t             *rohc_tvb           = NULL;
 
     tvbuff_t *payload_tvb;
 
@@ -1229,16 +1230,14 @@ static int dissect_pdcp_nr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
         }
 
         if (p_pdcp_info->bearerType == Bearer_DCCH) {
-            mac_included = TRUE;
-            mac_offset = tvb_reported_length(tvb)-4;
+            p_pdcp_info->maci_present = TRUE;
         } else {
             col_append_fstr(pinfo->cinfo, COL_INFO, " (%u bytes data)", data_length);
         }
     }
     else if (tvb_captured_length_remaining(payload_tvb, offset)) {
-        /* User-plane payload here.  Optional, not clear how it will be signalled yet. For now assume not. */
-        mac_included = FALSE;
-        gint payload_length = tvb_reported_length_remaining(payload_tvb, offset) - ((mac_included) ? 4 : 0);
+        /* User-plane payload here. */
+        gint payload_length = tvb_reported_length_remaining(payload_tvb, offset) - ((p_pdcp_info->maci_present) ? 4 : 0);
 
         /* If not compressed with ROHC, show as user-plane data */
         if (!p_pdcp_info->rohc.rohc_compression) {
@@ -1272,12 +1271,9 @@ static int dissect_pdcp_nr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 
                 }
                 else {
-                    proto_tree_add_item(pdcp_tree, hf_pdcp_nr_user_plane_data, payload_tvb, offset, -1, ENC_NA);
+                    proto_tree_add_item(pdcp_tree, hf_pdcp_nr_user_plane_data, payload_tvb, offset, payload_length, ENC_NA);
                 }
             }
-
-            /* Let RLC write to columns again */
-            col_set_writable(pinfo->cinfo, COL_INFO, global_pdcp_nr_layer_to_show == ShowRLCLayer);
         }
         else {
             /***************************/
@@ -1288,27 +1284,30 @@ static int dissect_pdcp_nr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
             if (!global_pdcp_dissect_rohc) {
                 col_append_fstr(pinfo->cinfo, COL_PROTOCOL, "|ROHC(%s)",
                                 val_to_str_const(p_pdcp_info->rohc.profile, rohc_profile_vals, "Unknown"));
-                return 1;
+                proto_tree_add_item(pdcp_tree, hf_pdcp_nr_user_plane_data, payload_tvb, offset, payload_length, ENC_NA);
             }
+            else {
+                rohc_tvb = tvb_new_subset_length(payload_tvb, offset, payload_length);
 
-            rohc_tvb = tvb_new_subset_length(payload_tvb, offset, payload_length);
+                /* Only enable writing to column if configured to show ROHC */
+                if (global_pdcp_nr_layer_to_show != ShowTrafficLayer) {
+                    col_set_writable(pinfo->cinfo, COL_INFO, FALSE);
+                }
+                else {
+                    col_clear(pinfo->cinfo, COL_INFO);
+                }
 
-            /* Only enable writing to column if configured to show ROHC */
-            if (global_pdcp_nr_layer_to_show != ShowTrafficLayer) {
-                col_set_writable(pinfo->cinfo, COL_INFO, FALSE);
-            }
-            else {
-                col_clear(pinfo->cinfo, COL_INFO);
+                /* Call the ROHC dissector */
+                call_dissector_with_data(rohc_handle, rohc_tvb, pinfo, tree, &p_pdcp_info->rohc);
             }
 
-            /* Call the ROHC dissector */
-            call_dissector_with_data(rohc_handle, rohc_tvb, pinfo, tree, &p_pdcp_info->rohc);
         }
     }
 
     /* MAC */
-    if (mac_included) {
+    if (p_pdcp_info->maci_present) {
         /* Last 4 bytes are MAC */
+        gint mac_offset = tvb_reported_length(tvb)-4;
         guint32 mac = tvb_get_ntohl(payload_tvb, mac_offset);
         proto_tree_add_item(pdcp_tree, hf_pdcp_nr_mac, payload_tvb, mac_offset, 4, ENC_BIG_ENDIAN);
 
index 46c81636a9f684a17a357f145649e57755499d31..bdfd49aa3cf42c17789097f76d7a30635699e2c7 100644 (file)
@@ -46,8 +46,9 @@ typedef struct pdcp_nr_info
     guint8             bearerId;
 
     /* Details of PDCP header */
-    enum pdcp_nr_plane    plane;
+    enum pdcp_nr_plane plane;
     guint8             seqnum_length;
+    gboolean           maci_present;
 
     /* RoHC settings */
     rohc_info          rohc;
@@ -133,6 +134,8 @@ typedef struct pdcp_nr_info
 #define PDCP_NR_ROHC_PROFILE_TAG           0x0E
 /* 2 bytes, network order */
 
+#define PDCP_NR_MACI_PRES_TAG              0x0F
+/* 0 byte */
 
 /* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU
    continues until the end of the frame) */