Ethereal-dev: [Ethereal-dev] Patch to packet-isup to display cause value string.

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Anders Broman (EAB)" <anders.broman@xxxxxxxxxxxxxxx>
Date: Thu, 20 Feb 2003 08:47:19 +0100
Hi,
Here's a patch to add printing of cause value string to packet-isup.c
Best regards
Anders Broman


--- packet-isup.c	Tue Feb 18 21:44:43 2003
+++ packet-isup_b.c	Tue Feb 18 21:48:15 2003
@@ -224,6 +224,8 @@
 #define PARAM_TYPE_GENERIC_NR           192
 #define PARAM_TYPE_GENERIC_DIGITS       193
 
+
+
 static const value_string isup_parameter_type_value[] = {
 { PARAM_TYPE_END_OF_OPT_PARAMS,        "End of optional parameters"},
   { PARAM_TYPE_CALL_REF,               "Call Reference (national use)"},
@@ -1439,11 +1441,214 @@
 /* ------------------------------------------------------------------
   Dissector Parameter Cause Indicators - no detailed dissection since defined in Rec. Q.850
  */
+
+/*
+ * Dissect a Cause information element.
+ * The decoding of cause indicators parameter field are defined in ITU-T
+ * Recommendation Q.850 which referes to Q.931 hence the naming is keept from
+ * the "packet-q931.c" which is copied here, cause code values is from q.850 though. 
+ */
+
+
+/*
+ * ITU-standardized coding.
+ */
+#define	Q931_ITU_STANDARDIZED_CODING	0x00
+/*
+ * Variable-length IEs.
+ */
+#define	Q931_IE_VL_EXTENSION		0x80	/* Extension flag */
+
+static const value_string q931_cause_coding_standard_vals[] = {
+	{ 0x00, "ITU-T standardized coding" },
+	{ 0x20, "ISO/IEC standard" },
+	{ 0x40, "National standard" },
+	{ 0x60, "Standard specific to identified location" },
+	{ 0,    NULL }
+};
+
+static const value_string q931_cause_location_vals[] = {
+	{ 0x00, "User (U)" },
+	{ 0x01, "Private network serving the local user (LPN)" },
+	{ 0x02, "Public network serving the local user (LN)" },
+	{ 0x03, "Transit network (TN)" },
+	{ 0x04, "Public network serving the remote user (RLN)" },
+	{ 0x05, "Private network serving the remote user (RPN)" },
+	{ 0x07, "International network (INTL)" },
+	{ 0x0A, "Network beyond interworking point (BI)" },
+	{ 0,    NULL }
+};
+
+static const value_string q931_cause_recommendation_vals[] = {
+	{ 0x00, "Q.931" },
+	{ 0x03, "X.21" },
+	{ 0x04, "X.25" },
+	{ 0x05, "Q.1031/Q.1051" },
+	{ 0,    NULL }
+};
+
+/*
+ * Cause codes for Cause.
+ */
+static const value_string q850_cause_code_vals[] = {
+	{ 0x00,	"Valid cause code not yet received" },
+	{ 0x01,	"Unallocated (unassigned) number" },
+	{ 0x02,	"No route to specified transit network" },
+	{ 0x03,	"No route to destination" },
+	{ 0x04,	"Send special information tone" },
+	{ 0x05,	"Misdialled trunk prefix" },
+	{ 0x06,	"Channel unacceptable" },
+	{ 0x07,	"Call awarded and being delivered in an established channel" },
+	{ 0x08,	"Preemtion" },
+	{ 0x09,	"Preemtion - circuit reserved for reuse" },
+	{ 0x0A,	" " },
+	{ 0x0B,	" " },
+        { 0x0E,	"QoR: ported number" },
+	{ 0x10,	"Normal call clearing" },
+	{ 0x11,	"User busy" },
+	{ 0x12,	"No user responding" },
+	{ 0x13,	"No answer from user (user alerted)" },
+	{ 0x14,	"Subscriber absent" },
+	{ 0x15,	"Call rejected" },
+	{ 0x16,	"Number changed" },
+	{ 0x17,	"Redirection to new destination" },
+	{ 0x18,	"Call rejected due to feature at the destination" },
+	{ 0x19,	"Exchange routing error" },
+	{ 0x1A,	"Non-selected user clearing" },
+	{ 0x1B,	"Destination out of order" },
+	{ 0x1C,	"Invalid number format (address incomplete)" },
+	{ 0x1D,	"Facility rejected" },
+	{ 0x1E,	"Response to STATUS ENQUIRY" },
+	{ 0x1F,	"Normal unspecified" },
+	{ 0x21,	"Circuit out of order" },
+	{ 0x22,	"No circuit/channel available" },
+	{ 0x23,	" " },
+	{ 0x25,	" " },
+	{ 0x26,	"Network out of order" },
+	{ 0x27,	"Permanent frame mode connection out of service" },
+	{ 0x28,	"Permanent frame mode connection operational" },
+	{ 0x29,	"Temporary failure" },
+	{ 0x2A,	"Switching equipment congestion" },
+	{ 0x2B,	"Access information discarded" },
+	{ 0x2C,	"Requested circuit/channel not available" },
+	{ 0x2D,	" " },
+	{ 0x2E,	"Precedence call blocked" },
+	{ 0x2F,	"Resources unavailable, unspecified" },
+	{ 0x31,	"Quality of service unavailable" },
+	{ 0x32,	"Requested facility not subscribed" },
+	{ 0x33,	" " },
+	{ 0x34,	" " },
+	{ 0x35,	"Outgoing calls barred within CUG" },
+	{ 0x36,	" " },
+	{ 0x37,	"Incoming calls barred within CUG" },
+	{ 0x38,	"Call waiting not subscribed" },
+	{ 0x39,	"Bearer capability not authorized" },
+	{ 0x3A,	"Bearer capability not presently available" },
+	{ 0x3E,	"Inconsistency in designated outgoing access information and subscriber class" },
+	{ 0x3F,	"Service or option not available, unspecified" },
+	{ 0x41,	"Bearer capability not implemented" },
+	{ 0x42,	"Channel type not implemented" },
+	{ 0x43,	" " },
+	{ 0x44,	" " },
+	{ 0x45,	"Requested facility not implemented" },
+	{ 0x46,	"Only restricted digital information bearer capability is available" },
+	{ 0x4F,	"Service or option not implemented, unspecified" },
+	{ 0x51,	"Invalid call reference value" },
+	{ 0x52,	"Identified channel does not exist" },
+	{ 0x53,	"Call identity does not exist for suspended call" },
+	{ 0x54,	"Call identity in use" },
+	{ 0x55,	"No call suspended" },
+	{ 0x56,	"Call having the requested call identity has been cleared" },
+	{ 0x57,	"Called user not member of CUG" },
+	{ 0x58,	"Incompatible destination" },
+	{ 0x59,	" " },
+	{ 0x5A,	"Non-existing CUG" },
+	{ 0x5B,	"Invalid transit network selection (national use)" },
+	{ 0x5C,	" " },
+	{ 0x5D,	" " },
+	{ 0x5F,	"Invalid message, unspecified" },
+	{ 0x60,	"Mandatory information element is missing" },
+	{ 0x61,	"Message type non-existent or not implemented" },
+	{ 0x62,	"Message not compatible with call state or message type non-existent or not implemented" },
+	{ 0x63,	"Information element nonexistant or not implemented" },
+	{ 0x64,	"Invalid information element contents" },
+	{ 0x65,	"Message not compatible with call state" },
+	{ 0x66,	"Recovery on timer expiry" },
+	{ 0x67,	"Parameter non-existent or not implemented - passed on" },
+	{ 0x6E,	"Message with unrecognized parameter discarded" },
+	{ 0x6F,	"Protocol error, unspecified" },
+	{ 0x7F,	"Internetworking, unspecified" },
+	{ 0,	NULL }
+};
+static void
+dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
+    proto_tree *tree )
+{
+	guint8 octet;
+	guint8 coding_standard;
+
+	if (len == 0)
+		return;
+	octet = tvb_get_guint8(tvb, offset);
+	coding_standard = octet & 0x60;
+	proto_tree_add_text(tree, tvb, offset, 1,
+	    "Coding standard: %s",
+	    val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
+	if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
+		/*
+		 * We don't know how the cause is encoded,
+		 * so just dump it as data and be done with it.
+		 */
+		proto_tree_add_text(tree, tvb, offset,
+		    len, "Data: %s",
+		    tvb_bytes_to_str(tvb, offset, len));
+		return;
+	}
+	proto_tree_add_text(tree, tvb, offset, 1,
+	    "Location: %s",
+	    val_to_str(octet & 0x0F, q931_cause_location_vals,
+	      "Unknown (0x%X)"));
+	offset += 1;
+	len -= 1;
+
+	if (!(octet & Q931_IE_VL_EXTENSION)) {
+		if (len == 0)
+			return;
+		octet = tvb_get_guint8(tvb, offset);
+		proto_tree_add_text(tree, tvb, offset, 1,
+		    "Recommendation: %s",
+		    val_to_str(octet & 0x7F, q931_cause_recommendation_vals,
+		      "Unknown (0x%02X)"));
+		offset += 1;
+		len -= 1;
+	}
+
+	if (len == 0)
+		return;
+	octet = tvb_get_guint8(tvb, offset);
+	proto_tree_add_text(tree, tvb, offset, 1,
+             "Cause value: %s (%i)",
+	    val_to_str(octet & 0x7F, q850_cause_code_vals,
+	      "Unknown (0x%02X)"));
+	offset += 1;
+	len -= 1;
+
+	if (len == 0)
+		return;
+	proto_tree_add_text(tree, tvb, offset, len,
+	    "Diagnostics: %s",
+	    tvb_bytes_to_str(tvb, offset, len));
+}
+
+
 static void
 dissect_isup_cause_indicators_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
 { guint length = tvb_length(parameter_tvb);
   proto_tree_add_text(parameter_tree, parameter_tvb,0, length, "Cause indicators (-> Q.850)");
+  dissect_q931_cause_ie(parameter_tvb,0,length,
+					    parameter_tree);
   proto_item_set_text(parameter_item, "Cause indicators, see Q.850 (%u byte%s length)", length , plurality(length, "", "s"));
+  
 }
 
 /* ------------------------------------------------------------------