From Laurent Rabret:
[obnox/wireshark/wip.git] / packet-m3ua.c
index dea88f2cdb13abe3ba30fcd9a81edbb9d6cfedde..bf20a10c5ba179528f6e24d89493ae7108e1cfab 100644 (file)
@@ -5,9 +5,9 @@
  * http://www.ietf.org/internet-drafts/draft-ietf-sigtran-m3ua-06.txt (expired)
  * http://www.ietf.org/rfc/rfc3332.txt
  *
- * Copyright 2000, 2001, 2002, 2003 Michael Tuexen <Michael.Tuexen [AT] siemens.com>
+ * Copyright 2000, 2001, 2002, 2003 Michael Tuexen <tuexen [AT] fh-muenster.de>
  *
- * $Id: packet-m3ua.c,v 1.28 2003/02/18 19:48:31 tuexen Exp $
+ * $Id: packet-m3ua.c,v 1.31 2003/04/22 13:47:38 tuexen Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -225,17 +225,6 @@ static const value_string message_class_type_acro_values[] = {
   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_DEREG_RSP ,    "DEREG_RSP" },
   { 0,                           NULL } };
 
-
-
-
-
-#define PROTOCOL_DATA_OFFSET PARAMETER_VALUE_OFFSET
-
-
-
-#define TRAFFIC_MODE_TYPE_LENGTH 4
-#define TRAFFIC_MODE_TYPE_OFFSET PARAMETER_VALUE_OFFSET
-
 /* Initialize the protocol and registered fields */
 static int proto_m3ua = -1;
 static int hf_version = -1;
@@ -330,10 +319,8 @@ dissect_v5_common_header(tvbuff_t *common_header_tvb, packet_info *pinfo, proto_
   message_class  = tvb_get_guint8(common_header_tvb, MESSAGE_CLASS_OFFSET);
   message_type   = tvb_get_guint8(common_header_tvb, MESSAGE_TYPE_OFFSET);
 
-  if (check_col(pinfo->cinfo, COL_INFO)) {
-    col_append_str(pinfo->cinfo, COL_INFO, val_to_str(message_class * 256 + message_type, v5_message_class_type_acro_values, "reserved"));
-    col_append_str(pinfo->cinfo, COL_INFO, " ");
-  }
+  if (check_col(pinfo->cinfo, COL_INFO))
+    col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str(message_class * 256 + message_type, v5_message_class_type_acro_values, "reserved"));
 
   if (m3ua_tree) {
     /* add the components of the common header to the protocol tree */
@@ -355,10 +342,8 @@ dissect_common_header(tvbuff_t *common_header_tvb, packet_info *pinfo, proto_tre
   message_class  = tvb_get_guint8(common_header_tvb, MESSAGE_CLASS_OFFSET);
   message_type   = tvb_get_guint8(common_header_tvb, MESSAGE_TYPE_OFFSET);
 
-  if (check_col(pinfo->cinfo, COL_INFO)) {
-    col_append_str(pinfo->cinfo, COL_INFO, val_to_str(message_class * 256 + message_type, message_class_type_acro_values, "reserved"));
-    col_append_str(pinfo->cinfo, COL_INFO, " ");
-  }
+  if (check_col(pinfo->cinfo, COL_INFO))
+    col_add_fstr(pinfo->cinfo, COL_INFO,"%s ", val_to_str(message_class * 256 + message_type, message_class_type_acro_values, "reserved"));
 
   if (m3ua_tree) {
     /* add the components of the common header to the protocol tree */
@@ -381,6 +366,8 @@ dissect_network_appearance_parameter(tvbuff_t *parameter_tvb, proto_tree *parame
   proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, NETWORK_APPEARANCE_OFFSET));
 }
 
+#define V5_PROTOCOL_DATA_OFFSET PARAMETER_VALUE_OFFSET
+
 static void
 dissect_v5_protocol_data_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_item *parameter_item)
 {
@@ -389,7 +376,7 @@ dissect_v5_protocol_data_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo,
 
   length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
   protocol_data_length = length - PARAMETER_HEADER_LENGTH;
-  payload_tvb          = tvb_new_subset(parameter_tvb, PROTOCOL_DATA_OFFSET, protocol_data_length, protocol_data_length);
+  payload_tvb          = tvb_new_subset(parameter_tvb, V5_PROTOCOL_DATA_OFFSET, protocol_data_length, protocol_data_length);
   proto_item_append_text(parameter_item, " (SS7 message of %u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
   proto_item_set_len(parameter_item, PARAMETER_HEADER_LENGTH);
   call_dissector(mtp3_handle, payload_tvb, pinfo, tree);
@@ -544,6 +531,9 @@ dissect_reason_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, pr
   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, REASON_OFFSET), reason_values, "unknown"));
 }
 
