diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-07-11 05:47:02 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-07-11 05:47:02 +0000 |
commit | ce81449ed9294f0104598762ce293c3521820987 (patch) | |
tree | 26efdeea2934c6e99869fc3e5761451043dc3e05 /epan | |
parent | 19d2d0dc765cd2417d693746226472207190434a (diff) |
packet dissection now takes pointer to tvb instead of guint8 data
implement frame_tvbuff, right now almost a copy of 'real' tvb.
svn path=/trunk/; revision=50497
Diffstat (limited to 'epan')
-rw-r--r-- | epan/epan.c | 8 | ||||
-rw-r--r-- | epan/epan.h | 4 | ||||
-rw-r--r-- | epan/packet.c | 29 | ||||
-rw-r--r-- | epan/packet.h | 2 | ||||
-rw-r--r-- | epan/tvbuff.c | 2 | ||||
-rw-r--r-- | epan/tvbuff.h | 2 |
6 files changed, 12 insertions, 35 deletions
diff --git a/epan/epan.c b/epan/epan.c index 47cfada4bb..554e86e2ea 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -197,13 +197,13 @@ epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols) void epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr, - const guint8* data, frame_data *fd, column_info *cinfo) + tvbuff_t *tvb, frame_data *fd, column_info *cinfo) { #ifdef HAVE_LUA wslua_prime_dfilter(edt); /* done before entering wmem scope */ #endif wmem_enter_packet_scope(); - dissect_packet(edt, phdr, data, fd, cinfo); + dissect_packet(edt, phdr, tvb, fd, cinfo); /* free all memory allocated */ ep_free_all(); @@ -212,11 +212,11 @@ epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr, void epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr, - const guint8* data, frame_data *fd, column_info *cinfo) + tvbuff_t *tvb, frame_data *fd, column_info *cinfo) { wmem_enter_packet_scope(); tap_queue_init(edt); - dissect_packet(edt, phdr, data, fd, cinfo); + dissect_packet(edt, phdr, tvb, fd, cinfo); tap_push_tapped_queue(edt); /* free all memory allocated */ diff --git a/epan/epan.h b/epan/epan.h index e138362df4..6882947c17 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -158,12 +158,12 @@ epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols); WS_DLL_PUBLIC void epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr, - const guint8* data, frame_data *fd, column_info *cinfo); + tvbuff_t *tvb, frame_data *fd, column_info *cinfo); WS_DLL_PUBLIC void epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr, - const guint8* data, frame_data *fd, column_info *cinfo); + tvbuff_t *tvb, frame_data *fd, column_info *cinfo); /** Prime a proto_tree using the fields/protocols used in a dfilter. */ WS_DLL_PUBLIC diff --git a/epan/packet.c b/epan/packet.c index ef62e803c2..43f15d89e2 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -320,7 +320,7 @@ final_registration_all_protocols(void) /* Creates the top-most tvbuff and calls dissect_frame() */ void dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr, - const guchar *pd, frame_data *fd, column_info *cinfo) + tvbuff_t *tvb, frame_data *fd, column_info *cinfo) { /* We have to preserve the pool pointer across the memzeroing */ wmem_allocator_t *tmp = edt->pi.pool; @@ -348,7 +348,7 @@ dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr, edt->pi.annex_a_used = MTP2_ANNEX_A_USED_UNKNOWN; edt->pi.dcerpc_procedure_name=""; edt->pi.link_dir = LINK_DIR_UNKNOWN; - edt->tvb = NULL; + edt->tvb = tvb; /* to enable decode as for ethertype=0x0000 (fix for bug 4721) */ edt->pi.ethertype = G_MAXINT; @@ -356,31 +356,6 @@ dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr, EP_CHECK_CANARY(("before dissecting frame %d",fd->num)); TRY { - /* - * XXX - currently, the length arguments to - * tvb_new_real_data() are signed, but the captured - * and reported length values are unsigned; this means - * that length values > 2^31 - 1 will appear as - * negative lengths in tvb_new_real_data(). - * - * Captured length values that large will already - * have been filtered out by the Wiretap modules - * (the file will be reported as corrupted), to - * avoid trying to allocate large chunks of data. - * - * Reported length values will not have been - * filtered out, and should not be filtered out, - * as those lengths are not necessarily invalid. - * - * For now, we clip the reported length at G_MAXINT, - * so that tvb_new_real_data() doesn't fail. It - * would throw an exception, which we'd catch, but - * that would mean we would have no tvbuffs - * associated with edt, which would upset much of - * the rest of the application. - */ - edt->tvb = tvb_new_real_data(pd, fd->cap_len, - fd->pkt_len > G_MAXINT ? G_MAXINT : fd->pkt_len); /* Add this tvbuffer into the data_src list */ add_new_data_source(&edt->pi, edt->tvb, "Frame"); diff --git a/epan/packet.h b/epan/packet.h index a1d3c5a6f6..2d1e231a75 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -442,7 +442,7 @@ WS_DLL_PUBLIC void mark_frame_as_depended_upon(packet_info *pinfo, guint32 frame * Dissectors should never modify the packet data. */ extern void dissect_packet(epan_dissect_t *edt, - struct wtap_pkthdr *phdr, const guchar *pd, + struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd, column_info *cinfo); /* These functions are in packet-ethertype.c */ diff --git a/epan/tvbuff.c b/epan/tvbuff.c index e504f0c8aa..bd1b644bfd 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -62,7 +62,7 @@ ensure_contiguous_no_exception(tvbuff_t *tvb, const gint offset, const gint leng static guint64 _tvb_get_bits64(tvbuff_t *tvb, guint bit_offset, const gint total_no_of_bits); -static tvbuff_t * +tvbuff_t * tvb_new(const struct tvb_ops *ops) { tvbuff_t *tvb; diff --git a/epan/tvbuff.h b/epan/tvbuff.h index e8530d1e53..a15f174b71 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -113,6 +113,8 @@ typedef struct tvbuff tvbuff_t; typedef void (*tvbuff_free_cb_t)(void*); +WS_DLL_PUBLIC tvbuff_t *tvb_new(const struct tvb_ops *ops) + /** Extracts 'number of bits' starting at 'bit offset'. * Returns a pointer to a newly initialized ep_alloc'd REAL_DATA * tvbuff with the bits octet aligned. |