GSM A DTAP: add UMTS EVS to supported codecs list IE
[metze/wireshark/wip.git] / epan / dissectors / packet-cmpp.c
index 5a2a8c11d0c2cae51a331eccc18b2a8cc284a300..ca68869eecab6edc76ac2be8d2133aed834907fe 100644 (file)
@@ -2,44 +2,26 @@
  * Routines for China Mobile Point to Point dissection
  * Copyright 2007, Andy Chu <chu.dev@gmail.com>
  *
- * $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
  */
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
+#include "config.h"
 
 #include <epan/packet.h>
-#include <epan/dissectors/packet-tcp.h>
+#include "packet-tcp.h"
 
-#define CMPP_FIX_HEADER_LENGTH 12
+#define CMPP_FIX_HEADER_LENGTH  12
 #define CMPP_DELIVER_REPORT_LEN 71
 
 /* These are not registered with IANA */
-#define CMPP_SP_LONG_PORT 7890
-#define CMPP_SP_SHORT_PORT 7900
-#define CMPP_ISMG_LONG_PORT 7930
-#define CMPP_ISMG_SHORT_PORT 9168
+#define CMPP_PORT_RANGE "7890,7900,7930,9168"
+
+void proto_register_cmpp(void);
+void proto_reg_handoff_cmpp(void);
 
 /* Initialize the protocol and registered fields */
 static gint proto_cmpp = -1;
@@ -151,40 +133,41 @@ static gboolean cmpp_desegment = TRUE;
 #define CMPP_PUSH_MT_ROUTE_UPDATE_RESP 0x80000015
 #define CMPP_PUSH_MO_ROUTE_UPDATE_RESP 0x80000016
 #define CMPP_GET_MO_ROUTE_RESP         0x80000017
