diff options
author | morriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-05-27 03:06:50 +0000 |
---|---|---|
committer | morriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-05-27 03:06:50 +0000 |
commit | 2dd3a926b3da7dcec405c7021d9bd9e79d9ece73 (patch) | |
tree | 87c08d45e5035c9e9755fd61766ae0c0cda51efe | |
parent | 484ab4ee0b38fbf46e0b6709729194026f01d5fa (diff) |
Make TVBs opaque for most users.
Convert TVB_RAW_OFFSET() and TVB_GET_DS_TVB() into functions.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@37422 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | asn1/h248/h248.cnf | 30 | ||||
-rw-r--r-- | epan/dissectors/packet-dcm.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-dtls.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-h248.c | 26 | ||||
-rw-r--r-- | epan/dissectors/packet-megaco.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-ssl.c | 6 | ||||
-rw-r--r-- | epan/libwireshark.def | 2 | ||||
-rw-r--r-- | epan/proto.c | 20 | ||||
-rw-r--r-- | epan/tvbuff-int.h | 91 | ||||
-rw-r--r-- | epan/tvbuff.c | 15 | ||||
-rw-r--r-- | epan/tvbuff.h | 75 | ||||
-rw-r--r-- | epan/wslua/init_wslua.c | 2 | ||||
-rw-r--r-- | epan/wslua/wslua_tvb.c | 2 | ||||
-rw-r--r-- | gtk/follow_udp.c | 1 | ||||
-rw-r--r-- | gtk/packet_win.c | 3 |
15 files changed, 164 insertions, 119 deletions
diff --git a/asn1/h248/h248.cnf b/asn1/h248/h248.cnf index 348929f4b1..2c5d941102 100644 --- a/asn1/h248/h248.cnf +++ b/asn1/h248/h248.cnf @@ -83,17 +83,17 @@ TransactionReply/transactionId trep_transactionId TransactionPending/transactionId tpend_transactionId #.FN_HDR Message - curr_info.msg = gcp_msg(actx->pinfo,TVB_RAW_OFFSET(tvb),keep_persistent_data); + curr_info.msg = gcp_msg(actx->pinfo,tvb_raw_offset(tvb),keep_persistent_data); #.END #.FN_FTR Message col_add_str(actx->pinfo->cinfo, COL_INFO, gcp_msg_to_str(curr_info.msg,keep_persistent_data)); - + if (keep_persistent_data) gcp_analyze_msg(h248_tree, h248_tvb, curr_info.msg, &h248_arrel); #.END -#.FN_BODY Message/version VAL_PTR = &h248_version +#.FN_BODY Message/version VAL_PTR = &h248_version %(DEFAULT_BODY)s #.END @@ -110,7 +110,7 @@ TransactionPending/transactionId tpend_transactionId curr_info.trx = gcp_trx(curr_info.msg, trx_id, GCP_TRX_PENDING, keep_persistent_data); error_code = 0; -#.FN_BODY TransactionReply/transactionId +#.FN_BODY TransactionReply/transactionId guint32 trx_id = 0; offset = dissect_h248_trx_id(implicit_tag, actx->pinfo, tree, tvb, offset, &trx_id); curr_info.trx = gcp_trx(curr_info.msg, trx_id, GCP_TRX_REPLY, keep_persistent_data); @@ -290,13 +290,13 @@ TransactionPending/transactionId tpend_transactionId #.FN_BODY ErrorDescriptor/errorCode offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_h248_error_code, &error_code); expert_add_info_format(actx->pinfo, actx->created_item, PI_RESPONSE_CODE, PI_WARN, "Errored Command"); - + if (curr_info.cmd) { gcp_cmd_set_error(curr_info.cmd,error_code); } else if (curr_info.trx) { gcp_trx_set_error(curr_info.trx,error_code); } - + return offset; #.END @@ -316,13 +316,13 @@ TransactionPending/transactionId tpend_transactionId wild_term = tvb_get_guint8(new_tvb,0) & 0x80 ? GCP_WILDCARD_CHOOSE : GCP_WILDCARD_ALL; /* limitation: assume only one wildcard is used */ wild_card = tvb_get_guint8(new_tvb,0); - + #.END #.FN_BODY TerminationID/id tvbuff_t* new_tvb; offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &new_tvb); - + if (new_tvb) { curr_info.term->len = tvb_length(new_tvb); curr_info.term->type = 0; /* unknown */ @@ -335,9 +335,9 @@ TransactionPending/transactionId tpend_transactionId curr_info.term = gcp_cmd_add_term(curr_info.msg, curr_info.trx, curr_info.cmd, curr_info.term, wild_term, keep_persistent_data); if (h248_term_handle) { - actx->pinfo->private_data = &wild_card; + actx->pinfo->private_data = &wild_card; call_dissector(h248_term_handle, new_tvb, actx->pinfo, tree); - wild_card = 0xFF; + wild_card = 0xFF; } } else { curr_info.term->len = 0; @@ -348,14 +348,14 @@ TransactionPending/transactionId tpend_transactionId #.FN_BODY SCreasonValue /* H248 v1 support */ - if ( h248_version >1 ) { + if ( h248_version >1 ) { /* Not V1, so call "standard" function */ -%(DEFAULT_BODY)s +%(DEFAULT_BODY)s } else { /* V1 so Value == octet string */ offset = dissect_h248_ValueV1( implicit_tag, tvb, offset, actx, tree, hf_index); }; - + #.END #.FN_BODY SCreasonValueOctetStr VAL_PTR = ¶meter_tvb @@ -380,14 +380,14 @@ TransactionPending/transactionId tpend_transactionId for( i=0;i<len;i++) { if(!isascii(tvb_get_guint8(tvb, offset+i)) || tvb_get_guint8(tvb, offset+i) == 0) { /* not ascii or NULL character so do string as hex string */ - proto_tree_add_text(tree, tvb, offset, len,"%s: 0x%s", + proto_tree_add_text(tree, tvb, offset, len,"%s: 0x%s", (proto_registrar_get_nth(hf_index))->name, tvb_bytes_to_str(tvb, 0, len)); return len; }; }; /* if here, then string is ascii */ - proto_tree_add_text(tree, tvb, offset, len,"%s: %s", + proto_tree_add_text(tree, tvb, offset, len,"%s: %s", (proto_registrar_get_nth(hf_index))->name, tvb_format_text(tvb, 0, len)); offset = len; diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c index 33a8958067..d629fe8df6 100644 --- a/epan/dissectors/packet-dcm.c +++ b/epan/dissectors/packet-dcm.c @@ -5150,7 +5150,7 @@ dissect_dcm_pdv_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, we need both values to uniquely identify a PDV */ - *pdv = dcm_state_pdv_get(pctx, pinfo->fd->num, TVB_RAW_OFFSET(tvb)+offset, TRUE); + *pdv = dcm_state_pdv_get(pctx, pinfo->fd->num, tvb_raw_offset(tvb)+offset, TRUE); if (*pdv == NULL) { return 0; /* Failed to allocate memory */ } diff --git a/epan/dissectors/packet-dtls.c b/epan/dissectors/packet-dtls.c index b87df025a4..b1ac0ed488 100644 --- a/epan/dissectors/packet-dtls.c +++ b/epan/dissectors/packet-dtls.c @@ -560,7 +560,7 @@ decrypt_dtls_record(tvbuff_t *tvb, packet_info *pinfo, guint32 offset, } if (ret && save_plaintext) { - ssl_add_data_info(proto_dtls, pinfo, dtls_decrypted_data.data, dtls_decrypted_data_avail, TVB_RAW_OFFSET(tvb)+offset, 0); + ssl_add_data_info(proto_dtls, pinfo, dtls_decrypted_data.data, dtls_decrypted_data_avail, tvb_raw_offset(tvb)+offset, 0); } return ret; @@ -791,7 +791,7 @@ dissect_dtls_record(tvbuff_t *tvb, packet_info *pinfo, decrypted = ssl_get_record_info(proto_dtls, pinfo, offset); if (decrypted) dissect_dtls_handshake(decrypted, pinfo, dtls_record_tree, 0, - decrypted->length, conv_version, ssl, content_type); + tvb_length(decrypted), conv_version, ssl, content_type); else dissect_dtls_handshake(tvb, pinfo, dtls_record_tree, offset, record_length, conv_version, ssl, content_type); @@ -821,7 +821,7 @@ dissect_dtls_record(tvbuff_t *tvb, packet_info *pinfo, association?association->info:"Application Data"); /* show decrypted data info, if available */ - appl_data = ssl_get_data_info(proto_dtls, pinfo, TVB_RAW_OFFSET(tvb)+offset); + appl_data = ssl_get_data_info(proto_dtls, pinfo, tvb_raw_offset(tvb)+offset); if (appl_data && (appl_data->plain_data.data_len > 0)) { tvbuff_t *next_tvb; diff --git a/epan/dissectors/packet-h248.c b/epan/dissectors/packet-h248.c index db038794fe..211f0ed29a 100644 --- a/epan/dissectors/packet-h248.c +++ b/epan/dissectors/packet-h248.c @@ -2014,13 +2014,13 @@ dissect_h248_T_errorCode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offse #line 291 "../../asn1/h248/h248.cnf" offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_h248_error_code, &error_code); expert_add_info_format(actx->pinfo, actx->created_item, PI_RESPONSE_CODE, PI_WARN, "Errored Command"); - + if (curr_info.cmd) { gcp_cmd_set_error(curr_info.cmd,error_code); } else if (curr_info.trx) { gcp_trx_set_error(curr_info.trx,error_code); } - + return offset; @@ -2127,7 +2127,7 @@ dissect_h248_WildcardField(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off wild_term = tvb_get_guint8(new_tvb,0) & 0x80 ? GCP_WILDCARD_CHOOSE : GCP_WILDCARD_ALL; /* limitation: assume only one wildcard is used */ wild_card = tvb_get_guint8(new_tvb,0); - + return offset; @@ -2153,7 +2153,7 @@ dissect_h248_T_terminationId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o #line 323 "../../asn1/h248/h248.cnf" tvbuff_t* new_tvb; offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &new_tvb); - + if (new_tvb) { curr_info.term->len = tvb_length(new_tvb); curr_info.term->type = 0; /* unknown */ @@ -2166,9 +2166,9 @@ dissect_h248_T_terminationId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o curr_info.term = gcp_cmd_add_term(curr_info.msg, curr_info.trx, curr_info.cmd, curr_info.term, wild_term, keep_persistent_data); if (h248_term_handle) { - actx->pinfo->private_data = &wild_card; + actx->pinfo->private_data = &wild_card; call_dissector(h248_term_handle, new_tvb, actx->pinfo, tree); - wild_card = 0xFF; + wild_card = 0xFF; } } else { curr_info.term->len = 0; @@ -4331,16 +4331,16 @@ static int dissect_h248_SCreasonValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { #line 350 "../../asn1/h248/h248.cnf" /* H248 v1 support */ - if ( h248_version >1 ) { + if ( h248_version >1 ) { /* Not V1, so call "standard" function */ offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset, SCreasonValue_sequence_of, hf_index, ett_h248_SCreasonValue); - + } else { /* V1 so Value == octet string */ offset = dissect_h248_ValueV1( implicit_tag, tvb, offset, actx, tree, hf_index); }; - + return offset; @@ -5157,14 +5157,14 @@ static const ber_sequence_t Message_sequence[] = { static int dissect_h248_Message(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { #line 86 "../../asn1/h248/h248.cnf" - curr_info.msg = gcp_msg(actx->pinfo,TVB_RAW_OFFSET(tvb),keep_persistent_data); + curr_info.msg = gcp_msg(actx->pinfo,tvb_raw_offset(tvb),keep_persistent_data); offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, Message_sequence, hf_index, ett_h248_Message); #line 90 "../../asn1/h248/h248.cnf" col_add_str(actx->pinfo->cinfo, COL_INFO, gcp_msg_to_str(curr_info.msg,keep_persistent_data)); - + if (keep_persistent_data) gcp_analyze_msg(h248_tree, h248_tvb, curr_info.msg, &h248_arrel); @@ -5251,14 +5251,14 @@ dissect_h248_ValueV1(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U for( i=0;i<len;i++) { if(!isascii(tvb_get_guint8(tvb, offset+i)) || tvb_get_guint8(tvb, offset+i) == 0) { /* not ascii or NULL character so do string as hex string */ - proto_tree_add_text(tree, tvb, offset, len,"%s: 0x%s", + proto_tree_add_text(tree, tvb, offset, len,"%s: 0x%s", (proto_registrar_get_nth(hf_index))->name, tvb_bytes_to_str(tvb, 0, len)); return len; }; }; /* if here, then string is ascii */ - proto_tree_add_text(tree, tvb, offset, len,"%s: %s", + proto_tree_add_text(tree, tvb, offset, len,"%s: %s", (proto_registrar_get_nth(hf_index))->name, tvb_format_text(tvb, 0, len)); offset = len; diff --git a/epan/dissectors/packet-megaco.c b/epan/dissectors/packet-megaco.c index dc8812698e..94147252e9 100644 --- a/epan/dissectors/packet-megaco.c +++ b/epan/dissectors/packet-megaco.c @@ -367,7 +367,7 @@ dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) return; } - msg = gcp_msg(pinfo, TVB_RAW_OFFSET(tvb), keep_persistent_data); + msg = gcp_msg(pinfo, tvb_raw_offset(tvb), keep_persistent_data); /* * Check to see whether we're really dealing with MEGACO by looking diff --git a/epan/dissectors/packet-ssl.c b/epan/dissectors/packet-ssl.c index dc9af25eac..9e4f1ee905 100644 --- a/epan/dissectors/packet-ssl.c +++ b/epan/dissectors/packet-ssl.c @@ -788,7 +788,7 @@ decrypt_ssl3_record(tvbuff_t *tvb, packet_info *pinfo, guint32 offset, ssl_data_set(data_for_iv, (guchar*)tvb_get_ptr(tvb, offset + record_length - data_for_iv_len, data_for_iv_len), data_for_iv_len); } if (ret && save_plaintext) { - ssl_add_data_info(proto_ssl, pinfo, ssl_decrypted_data.data, ssl_decrypted_data_avail, TVB_RAW_OFFSET(tvb)+offset, decoder->flow); + ssl_add_data_info(proto_ssl, pinfo, ssl_decrypted_data.data, ssl_decrypted_data_avail, tvb_raw_offset(tvb)+offset, decoder->flow); } return ret; } @@ -1234,7 +1234,7 @@ dissect_ssl_payload(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *t save_can_desegment = pinfo->can_desegment; /* show decrypted data info, if available */ - appl_data = ssl_get_data_info(proto_ssl, pinfo, TVB_RAW_OFFSET(tvb)+offset); + appl_data = ssl_get_data_info(proto_ssl, pinfo, tvb_raw_offset(tvb)+offset); if (!appl_data || !appl_data->plain_data.data_len) return; /* try to dissect decrypted data*/ @@ -1559,7 +1559,7 @@ dissect_ssl3_record(tvbuff_t *tvb, packet_info *pinfo, /* add desegmented data to the data source list */ add_new_data_source(pinfo, decrypted, "Decrypted SSL record"); dissect_ssl3_handshake(decrypted, pinfo, ssl_record_tree, 0, - decrypted->length, conv_version, ssl, content_type); + tvb_length(decrypted), conv_version, ssl, content_type); } else { dissect_ssl3_handshake(tvb, pinfo, ssl_record_tree, offset, record_length, conv_version, ssl, content_type); diff --git a/epan/libwireshark.def b/epan/libwireshark.def index c8a1e2f85e..dde4458c37 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -1077,6 +1077,7 @@ tvb_get_bits16 tvb_get_bits32 tvb_get_bits64 tvb_get_const_stringz +tvb_get_ds_tvb tvb_get_ephemeral_faked_unicode tvb_get_ephemeral_string tvb_get_ephemeral_stringz @@ -1126,6 +1127,7 @@ tvb_new_subset_remaining tvb_offset_exists tvb_offset_from_real_beginning tvb_pbrk_guint8 +tvb_raw_offset tvb_reported_length tvb_reported_length_remaining tvb_set_child_real_data_tvbuff diff --git a/epan/proto.c b/epan/proto.c index 6472cb3354..9884d9d400 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -273,7 +273,7 @@ static GMemChunk *gmc_hfinfo = NULL; /* Contains information about a field when a dissector calls * proto_tree_add_item. */ -static struct ws_memory_slab field_info_slab = +static struct ws_memory_slab field_info_slab = WS_MEMORY_SLAB_INIT(field_info, 128); static field_info *field_info_tmp=NULL; @@ -283,7 +283,7 @@ static field_info *field_info_tmp=NULL; sl_free(&field_info_slab, fi) /* Contains the space for proto_nodes. */ -static struct ws_memory_slab proto_node_slab = +static struct ws_memory_slab proto_node_slab = WS_MEMORY_SLAB_INIT(proto_node, 128); #define PROTO_NODE_NEW(node) \ @@ -296,7 +296,7 @@ static struct ws_memory_slab proto_node_slab = sl_free(&proto_node_slab, node) /* String space for protocol and field items for the GUI */ -static struct ws_memory_slab item_label_slab = +static struct ws_memory_slab item_label_slab = WS_MEMORY_SLAB_INIT(item_label_t, 128); #define ITEM_LABEL_NEW(il) \ @@ -3582,7 +3582,7 @@ new_field_info(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb, fi->hfinfo = hfinfo; fi->start = start; - fi->start+=(tvb)?TVB_RAW_OFFSET(tvb):0; + fi->start+=(tvb)?tvb_raw_offset(tvb):0; fi->length = item_length; fi->tree_type = -1; fi->flags = 0; @@ -3592,7 +3592,7 @@ new_field_info(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb, fi->rep = NULL; /* add the data source tvbuff */ - fi->ds_tvb=tvb?TVB_GET_DS_TVB(tvb):NULL; + fi->ds_tvb=tvb?tvb_get_ds_tvb(tvb):NULL; fi->appendix_start = 0; fi->appendix_length = 0; @@ -4124,7 +4124,7 @@ proto_item_set_end(proto_item *pi, tvbuff_t *tvb, gint end) if (fi == NULL) return; - end += TVB_RAW_OFFSET(tvb); + end += tvb_raw_offset(tvb); DISSECTOR_ASSERT(end >= fi->start); fi->length = end - fi->start; } @@ -4349,7 +4349,7 @@ proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, if (fi == NULL) return; - start += TVB_RAW_OFFSET(tvb); + start += tvb_raw_offset(tvb); DISSECTOR_ASSERT(start >= 0); DISSECTOR_ASSERT(length >= 0); @@ -5263,9 +5263,9 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_EUI64: integer64 = fvalue_get_integer64(&fi->value); g_snprintf(label_str, ITEM_LABEL_LENGTH, - "%s: %s (%s)", hfinfo->name, - get_eui64_name(integer64), - eui64_to_str(integer64)); + "%s: %s (%s)", hfinfo->name, + get_eui64_name(integer64), + eui64_to_str(integer64)); break; case FT_STRING: case FT_STRINGZ: diff --git a/epan/tvbuff-int.h b/epan/tvbuff-int.h new file mode 100644 index 0000000000..e09c76bd8f --- /dev/null +++ b/epan/tvbuff-int.h @@ -0,0 +1,91 @@ +/* tvbuff-int.h + * + * Structures that most TVB users should not be accessing directly. + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __TVBUFF_INT_H__ +#define __TVBUFF_INT_H__ + +typedef struct { + /** The backing tvbuff_t */ + struct tvbuff *tvb; + + /** The offset of 'tvb' to which I'm privy */ + guint offset; + /** The length of 'tvb' to which I'm privy */ + guint length; + +} tvb_backing_t; + +typedef struct { + GSList *tvbs; + + /* Used for quick testing to see if this + * is the tvbuff that a COMPOSITE is + * interested in. */ + guint *start_offsets; + guint *end_offsets; + +} tvb_comp_t; + +struct tvbuff { + /* Record-keeping */ + tvbuff_type type; + gboolean initialized; + guint usage_count; + struct tvbuff *ds_tvb; /**< data source top-level tvbuff */ + + /** The tvbuffs in which this tvbuff is a member + * (that is, a backing tvbuff for a TVBUFF_SUBSET + * or a member for a TVB_COMPOSITE) */ + GSList *used_in; + + /** TVBUFF_SUBSET and TVBUFF_COMPOSITE keep track + * of the other tvbuff's they use */ + union { + tvb_backing_t subset; + tvb_comp_t composite; + } tvbuffs; + + /** We're either a TVBUFF_REAL_DATA or a + * TVBUFF_SUBSET that has a backing buffer that + * has real_data != NULL, or a TVBUFF_COMPOSITE + * which has flattened its data due to a call + * to tvb_get_ptr(). + */ + const guint8 *real_data; + + /** Length of virtual buffer (and/or real_data). */ + guint length; + + /** Reported length. */ + guint reported_length; + + /* Offset from beginning of first TVBUFF_REAL. */ + gint raw_offset; + + /** Func to call when actually freed */ + tvbuff_free_cb_t free_cb; +}; + +#endif diff --git a/epan/tvbuff.c b/epan/tvbuff.c index c56b1d511a..24196cfb1b 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -47,6 +47,7 @@ #include "pint.h" #include "tvbuff.h" +#include "tvbuff-int.h" #include "strutil.h" #include "emem.h" #include "proto.h" /* XXX - only used for DISSECTOR_ASSERT, probably a new header file? */ @@ -3544,7 +3545,8 @@ tvb_uncompress(tvbuff_t *tvb _U_, const int offset _U_, int comprlen _U_) } #endif -tvbuff_t* tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, const int offset, int comprlen) +tvbuff_t * +tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, const int offset, int comprlen) { tvbuff_t *new_tvb = tvb_uncompress(tvb, offset, comprlen); if (new_tvb) @@ -3552,3 +3554,14 @@ tvbuff_t* tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, const int offset return new_tvb; } +gint +tvb_raw_offset(tvbuff_t *tvb) +{ + return ((tvb->raw_offset==-1)?(tvb->raw_offset = tvb_offset_from_real_beginning(tvb)):tvb->raw_offset); +} + +struct tvbuff * +tvb_get_ds_tvb(tvbuff_t *tvb) +{ + return(tvb->ds_tvb); +} diff --git a/epan/tvbuff.h b/epan/tvbuff.h index 1c2acbe765..74bdeed12f 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -58,71 +58,8 @@ typedef enum { TVBUFF_COMPOSITE } tvbuff_type; -typedef struct { - /** The backing tvbuff_t */ - struct tvbuff *tvb; - - /** The offset of 'tvb' to which I'm privy */ - guint offset; - /** The length of 'tvb' to which I'm privy */ - guint length; - -} tvb_backing_t; - -typedef struct { - GSList *tvbs; - - /* Used for quick testing to see if this - * is the tvbuff that a COMPOSITE is - * interested in. */ - guint *start_offsets; - guint *end_offsets; - -} tvb_comp_t; - -typedef void (*tvbuff_free_cb_t)(void*); - -typedef struct tvbuff { - /* Record-keeping */ - tvbuff_type type; - gboolean initialized; - guint usage_count; - struct tvbuff *ds_tvb; /**< data source top-level tvbuff */ - - /** The tvbuffs in which this tvbuff is a member - * (that is, a backing tvbuff for a TVBUFF_SUBSET - * or a member for a TVB_COMPOSITE) */ - GSList *used_in; - - /** TVBUFF_SUBSET and TVBUFF_COMPOSITE keep track - * of the other tvbuff's they use */ - union { - tvb_backing_t subset; - tvb_comp_t composite; - } tvbuffs; - - /** We're either a TVBUFF_REAL_DATA or a - * TVBUFF_SUBSET that has a backing buffer that - * has real_data != NULL, or a TVBUFF_COMPOSITE - * which has flattened its data due to a call - * to tvb_get_ptr(). - */ - const guint8 *real_data; - - /** Length of virtual buffer (and/or real_data). */ - guint length; - - /** Reported length. */ - guint reported_length; - - /* Offset from beginning of first TVBUFF_REAL. */ - gint raw_offset; - - /** Func to call when actually freed */ - tvbuff_free_cb_t free_cb; -} tvbuff_t; - - +struct tvbuff; +typedef struct tvbuff tvbuff_t; /** TVBUFF_REAL_DATA contains a guint8* that points to real data. * The data is allocated and contiguous. @@ -142,6 +79,8 @@ typedef struct tvbuff { * you want a tvbuff that points to other data. */ +typedef void (*tvbuff_free_cb_t)(void*); + /** "class" initialization. Called once during execution of program * so that tvbuff.c can initialize its data. */ @@ -308,8 +247,7 @@ extern void tvb_set_reported_length(tvbuff_t*, const guint); extern guint tvb_offset_from_real_beginning(const 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 = tvb_offset_from_real_beginning(tvb)):tvb->raw_offset) +extern gint tvb_raw_offset(tvbuff_t *tvb); /************** START OF ACCESSORS ****************/ /* All accessors will throw an exception if appropriate */ @@ -691,8 +629,7 @@ dgt_set_t; extern gchar *tvb_bcd_dig_to_ep_str(tvbuff_t *tvb, const gint offset, const gint len, dgt_set_t *dgt, gboolean skip_first); -#define TVB_GET_DS_TVB(tvb) \ - (tvb->ds_tvb) +struct tvbuff *tvb_get_ds_tvb(tvbuff_t *tvb); /** Locate a sub-tvbuff within another tvbuff, starting at position * 'haystack_offset'. Returns the index of the beginning of 'needle' within diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index 15f192a7d7..a1a9b2ab32 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -65,7 +65,7 @@ static int wslua_not_register_menu(lua_State* LS) { } int dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) { - int consumed_bytes = tvb->length; + int consumed_bytes = tvb_length(tvb); lua_pinfo = pinfo; lua_tvb = tvb; diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c index 222e42d9fb..254a1c01c0 100644 --- a/epan/wslua/wslua_tvb.c +++ b/epan/wslua/wslua_tvb.c @@ -475,7 +475,7 @@ WSLUA_METHOD Tvb_offset(lua_State* L) { return 0; } - lua_pushnumber(L,TVB_RAW_OFFSET(tvb->ws_tvb)); + lua_pushnumber(L,tvb_raw_offset(tvb->ws_tvb)); WSLUA_RETURN(1); /* The raw offset of the Tvb. */ } diff --git a/gtk/follow_udp.c b/gtk/follow_udp.c index 81af8f3378..30cfda4c10 100644 --- a/gtk/follow_udp.c +++ b/gtk/follow_udp.c @@ -36,6 +36,7 @@ #include <epan/ipproto.h> #include <epan/strutil.h> #include <epan/tap.h> +#include <epan/tvbuff-int.h> #include <../simple_dialog.h> diff --git a/gtk/packet_win.c b/gtk/packet_win.c index 6355e1fa58..0c5c85c63e 100644 --- a/gtk/packet_win.c +++ b/gtk/packet_win.c @@ -53,6 +53,7 @@ #include <epan/plugins.h> #include <epan/epan_dissect.h> #include <epan/strutil.h> +#include <epan/tvbuff-int.h> #include "../file.h" #include "../print.h" @@ -838,7 +839,7 @@ edit_pkt_destroy_new_window(GtkObject *object _U_, gpointer user_data) /* XXX, notify main packet list that packet should be redisplayed */ } -static gint g_direct_compare_func(gconstpointer a, gconstpointer b, gpointer user_data _U_) { +static gint g_direct_compare_func(gconstpointer a, gconstpointer b, gpointer user_data _U_) { if (a > b) return 1; else if (a < b) |