aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-10 16:54:02 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-10 16:54:02 +0000
commitb97cfa22fdc00dbb2e8703ae1f4b8a7619d4d382 (patch)
treeb4e35edeb18125a40e127ec80090de39d8f174a4
parent22dcdd3f9ace3cac3523841545872d4b8a20f8b7 (diff)
offset_from_real_beginning() is only called with 0 as second argument, so remove the argument completely. It seems that the second argument only acts as an accumulator allowing offset_from_real_beginning() to call itself recursively. To be consistent offset_from_real_beginning() is renamed to tvb_offset_from_real_beginning().
svn path=/trunk/; revision=29844
-rw-r--r--asn1/snmp/packet-snmp-template.c6
-rw-r--r--epan/dissectors/packet-sccp.c2
-rw-r--r--epan/dissectors/packet-snmp.c34
-rw-r--r--epan/dissectors/packet-sua.c2
-rw-r--r--epan/libwireshark.def2
-rw-r--r--epan/tvbuff.c14
-rw-r--r--epan/tvbuff.h4
7 files changed, 35 insertions, 29 deletions
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c
index 6f99f14c1d..d703de9ecd 100644
--- a/asn1/snmp/packet-snmp-template.c
+++ b/asn1/snmp/packet-snmp-template.c
@@ -1431,7 +1431,7 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
usm_p.msg_tvb = tvb;
- usm_p.start_offset = offset_from_real_beginning(tvb,0) ;
+ usm_p.start_offset = tvb_offset_from_real_beginning(tvb);
usm_p.engine_tvb = NULL;
usm_p.user_tvb = NULL;
usm_p.auth_item = NULL;
@@ -1564,7 +1564,7 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
return length_remaining;
break;
}
-
+
/* There may be appended data after the SNMP data, so treat as raw
* data which needs to be dissected in case of UDP as UDP is PDU oriented.
*/
@@ -1606,7 +1606,7 @@ dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
/* then comes a length which spans the rest of the tvb */
offset = get_ber_length(tvb, offset, &tmp_length, &tmp_ind);
- /* if(tmp_length!=(guint32)tvb_reported_length_remaining(tvb, offset)){
+ /* if(tmp_length!=(guint32)tvb_reported_length_remaining(tvb, offset)){
* Losen the heuristic a bit to handle the case where data has intentionally
* been added after the snmp PDU ( UDP case)
*/
diff --git a/epan/dissectors/packet-sccp.c b/epan/dissectors/packet-sccp.c
index 7f999295b1..182b4237ae 100644
--- a/epan/dissectors/packet-sccp.c
+++ b/epan/dissectors/packet-sccp.c
@@ -2134,7 +2134,7 @@ dissect_sccp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *sccp_tree,
fragment_data *frag_msg = NULL;
guint32 source_local_ref=0;
guint8 more;
- guint msg_offset = offset_from_real_beginning(tvb,0);
+ guint msg_offset = tvb_offset_from_real_beginning(tvb);
/* Macro for getting pointer to mandatory variable parameters */
#define VARIABLE_POINTER(var, hf_var, ptr_size) \
diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c
index b6c6970239..080c5025f8 100644
--- a/epan/dissectors/packet-snmp.c
+++ b/epan/dissectors/packet-snmp.c
@@ -2041,7 +2041,7 @@ dissect_snmp_T_msgAuthenticationParameters(gboolean implicit_tag _U_, tvbuff_t *
offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_index, &usm_p.auth_tvb);
if (usm_p.auth_tvb) {
usm_p.auth_item = actx->created_item;
- usm_p.auth_offset = offset_from_real_beginning(usm_p.auth_tvb,0);
+ usm_p.auth_offset = tvb_offset_from_real_beginning(usm_p.auth_tvb);
}
@@ -2100,11 +2100,11 @@ dissect_snmp_T_msgFlags(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
if (parameter_tvb){
guint8 v3_flags = tvb_get_guint8(parameter_tvb, 0);
proto_tree* flags_tree = proto_item_add_subtree(actx->created_item,ett_msgFlags);
-
+
proto_tree_add_item(flags_tree, hf_snmp_v3_flags_report, parameter_tvb, 0, 1, FALSE);
proto_tree_add_item(flags_tree, hf_snmp_v3_flags_crypt, parameter_tvb, 0, 1, FALSE);
proto_tree_add_item(flags_tree, hf_snmp_v3_flags_auth, parameter_tvb, 0, 1, FALSE);
-
+
usm_p.encrypted = v3_flags & TH_CRYPT ? TRUE : FALSE;
usm_p.authenticated = v3_flags & TH_AUTH ? TRUE : FALSE;
}
@@ -2149,7 +2149,7 @@ dissect_snmp_T_msgSecurityParameters(gboolean implicit_tag _U_, tvbuff_t *tvb _U
#line 155 "snmp.cnf"
switch(MsgSecurityModel){
- case SNMP_SEC_USM: /* 3 */
+ case SNMP_SEC_USM: /* 3 */
offset = dissect_snmp_UsmSecurityParameters(FALSE, tvb, offset+2, actx, tree, -1);
usm_p.user_assoc = get_user_assoc(usm_p.engine_tvb, usm_p.user_tvb);
break;
@@ -2195,7 +2195,7 @@ dissect_snmp_T_encryptedPDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of
if( usm_p.encrypted && crypt_tvb
&& usm_p.user_assoc
&& usm_p.user_assoc->user.privProtocol ) {
-
+
const gchar* error = NULL;
proto_tree* encryptedpdu_tree = proto_item_add_subtree(actx->created_item,ett_encryptedPDU);
tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, &error );
@@ -2203,13 +2203,13 @@ dissect_snmp_T_encryptedPDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of
if (! cleartext_tvb) {
proto_item* cause = proto_tree_add_text(encryptedpdu_tree, crypt_tvb, 0, -1,
"Failed to decrypt encryptedPDU: %s", error);
-
+
expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN,
"Failed to decrypt encryptedPDU: %s", error);
if (check_col(actx->pinfo->cinfo, COL_INFO))
col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Failed to decrypt");
-
+
return offset;
} else {
proto_item* decrypted_item;
@@ -2218,19 +2218,19 @@ dissect_snmp_T_encryptedPDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of
if (! check_ScopedPdu(cleartext_tvb)) {
proto_item* cause = proto_tree_add_text(encryptedpdu_tree, cleartext_tvb, 0, -1,
"Decrypted data not formatted as expected, wrong key?");
-
+
expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN,
"Decrypted data not formatted as expected");
if (check_col(actx->pinfo->cinfo, COL_INFO))
col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Decrypted data not formatted as expected");
-
+
return offset;
}
-
+
add_new_data_source(actx->pinfo, cleartext_tvb, "Decrypted ScopedPDU");
-
+
decrypted_item = proto_tree_add_item(encryptedpdu_tree, hf_snmp_decryptedPDU,cleartext_tvb,0,-1,FALSE);
decrypted_tree = proto_item_add_subtree(decrypted_item,ett_decrypted);
dissect_snmp_ScopedPDU(FALSE, cleartext_tvb, 0, actx, decrypted_tree, -1);
@@ -2291,7 +2291,7 @@ dissect_snmp_SNMPv3Message(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off
proto_tree* authen_tree = proto_item_add_subtree(usm_p.auth_item,ett_authParameters);
guint8* calc_auth;
guint calc_auth_len;
-
+
usm_p.authOK = usm_p.user_assoc->user.authModel->authenticate( &usm_p, &calc_auth, &calc_auth_len, &error );
if (error) {
@@ -2300,11 +2300,11 @@ dissect_snmp_SNMPv3Message(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off
expert_add_info_format( actx->pinfo, authen_item, PI_MALFORMED, PI_ERROR, "Error while verifying Message authenticity: %s", error );
} else {
int severity;
- gchar* msg;
+ gchar* msg;
authen_item = proto_tree_add_boolean(authen_tree, hf_snmp_msgAuthentication, tvb, 0, 0, usm_p.authOK);
PROTO_ITEM_SET_GENERATED(authen_item);
-
+
if (usm_p.authOK) {
msg = "SNMP Authentication OK";
severity = PI_CHAT;
@@ -2623,7 +2623,7 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
usm_p.msg_tvb = tvb;
- usm_p.start_offset = offset_from_real_beginning(tvb,0) ;
+ usm_p.start_offset = tvb_offset_from_real_beginning(tvb);
usm_p.engine_tvb = NULL;
usm_p.user_tvb = NULL;
usm_p.auth_item = NULL;
@@ -2756,7 +2756,7 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
return length_remaining;
break;
}
-
+
/* There may be appended data after the SNMP data, so treat as raw
* data which needs to be dissected in case of UDP as UDP is PDU oriented.
*/
@@ -2798,7 +2798,7 @@ dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
/* then comes a length which spans the rest of the tvb */
offset = get_ber_length(tvb, offset, &tmp_length, &tmp_ind);
- /* if(tmp_length!=(guint32)tvb_reported_length_remaining(tvb, offset)){
+ /* if(tmp_length!=(guint32)tvb_reported_length_remaining(tvb, offset)){
* Losen the heuristic a bit to handle the case where data has intentionally
* been added after the snmp PDU ( UDP case)
*/
diff --git a/epan/dissectors/packet-sua.c b/epan/dissectors/packet-sua.c
index 9508663e6c..d14177698e 100644
--- a/epan/dissectors/packet-sua.c
+++ b/epan/dissectors/packet-sua.c
@@ -1911,7 +1911,7 @@ dissect_sua_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *sua_t
/* XXX: this might fail with multihomed SCTP (on a path failure during a call) */
sccp_assoc_info_t* assoc;
reset_sccp_assoc();
- assoc = get_sccp_assoc(pinfo, offset_from_real_beginning(message_tvb,0), srn, drn, message_type);
+ assoc = get_sccp_assoc(pinfo, tvb_offset_from_real_beginning(message_tvb), srn, drn, message_type);
if (assoc && assoc->curr_msg) {
pinfo->sccp_info = assoc->curr_msg;
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index b34eaf980e..ed41699179 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -605,7 +605,6 @@ nstime_to_msec
nstime_to_sec
nt_cmd_vals DATA
num_tree_types DATA
-offset_from_real_beginning
oid_add
oid_add_from_encoded
oid_add_from_string
@@ -1010,6 +1009,7 @@ tvb_new_child_real_data
tvb_new_subset
tvb_new_subset_remaining
tvb_offset_exists
+tvb_offset_from_real_beginning
tvb_pbrk_guint8
tvb_reported_length
tvb_reported_length_remaining
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 25dc16f675..97e9406598 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -328,7 +328,7 @@ tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, guint length, gint
if (tvb) {
tvb_set_child_real_data_tvbuff (parent, tvb);
}
-
+
return tvb;
}
@@ -410,7 +410,7 @@ compute_offset_length(guint tvb_length, guint tvb_reported_length, gint offset,
static gboolean
-check_offset_length_no_exception(guint tvb_length, guint tvb_reported_length, gint offset, gint length,
+check_offset_length_no_exception(guint tvb_length, guint tvb_reported_length, gint offset, gint length,
guint *offset_ptr, guint *length_ptr, int *exception)
{
guint end_offset;
@@ -804,8 +804,8 @@ first_real_data_ptr(tvbuff_t *tvb)
}
#endif
-int
-offset_from_real_beginning(tvbuff_t *tvb, int counter)
+static guint
+offset_from_real_beginning(tvbuff_t *tvb, guint counter)
{
tvbuff_t *member;
@@ -824,6 +824,12 @@ offset_from_real_beginning(tvbuff_t *tvb, int counter)
return 0;
}
+guint
+tvb_offset_from_real_beginning(tvbuff_t *tvb)
+{
+ return offset_from_real_beginning(tvb, 0);
+}
+
static const guint8*
composite_ensure_contiguous_no_exception(tvbuff_t *tvb, guint abs_offset,
guint abs_length)
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 8632b4da28..c60db6441f 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -304,11 +304,11 @@ extern gint tvb_reported_length_remaining(tvbuff_t *tvb, gint offset);
Also adjusts the data length. */
extern void tvb_set_reported_length(tvbuff_t*, guint);
-extern int offset_from_real_beginning(tvbuff_t *tvb, int counter);
+extern guint tvb_offset_from_real_beginning(tvbuff_t *tvb);
/* Returns the offset from the first byte of real data. */
#define TVB_RAW_OFFSET(tvb) \
- ((tvb->raw_offset==-1)?(tvb->raw_offset = offset_from_real_beginning(tvb, 0)):tvb->raw_offset)
+ ((tvb->raw_offset==-1)?(tvb->raw_offset = tvb_offset_from_real_beginning(tvb)):tvb->raw_offset)
/************** START OF ACCESSORS ****************/
/* All accessors will throw an exception if appropriate */