+
 static const value_string vals_command_Id[] = {                /* Operation    */
-    { CMPP_CONNECT, "CMPP_CONNECT" },
-    { CMPP_CONNECT_RESP, "CMPP_CONNECT_RESP" },
-    { CMPP_TERMINATE, "CMPP_TERMINATE" },
-    { CMPP_TERMINATE_RESP, "CMPP_TERMINATE_RESP" },
-    { CMPP_SUBMIT, "CMPP_SUBMIT" },
-    { CMPP_SUBMIT_RESP, "CMPP_SUBMIT_RESP" },
-    { CMPP_DELIVER, "CMPP_DELIVER" },
-    { CMPP_DELIVER_RESP, "CMPP_DELIVER_RESP" },
-    { CMPP_QUERY, "CMPP_QUERY" },
-    { CMPP_QUERY_RESP, "CMPP_QUERY" },
-    { CMPP_CANCEL, "CMPP_CANCEL" },
-    { CMPP_CANCEL_RESP, "CMPP_CANCEL_RESP" },
-    { CMPP_ACTIVE_TEST, "CMPP_ACTIVE_TEST" },
-    { CMPP_ACTIVE_TEST_RESP, "CMPP_ACTIVE_TEST_RESP" },
-    { CMPP_FWD, "CMPP_FWD" },
-    { CMPP_FWD_RESP, "CMPP_FWD_RESP" },
-    { CMPP_MT_ROUTE, "CMPP_MT_ROUTE" },
-    { CMPP_MO_ROUTE, "CMPP_MO_ROUTE" },
-    { CMPP_GET_MT_ROUTE, "CMPP_GET_MT_ROUTE" },
-    { CMPP_MT_ROUTE_UPDATE, "CMPP_MT_ROUTE_UPDATE" },
-    { CMPP_MO_ROUTE_UPDATE, "CMPP_MO_ROUTE_UPDATE" },
-    { CMPP_PUSH_MT_ROUTE_UPDATE, "CMPP_PUSH_MT_ROUTE_UPDATE" },
-    { CMPP_PUSH_MO_ROUTE_UPDATE, "CMPP_PUSH_MO_ROUTE_UPDATE" },
-    { CMPP_GET_MO_ROUTE, "CMPP_GET_MO_ROUTE" },
-    { CMPP_MT_ROUTE_RESP, "CMPP_MT_ROUTE_RESP" },
-    { CMPP_MO_ROUTE_RESP, "CMPP_MO_ROUTE_RESP" },
-    { CMPP_GET_MT_ROUTE_RESP, "CMPP_GET_MT_ROUTE_RESP" },
-    { CMPP_MT_ROUTE_UPDATE_RESP, "CMPP_MT_ROUTE_UPDATE_RESP" },
-    { CMPP_MO_ROUTE_UPDATE_RESP, "CMPP_MO_ROUTE_UPDATE_RESP" },
-    { CMPP_PUSH_MT_ROUTE_UPDATE_RESP, "CMPP_PUSH_MT_ROUTE_UPDATE_RESP" },
-    { CMPP_PUSH_MO_ROUTE_UPDATE_RESP, "CMPP_PUSH_MO_ROUTE_UPDATE_RESP" },
-    { CMPP_GET_MO_ROUTE_RESP, "CMPP_GET_MO_ROUTE_RESP" },
-    { 0, NULL }
+       { CMPP_CONNECT,                   "CMPP_CONNECT" },
+       { CMPP_CONNECT_RESP,              "CMPP_CONNECT_RESP" },
+       { CMPP_TERMINATE,                 "CMPP_TERMINATE" },
+       { CMPP_TERMINATE_RESP,            "CMPP_TERMINATE_RESP" },
+       { CMPP_SUBMIT,                    "CMPP_SUBMIT" },
+       { CMPP_SUBMIT_RESP,               "CMPP_SUBMIT_RESP" },
+       { CMPP_DELIVER,                   "CMPP_DELIVER" },
+       { CMPP_DELIVER_RESP,              "CMPP_DELIVER_RESP" },
+       { CMPP_QUERY,                     "CMPP_QUERY" },
+       { CMPP_QUERY_RESP,                "CMPP_QUERY" },
+       { CMPP_CANCEL,                    "CMPP_CANCEL" },
+       { CMPP_CANCEL_RESP,               "CMPP_CANCEL_RESP" },
+       { CMPP_ACTIVE_TEST,               "CMPP_ACTIVE_TEST" },
+       { CMPP_ACTIVE_TEST_RESP,          "CMPP_ACTIVE_TEST_RESP" },
+       { CMPP_FWD,                       "CMPP_FWD" },
+       { CMPP_FWD_RESP,                  "CMPP_FWD_RESP" },
+       { CMPP_MT_ROUTE,                  "CMPP_MT_ROUTE" },
+       { CMPP_MO_ROUTE,                  "CMPP_MO_ROUTE" },
+       { CMPP_GET_MT_ROUTE,              "CMPP_GET_MT_ROUTE" },
+       { CMPP_MT_ROUTE_UPDATE,           "CMPP_MT_ROUTE_UPDATE" },
+       { CMPP_MO_ROUTE_UPDATE,           "CMPP_MO_ROUTE_UPDATE" },
+       { CMPP_PUSH_MT_ROUTE_UPDATE,      "CMPP_PUSH_MT_ROUTE_UPDATE" },
+       { CMPP_PUSH_MO_ROUTE_UPDATE,      "CMPP_PUSH_MO_ROUTE_UPDATE" },
+       { CMPP_GET_MO_ROUTE,              "CMPP_GET_MO_ROUTE" },
+       { CMPP_MT_ROUTE_RESP,             "CMPP_MT_ROUTE_RESP" },
+       { CMPP_MO_ROUTE_RESP,             "CMPP_MO_ROUTE_RESP" },
+       { CMPP_GET_MT_ROUTE_RESP,         "CMPP_GET_MT_ROUTE_RESP" },
+       { CMPP_MT_ROUTE_UPDATE_RESP,      "CMPP_MT_ROUTE_UPDATE_RESP" },
+       { CMPP_MO_ROUTE_UPDATE_RESP,      "CMPP_MO_ROUTE_UPDATE_RESP" },
+       { CMPP_PUSH_MT_ROUTE_UPDATE_RESP, "CMPP_PUSH_MT_ROUTE_UPDATE_RESP" },
+       { CMPP_PUSH_MO_ROUTE_UPDATE_RESP, "CMPP_PUSH_MO_ROUTE_UPDATE_RESP" },
+       { CMPP_GET_MO_ROUTE_RESP,         "CMPP_GET_MO_ROUTE_RESP" },
+       { 0, NULL }
 };
 
 static const value_string vals_connect_resp_status[] = {       /* Connection Status */
@@ -253,26 +236,25 @@ static gint ett_deliver_report = -1;
 
 /* Helper functions */
 
-static char*
+static const guint8*
 cmpp_octet_string(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset, gint length)
 {
-       char *display;
+       const guint8 *display;
 
-       display = (char *)tvb_get_ephemeral_string(tvb, offset, length);
-       proto_tree_add_string(tree, field, tvb, offset, length, display);
+       proto_tree_add_item_ret_string(tree, field, tvb, offset, length, ENC_ASCII, wmem_packet_scope(), &display);
        return display;
 }
 
 static char*
 cmpp_version(proto_tree *tree, tvbuff_t *tvb, gint  field, gint offset)
 {
-       gint8 version, major, minor;
-       char *strval;
+       gint8  version, major, minor;
+       char  *strval;
 
        version = tvb_get_guint8(tvb, offset);
-       minor = version & 0x0F;
-       major = (version & 0xF0) >> 4;
-       strval = ep_strdup_printf("%02u.%02u", major, minor);
+       minor   = version & 0x0F;
+       major   = (version & 0xF0) >> 4;
+       strval  = wmem_strdup_printf(wmem_packet_scope(), "%02u.%02u", major, minor);
        /* TODO: the version should be added as a uint_format */
        proto_tree_add_string(tree, field, tvb, offset, 1, strval);
        return strval;
@@ -281,9 +263,9 @@ cmpp_version(proto_tree *tree, tvbuff_t *tvb, gint  field, gint offset)
 static char*
 cmpp_timestamp(proto_tree *tree, tvbuff_t *tvb, gint  field, gint offset)
 {
-       gint8 month, day, hour, minute, second;
-       gint32 timevalue;
-       char *strval;
+       gint8   month, day, hour, minute, second;
+       gint32  timevalue;
+       char   *strval;
 
        timevalue = tvb_get_ntohl(tvb, offset);
        second = timevalue % 100;
@@ -294,7 +276,7 @@ cmpp_timestamp(proto_tree *tree, tvbuff_t *tvb, gint  field, gint offset)
        timevalue /= 100;
        day = timevalue % 100;
        month = timevalue / 100;
-       strval = ep_strdup_printf("%02u/%02u %02u:%02u:%02u", month, day,
+       strval = wmem_strdup_printf(wmem_packet_scope(), "%02u/%02u %02u:%02u:%02u", month, day,
                hour, minute, second);
        proto_tree_add_string(tree, field, tvb, offset, 4, strval);
        return strval;
@@ -344,20 +326,21 @@ cmpp_boolean(proto_tree *tree, tvbuff_t *tvb, gint  field, gint offset)
 static void
 cmpp_msg_id(proto_tree *tree, tvbuff_t *tvb, gint  field, gint offset)
 {
-       guint8 month,day,hour,minute,second;
-       guint32 ismg_code;
-       proto_item *sub_tree;
-       char *strval;
+       guint8      month,day,hour,minute,second;
+       guint32     ismg_code;
+       proto_item *pi;
+       proto_tree *sub_tree;
+       char       *strval;
 
-       sub_tree = proto_tree_add_item(tree, field, tvb, offset, 8, FALSE);
-       proto_item_add_subtree(sub_tree, ett_msg_id);
+       pi = proto_tree_add_item(tree, field, tvb, offset, 8, ENC_BIG_ENDIAN);
+       sub_tree = proto_item_add_subtree(pi, ett_msg_id);
 
        month = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4;
        day = (tvb_get_ntohs(tvb, offset) & 0x0F80) >> 7;
        hour = (tvb_get_guint8(tvb, offset + 1) & 0x7C) >> 2;
        minute = (tvb_get_ntohs(tvb, offset + 1) & 0x03F0) >> 4;
        second = (tvb_get_ntohs(tvb, offset + 2) & 0x0FC0) >> 6;
-       strval = ep_strdup_printf("%02u/%02u %02u:%02u:%02u", month, day,
+       strval = wmem_strdup_printf(wmem_packet_scope(), "%02u/%02u %02u:%02u:%02u", month, day,
                hour, minute, second);
 
        ismg_code = (tvb_get_ntohl(tvb, offset + 3) & 0x3FFFFF00) >> 16;
@@ -397,8 +380,8 @@ cmpp_connect_resp(proto_tree *tree, tvbuff_t *tvb)
 static void
 cmpp_submit(proto_tree *tree, tvbuff_t *tvb)
 {
-       int offset, i;
-       guint8 msg_format, destUsr, msgLen;
+       int    offset, i;
+       guint8 destUsr, msgLen;
        offset = CMPP_FIX_HEADER_LENGTH;
        cmpp_msg_id(tree, tvb, hf_cmpp_msg_id, offset);
        offset += 8;
@@ -422,7 +405,7 @@ cmpp_submit(proto_tree *tree, tvbuff_t *tvb)
        offset++;
        cmpp_uint1(tree, tvb, hf_cmpp_TP_udhi, offset);
        offset++;
-       msg_format = cmpp_uint1(tree, tvb, hf_cmpp_Msg_Fmt, offset);
+       cmpp_uint1(tree, tvb, hf_cmpp_Msg_Fmt, offset);
        offset++;
        cmpp_octet_string(tree, tvb, hf_cmpp_submit_Msg_src, offset, 6);
        offset += 6;
@@ -471,9 +454,11 @@ cmpp_submit_resp(proto_tree *tree, tvbuff_t *tvb)
 static void
 cmpp_deliver_report(proto_tree *tree, tvbuff_t *tvb, gint  field, guint offset)
 {
-       proto_item *sub_tree;
-       sub_tree = proto_tree_add_item(tree, field, tvb, offset, CMPP_DELIVER_REPORT_LEN, FALSE);
-       proto_item_add_subtree(sub_tree, ett_deliver_report);
+       proto_item *pi;
+       proto_tree *sub_tree;
+
+       pi = proto_tree_add_item(tree, field, tvb, offset, CMPP_DELIVER_REPORT_LEN, ENC_BIG_ENDIAN);
+       sub_tree = proto_item_add_subtree(pi, ett_deliver_report);
        cmpp_msg_id(sub_tree, tvb, hf_cmpp_msg_id, offset);
        offset += 8;
        cmpp_octet_string(sub_tree, tvb, hf_cmpp_deliver_Report_Stat, offset, 7);
@@ -490,7 +475,7 @@ cmpp_deliver_report(proto_tree *tree, tvbuff_t *tvb, gint  field, guint offset)
 static void
 cmpp_deliver(proto_tree *tree, tvbuff_t *tvb)
 {
-       guint offset, msgLen;
+       guint    offset, msgLen;
        gboolean report;
        offset = CMPP_FIX_HEADER_LENGTH;
        cmpp_msg_id(tree, tvb, hf_cmpp_msg_id, offset);
@@ -533,31 +518,31 @@ cmpp_deliver_resp(proto_tree *tree, tvbuff_t *tvb)
 }
 
 /* Code to actually dissect the packets */
-static void
-dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int
+dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
 {
 
 /* Set up structures needed to add the protocol subtree and manage it */
-       proto_item *ti;
-       proto_tree *cmpp_tree;
-       guint command_id;
-       guint tvb_len;
-       guint total_length;
+       proto_item  *ti;
+       proto_tree  *cmpp_tree;
+       guint        command_id;
+       guint        tvb_len;
+       guint        total_length;
        const gchar *command_str; /* Header command string */
 
        /* Get the length of the PDU */
-       tvb_len = tvb_length(tvb);
+       tvb_len = tvb_captured_length(tvb);
        /* if the length of the tvb is shorder then the cmpp header length exit */
        if (tvb_len < CMPP_FIX_HEADER_LENGTH)
-               return;
+               return 0;
 
        total_length = tvb_get_ntohl(tvb, 0); /* Get the pdu length */
        command_id = tvb_get_ntohl(tvb, 4); /* get the pdu command id */
 
-       if (match_strval(command_id, vals_command_Id) == NULL)
+       if (try_val_to_str(command_id, vals_command_Id) == NULL)
        {
                /* Should never happen: we checked this in dissect_cmpp() */
-               return;
+               return 0;
        }
 
        command_str = val_to_str(command_id, vals_command_Id,
@@ -567,20 +552,17 @@ dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        if (tvb_len < total_length)
        {
                /* Should never happen: TCP should have desegmented for us */
-               return;
+               return 0;
        }
 
        /* Make entries in Protocol column and Info column on summary display */
        col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMPP");
 
-       if (check_col(pinfo->cinfo, COL_INFO))
-       {
-               col_append_fstr(pinfo->cinfo, COL_INFO, "%s. ", command_str);
-       }
+       col_append_fstr(pinfo->cinfo, COL_INFO, "%s. ", command_str);
 
        if (tree)
        {
-               ti = proto_tree_add_item(tree, proto_cmpp, tvb, 0, -1, FALSE);
+               ti = proto_tree_add_item(tree, proto_cmpp, tvb, 0, -1, ENC_NA);
 
                cmpp_tree = proto_item_add_subtree(ti, ett_cmpp);
 
@@ -618,23 +600,25 @@ dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                break;
                }
        }
+
+       return tvb_reported_length(tvb);
 }
 
 
 /* Get the CMPP PDU Length */
 static guint
-get_cmpp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, gint offset)
+get_cmpp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
 {
-    return tvb_get_ntohl(tvb, offset);
+       return tvb_get_ntohl(tvb, offset);
 }
 
 
 static int
-dissect_cmpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_cmpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
 {
        guint total_length, command_id, tvb_len;
        /* Check that there's enough data */
-       tvb_len = tvb_length(tvb);
+       tvb_len = tvb_captured_length(tvb);
        if (tvb_len < CMPP_FIX_HEADER_LENGTH)
                return 0;
 
@@ -649,311 +633,308 @@ dissect_cmpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        if (total_length < CMPP_FIX_HEADER_LENGTH || total_length > 1000)
                return 0;
 
-       if (match_strval(command_id, vals_command_Id) == NULL)
+       if (try_val_to_str(command_id, vals_command_Id) == NULL)
                return 0;
 
        col_clear(pinfo->cinfo, COL_INFO);
 
        tcp_dissect_pdus(tvb, pinfo, tree, cmpp_desegment, CMPP_FIX_HEADER_LENGTH,
-                        get_cmpp_pdu_len, dissect_cmpp_tcp_pdu);
+                        get_cmpp_pdu_len, dissect_cmpp_tcp_pdu, data);
 
        /* Return the amount of data this dissector was able to dissect */
-       return tvb_length(tvb);
+       return tvb_reported_length(tvb);
 
 }
 
 /* Register the protocol with Wireshark */
 
-/* this format is require because a script is used to build the C function
-   that calls all the protocol registration.
-*/
 void
 proto_register_cmpp(void) {
 
 /* Setup list of header fields  See Section 1.6.1 for details*/
        static hf_register_info hf[] = {
                { &hf_cmpp_Total_Length,
-                       { "Total Length", "cmpp.Total_Length",
-                         FT_UINT32, BASE_DEC, NULL, 0x00,
-                         "Total length of the CMPP PDU.",
-                         HFILL }
+                 { "Total Length", "cmpp.Total_Length",
+                   FT_UINT32, BASE_DEC, NULL, 0x00,
+                   "Total length of the CMPP PDU.",
+                   HFILL }
                },
                { &hf_cmpp_Command_Id,
-                       { "Command Id", "cmpp.Command_Id",
-                         FT_UINT32, BASE_HEX, VALS(vals_command_Id), 0x00,
-                         "Command Id of the CMPP messages",
-                         HFILL }
+                 { "Command Id", "cmpp.Command_Id",
+                   FT_UINT32, BASE_HEX, VALS(vals_command_Id), 0x00,
+                   "Command Id of the CMPP messages",
+                   HFILL }
                },
                { &hf_cmpp_Sequence_Id,
-                       { "Sequence Id", "cmpp.Sequence_Id",
-                         FT_UINT32, BASE_DEC, NULL, 0x00,
-                         "Sequence Id of the CMPP messages",
-                         HFILL }
+                 { "Sequence Id", "cmpp.Sequence_Id",
+                   FT_UINT32, BASE_DEC, NULL, 0x00,
+                   "Sequence Id of the CMPP messages",
+                   HFILL }
                },
                { &hf_cmpp_connect_Source_Addr,
-                       { "Source Addr", "cmpp.connect.Source_Addr",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Source Address, the SP_Id",
-                         HFILL }
+                 { "Source Addr", "cmpp.connect.Source_Addr",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Source Address, the SP_Id",
+                   HFILL }
                },
                { &hf_cmpp_connect_AuthenticatorSource,
-                       { "Authenticator Source", "cmpp.connect.AuthenticatorSource",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Authenticator source, MD5(Source_addr + 9 zero + shared secret + timestamp)",
-                         HFILL }
+                 { "Authenticator Source", "cmpp.connect.AuthenticatorSource",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Authenticator source, MD5(Source_addr + 9 zero + shared secret + timestamp)",
+                   HFILL }
                },
 
                { &hf_cmpp_Version,
-                       { "Version", "cmpp.Version",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "CMPP Version",
-                         HFILL }
+                 { "Version", "cmpp.Version",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "CMPP Version",
+                   HFILL }
                },
                { &hf_cmpp_connect_Timestamp,
-                       { "Timestamp", "cmpp.connect.Timestamp",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Timestamp MM/DD HH:MM:SS",
-                         HFILL }
+                 { "Timestamp", "cmpp.connect.Timestamp",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Timestamp MM/DD HH:MM:SS",
+                   HFILL }
                },
                { &hf_cmpp_connect_resp_status,
-                       { "Connect Response Status", "cmpp.connect_resp.Status",
-                         FT_UINT32, BASE_DEC, VALS(vals_connect_resp_status), 0x00,
-                         "Response Status, Value higher then 4 means other error",
-                         HFILL }
+                 { "Connect Response Status", "cmpp.connect_resp.Status",
+                   FT_UINT32, BASE_DEC, VALS(vals_connect_resp_status), 0x00,
+                   "Response Status, Value higher then 4 means other error",
+                   HFILL }
                },
                { &hf_cmpp_connect_resp_AuthenticatorISMG,
-                       { "SIMG Authenticate result", "cmpp.connect_resp.AuthenticatorISMG",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Authenticator result, MD5(Status + AuthenticatorSource + shared secret)",
-                         HFILL }
+                 { "SIMG Authenticate result", "cmpp.connect_resp.AuthenticatorISMG",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Authenticator result, MD5(Status + AuthenticatorSource + shared secret)",
+                   HFILL }
                },
                { &hf_cmpp_msg_id,
-                       { "Msg_Id", "cmpp.Msg_Id",
-                         FT_UINT64, BASE_HEX, NULL, 0x00,
-                         "Message ID",
-                         HFILL }
+                 { "Msg_Id", "cmpp.Msg_Id",
+                   FT_UINT64, BASE_HEX, NULL, 0x00,
+                   "Message ID",
+                   HFILL }
                },
                { &hf_cmpp_submit_pk_total,
-                       { "Number of Part", "cmpp.submit.Pk_total",
-                         FT_UINT8, BASE_DEC, NULL, 0x00,
-                         "Total number of parts of the message with the same Msg_Id, start from 1",
-                         HFILL }
+                 { "Number of Part", "cmpp.submit.Pk_total",
+                   FT_UINT8, BASE_DEC, NULL, 0x00,
+                   "Total number of parts of the message with the same Msg_Id, start from 1",
+                   HFILL }
                },
                { &hf_cmpp_submit_pk_number,
-                       { "Part Number", "cmpp.submit.Pk_number",
-                         FT_UINT8, BASE_DEC, NULL, 0x00,
-                         "Part number of the message with the same Msg_Id, start from 1",
-                         HFILL }
+                 { "Part Number", "cmpp.submit.Pk_number",
+                   FT_UINT8, BASE_DEC, NULL, 0x00,
+                   "Part number of the message with the same Msg_Id, start from 1",
+                   HFILL }
                },
                { &hf_msg_id_timestamp,
-                       { "Timestamp", "cmpp.Msg_Id.timestamp",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Timestamp MM/DD HH:MM:SS Bit 64 ~ 39",
-                         HFILL }
+                 { "Timestamp", "cmpp.Msg_Id.timestamp",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Timestamp MM/DD HH:MM:SS Bit 64 ~ 39",
+                   HFILL }
                },
                { &hf_msg_id_ismg_code,
-                       { "ISMG Code", "cmpp.Msg_Id.ismg_code",
-                         FT_UINT32, BASE_DEC, NULL, 0x00,
-                         "ISMG Code, bit 38 ~ 17",
-                         HFILL }
+                 { "ISMG Code", "cmpp.Msg_Id.ismg_code",
+                   FT_UINT32, BASE_DEC, NULL, 0x00,
+                   "ISMG Code, bit 38 ~ 17",
+                   HFILL }
                },
                { &hf_msg_id_sequence_id,
-                       { "Msg_Id sequence Id", "cmpp.Msg_Id.sequence_id",
-                         FT_UINT16, BASE_DEC, NULL, 0x00,
-                         "Msg_Id sequence Id, bit 16 ~ 1",
-                         HFILL }
+                 { "Msg_Id sequence Id", "cmpp.Msg_Id.sequence_id",
+                   FT_UINT16, BASE_DEC, NULL, 0x00,
+                   "Msg_Id sequence Id, bit 16 ~ 1",
+                   HFILL }
                },
                { &hf_cmpp_submit_Registered_Delivery,
-                       { "Registered Delivery", "cmpp.submit.Registered_Delivery",
-                         FT_BOOLEAN, BASE_NONE, NULL, 0x0,
-                         "Registered Delivery flag",
-                         HFILL }
+                 { "Registered Delivery", "cmpp.submit.Registered_Delivery",
+                   FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+                   "Registered Delivery flag",
+                   HFILL }
                },
                { &hf_cmpp_submit_Msg_level,
-                       { "Message Level", "cmpp.submit.Msg_level",
-                         FT_UINT8, BASE_DEC, NULL, 0x00,
-                         NULL,
-                         HFILL }
+                 { "Message Level", "cmpp.submit.Msg_level",
+                   FT_UINT8, BASE_DEC, NULL, 0x00,
+                   NULL,
+                   HFILL }
                },
                { &hf_cmpp_Service_Id,
-                       { "Service ID", "cmpp.Servicd_Id",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Service ID, a mix of characters, numbers and symbol",
-                         HFILL }
+                 { "Service ID", "cmpp.Servicd_Id",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Service ID, a mix of characters, numbers and symbol",
+                   HFILL }
                },
                { &hf_cmpp_submit_Fee_UserType,
-                       { "Charging Informations", "cmpp.submit.Fee_UserType",
-                         FT_UINT8, BASE_DEC, VALS(vals_submit_Fee_UserType), 0x00,
-                         "Charging Informations, if value is 3, this field will not be used",
-                         HFILL }
+                 { "Charging Informations", "cmpp.submit.Fee_UserType",
+                   FT_UINT8, BASE_DEC, VALS(vals_submit_Fee_UserType), 0x00,
+                   "Charging Informations, if value is 3, this field will not be used",
+                   HFILL }
                },
                { &hf_cmpp_submit_Fee_terminal_Id,
-                       { "Fee Terminal ID", "cmpp.submit.Fee_terminal_Id",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Fee Terminal ID, Valid only when Fee_UserType is 3",
-                         HFILL }
+                 { "Fee Terminal ID", "cmpp.submit.Fee_terminal_Id",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Fee Terminal ID, Valid only when Fee_UserType is 3",
+                   HFILL }
                },
                { &hf_cmpp_submit_Fee_terminal_type,
-                       { "Fake Fee Terminal", "cmpp.submit.Fee_terminal_type",
-                         FT_BOOLEAN, BASE_NONE, NULL, 0x0,
-                         "Fee terminal type, 0 is real, 1 is fake",
-                         HFILL }
+                 { "Fake Fee Terminal", "cmpp.submit.Fee_terminal_type",
+                   FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+                   "Fee terminal type, 0 is real, 1 is fake",
+                   HFILL }
                },
                { &hf_cmpp_TP_pId,
-                       { "TP pId", "cmpp.TP_pId",
-                         FT_UINT8, BASE_DEC, NULL, 0x00,
-                         "GSM TP pId Field",
-                         HFILL }
+                 { "TP pId", "cmpp.TP_pId",
+                   FT_UINT8, BASE_DEC, NULL, 0x00,
+                   "GSM TP pId Field",
+                   HFILL }
                },
                { &hf_cmpp_TP_udhi,
-                       { "TP udhi", "cmpp.TP_udhi",
-                         FT_UINT8, BASE_DEC, NULL, 0x00,
-                         "GSM TP udhi field",
-                         HFILL }
+                 { "TP udhi", "cmpp.TP_udhi",
+                   FT_UINT8, BASE_DEC, NULL, 0x00,
+                   "GSM TP udhi field",
+                   HFILL }
                },
                { &hf_cmpp_Msg_Fmt,
-                       { "Message Format", "cmpp.Msg_Fmt",
-                         FT_UINT8, BASE_DEC, VALS(vals_Msg_Fmt), 0x00,
-                         NULL,
-                         HFILL }
+                 { "Message Format", "cmpp.Msg_Fmt",
+                   FT_UINT8, BASE_DEC, VALS(vals_Msg_Fmt), 0x00,
+                   NULL,
+                   HFILL }
                },
                { &hf_cmpp_submit_Msg_src,
-                       { "Message Source SP_Id", "cmpp.submit.Msg_src",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Message source SP ID",
-                         HFILL }
+                 { "Message Source SP_Id", "cmpp.submit.Msg_src",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Message source SP ID",
+                   HFILL }
                },
                { &hf_cmpp_submit_FeeType, /* TODO Replace this with a vals_string*/
-                       { "Fee Type", "cmpp.submit.FeeType",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         NULL,
-                         HFILL }
+                 { "Fee Type", "cmpp.submit.FeeType",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   NULL,
+                   HFILL }
                },
                { &hf_cmpp_submit_FeeCode,
-                       { "Fee Code", "cmpp.submit.FeeCode",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         NULL,
-                         HFILL }
+                 { "Fee Code", "cmpp.submit.FeeCode",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   NULL,
+                   HFILL }
                },
                { &hf_cmpp_submit_Valld_Time,
-                       { "Valid time", "cmpp.submit.Valld_Time",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Message Valid Time, format follow SMPP 3.3",
-                         HFILL }
+                 { "Valid time", "cmpp.submit.Valld_Time",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Message Valid Time, format follow SMPP 3.3",
+                   HFILL }
                },
                { &hf_cmpp_submit_At_Time,
-                       { "Send time", "cmpp.submit.At_time",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Message send time, format following SMPP 3.3",
-                         HFILL }
+                 { "Send time", "cmpp.submit.At_time",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Message send time, format following SMPP 3.3",
+                   HFILL }
                },
                { &hf_cmpp_submit_Src_Id,
-                       { "Source ID", "cmpp.submit.Src_Id",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "This value matches SMPP submit_sm source_addr field",
-                         HFILL }
+                 { "Source ID", "cmpp.submit.Src_Id",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "This value matches SMPP submit_sm source_addr field",
+                   HFILL }
                },
                { &hf_cmpp_submit_DestUsr_tl,
-                       { "Destination Address Count", "cmpp.submit.DestUsr_tl",
-                         FT_UINT8, BASE_DEC, NULL, 0x00,
-                         "Number of destination address, must smaller then 100",
-                         HFILL }
+                 { "Destination Address Count", "cmpp.submit.DestUsr_tl",
+                   FT_UINT8, BASE_DEC, NULL, 0x00,
+                   "Number of destination address, must smaller then 100",
+                   HFILL }
                },
                { &hf_cmpp_Dest_terminal_Id,
-                       { "Destination Address", "cmpp.Dest_terminal_Id",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "MSISDN number which receive the SMS",
-                         HFILL }
+                 { "Destination Address", "cmpp.Dest_terminal_Id",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "MSISDN number which receive the SMS",
+                   HFILL }
                },
                { &hf_cmpp_submit_Dest_terminal_type,
-                       { "Fake Destination Terminal", "cmpp.submit.Dest_terminal_type",
-                         FT_BOOLEAN, BASE_NONE, NULL, 0x0,
-                         "destination terminal type, 0 is real, 1 is fake",
-                         HFILL }
+                 { "Fake Destination Terminal", "cmpp.submit.Dest_terminal_type",
+                   FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+                   "destination terminal type, 0 is real, 1 is fake",
+                   HFILL }
                },
                { &hf_cmpp_Msg_Length,
-                       { "Message length", "cmpp.Msg_Length",
-                         FT_UINT8, BASE_DEC, NULL, 0x00,
-                         "SMS Message length, ASCII must be <= 160 bytes, other must be <= 140 bytes",
-                         HFILL }
+                 { "Message length", "cmpp.Msg_Length",
+                   FT_UINT8, BASE_DEC, NULL, 0x00,
+                   "SMS Message length, ASCII must be <= 160 bytes, other must be <= 140 bytes",
+                   HFILL }
                },
                { &hf_cmpp_Msg_Content,
-                       { "Message Content", "cmpp.Msg_Content",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         NULL,
-                         HFILL }
+                 { "Message Content", "cmpp.Msg_Content",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   NULL,
+                   HFILL }
                },
                { &hf_cmpp_LinkID,
-                       { "Link ID", "cmpp.LinkID",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         NULL,
-                         HFILL }
+                 { "Link ID", "cmpp.LinkID",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   NULL,
+                   HFILL }
                },
                { &hf_cmpp_submit_resp_Result,
-                       { "Result", "cmpp.submit_resp.Result",
-                         FT_UINT32, BASE_DEC, VALS(vals_Submit_Resp_Result), 0x00,
-                         "Submit Result",
-                         HFILL }
+                 { "Result", "cmpp.submit_resp.Result",
+                   FT_UINT32, BASE_DEC, VALS(vals_Submit_Resp_Result), 0x00,
+                   "Submit Result",
+                   HFILL }
                },
                { &hf_cmpp_deliver_Dest_Id,
-                       { "Destination ID", "cmpp.deliver.Dest_Id",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "SP Service ID or server number",
-                         HFILL }
+                 { "Destination ID", "cmpp.deliver.Dest_Id",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "SP Service ID or server number",
+                   HFILL }
                },
                { &hf_cmpp_deliver_Src_terminal_Id,
-                       { "Src_terminal_Id", "cmpp.deliver.Src_terminal_Id",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Source MSISDN number, if it is deliver report, this will be the CMPP_SUBMIT destination number",
-                         HFILL }
+                 { "Src_terminal_Id", "cmpp.deliver.Src_terminal_Id",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Source MSISDN number, if it is deliver report, this will be the CMPP_SUBMIT destination number",
+                   HFILL }
                },
                { &hf_cmpp_deliver_Src_terminal_type,
-                       { "Fake source terminal type", "cmpp.deliver.Src_terminal_type",
-                         FT_BOOLEAN, BASE_NONE, NULL, 0x0,
-                         "Type of the source terminal, can be 0 (real) or 1 (fake)",
-                         HFILL }
+                 { "Fake source terminal type", "cmpp.deliver.Src_terminal_type",
+                   FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+                   "Type of the source terminal, can be 0 (real) or 1 (fake)",
+                   HFILL }
                },
                { &hf_cmpp_deliver_Registered_Delivery,
-                       { "Deliver Report", "cmpp.deliver.Registered_Delivery",
-                         FT_BOOLEAN, BASE_NONE, NULL, 0x0,
-                         "The message is a deliver report if this value = 1",
-                         HFILL }
+                 { "Deliver Report", "cmpp.deliver.Registered_Delivery",
+                   FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+                   "The message is a deliver report if this value = 1",
+                   HFILL }
                },
                { &hf_cmpp_deliver_Report,
-                       { "Detail Deliver Report", "cmpp.deliver.Report",
-                         FT_NONE, BASE_NONE, NULL, 0x00,
-                         "The detail report",
-                         HFILL }
+                 { "Detail Deliver Report", "cmpp.deliver.Report",
+                   FT_NONE, BASE_NONE, NULL, 0x00,
+                   "The detail report",
+                   HFILL }
                },
                { &hf_cmpp_deliver_Report_Stat,
-                       { "Deliver Status", "cmpp.deliver.Report.Status",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         NULL,
-                         HFILL }
+                 { "Deliver Status", "cmpp.deliver.Report.Status",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   NULL,
+                   HFILL }
                },
                { &hf_cmpp_deliver_Report_Submit_time,
-                       { "Submit_time", "cmpp.deliver.Report.Submit_time",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Format YYMMDDHHMM",
-                         HFILL }
+                 { "Submit_time", "cmpp.deliver.Report.Submit_time",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Format YYMMDDHHMM",
+                   HFILL }
                },
                { &hf_cmpp_deliver_Report_Done_time,
-                       { "Done_time", "cmpp.deliver.Report.Done_time",
-                         FT_STRING, BASE_NONE, NULL, 0x00,
-                         "Format YYMMDDHHMM",
-                         HFILL }
+                 { "Done_time", "cmpp.deliver.Report.Done_time",
+                   FT_STRING, BASE_NONE, NULL, 0x00,
+                   "Format YYMMDDHHMM",
+                   HFILL }
                },
                { &hf_cmpp_deliver_Report_SMSC_sequence,
-                       { "SMSC_sequence", "cmpp.Report.SMSC_sequence",
-                         FT_UINT32, BASE_DEC, NULL, 0x00,
-                         "Sequence number",
-                         HFILL }
+                 { "SMSC_sequence", "cmpp.Report.SMSC_sequence",
+                   FT_UINT32, BASE_DEC, NULL, 0x00,
+                   "Sequence number",
+                   HFILL }
                },
                { &hf_cmpp_deliver_resp_Result,
-                       { "Result", "cmpp.deliver_resp.Result",
-                         FT_UINT32, BASE_DEC, VALS(vals_Deliver_Resp_Result), 0x00,
-                         "Deliver Result",
-                         HFILL }
+                 { "Result", "cmpp.deliver_resp.Result",
+                   FT_UINT32, BASE_DEC, VALS(vals_Deliver_Resp_Result), 0x00,
+                   "Deliver Result",
+                   HFILL }
                }
        };
 
@@ -980,9 +961,19 @@ proto_reg_handoff_cmpp(void)
 {
        dissector_handle_t cmpp_handle;
 
-       cmpp_handle = new_create_dissector_handle(dissect_cmpp, proto_cmpp);
-       dissector_add_uint("tcp.port", CMPP_SP_LONG_PORT, cmpp_handle);
-       dissector_add_uint("tcp.port", CMPP_SP_SHORT_PORT, cmpp_handle);
-       dissector_add_uint("tcp.port", CMPP_ISMG_LONG_PORT, cmpp_handle);
-       dissector_add_uint("tcp.port", CMPP_ISMG_SHORT_PORT, cmpp_handle);
+       cmpp_handle = create_dissector_handle(dissect_cmpp, proto_cmpp);
+       dissector_add_uint_range_with_preference("tcp.port", CMPP_PORT_RANGE, cmpp_handle);
 }
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */