Fix some duplicate display filter names.
[obnox/wireshark/wip.git] / epan / dissectors / packet-q2931.c
index 167fbda1ee3f6ab025dc964349962504d840e0ce..814e1d20a7334a9e18a817e48fd83ca0a75e8782 100644 (file)
@@ -4,8 +4,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998
  *
  * This program is free software; you can redistribute it and/or
 # include "config.h"
 #endif
 
-#include <stdio.h>
 #include <glib.h>
-#include <string.h>
 #include <epan/packet.h>
-#include "oui.h"
-#include "nlpid.h"
-#include "etypes.h"
+#include <epan/oui.h>
+#include <epan/nlpid.h>
+#include <epan/etypes.h>
 #include "packet-q931.h"
 #include "packet-arp.h"
 
@@ -378,7 +376,7 @@ dissect_q2931_aal_parameters_ie(tvbuff_t *tvb, int offset, int len,
                return;
        }
 
-       while (len != 0) {
+       while (len >= 0) {
                identifier = tvb_get_guint8(tvb, offset);
                switch (identifier) {
 
@@ -567,7 +565,7 @@ dissect_q2931_atm_cell_rate_ie(tvbuff_t *tvb, int offset, int len,
        guint8 identifier;
        guint32 value;
 
-       while (len != 0) {
+       while (len >= 0) {
                identifier = tvb_get_guint8(tvb, offset);
                switch (identifier) {
 
@@ -1103,7 +1101,7 @@ static const value_string q2931_cause_code_vals[] = {
        { Q2931_CAUSE_MAND_IE_MISSING,  "Mandatory information element is missing" },
        { Q2931_CAUSE_MT_NONEX_OR_UNIMPL,"Message type non-existent or not implemented" },
        { 0x62,                         "Message not compatible with call state or message type non-existent or not implemented" },
-       { Q2931_CAUSE_IE_NONEX_OR_UNIMPL,"Information element nonexistant or not implemented" },
+       { Q2931_CAUSE_IE_NONEX_OR_UNIMPL,"Information element non-existent or not implemented" },
        { Q2931_CAUSE_INVALID_IE_CONTENTS,"Invalid information element contents" },
        { Q2931_CAUSE_MSG_INCOMPAT_W_CS,"Message not compatible with call state" },
        { Q2931_CAUSE_REC_TIMER_EXP,    "Recovery on timer expiry" },
@@ -1255,7 +1253,7 @@ dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
                              "Unknown (0x%02X)"));
                        offset += 1;
                        len -= 1;
-               } while (len != 0);
+               } while (len >= 0);
                break;
 
        case Q2931_CAUSE_CELL_RATE_UNAVAIL:
@@ -1266,7 +1264,7 @@ dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
                              "Unknown (0x%02X)"));
                        offset += 1;
                        len -= 1;
-               } while (len != 0);
+               } while (len >= 0);
                break;
 
        case Q2931_CAUSE_CHAN_NONEXISTENT:
@@ -1295,7 +1293,7 @@ dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
                if (len < 3)
                        return;
                proto_tree_add_text(tree, tvb, offset, 3,
-                   "Timer: %.3s", tvb_get_ptr(tvb, offset, 3));
+                   "Timer: %.3s", tvb_get_ephemeral_string(tvb, offset, 3));
                break;
 
        default:
@@ -1430,7 +1428,7 @@ dissect_q2931_number_ie(tvbuff_t *tvb, int offset, int len,
 
        case Q2931_ISDN_NUMBERING:
                proto_tree_add_text(tree, tvb, offset, len, "Number: %.*s",
-                   len, tvb_get_ptr(tvb, offset, len));
+                   len, tvb_get_ephemeral_string(tvb, offset, len));
                break;
 
        case Q2931_NSAP_ADDRESSING:
@@ -1556,6 +1554,7 @@ dissect_q2931_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
        while (len >= 3) {
                identifier = tvb_get_guint8(tvb, offset);
                value = tvb_get_ntohs(tvb, offset + 1);
+               len -=3;
                switch (identifier) {
 
                case 0x01:      /* Cumulative transit delay identifier */
@@ -1673,7 +1672,7 @@ dissect_q2931_bband_sending_compl_ie(tvbuff_t *tvb, int offset, int len,
 {
        guint8 identifier;
 
-       while (len != 0) {
+       while (len >= 0) {
                identifier = tvb_get_guint8(tvb, offset);
                switch (identifier) {
 
@@ -1733,7 +1732,7 @@ dissect_q2931_transit_network_sel_ie(tvbuff_t *tvb, int offset, int len,
        if (len == 0)
                return;
        proto_tree_add_text(tree, tvb, offset, len,
-           "Network identification: %.*s", len, tvb_get_ptr(tvb, offset, len));
+           "Network identification: %.*s", len, tvb_get_ephemeral_string(tvb, offset, len));
 }
 
 /*
@@ -1746,7 +1745,7 @@ static const value_string q2931_shaping_indicator_vals[] = {
 };
 
 static const value_string q2931_user_net_fault_mgmt_vals[] = {
-       { 0x00, "No user-originated fault managment indications" },
+       { 0x00, "No user-originated fault management indications" },
        { 0x01, "User-originated fault management indications, cell rate 1 cell/s" },
        { 0,    NULL }
 };
@@ -1989,17 +1988,17 @@ dissect_q2931_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
            "Information element extension: 0x%02x",
            info_element_ext);
        ie_ext_tree = proto_item_add_subtree(ti, ett_q2931_ie_ext);
-       proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1,
+       proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1, "%s",
            decode_enumerated_bitfield(info_element_ext,
                Q2931_IE_COMPAT_CODING_STD, 8,
                coding_std_vals, "Coding standard: %s"));
-       proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1,
+       proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1, "%s",
            decode_boolean_bitfield(info_element_ext,
            Q2931_IE_COMPAT_FOLLOW_INST, 8,
            "Follow explicit error handling instructions",
            "Regular error handling procedures apply"));
        if (info_element_ext & Q2931_IE_COMPAT_FOLLOW_INST) {
-               proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1,
+               proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1, "%s",
                    decode_enumerated_bitfield(info_element_ext,
                        Q2931_IE_COMPAT_ACTION_IND, 8,
                        ie_action_ind_vals,
@@ -2036,15 +2035,16 @@ dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        guint8          info_element;
        guint8          info_element_ext;
        guint16         info_element_len;
+#if 0
        int             codeset;
        gboolean        non_locking_shift;
+#endif
 
-       if (check_col(pinfo->cinfo, COL_PROTOCOL))
-               col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.2931");
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.2931");
 
        if (tree) {
                ti = proto_tree_add_item(tree, proto_q2931, tvb, offset, -1,
-                   FALSE);
+                   ENC_NA);
                q2931_tree = proto_item_add_subtree(ti, ett_q2931);
 
                proto_tree_add_uint(q2931_tree, hf_q2931_discriminator, tvb, offset, 1, tvb_get_guint8(tvb, offset));
@@ -2096,8 +2096,10 @@ dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        /*
         * And now for the information elements....
         */
+#if 0
        codeset = 0;    /* start out in codeset 0 */
        non_locking_shift = TRUE;
+#endif
        while (tvb_reported_length_remaining(tvb, offset) > 0) {
                info_element = tvb_get_guint8(tvb, offset);
                info_element_ext = tvb_get_guint8(tvb, offset + 1);
@@ -2106,9 +2108,9 @@ dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        dissect_q2931_ie(tvb, offset, info_element_len,
                            q2931_tree, info_element, info_element_ext);
                }
+#if 0 /* XXX: Is codeset & etc supoosed to be used somehow ? */
                if (non_locking_shift)
                        codeset = 0;
-
                /*
                 * Handle shifts.
                 */
@@ -2128,6 +2130,7 @@ dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        }
                        break;
                }
+#endif
                offset += 1 + 1 + 2 + info_element_len;
        }
 }
@@ -2138,39 +2141,39 @@ proto_register_q2931(void)
        static hf_register_info hf[] = {
                { &hf_q2931_discriminator,
                  { "Protocol discriminator", "q2931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_q2931_call_ref_len,
                  { "Call reference value length", "q2931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_q2931_call_ref_flag,
                  { "Call reference flag", "q2931.call_ref_flag", FT_BOOLEAN, BASE_NONE, TFS(&tfs_call_ref_flag), 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_q2931_call_ref,
-                 { "Call reference value", "q2931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
-                       "", HFILL }},
+                 { "Call reference value", "q2931.call_ref", FT_BYTES, BASE_NONE, NULL, 0x0,
+                       NULL, HFILL }},
 
                { &hf_q2931_message_type,
                  { "Message type", "q2931.message_type", FT_UINT8, BASE_HEX, VALS(q2931_message_type_vals), 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_q2931_message_type_ext,
                  { "Message type extension", "q2931.message_type_ext", FT_UINT8, BASE_HEX, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_q2931_message_flag,
                  { "Flag", "q2931.message_flag", FT_BOOLEAN, 8, TFS(&tos_msg_flag), Q2931_MSG_TYPE_EXT_FOLLOW_INST,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_q2931_message_action_indicator,
                  { "Action indicator", "q2931.message_action_indicator", FT_UINT8, BASE_DEC, VALS(msg_action_ind_vals), Q2931_MSG_TYPE_EXT_ACTION_IND,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_q2931_message_len,
                  { "Message length", "q2931.message_len", FT_UINT16, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
        };
        static gint *ett[] = {