+#define TRAFFIC_MODE_TYPE_LENGTH 4
+#define TRAFFIC_MODE_TYPE_OFFSET PARAMETER_VALUE_OFFSET
+
 static const value_string v5_traffic_mode_type_values[] = {
   { 1, "Over-ride"            },
   { 2, "Load-share"           },
@@ -759,6 +749,8 @@ dissect_asp_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_
   proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, ASP_IDENTIFIER_OFFSET));
 }
 
+#define PROTOCOL_DATA_1_OFFSET PARAMETER_VALUE_OFFSET
+
 static void
 dissect_protocol_data_1_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_item *parameter_item)
 {
@@ -766,15 +758,15 @@ dissect_protocol_data_1_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, p
   tvbuff_t *payload_tvb;
 
   protocol_data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
-  payload_tvb          = tvb_new_subset(parameter_tvb, PROTOCOL_DATA_OFFSET, protocol_data_length, protocol_data_length);
+  payload_tvb          = tvb_new_subset(parameter_tvb, PROTOCOL_DATA_1_OFFSET, protocol_data_length, protocol_data_length);
   proto_item_append_text(parameter_item, " (SS7 message of %u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
   proto_item_set_len(parameter_item, PARAMETER_HEADER_LENGTH);
   call_dissector(mtp3_handle, payload_tvb, pinfo, tree);
-
 }
 
 #define LI_OCTETT_LENGTH 1
 #define LI_OCTETT_OFFSET PARAMETER_VALUE_OFFSET
+#define PROTOCOL_DATA_2_OFFSET (PARAMETER_VALUE_OFFSET + LI_OCTETT_LENGTH)
 
 static void
 dissect_protocol_data_2_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parameter_tree, proto_item *parameter_item)
@@ -785,7 +777,7 @@ dissect_protocol_data_2_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, p
 
   li                   = tvb_get_guint8(parameter_tvb, LI_OCTETT_OFFSET);
   protocol_data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - LI_OCTETT_LENGTH;
-  payload_tvb          = tvb_new_subset(parameter_tvb, PROTOCOL_DATA_OFFSET + LI_OCTETT_LENGTH, protocol_data_length, protocol_data_length);
+  payload_tvb          = tvb_new_subset(parameter_tvb, PROTOCOL_DATA_2_OFFSET, protocol_data_length, protocol_data_length);
   proto_tree_add_item(parameter_tree, hf_li, parameter_tvb, LI_OCTETT_OFFSET, LI_OCTETT_LENGTH, NETWORK_BYTE_ORDER);
   proto_item_append_text(parameter_item, " (SS7 message of %u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
   proto_item_set_len(parameter_item, PARAMETER_HEADER_LENGTH + LI_OCTETT_LENGTH);
@@ -821,16 +813,16 @@ dissect_routing_key_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto
 }
 
 static const value_string registration_result_status_values[] = {
-  { 0,           "Successfully Registered" } ,
-  { 1,           "Error - Unknown" } ,
-  { 2,           "Error - Invalid DPC" } ,
-  { 3,           "Error - Invalid Network Appearance" } ,
-  { 4,           "Error - Invalid Routing Key" } ,
-  { 5,           "Error - Permission Denied" } ,
-  { 6,           "Error - Overlapping (Non-unique) Routing Key" } ,
-  { 7,           "Error - Routing Key not Provisioned" } ,
-  { 8,           "Error - Insufficient Resources" } ,
-  { 0,           NULL } };
+  { 0, "Successfully Registered" } ,
+  { 1, "Error - Unknown" } ,
+  { 2, "Error - Invalid DPC" } ,
+  { 3, "Error - Invalid Network Appearance" } ,
+  { 4, "Error - Invalid Routing Key" } ,
+  { 5, "Error - Permission Denied" } ,
+  { 6, "Error - Overlapping (Non-unique) Routing Key" } ,
+  { 7, "Error - Routing Key not Provisioned" } ,
+  { 8, "Error - Insufficient Resources" } ,
+  { 0, NULL } };
 
 #define REG_RES_IDENTIFIER_LENGTH 4
 #define REG_RES_STATUS_LENGTH     4
