GSM A DTAP: add UMTS EVS to supported codecs list IE
[metze/wireshark/wip.git] / epan / dissectors / packet-mpeg-pat.c
index aaf292c2640f292c6ce79208fbacb58137d09618..725cb22a574953c3338ef031fabcf111083dd70f 100644 (file)
@@ -2,34 +2,20 @@
  * Routines for MPEG2 (ISO/ISO 13818-1) Program Associate Table (PAT) dissection
  * Copyright 2012, Guy Martin <gmsoft@tuxicoman.be>
  *
- * $Id$
- *
  * Wireshark - Network traffic analyzer
  * 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-mpeg-sect.h>
+#include "packet-mpeg-sect.h"
+
+void proto_register_mpeg_pat(void);
+void proto_reg_handoff_mpeg_pat(void);
 
 static int proto_mpeg_pat = -1;
 static int hf_mpeg_pat_transport_stream_id = -1;
@@ -60,16 +46,14 @@ static const true_false_string mpeg_pat_cur_next_vals = {
 
 };
 
-static void
-dissect_mpeg_pat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int
+dissect_mpeg_pat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
 {
-
     guint offset = 0, length = 0;
     guint16 prog_num, prog_pid;
 
     proto_item *ti;
     proto_tree *mpeg_pat_tree;
-    proto_item *pi;
     proto_tree *mpeg_pat_prog_tree;
 
     /* The TVB should start right after the section_length in the Section packet */
@@ -97,7 +81,7 @@ dissect_mpeg_pat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     offset += 1;
 
     if (offset >= length)
-        return;
+        return offset;
 
 
     /* Parse all the programs */
@@ -106,8 +90,8 @@ dissect_mpeg_pat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         prog_num = tvb_get_ntohs(tvb, offset);
         prog_pid = tvb_get_ntohs(tvb, offset + 2) & MPEG_PAT_PROGRAM_MAP_PID_MASK;
 
-        pi = proto_tree_add_text(mpeg_pat_tree, tvb, offset, 4, "Program 0x%04hx -> PID 0x%04hx", prog_num, prog_pid);
-        mpeg_pat_prog_tree = proto_item_add_subtree(pi, ett_mpeg_pat_prog);
+        mpeg_pat_prog_tree = proto_tree_add_subtree_format(mpeg_pat_tree, tvb, offset, 4,
+                        ett_mpeg_pat_prog, NULL, "Program 0x%04hx -> PID 0x%04hx", prog_num, prog_pid);
 
         proto_tree_add_item(mpeg_pat_prog_tree, hf_mpeg_pat_program_number, tvb, offset, 2, ENC_BIG_ENDIAN);
         offset += 2;
@@ -120,6 +104,7 @@ dissect_mpeg_pat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
     offset += packet_mpeg_sect_crc(tvb, pinfo, mpeg_pat_tree, 0, offset);
     proto_item_set_len(ti, offset);
+    return tvb_captured_length(tvb);
 }