aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2006-02-07 19:29:51 +0000
committerAnders Broman <anders.broman@ericsson.com>2006-02-07 19:29:51 +0000
commitb7cff15f97835b20ed607c96330a487afc530b65 (patch)
treea100d7dbca53f0cf44cb72154c0007e2098cce17
parent4df342823aee170ecc008fd0495278a721c0d555 (diff)
Packet-bssap.c - Dissect BCD coded IE:s
Packet-g723.c - B0 and B1 should be treated together. packet-tipc.c - Change desgementation code to handle more than 2 segments. svn path=/trunk/; revision=17204
-rw-r--r--epan/dissectors/packet-bssap.c135
-rw-r--r--epan/dissectors/packet-g723.c50
-rw-r--r--epan/dissectors/packet-tipc.c28
3 files changed, 168 insertions, 45 deletions
diff --git a/epan/dissectors/packet-bssap.c b/epan/dissectors/packet-bssap.c
index fba7120346..f390de1969 100644
--- a/epan/dissectors/packet-bssap.c
+++ b/epan/dissectors/packet-bssap.c
@@ -51,6 +51,8 @@
#include "epan/packet.h"
#include <epan/prefs.h>
+#include <epan/emem.h>
+
#include "packet-bssap.h"
#include "packet-gsm_a.h"
#include "packet-e212.h"
@@ -282,6 +284,7 @@ static int hf_bssap_extension = -1;
static int hf_bssap_type_of_number = -1;
static int hf_bssap_numbering_plan_id = -1;
static int hf_bssap_sgsn_number = -1;
+static int hf_bssap_vlr_number = -1;
static int hf_bssap_call_priority = -1;
static int hf_bssap_gprs_loc_upd_type_ie = -1;
static int hf_bssap_Gs_cause_ie = -1;
@@ -296,6 +299,9 @@ static int hf_bssap_gprs_erroneous_msg_ie = -1;
static int hf_bssap_gprs_loc_upd_type = -1;
static int hf_bssap_Gs_cause = -1;
+static int hf_bssap_imei = -1;
+static int hf_bssap_imeisv = -1;
+static int hf_bssap_imsi = -1;
static int hf_bssap_imsi_det_from_gprs_serv_type = -1;
static int hf_bssap_info_req = -1;
static int hf_bssap_loc_inf_age = -1;
@@ -581,6 +587,70 @@ dissect_bssap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
dissect_bssap_message(tvb, pinfo, bssap_tree, tree);
}
+
+/*
+ * BSSAP+ Routines
+ */
+
+typedef struct dgt_set_t
+{
+ unsigned char out[15];
+}
+dgt_set_t;
+
+static dgt_set_t Dgt_tbcd = {
+ {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e */
+ '0','1','2','3','4','5','6','7','8','9','?','B','C','*','#'
+ }
+};
+static dgt_set_t Dgt1_9_bcd = {
+ {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e */
+ '0','1','2','3','4','5','6','7','8','9','?','?','?','?','?'
+ }
+};
+/* Assumes the rest of the tvb contains the digits to be turned into a string
+ */
+static char*
+unpack_digits(tvbuff_t *tvb, int offset,dgt_set_t *dgt,gboolean skip_first){
+
+ int length;
+ guint8 octet;
+ int i=0;
+ char *digit_str;
+
+ length = tvb_length(tvb);
+ if (length < offset)
+ return "";
+ digit_str = ep_alloc((length - offset)*2+1);
+
+ while ( offset < length ){
+
+ octet = tvb_get_guint8(tvb,offset);
+ if (!skip_first){
+ digit_str[i] = dgt->out[octet & 0x0f];
+ i++;
+ }
+ skip_first = FALSE;
+
+ /*
+ * unpack second value in byte
+ */
+ octet = octet >> 4;
+
+ if (octet == 0x0f) /* odd number bytes - hit filler */
+ break;
+
+ digit_str[i] = dgt->out[octet & 0x0f];
+ i++;
+ offset++;
+
+ }
+ digit_str[i]= '\0';
+ return digit_str;
+}
+
static gboolean
check_ie(tvbuff_t *tvb, proto_tree *tree, int *offset, guint8 expected_ie){
guint8 ie_type;
@@ -860,7 +930,9 @@ dissect_bssap_imei(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offs
proto_item *item = NULL;
proto_tree *ie_tree = NULL;
guint8 ie_len;
-
+ tvbuff_t *ie_tvb;
+ char *digit_str;
+
ie_len = tvb_get_guint8(tvb,offset+1);
item = proto_tree_add_item(tree, hf_bssap_imei_ie, tvb, offset, ie_len+2, FALSE);
ie_tree = proto_item_add_subtree(item, ett_bassp_imei);
@@ -872,8 +944,9 @@ dissect_bssap_imei(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offs
/* The IMEI is coded as a sequence of BCD digits, compressed two into each octet.
* The IMEI consists of 15 digits (see 3GPP TS 23.003).
*/
- proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, FALSE);
-
+ ie_tvb = tvb_new_subset(tvb, offset, ie_len, ie_len);
+ digit_str = unpack_digits(ie_tvb, 0, &Dgt1_9_bcd, FALSE);
+ proto_tree_add_string(ie_tree, hf_bssap_imei, ie_tvb, 0, -1, digit_str);
return offset + ie_len;
@@ -885,6 +958,8 @@ dissect_bssap_imesiv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of
proto_item *item = NULL;
proto_tree *ie_tree = NULL;
guint8 ie_len;
+ tvbuff_t *ie_tvb;
+ char *digit_str;
ie_len = tvb_get_guint8(tvb,offset+1);
item = proto_tree_add_item(tree, hf_bssap_imesiv_ie, tvb, offset, ie_len+2, FALSE);
@@ -897,7 +972,9 @@ dissect_bssap_imesiv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of
/* The IMEISV is coded as a sequence of BCD digits, compressed two into each octet.
* The IMEISV consists of 16 digits (see 3GPP TS 23.003).
*/
- proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, FALSE);
+ ie_tvb = tvb_new_subset(tvb, offset, ie_len, ie_len);
+ digit_str = unpack_digits(ie_tvb, 0, &Dgt1_9_bcd, FALSE);
+ proto_tree_add_string(ie_tree, hf_bssap_imeisv, ie_tvb, 0, -1, digit_str);
return offset + ie_len;
@@ -915,6 +992,8 @@ dissect_bssap_imsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offs
proto_item *item = NULL;
proto_tree *ie_tree = NULL;
guint8 ie_len;
+ tvbuff_t *ie_tvb;
+ char *digit_str;
ie_len = tvb_get_guint8(tvb,offset+1);
item = proto_tree_add_item(tree, hf_bssap_imsi_ie, tvb, offset, ie_len+2, FALSE);
@@ -924,9 +1003,10 @@ dissect_bssap_imsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offs
offset++;
proto_tree_add_item(ie_tree, hf_bssap_plus_ie_len, tvb, offset, 1, FALSE);
offset++;
- proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, FALSE);
-
-
+ ie_tvb = tvb_new_subset(tvb, offset, ie_len,ie_len);
+ digit_str = unpack_digits(ie_tvb, 0, &Dgt1_9_bcd, TRUE);
+ proto_tree_add_string(ie_tree, hf_bssap_imsi, ie_tvb, 0, -1, digit_str);
+
return offset + ie_len;
}
@@ -1263,7 +1343,6 @@ dissect_bssap_service_area_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
*/
proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, FALSE);
-
return offset + ie_len;
}
@@ -1281,6 +1360,8 @@ dissect_bssap_sgsn_number(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i
proto_item *item = NULL;
proto_tree *ie_tree = NULL;
guint8 ie_len;
+ tvbuff_t *number_tvb;
+ char *digit_str;
ie_len = tvb_get_guint8(tvb,offset+1);
item = proto_tree_add_item(tree, hf_bssap_sgsn_nr_ie, tvb, offset, ie_len+2, FALSE);
@@ -1296,10 +1377,16 @@ dissect_bssap_sgsn_number(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i
* and includes a length indicator. The value part of the SGSN number information element
* (not including IEI, Length indicator and Octet 3) shall not exceed 15 digits.
*/
- proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, FALSE);
+ proto_tree_add_item(ie_tree, hf_bssap_extension, tvb, offset, 1, FALSE);
+ proto_tree_add_item(ie_tree, hf_bssap_type_of_number, tvb, offset, 1, FALSE);
+ proto_tree_add_item(ie_tree, hf_bssap_numbering_plan_id, tvb, offset, 1, FALSE);
+ offset++;
+ number_tvb = tvb_new_subset(tvb, offset, ie_len-1,ie_len-1);
+ digit_str = unpack_digits(number_tvb, 0, &Dgt1_9_bcd, FALSE);
+ proto_tree_add_string(ie_tree, hf_bssap_sgsn_number, number_tvb, 0, -1, digit_str);
- return offset + ie_len;
+ return offset + ie_len-1;
}
/* 18.4.23 TMSI */
@@ -1412,6 +1499,8 @@ dissect_bssap_vlr_number(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in
proto_item *item = NULL;
proto_tree *ie_tree = NULL;
guint8 ie_len;
+ tvbuff_t *number_tvb;
+ char *digit_str;
ie_len = tvb_get_guint8(tvb,offset+1);
item = proto_tree_add_item(tree, hf_bssap_vlr_number_ie, tvb, offset, ie_len+2, FALSE);
@@ -1427,10 +1516,16 @@ dissect_bssap_vlr_number(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in
* and includes a length indicator. The value part of the VLR number information element
* (not including IEI, length indicator and Octet 3), shall not exceed 15 digits.
*/
- proto_tree_add_item(ie_tree, hf_bssap_plus_ie_data, tvb, offset, ie_len, FALSE);
+ proto_tree_add_item(ie_tree, hf_bssap_extension, tvb, offset, 1, FALSE);
+ proto_tree_add_item(ie_tree, hf_bssap_type_of_number, tvb, offset, 1, FALSE);
+ proto_tree_add_item(ie_tree, hf_bssap_numbering_plan_id, tvb, offset, 1, FALSE);
+ offset++;
+ number_tvb = tvb_new_subset(tvb, offset, ie_len-1,ie_len-1);
+ digit_str = unpack_digits(number_tvb, 0, &Dgt1_9_bcd, FALSE);
+ proto_tree_add_string(ie_tree, hf_bssap_sgsn_number, number_tvb, 0, -1, digit_str);
- return offset + ie_len;
+ return offset + ie_len-1;
}
/* 18.4.27 Global CN-Id */
@@ -2091,6 +2186,10 @@ proto_register_bssap(void)
{ "SGSN number", "bssap.sgsn_number",
FT_STRING, BASE_NONE, NULL, 0,
"SGSN number", HFILL }},
+ { &hf_bssap_vlr_number,
+ { "VLR number", "bssap.vlr_number",
+ FT_STRING, BASE_NONE, NULL, 0,
+ "VLR number", HFILL }},
{ &hf_bssap_cell_global_id_ie,
{ "Cell global identity IE", "bssap.cell_global_id_ie",
FT_NONE, BASE_NONE, NULL, 0,
@@ -2221,6 +2320,18 @@ proto_register_bssap(void)
{ "Gs cause", "bssap.gprs_loc_upd_type",
FT_UINT8, BASE_DEC, VALS(bssap_Gs_cause_values), 0x0,
"Gs cause", HFILL}},
+ { &hf_bssap_imei,
+ { "IMEI", "bssap.imei",
+ FT_STRING, BASE_NONE, NULL, 0,
+ "IMEI", HFILL }},
+ { &hf_bssap_imeisv,
+ { "IMEISV", "bssap.imeisv",
+ FT_STRING, BASE_NONE, NULL, 0,
+ "IMEISV", HFILL }},
+ { &hf_bssap_imsi,
+ { "IMSI", "bssap.imsi",
+ FT_STRING, BASE_NONE, NULL, 0,
+ "IMSI", HFILL }},
{ &hf_bssap_imsi_det_from_gprs_serv_type,
{ "IMSI detach from GPRS service type", "bssap.imsi_det_from_gprs_serv_type",
FT_UINT8, BASE_DEC, VALS(bssap_Gs_cause_values), 0x0,
diff --git a/epan/dissectors/packet-g723.c b/epan/dissectors/packet-g723.c
index 6bbdf2be31..b01dab3f59 100644
--- a/epan/dissectors/packet-g723.c
+++ b/epan/dissectors/packet-g723.c
@@ -40,21 +40,30 @@
/* Initialize the protocol and registered fields */
-static int proto_g723 = -1;
-static int hf_g723_rate_flag = -1;
-static int hf_g723_vad_flag = -1;
-static int hf_g723_lpc_B5_B0 = -1;
+static int proto_g723 = -1;
+static int hf_g723_frame_size_and_codec = -1;
+static int hf_g723_lpc_B5_B0 = -1;
/* Initialize the subtree pointers */
static int ett_g723 = -1;
-static const true_false_string g723_rate_flag_vals = {
- "Low rate(5.3kb/s)",
- "High rate(6.3kb/s)"
-};
-static const true_false_string g723_vad_flag_vals = {
- "Non-speech",
- "Speech"
+
+/* RFC 3551
+ The least significant two bits of the first
+ octet in the frame determine the frame size and codec type:
+ bits content octets/frame
+ 00 high-rate speech (6.3 kb/s) 24
+ 01 low-rate speech (5.3 kb/s) 20
+ 10 SID frame 4
+ 11 reserved
+
+ */
+static const value_string g723_frame_size_and_codec_type_value[] = {
+ {0, "High-rate speech (6.3 kb/s)"},
+ {1, "Low-rate speech (5.3 kb/s)"}, /* Not coded */
+ {2, "SID frame"},
+ {3, "Reserved"},
+ { 0, NULL }
};
@@ -78,17 +87,11 @@ dissect_g723(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
g723_tree = proto_item_add_subtree(ti, ett_g723);
octet = tvb_get_guint8(tvb,offset);
- proto_tree_add_item(g723_tree, hf_g723_rate_flag, tvb, offset, 1, FALSE);
- proto_tree_add_item(g723_tree, hf_g723_vad_flag, tvb, offset, 1, FALSE);
+ proto_tree_add_item(g723_tree, hf_g723_frame_size_and_codec, tvb, offset, 1, FALSE);
proto_tree_add_item(g723_tree, hf_g723_lpc_B5_B0, tvb, offset, 1, FALSE);
if ((offset & 0x1) == 1 ) /* Low rate */
return;
-
-
-
-
-
}/* if tree */
}
@@ -121,16 +124,11 @@ proto_register_g723(void)
/* Setup list of header fields See Section 1.6.1 for details*/
static hf_register_info hf[] = {
- { &hf_g723_rate_flag,
- { "RATEFLAG_B0", "g723.rate.flag",
- FT_BOOLEAN, 8, TFS(&g723_rate_flag_vals), 0x01,
+ { &hf_g723_frame_size_and_codec,
+ { "Frame size and codec type", "g723.frame_size_and_codec",
+ FT_UINT8, BASE_HEX, VALS(g723_frame_size_and_codec_type_value), 0x03,
"RATEFLAG_B0", HFILL }
},
- { &hf_g723_vad_flag,
- { "VADFLAG_B0", "g723.vad.flag",
- FT_BOOLEAN, 8, TFS(&g723_vad_flag_vals), 0x02,
- "VADFLAG_B0", HFILL }
- },
{ &hf_g723_lpc_B5_B0,
{ "LPC_B5...LPC_B0", "g723.lpc.b5b0",
FT_UINT8, BASE_HEX, NULL, 0xfc,
diff --git a/epan/dissectors/packet-tipc.c b/epan/dissectors/packet-tipc.c
index 358ce7ca52..a703e6a36a 100644
--- a/epan/dissectors/packet-tipc.c
+++ b/epan/dissectors/packet-tipc.c
@@ -107,6 +107,10 @@ static gint ett_tipc_data = -1;
static gboolean tipc_defragment = TRUE;
static gboolean dissect_tipc_data = FALSE;
+static gboolean extra_ethertype = FALSE;
+
+#define ETHERTYPE_TIPC2 0x0807
+
dissector_handle_t ip_handle;
proto_tree *top_tree;
@@ -348,11 +352,13 @@ dissect_tipc_int_prot_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tipc_tr
guint8 link_sel;
guint16 link_lev_seq_no;
guint32 reassembled_msg_length = 0;
+ guint32 no_of_segments = 0;
gboolean save_fragmented;
tvbuff_t* new_tvb = NULL;
tvbuff_t* next_tvb = NULL;
fragment_data *frag_msg = NULL;
+ proto_item *item;
link_lev_seq_no = tvb_get_ntohl(tvb,4) & 0xffff;
/* Internal Protocol Header */
@@ -468,8 +474,16 @@ dissect_tipc_int_prot_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tipc_tr
TRUE); /* More fragments? */
if (msg_type == TIPC_FIRST_SEGMENT ){
reassembled_msg_length = tvb_get_ntohl(tvb,offset) & 0x1ffff;
- /* This currently only works with two segments */
- fragment_set_tot_len(pinfo, link_sel, tipc_msg_fragment_table, 1);
+ /* The number of segments needed fot he complete message (Including header) will be
+ * The size of the data section of the first message, divided by the complete message size
+ * + one segment for the remainder (if any).
+ */
+ no_of_segments = reassembled_msg_length/(msg_size - 28);
+ if (reassembled_msg_length > (no_of_segments * (msg_size - 28)))
+ no_of_segments++;
+ fragment_set_tot_len(pinfo, link_sel, tipc_msg_fragment_table, no_of_segments-1);
+ item = proto_tree_add_text(tipc_tree, tvb, offset, -1,"Segmented message size %u bytes -> No segments = %i",reassembled_msg_length,no_of_segments);
+ PROTO_ITEM_SET_GENERATED(item);
}
new_tvb = process_reassembled_data(tvb, offset, pinfo,
@@ -731,7 +745,7 @@ dissect_tipc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if ( hdr_size > 8){
if (user == TIPC_NAME_DISTRIBUTOR ){
/*
- Although an internal service, the name distributor uses the full 40-byte “external” data header
+ Although an internal service, the name distributor uses the full 40-byte "external" data header
format when updating the naming table instances. This is because its messages may need
routing, - all system processor must contain the publications from all device processors and
vice versa, whether they are directly linked or not. The fields name type, name instance, and
@@ -761,7 +775,7 @@ dissect_tipc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
case TIPC_NAMED_MSG:
data_tvb = tvb_new_subset(tipc_tvb, offset+14, -1, -1);
proto_tree_add_text(tipc_tree, tipc_tvb, offset, 14,"TIPC_NAMED_MSG Hdr");
- call_dissector(ip_handle, data_tvb, pinfo, top_tree);
+ proto_tree_add_text(tipc_tree, data_tvb,0, -1,"%u bytes Data",(msg_size - hdr_size *4));
return;
break;
case TIPC_DIRECT_MSG:
@@ -1065,10 +1079,8 @@ proto_register_tipc(void)
"Dissect TIPC data",
"Whether to try to dissect TIPC data or not",
&dissect_tipc_data);
-
}
-
void
proto_reg_handoff_tipc(void)
{
@@ -1076,6 +1088,8 @@ proto_reg_handoff_tipc(void)
tipc_handle = create_dissector_handle(dissect_tipc, proto_tipc);
dissector_add("ethertype", ETHERTYPE_TIPC, tipc_handle);
-
+ if (extra_ethertype)
+ dissector_add("ethertype", ETHERTYPE_TIPC2, tipc_handle);
+
ip_handle = find_dissector("ip");
}