@@ -1069,18 +1061,18 @@ dissect_correlation_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *pa
 #define REG_STATUS_OFFSET  PARAMETER_VALUE_OFFSET
 
 static const value_string registration_status_values[] = {
-  {  0,           "Successfully Registered" },
-  {  1,           "Error - Unknown" },
-  {  2,           "Error - Invalid DPC" },
-  {  3,           "Error - Invalid Network Appearance" },
-  {  4,           "Error - Invalid Routing Key" },
-  {  5,           "Error - Permission Denied" },
-  {  6,           "Error - Cannot Support Unique Routing" },
-  {  7,           "Error - Routing Key not Currently Provisioned" },
-  {  8,           "Error - Insufficient Resources" },
-  {  9,           "Error - Unsupported RK parameter Field" },
-  { 10,           "Error - Unsupported/Invalid Traffic Handling Mode" },
-  {  0,           NULL } };
+  {  0, "Successfully Registered" },
+  {  1, "Error - Unknown" },
+  {  2, "Error - Invalid DPC" },
+  {  3, "Error - Invalid Network Appearance" },
+  {  4, "Error - Invalid Routing Key" },
+  {  5, "Error - Permission Denied" },
+  {  6, "Error - Cannot Support Unique Routing" },
+  {  7, "Error - Routing Key not Currently Provisioned" },
+  {  8, "Error - Insufficient Resources" },
+  {  9, "Error - Unsupported RK parameter Field" },
+  { 10, "Error - Unsupported/Invalid Traffic Handling Mode" },
+  {  0, NULL } };
 
 static void
 dissect_registration_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
@@ -1093,13 +1085,13 @@ dissect_registration_status_parameter(tvbuff_t *parameter_tvb, proto_tree *param
 #define DEREG_STATUS_OFFSET  PARAMETER_VALUE_OFFSET
 
 static const value_string deregistration_status_values[] = {
-  { 0,          "Successfully Deregistered" },
-  { 1,          "Error - Unknown" },
-  { 2,          "Error - Invalid Routing Context" },
-  { 3,          "Error - Permission Denied" },
-  { 4,          "Error - Not Registered" },
-  { 5,          "Error - ASP Currently Active for Routing Context" },
-  { 0,          NULL } };
+  { 0, "Successfully Deregistered" },
+  { 1, "Error - Unknown" },
+  { 2, "Error - Invalid Routing Context" },
+  { 3, "Error - Permission Denied" },
+  { 4, "Error - Not Registered" },
+  { 5, "Error - ASP Currently Active for Routing Context" },
+  { 0, NULL } };
 
 static void
 dissect_deregistration_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
@@ -1641,6 +1633,7 @@ dissect_m3ua(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree)
   } else {
     m3ua_tree = NULL;
   };
+
   /* dissect the message */
   dissect_message(message_tvb, pinfo, tree, m3ua_tree);
 }