forked from osmocom/wireshark
From Tim Endean:
Small patch to ber.c The tcap dissector has been updated to use this length. I have not tested other asn.1 dissectors to ensure that they correctly use the indefinite encoding flag instead of the length value returning zero. There may also be some problems when re-assembly is needed, but the ability to deal with indefinite length is much more useful. For developers the get_ber_length now returns the length of the pdu including the EOC, where you have dissectors that use packet-ber.c the eoc may need to be dealt with separately. The tcap dissector has had numerous changes to make it less cluttered, and the useful feature of the previous version where a dialogue could be filtered out by selecting either the source or destination transaction ID has been incorporated into this version. svn path=/trunk/; revision=15414
This commit is contained in:
parent
eadeaedc34
commit
1e1df99990
|
@ -47,6 +47,7 @@ int proto_tcap = -1;
|
|||
static int hf_tcap_tag = -1;
|
||||
static int hf_tcap_length = -1;
|
||||
static int hf_tcap_data = -1;
|
||||
static int hf_tcap_tid = -1;
|
||||
#include "packet-tcap-hf.c"
|
||||
static guint tcap_itu_ssn = 106;
|
||||
|
||||
|
@ -56,6 +57,10 @@ static guint global_tcap_itu_ssn = 1;
|
|||
static gint ett_tcap = -1;
|
||||
static gint ett_param = -1;
|
||||
|
||||
static gint ett_otid = -1;
|
||||
static gint ett_dtid = -1;
|
||||
|
||||
|
||||
#include "packet-tcap-ett.c"
|
||||
|
||||
#define MAX_SSN 254
|
||||
|
@ -127,6 +132,8 @@ void proto_reg_handoff_tcap(void);
|
|||
/* this format is require because a script is used to build the C function
|
||||
that calls all the protocol registration.
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
proto_register_tcap(void)
|
||||
{
|
||||
|
@ -148,6 +155,11 @@ proto_register_tcap(void)
|
|||
FT_BYTES, BASE_HEX, NULL, 0,
|
||||
"", HFILL }
|
||||
},
|
||||
{ &hf_tcap_tid,
|
||||
{ "Transaction Id", "tcap.tid",
|
||||
FT_BYTES, BASE_HEX, NULL, 0,
|
||||
"", HFILL }
|
||||
},
|
||||
#include "packet-tcap-hfarr.c"
|
||||
};
|
||||
|
||||
|
@ -155,6 +167,8 @@ proto_register_tcap(void)
|
|||
static gint *ett[] = {
|
||||
&ett_tcap,
|
||||
&ett_param,
|
||||
&ett_otid,
|
||||
&ett_dtid,
|
||||
#include "packet-tcap-ettarr.c"
|
||||
};
|
||||
|
||||
|
@ -294,9 +308,13 @@ dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offs
|
|||
|
||||
proto_tree_add_uint(subtree, hf_tcap_length, tvb,
|
||||
tag_offset, len_offset-tag_offset, len);
|
||||
/* need to handle indefinite length */
|
||||
next_tvb = tvb_new_subset(tvb, offset, len, len);
|
||||
dissect_tcap_param(pinfo, subtree,next_tvb,0);
|
||||
if (len-(2*ind_field)) /*should always be positive unless we get an empty contructor pointless? */
|
||||
{
|
||||
next_tvb = tvb_new_subset(tvb, offset, len-(2*ind_field), len-(2*ind_field));
|
||||
dissect_tcap_param(pinfo, subtree,next_tvb,0);
|
||||
}
|
||||
if (ind_field)
|
||||
proto_tree_add_text(subtree, tvb, offset+len-2, 2, "CONSTRUCTOR EOC");
|
||||
offset += len;
|
||||
}
|
||||
else
|
||||
|
@ -311,9 +329,12 @@ dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offs
|
|||
|
||||
proto_tree_add_uint(subtree, hf_tcap_length, tvb,
|
||||
saved_offset+1, 1, len);
|
||||
next_tvb = tvb_new_subset(tvb, offset, len, len);
|
||||
dissect_ber_octet_string(TRUE, pinfo, tree, next_tvb, 0, hf_tcap_data,
|
||||
NULL);
|
||||
if (len) /* check for NULLS */
|
||||
{
|
||||
next_tvb = tvb_new_subset(tvb, offset, len, len);
|
||||
dissect_ber_octet_string(TRUE, pinfo, tree, next_tvb, 0, hf_tcap_data,
|
||||
NULL);
|
||||
}
|
||||
offset += len;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,130 +18,121 @@
|
|||
#.FIELD_RENAME
|
||||
|
||||
#.FN_BODY DialogueOC
|
||||
tvbuff_t *parameter_tvb;
|
||||
tvbuff_t *next_tvb;
|
||||
gint8 class;
|
||||
guint8 class;
|
||||
gboolean pc;
|
||||
gint32 tag;
|
||||
guint32 tag;
|
||||
guint32 len;
|
||||
gboolean ind_field;
|
||||
guint32 ind_field;
|
||||
|
||||
|
||||
offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
|
||||
offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
|
||||
next_tvb = tvb_new_subset(tvb, offset, len, len);
|
||||
offset = dissect_ber_octet_string(TRUE, pinfo, tree, next_tvb, 0, hf_index,
|
||||
¶meter_tvb);
|
||||
next_tvb = tvb_new_subset(tvb, offset, len-(2*ind_field), len-(2*ind_field));
|
||||
|
||||
|
||||
if (!parameter_tvb)
|
||||
return offset;
|
||||
dissect_tcap_ExternalPDU(TRUE, parameter_tvb, 2, pinfo, tree, -1);
|
||||
if (!next_tvb)
|
||||
return offset;
|
||||
|
||||
return offset+2;
|
||||
dissect_tcap_ExternalPDU(TRUE, next_tvb, 2, pinfo, tree, -1);
|
||||
|
||||
|
||||
return offset+len;
|
||||
|
||||
#.FN_BODY Dialog1
|
||||
tvbuff_t *parameter_tvb;
|
||||
tvbuff_t *next_tvb;
|
||||
gint8 class;
|
||||
guint8 class;
|
||||
gboolean pc;
|
||||
gint32 tag;
|
||||
guint32 tag;
|
||||
guint32 len;
|
||||
gboolean ind_field;
|
||||
guint32 ind_field;
|
||||
|
||||
|
||||
offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
|
||||
offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
|
||||
next_tvb = tvb_new_subset(tvb, offset, len, len);
|
||||
offset = dissect_ber_octet_string(TRUE, pinfo, tree, tvb, 0, hf_index,
|
||||
¶meter_tvb);
|
||||
|
||||
/*offset = dissect_ber_octet_string(TRUE, pinfo, tree, tvb, offset, hf_index,
|
||||
* ¶meter_tvb);
|
||||
*/
|
||||
if (!parameter_tvb)
|
||||
return offset;
|
||||
dissect_tcap_DialoguePDU(TRUE, parameter_tvb, 0, pinfo, tree, -1);
|
||||
dissect_tcap_DialoguePDU(TRUE, tvb, 0, pinfo, tree, -1);
|
||||
|
||||
return offset+len;
|
||||
|
||||
#.FN_BODY Parameter
|
||||
tvbuff_t *next_tvb;
|
||||
gint8 class;
|
||||
guint8 class;
|
||||
gboolean pc;
|
||||
gint32 tag;
|
||||
guint32 tag;
|
||||
guint32 len;
|
||||
gboolean ind_field;
|
||||
guint32 ind_field;
|
||||
|
||||
|
||||
offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
|
||||
offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
|
||||
offset = dissect_ber_octet_string(TRUE, pinfo, tree, tvb, 0, hf_index,
|
||||
&next_tvb);
|
||||
|
||||
if (!next_tvb)
|
||||
return offset;
|
||||
dissect_tcap_param(pinfo,tree,next_tvb,0);
|
||||
offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
|
||||
offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
|
||||
/* need to strip the EOC off the next_tvb */
|
||||
next_tvb = tvb_new_subset(tvb, offset, len-(2*ind_field), len-(2*ind_field));
|
||||
|
||||
if (!next_tvb)
|
||||
return offset;
|
||||
dissect_tcap_param(pinfo,tree,tvb,0);
|
||||
offset += len;
|
||||
return offset;
|
||||
|
||||
#.FN_BODY User_information
|
||||
tvbuff_t *parameter_tvb;
|
||||
tvbuff_t *next_tvb;
|
||||
gint8 class;
|
||||
guint8 class;
|
||||
gboolean pc;
|
||||
gint32 tag;
|
||||
guint32 tag;
|
||||
guint32 len;
|
||||
gboolean ind_field;
|
||||
guint32 ind_field;
|
||||
|
||||
|
||||
offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
|
||||
offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
|
||||
next_tvb = tvb_new_subset(tvb, offset, len, len);
|
||||
dissect_ber_octet_string(TRUE, pinfo, tree, next_tvb, 0, hf_index,
|
||||
¶meter_tvb);
|
||||
|
||||
if (parameter_tvb)
|
||||
dissect_tcap_UserInformation(TRUE, parameter_tvb, 0, pinfo, tree, -1);
|
||||
next_tvb = tvb_new_subset(tvb, offset, len-(2*ind_field), len-(2*ind_field));
|
||||
if (!next_tvb)
|
||||
return offset+len;
|
||||
dissect_tcap_UserInformation(TRUE, next_tvb, 0, pinfo, tree, -1);
|
||||
|
||||
|
||||
return offset+len;
|
||||
#.FN_BODY Component
|
||||
tvbuff_t *next_tvb;
|
||||
gint8 class;
|
||||
guint8 class;
|
||||
gboolean pc;
|
||||
gint32 tag;
|
||||
guint32 len;
|
||||
gboolean ind_field;
|
||||
guint32 tag;
|
||||
guint32 len, s_offset;
|
||||
guint32 ind_field;
|
||||
/*
|
||||
* ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it.
|
||||
*/
|
||||
ber_oid_dissector_table = find_dissector_table("ber.oid");
|
||||
tcap_itu_ssn_dissector_table = find_dissector_table("tcap.itu_ssn");
|
||||
|
||||
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
|
||||
s_offset = offset;
|
||||
offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
|
||||
offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
|
||||
/* we can believe the length now */
|
||||
next_tvb = tvb_new_subset(tvb, s_offset, len+(offset-s_offset), len+(offset-s_offset));
|
||||
if (!next_tvb)
|
||||
return offset+len;
|
||||
|
||||
dissect_ber_choice(pinfo, tree, next_tvb, 0,
|
||||
Component_choice, hf_index, ett_tcap_Component,NULL);
|
||||
|
||||
if (ber_oid_dissector_table && cur_oid){
|
||||
if(!dissector_try_string(ber_oid_dissector_table, cur_oid, next_tvb, pinfo, tcap_top_tree))
|
||||
{
|
||||
if (!dissector_try_port(tcap_itu_ssn_dissector_table, pinfo->match_port, next_tvb,pinfo, tcap_top_tree))
|
||||
dissect_ber_choice(pinfo, tree, next_tvb, 0,
|
||||
Component_choice, hf_index, ett_tcap_Component, NULL);
|
||||
dissector_try_port(tcap_itu_ssn_dissector_table, pinfo->match_port, next_tvb,pinfo, tcap_top_tree);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!dissector_try_port(tcap_itu_ssn_dissector_table, pinfo->match_port, next_tvb, pinfo, tcap_top_tree))
|
||||
dissect_ber_choice(pinfo, tree, next_tvb, 0,
|
||||
Component_choice, hf_index, ett_tcap_Component, NULL);
|
||||
|
||||
offset+=len;
|
||||
dissector_try_port(tcap_itu_ssn_dissector_table, pinfo->match_port, next_tvb, pinfo, tcap_top_tree);
|
||||
return offset+len;
|
||||
|
||||
#.FN_BODY Applicationcontext
|
||||
static char buffer[MAX_OID_STR_LEN];
|
||||
static char buffer[128];
|
||||
cur_oid = buffer;
|
||||
pinfo->private_data = buffer;
|
||||
offset = dissect_ber_object_identifier(FALSE, pinfo, tree, tvb, offset,
|
||||
hf_index, cur_oid);
|
||||
|
||||
#.FN_BODY UserInfoOID
|
||||
static char buffer[MAX_OID_STR_LEN];
|
||||
static char buffer[128];
|
||||
tcapext_oid = buffer;
|
||||
pinfo->private_data = buffer;
|
||||
offset = dissect_ber_object_identifier(FALSE, pinfo, tree, tvb, offset,
|
||||
|
@ -149,11 +140,11 @@ offset+=len;
|
|||
|
||||
#.FN_BODY ExternUserInfo
|
||||
tvbuff_t *next_tvb;
|
||||
gint8 class;
|
||||
guint8 class;
|
||||
gboolean pc;
|
||||
gint32 tag;
|
||||
guint32 tag;
|
||||
guint32 len, start_offset;
|
||||
gboolean ind_field;
|
||||
guint32 ind_field;
|
||||
/*
|
||||
* ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it.
|
||||
*/
|
||||
|
@ -161,14 +152,17 @@ ber_oid_dissector_table = find_dissector_table("ber.oid");
|
|||
start_offset = offset;
|
||||
offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
|
||||
offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
|
||||
/* Use the recived length, XXX What if it was indefenet? */
|
||||
/* Use the recived length, XXX What if it was indefenet? length is good now */
|
||||
next_tvb = tvb_new_subset(tvb, start_offset, len +(offset - start_offset), len+(offset - start_offset));
|
||||
if (!next_tvb)
|
||||
return offset+len;
|
||||
if (ber_oid_dissector_table && tcapext_oid){
|
||||
if(!dissector_try_string(ber_oid_dissector_table, tcapext_oid, next_tvb, pinfo, tcap_top_tree))
|
||||
{
|
||||
}
|
||||
}
|
||||
offset+=len;
|
||||
dissect_tcap_param(pinfo,tree,next_tvb,0);
|
||||
offset+=len;
|
||||
|
||||
|
||||
#.FN_BODY ANSIParameters
|
||||
|
@ -185,19 +179,21 @@ offset = dissect_ber_octet_string(TRUE, pinfo, tree, tvb, 0, hf_index,
|
|||
#.FN_BODY ComponentPDU
|
||||
tvbuff_t *next_tvb;
|
||||
|
||||
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
|
||||
next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_length_remaining(tvb, offset));
|
||||
|
||||
if (!dissector_try_port(tcap_ansi_ssn_dissector_table, pinfo->match_port, next_tvb, pinfo, tcap_top_tree))
|
||||
{
|
||||
offset = dissect_ber_choice(pinfo, tree, tvb, offset,
|
||||
ComponentPDU_choice, hf_index, ett_tcap_ComponentPDU, NULL);
|
||||
}
|
||||
|
||||
dissector_try_port(tcap_ansi_ssn_dissector_table, pinfo->match_port, next_tvb, pinfo, tcap_top_tree);
|
||||
|
||||
offset = dissect_ber_choice(pinfo, tree, tvb, offset,
|
||||
ComponentPDU_choice, hf_index, ett_tcap_ComponentPDU,NULL);
|
||||
|
||||
#.FN_BODY OrigTransactionID
|
||||
tvbuff_t *parameter_tvb;
|
||||
guint8 len, i;
|
||||
offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
|
||||
proto_item *tid_item;
|
||||
proto_tree *subtree;
|
||||
tid_item = proto_tree_add_text(tree, tvb, offset, -1, "Source Transaction ID");
|
||||
subtree = proto_item_add_subtree(tid_item, ett_otid);
|
||||
offset = dissect_ber_octet_string(implicit_tag, pinfo, subtree, tvb, offset, hf_tcap_tid,
|
||||
¶meter_tvb);
|
||||
|
||||
if (parameter_tvb){
|
||||
|
@ -209,12 +205,19 @@ if (parameter_tvb){
|
|||
col_append_fstr(pinfo->cinfo, COL_INFO, ") ");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#.FN_BODY DestTransactionID
|
||||
tvbuff_t *parameter_tvb;
|
||||
guint8 len , i;
|
||||
offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
|
||||
proto_item *tid_item;
|
||||
proto_tree *subtree;
|
||||
tid_item = proto_tree_add_text(tree, tvb, offset, -1, "Destination Transaction ID");
|
||||
subtree = proto_item_add_subtree(tid_item, ett_otid);
|
||||
offset = dissect_ber_octet_string(implicit_tag, pinfo, subtree, tvb, offset, hf_tcap_tid,
|
||||
¶meter_tvb);
|
||||
|
||||
if (parameter_tvb){
|
||||
len = tvb_length_remaining(parameter_tvb, 0);
|
||||
if ((len)&&(check_col(pinfo->cinfo, COL_INFO))){
|
||||
|
@ -269,5 +272,3 @@ if ((hf_index == hf_tcap_ansiconversationWithoutPerm)&&(check_col(pinfo->cinfo,
|
|||
TransactionPDU_sequence, hf_index, ett_tcap_TransactionPDU);
|
||||
|
||||
#.END
|
||||
|
||||
|
||||
|
|
|
@ -951,16 +951,6 @@ printf("SEQUENCE dissect_ber_sequence(%s) calling subdissector\n",name);
|
|||
}
|
||||
#endif
|
||||
count=seq->func(pinfo, tree, next_tvb, 0);
|
||||
if(!(seq->flags & BER_FLAGS_NOOWNTAG) ) {
|
||||
/* if we stripped the tag and length we should also strip the EOC is ind_len */
|
||||
if(ind_field == 1)
|
||||
{
|
||||
/* skip over EOC */
|
||||
if(show_internal_ber_fields){
|
||||
proto_tree_add_text(tree, tvb, offset, count, "SEQ FIELD EOC");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BER
|
||||
{
|
||||
|
@ -984,6 +974,17 @@ printf("SEQUENCE dissect_ber_sequence(%s) subdissector ate %d bytes\n",name,coun
|
|||
}
|
||||
offset = eoffset;
|
||||
seq++;
|
||||
if(!(seq->flags & BER_FLAGS_NOOWNTAG) ) {
|
||||
/* if we stripped the tag and length we should also strip the EOC is ind_len */
|
||||
if(ind_field == 1)
|
||||
{
|
||||
/* skip over EOC */
|
||||
if(show_internal_ber_fields){
|
||||
proto_tree_add_text(tree, tvb, offset, count, "SEQ FIELD EOC");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* if we didnt end up at exactly offset, then we ate too many bytes */
|
||||
|
@ -1213,16 +1214,6 @@ printf("SEQUENCE dissect_ber_sequence(%s) calling subdissector\n",name);
|
|||
}
|
||||
#endif
|
||||
count=seq->func(pinfo, tree, next_tvb, 0);
|
||||
if(!(seq->flags & BER_FLAGS_NOOWNTAG) ) {
|
||||
/* if we stripped the tag and length we should also strip the EOC is ind_len */
|
||||
if(ind_field == 1)
|
||||
{
|
||||
/* skip over EOC */
|
||||
if(show_internal_ber_fields){
|
||||
proto_tree_add_text(tree, tvb, offset, count, "SEQ FIELD EOC");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BER
|
||||
{
|
||||
|
@ -1246,6 +1237,17 @@ printf("SEQUENCE dissect_ber_sequence(%s) subdissector ate %d bytes\n",name,coun
|
|||
}
|
||||
offset = eoffset;
|
||||
seq++;
|
||||
if(!(seq->flags & BER_FLAGS_NOOWNTAG) ) {
|
||||
/* if we stripped the tag and length we should also strip the EOC is ind_len */
|
||||
if(ind_field == 1)
|
||||
{
|
||||
/* skip over EOC */
|
||||
if(show_internal_ber_fields){
|
||||
proto_tree_add_text(tree, tvb, offset, count, "SEQ FIELD EOC");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* if we didnt end up at exactly offset, then we ate too many bytes */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
/* Do not modify this file. */
|
||||
/* It is created automatically by the ASN.1 to Ethereal dissector compiler */
|
||||
/* ./packet-tcap.h */
|
||||
/* .\packet-tcap.h */
|
||||
/* ../../tools/asn2eth.py -X -b -e -p tcap -c tcap.cnf -s packet-tcap-template tcap.asn */
|
||||
|
||||
/* Input file: packet-tcap-template.h */
|
||||
|
|
Loading…
Reference in New Issue