Provide data to inner dissector for PER open type
[metze/wireshark/wip.git] / epan / dissectors / packet-ua.c
index 1bfbbaa3241e93f242c4646ba657fb1867e8590e..168e02642745065b240c24ee928c321ec573f2dc 100644 (file)
@@ -6,30 +6,12 @@
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include "config.h"
 
-#include <glib.h>
-
-#include "epan/packet.h"
-#include "epan/prefs.h"
-
-#include "epan/dissectors/packet-rtp.h"
-#include "epan/dissectors/packet-rtcp.h"
+#include <epan/packet.h>
 
 #include "packet-uaudp.h"
 
@@ -46,8 +28,6 @@ static dissector_table_t ua_opcode_dissector_table;
 static int  proto_ua_msg        = -1;
 static gint ett_ua_msg          = -1;
 
-static gboolean setup_conversations_enabled = TRUE;
-
 static dissector_handle_t noe_handle;
 static dissector_handle_t ua3g_handle;
 
@@ -149,14 +129,11 @@ static void uadecode(e_ua_direction  direction,
     default:
         {
             /* add text to the frame "INFO" column */
-            col_append_str(pinfo->cinfo, COL_INFO, " - UA3G Message ERR: Opcode Unknown");
-
-            proto_tree_add_text(tree,
-                tvb,
-                offset,
-                length,
-                "Opcode Unknown 0x%02x",
-                tvb_get_guint8(tvb, (offset + 2)));
+            col_append_fstr(pinfo->cinfo, COL_INFO, " - UA3G Message ERR: Opcode (0x%02x) Unknown", tvb_get_guint8(tvb, (offset + 2)));
+
+            call_data_dissector(tvb_new_subset_length(tvb, offset, length),
+                           pinfo,
+                           tree);
             break;
         }
     }
@@ -185,59 +162,8 @@ static void _dissect_ua_msg(tvbuff_t       *tvb,
 
     while (tvb_offset_exists(tvb, offset))
     {
-        gint length;
-        gint opcode;
-
-        length = tvb_get_letohs(tvb, offset) + 2;
-        opcode = tvb_get_guint8(tvb, offset+2);
-
-        /* RTP/RTCP conversation setup */
-        if (setup_conversations_enabled && (opcode==0x13) && (tvb_get_guint8(tvb, offset+3)==0x01))
-        {
-            address remote_rtp_addr;
-            guint32 remote_rtp_port;
-            gint    suboffset;
-
-            remote_rtp_addr.data = NULL;
-            remote_rtp_port = 0;
-
-            /* StartRTP */
-            suboffset = offset + 5;
-
-            while (suboffset < offset+length)
-            {
-                switch (tvb_get_guint8(tvb, suboffset))
-                {
-                case 0x00: /* local port */
-                    {
-                    /*local_rtp_port = tvb_get_ntohs(tvb, suboffset+2);*/
-                    break;
-                    }
-                case 0x01: /* remote IP */
-                    {
-                    remote_rtp_addr.type = AT_IPv4;
-                    remote_rtp_addr.len  = 4;
-                    remote_rtp_addr.data = tvb_get_ptr(tvb, suboffset+2, 4);
-                    break;
-                    }
-                case 0x02: /* remote port */
-                    {
-                    remote_rtp_port = tvb_get_ntohs(tvb, suboffset+2);
-                    break;
-                    }
-                }
-
-            suboffset += tvb_get_guint8(tvb, suboffset+1) + 2;
-            }
-
-            if ((remote_rtp_addr.data != NULL) && (remote_rtp_port != 0))
-            {
-                rtp_add_address(pinfo, &remote_rtp_addr, remote_rtp_port, 0,
-                        "UA", pinfo->fd->num, 0, NULL);
-                rtcp_add_address(pinfo, &remote_rtp_addr, remote_rtp_port+1, 0,
-                         "UA", pinfo->fd->num);
-            }
-        }
+        gint length = tvb_get_letohs(tvb, offset) + 2;
+        gint opcode = tvb_get_guint8(tvb, offset+2);
 
         uadecode(direction, ua_msg_tree, pinfo, tvb, offset, opcode, length);
 
@@ -246,14 +172,16 @@ static void _dissect_ua_msg(tvbuff_t       *tvb,
 }
 
 
-static void dissect_ua_sys_to_term(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int dissect_ua_sys_to_term(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
 {
     _dissect_ua_msg(tvb, pinfo, tree, SYS_TO_TERM);
+    return tvb_captured_length(tvb);
 }
 
-static void dissect_ua_term_to_sys(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int dissect_ua_term_to_sys(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
 {
     _dissect_ua_msg(tvb, pinfo, tree, TERM_TO_SYS);
+    return tvb_captured_length(tvb);
 }
 
 
@@ -263,8 +191,6 @@ static void dissect_ua_term_to_sys(tvbuff_t *tvb, packet_info *pinfo, proto_tree
 
 void proto_register_ua_msg(void)
 {
-    module_t *ua_msg_module;
-
     static gint *ett[] =
     {
         &ett_ua_msg,
@@ -278,14 +204,6 @@ void proto_register_ua_msg(void)
 
     /* Common subtree array registration */
     proto_register_subtree_array(ett, array_length(ett));
-
-    /* Register preferences */
-    ua_msg_module = prefs_register_protocol(proto_ua_msg, NULL);
-
-    prefs_register_bool_preference(ua_msg_module, "setup_conversations",
-        "Setup RTP/RTCP conversations on Start RTP",
-        "Setup RTP/RTCP conversations when parsing Start RTP messages",
-        &setup_conversations_enabled);
 }
 
 void proto_reg_handoff_ua_msg(void)
@@ -310,7 +228,20 @@ void proto_reg_handoff_ua_msg(void)
 
 
 #endif
-    noe_handle  = find_dissector("noe");
-    ua3g_handle = find_dissector("ua3g");
+    noe_handle  = find_dissector_add_dependency("noe", proto_ua_msg);
+    ua3g_handle = find_dissector_add_dependency("ua3g", proto_ua_msg);
 
 }
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */