From 513b7816766f408e15062a83058ba3bfd496badc Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Sun, 8 May 2005 20:34:57 +0000 Subject: From Javier Acuna: Added some code to dissect DateAndTime. svn path=/trunk/; revision=14327 --- asn1/camel/camel.asn | 30 +++++---- asn1/camel/camel.cnf | 130 ++++++++++++++++++++++++++++++++++--- asn1/camel/packet-camel-template.c | 47 ++++++++++++++ asn1/camel/packet-camel-template.h | 4 +- 4 files changed, 188 insertions(+), 23 deletions(-) (limited to 'asn1') diff --git a/asn1/camel/camel.asn b/asn1/camel/camel.asn index b74efcd32e..89bf25a32d 100644 --- a/asn1/camel/camel.asn +++ b/asn1/camel/camel.asn @@ -516,12 +516,7 @@ Carrier ::= OCTET STRING (SIZE (cAPSpecificBoundSetminCarrierLength ..cAPSpecificBoundSetmaxCarrierLength )) --- Cause notes: not recursive, exported, --- locally refd 10 times, import refd 0 times -Cause ::= - - - OCTET STRING (SIZE (minCauseLength..cAPSpecificBoundSetmaxCauseLength)) + -- CGEncountered notes: not recursive, exported, -- locally refd 1 times, import refd 0 times @@ -1648,10 +1643,16 @@ OCTET STRING (SIZE (1..160)) -- ApplyChargingReportArg notes: not recursive, exported, -- locally refd 1 times, import refd 0 times -ApplyChargingReportArg ::= - +CallresultoctetPDU ::= OCTET STRING (SIZE (cAPSpecificBoundSetminCallResultLength..cAPSpecificBoundSetmaxCallResultLength)) -OCTET STRING (SIZE (cAPSpecificBoundSetminCallResultLength..cAPSpecificBoundSetmaxCallResultLength)) +ApplyChargingReportArg ::= SEQUENCE { + callresultOctet CallresultoctetPDU + } +-- ( +-- CONTAINING CamelCallResult +-- ENCODED BY enc-BER +-- ) + -- CallResult type @@ -1673,10 +1674,16 @@ FurnishChargingInformationArg ::= CamelFCIBillingChargingCharacteristics -- ReleaseCallArg notes: not recursive, exported, -- locally refd 1 times, import refd 0 times +-- ReleaseCallArg ::= OCTET STRING (SIZE (minCauseLength..32)) ReleaseCallArg ::= Q850Cause -Q850Cause ::=OCTET STRING (SIZE (minCauseLength..32)) +Q850Cause ::=OCTET STRING (SIZE (minCauseLength..32)) +-- Cause notes: not recursive, exported, +-- locally refd 10 times, import refd 0 times +Cause ::= OCTET STRING (SIZE (minCauseLength..cAPSpecificBoundSetmaxCauseLength)) + +-- -- ReceivedInformationArg notes: not recursive, exported, -- locally refd 1 times, import refd 0 times ReceivedInformationArg ::= @@ -1820,9 +1827,6 @@ InitialDPArgExtension ::= SEQUENCE gmscAddress [0] ISDN-AddressString OPTIONAL } - - - CellGlobalIdOrServiceAreaIdOrLAI ::= OCTET STRING (SIZE (5..7)) diff --git a/asn1/camel/camel.cnf b/asn1/camel/camel.cnf index ce9a28b744..3264f847b1 100644 --- a/asn1/camel/camel.cnf +++ b/asn1/camel/camel.cnf @@ -1,5 +1,5 @@ -# inap.cnf -# inap conformation file +# camel.cnf +# camel conformation file # $Id$ @@ -41,11 +41,14 @@ proto_item* parameter_item; proto_item* parameter_tree; tvbuff_t *isup_tvb; + guint32 len; + len=tvb_length_remaining(tvb,offset); parameter_item = proto_tree_add_item(tree, hf_index, tvb, offset, -1, FALSE); parameter_tree = proto_item_add_subtree(parameter_item, ett_camelisup_parameter); isup_tvb = tvb_new_subset(tvb, offset,-1 , -1 ); dissect_isup_called_party_number_parameter(isup_tvb, parameter_tree, parameter_item); + offset += len; #.END @@ -78,23 +81,132 @@ return offset; proto_tree_add_item(tree, hf_camel_addr_extension, parameter_tvb, 0,1,FALSE); + proto_tree_add_item(tree, hf_camel_addr_natureOfAddressIndicator, parameter_tvb, 0,1,FALSE); proto_tree_add_item(tree, hf_camel_addr_numberingPlanInd, parameter_tvb, 0,1,FALSE); digit_str = unpack_digits(parameter_tvb, 1); proto_tree_add_string(tree, hf_camel_addr_digits, parameter_tvb, 1, -1, digit_str); #.END + #---------------------------------------------------------------------------------------- -#.FN_BODY Q850Cause +#.FN_BODY CallresultoctetPDU +tvbuff_t *parameter_tvb; + offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, + ¶meter_tvb); + + if (!parameter_tvb) + return offset; + dissect_camel_CamelCallResult(implicit_tag, parameter_tvb, 0, pinfo, tree, -1); - tvbuff_t *camel_tvb; - guint8 Cause_value; - offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, &camel_tvb); +#.END - dissect_q931_cause_ie(camel_tvb, 0, tvb_length_remaining(camel_tvb,0), - tree, hf_camel_cause_indicator, &Cause_value); +#---------------------------------------------------------------------------------------- +#.FN_BODY Q850Cause + tvbuff_t *camel_tvb; + guint8 Cause_value; + offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, &camel_tvb); - return offset; + dissect_q931_cause_ie(camel_tvb, 0, tvb_length_remaining(camel_tvb,0), tree, hf_camel_cause_indicator, &Cause_value); + + + return offset; #.END +#---------------------------------------------------------------------------------------- +#.FN_BODY DateAndTime + + +/* +* date_option = 1 european dd:mm:yyyy +* date_option = 2 american mm:dd:yyyy +*/ + +/* +* Output should be HH:MM:SS;dd/mm/yyyy +* if european is selected, and HH:MM:SS;mm/dd/yyyy +* otherwise. +*/ + + guint8 digit_pair; + guint8 i = 0, curr_offset; + char *time = (char *)(calloc (2*7 + 5 + 1, sizeof(char))); + + char c[ 2*7 + 5] = ""; /*temporary container*/ + time[ 2*7 + 5 +1 ] = '\0'; + /* 2 digits per octet, 7 octets total + 5 delimiters */ + + for (curr_offset = 0; curr_offset < 7 ; curr_offset++) + /*Loop to extract date*/ + { + digit_pair = tvb_get_guint8(tvb, curr_offset); + + proto_tree_add_uint(tree, + hf_digit, + tvb, + curr_offset, + 1, + digit_pair & 0x0F); + + proto_tree_add_uint(tree, + hf_digit, + tvb, + curr_offset, + 1, + digit_pair & 0xF0); + + + c[i] = camel_number_to_char( digit_pair & 0x0F); + i++; + c[i] = camel_number_to_char( digit_pair & 0xF0); + i++; + } + + /* Pretty print date */ + + time[0] = c[9]; + time[1] = c[8]; + time[2] = ':'; + time[3] = c[10]; + time[4] = c[11]; + time[5] = ':'; + time[6] = c[12]; + time[7] = c[13]; + time[8] = ';'; + if ( EUROPEAN_DATE == date_format) /*european*/ + { + time[9] = c[6]; /*day*/ + time[10] = c[7]; + time[11] = '/'; + time[12] = c[4]; /*month*/ + time[13] = c[5]; + } + else /*american*/ + { + time[9] = c[4]; /*month*/ + time[10] = c[5]; + time[11] = '/'; + time[12] = c[6]; /*day*/ + time[13] = c[7]; + } + time[14] = '/'; + time[15] = c[0]; + time[16] = c[1]; + time[17] = c[2]; + time[18] = c[3]; + +/*start = 0, length = 7*/ + + proto_tree_add_string(tree, + hf_index, + tvb, + 0, + 7, + time); + free (time); + return 7; /* 7 octetes eaten*/ + +#.END + + diff --git a/asn1/camel/packet-camel-template.c b/asn1/camel/packet-camel-template.c index 102643e736..1adbee075c 100644 --- a/asn1/camel/packet-camel-template.c +++ b/asn1/camel/packet-camel-template.c @@ -2,6 +2,7 @@ * Routines for Camel * Copyright 2004, Tim Endean * Copyright 2005, Olivier Jacques + * Copyright 2005, Javier AcuÇña * Built from the gsm-map dissector Copyright 2004, Anders Broman * * Ethereal - Network traffic analyzer @@ -53,6 +54,8 @@ /* Initialize the protocol and registered fields */ int proto_camel = -1; +int date_format = 1; /*assume european date format */ +static int hf_digit = -1; static int hf_camel_invokeCmd = -1; /* Opcode */ static int hf_camel_invokeid = -1; /* INTEGER */ static int hf_camel_absent = -1; /* NULL */ @@ -102,6 +105,33 @@ static const true_false_string camel_extension_value = { "No Extension", "Extension" }; +#define EUROPEAN_DATE 1 +#define AMERICAN_DATE 2 + +static enum_val_t date_options[] = { + { "european", "DD/MM/YYYY", EUROPEAN_DATE }, + { "american", "MM/DD/YYYY", AMERICAN_DATE }, + { NULL, NULL, 0 } +}; + +static const value_string digit_value[] = { + { 0, "0"}, + { 1, "1"}, + { 2, "2"}, + { 3, "3"}, + { 4, "4"}, + { 5, "5"}, + { 6, "6"}, + { 7, "7"}, + { 8, "8"}, + { 9, "9"}, + { 10, "spare"}, + { 11, "spare"}, + { 12, "spare"}, + { 13, "spare"}, + { 0, NULL}}; + + static const value_string camel_nature_of_addr_indicator_values[] = { { 0x00, "unknown" }, { 0x01, "International Number" }, @@ -182,6 +212,13 @@ const value_string camel_opr_code_strings[] = { {83, "SendChargingInformationGPRS"} }; +char camel_number_to_char(int number) +{ + if (number < 10) + return (char) (number + 48 ); /* this is ASCII specific */ + else + return (char) (number + 55 ); +} static guint32 opcode=0; @@ -595,6 +632,11 @@ void proto_register_camel(void) { { "Address digits", "camel.address_digits", FT_STRING, BASE_NONE, NULL, 0, "Address digits", HFILL }}, + { &hf_digit, + { "Digit Value", "camel.digit_value", + FT_UINT8, BASE_DEC, + VALS(digit_value), + 0, "", HFILL }}, #ifdef REMOVED #endif #include "packet-camel-hfarr.c" @@ -629,6 +671,11 @@ void proto_register_camel(void) { camel_module = prefs_register_protocol(proto_camel, proto_reg_handoff_camel); + prefs_register_enum_preference(camel_module, "date format", "Date Format", + "The date format: (DD/MM) or (MM/DD)", + &date_format, date_options, FALSE); + + prefs_register_range_preference(camel_module, "tcap.ssn", "TCAP SSNs", "TCAP Subsystem numbers used for Camel", diff --git a/asn1/camel/packet-camel-template.h b/asn1/camel/packet-camel-template.h index 3e37f640f4..5d0470812e 100644 --- a/asn1/camel/packet-camel-template.h +++ b/asn1/camel/packet-camel-template.h @@ -32,6 +32,8 @@ #ifndef PACKET_camel_H #define PACKET_camel_H +char camel_number_to_char(int ); + /* Defines for the camel taps */ #define camel_MAX_NUM_OPR_CODES 256 @@ -40,4 +42,4 @@ ETH_VAR_IMPORT const value_string camel_opr_code_strings[]; static int dissect_camel_DestinationAddress(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_); /* #include "packet-camel-exp.h"*/ -#endif /* PACKET_camel_H */ \ No newline at end of file +#endif /* PACKET_camel_H */ -- cgit v1.2.3