summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2012-10-20 19:54:56 +0000
committerJakub Zawadzki <darkjames-ws@darkjames.pl>2012-10-20 19:54:56 +0000
commitb53dbea042a90e550fdc7e43c1453144510b6df1 (patch)
tree223164bfba38231813a640546a126319728a06fe
parent33b064cd812d228ccc5ee1d939fb77e677018a32 (diff)
downloadwireshark-b53dbea042a90e550fdc7e43c1453144510b6df1.tar.gz
Make data_source opqaue, add getter for tvb.
svn path=/trunk/; revision=45672
-rw-r--r--epan/frame_data.h10
-rw-r--r--epan/libwireshark.def1
-rw-r--r--epan/packet.c27
-rw-r--r--epan/packet.h7
-rw-r--r--epan/wslua/wslua_dumper.c6
-rw-r--r--print.c18
-rw-r--r--ui/gtk/packet_panes.c4
-rw-r--r--ui/gtk/packet_win.c4
-rw-r--r--ui/qt/packet_list.cpp6
9 files changed, 43 insertions, 40 deletions
diff --git a/epan/frame_data.h b/epan/frame_data.h
index 252a683be7..dc4f177a34 100644
--- a/epan/frame_data.h
+++ b/epan/frame_data.h
@@ -79,16 +79,6 @@ typedef struct {
} modified_frame_data;
#endif
-/**
- * A data source.
- * Has a tvbuff and a name.
- */
-typedef struct {
- tvbuff_t *tvb;
- gboolean name_initialized;
- const char *name;
-} data_source;
-
/* Utility routines used by packet*.c */
extern void p_add_proto_data(frame_data *fd, int proto, void *proto_data);
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index 6de632af9c..28eaadad69 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -568,6 +568,7 @@ get_column_width_string
get_datafile_dir
get_datafile_path
get_data_source_name
+get_data_source_tvb
get_dirname
get_dissector_table_selector_type
get_dissector_table_ui_name
diff --git a/epan/packet.c b/epan/packet.c
index a1287e112e..98daa470e3 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -60,6 +60,15 @@ static gint proto_malformed = -1;
static dissector_handle_t frame_handle = NULL;
static dissector_handle_t data_handle = NULL;
+/**
+ * A data source.
+ * Has a tvbuff and a name.
+ */
+struct data_source {
+ tvbuff_t *tvb;
+ const char *name;
+};
+
void
packet_init(void)
{
@@ -218,24 +227,24 @@ postseq_cleanup_all_protocols(void)
void
add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name)
{
- data_source *src;
+ struct data_source *src;
- src = ep_alloc(sizeof (data_source));
+ src = ep_alloc(sizeof (struct data_source));
src->tvb = tvb;
- src->name_initialized = FALSE;
src->name = name;
pinfo->data_src = g_slist_append(pinfo->data_src, src);
}
const char*
-get_data_source_name(data_source *src)
+get_data_source_name(const struct data_source *src)
{
- if (!src->name_initialized) {
- src->name = ep_strdup_printf("%s (%u bytes)", src->name, tvb_length(src->tvb));
- src->name_initialized = TRUE;
- }
+ return ep_strdup_printf("%s (%u bytes)", src->name, tvb_length(src->tvb));
+}
- return src->name;
+tvbuff_t *
+get_data_source_tvb(const struct data_source *src)
+{
+ return src->tvb;
}
/*
diff --git a/epan/packet.h b/epan/packet.h
index 588a1f9e6a..0d933994cd 100644
--- a/epan/packet.h
+++ b/epan/packet.h
@@ -414,10 +414,13 @@ final_registration_all_protocols(void);
extern void add_new_data_source(packet_info *pinfo, tvbuff_t *tvb,
const char *name);
+
/*
- * Return the data source name.
+ * Return the data source name, tvb.
*/
-extern const char* get_data_source_name(data_source *src);
+struct data_source;
+extern const char *get_data_source_name(const struct data_source *src);
+extern tvbuff_t *get_data_source_tvb(const struct data_source *src);
/*
* Free up a frame's list of data sources.
diff --git a/epan/wslua/wslua_dumper.c b/epan/wslua/wslua_dumper.c
index 14eb7d5bee..8b081f00ec 100644
--- a/epan/wslua/wslua_dumper.c
+++ b/epan/wslua/wslua_dumper.c
@@ -361,18 +361,18 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
struct wtap_pkthdr pkthdr;
const guchar* data;
tvbuff_t* tvb;
- data_source *data_src;
+ struct data_source *data_src;
int err = 0;
if (!d) return 0;
if (! lua_pinfo ) WSLUA_ERROR(Dumper_new_for_current,"Cannot be used outside a tap or a dissector");
- data_src = (data_source*) (lua_pinfo->data_src->data);
+ data_src = (struct data_source*) (lua_pinfo->data_src->data);
if (!data_src)
return 0;
- tvb = data_src->tvb;
+ tvb = get_data_source_tvb(data_src);
memset(&pkthdr, 0, sizeof(pkthdr));
diff --git a/print.c b/print.c
index 46240584df..4ea11443eb 100644
--- a/print.c
+++ b/print.c
@@ -709,7 +709,7 @@ proto_tree_write_carrays(guint32 num, FILE *fh, epan_dissect_t *edt)
{
guint32 i = 0, src_num = 0;
GSList *src_le;
- data_source *src;
+ struct data_source *src;
tvbuff_t *tvb;
const char *name;
const guchar *cp;
@@ -718,8 +718,8 @@ proto_tree_write_carrays(guint32 num, FILE *fh, epan_dissect_t *edt)
for (src_le = edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
memset(ascii, 0, sizeof(ascii));
- src = (data_source *)src_le->data;
- tvb = src->tvb;
+ src = (struct data_source *)src_le->data;
+ tvb = get_data_source_tvb(src);
length = tvb_length(tvb);
if (length == 0)
continue;
@@ -779,13 +779,13 @@ static const guint8 *
get_field_data(GSList *src_list, field_info *fi)
{
GSList *src_le;
- data_source *src;
+ struct data_source *src;
tvbuff_t *src_tvb;
gint length, tvbuff_length;
for (src_le = src_list; src_le != NULL; src_le = src_le->next) {
- src = (data_source *)src_le->data;
- src_tvb = src->tvb;
+ src = (struct data_source *)src_le->data;
+ src_tvb = get_data_source_tvb(src);
if (fi->ds_tvb == src_tvb) {
/*
* Found it.
@@ -878,7 +878,7 @@ print_hex_data(print_stream_t *stream, epan_dissect_t *edt)
{
gboolean multiple_sources;
GSList *src_le;
- data_source *src;
+ struct data_source *src;
tvbuff_t *tvb;
const char *name;
char *line;
@@ -895,8 +895,8 @@ print_hex_data(print_stream_t *stream, epan_dissect_t *edt)
for (src_le = edt->pi.data_src; src_le != NULL;
src_le = src_le->next) {
- src = (data_source *)src_le->data;
- tvb = src->tvb;
+ src = (struct data_source *)src_le->data;
+ tvb = get_data_source_tvb(src);
if (multiple_sources) {
name = get_data_source_name(src);
print_line(stream, 0, "");
diff --git a/ui/gtk/packet_panes.c b/ui/gtk/packet_panes.c
index 95af737f81..d327475577 100644
--- a/ui/gtk/packet_panes.c
+++ b/ui/gtk/packet_panes.c
@@ -499,7 +499,7 @@ add_byte_views(epan_dissect_t *edt, GtkWidget *tree_view,
GtkWidget *byte_nb_ptr)
{
GSList *src_le;
- data_source *src;
+ struct data_source *src;
/*
* Get rid of all the old notebook tabs.
@@ -513,7 +513,7 @@ add_byte_views(epan_dissect_t *edt, GtkWidget *tree_view,
*/
for (src_le = edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
src = src_le->data;
- add_byte_tab(byte_nb_ptr, get_data_source_name(src), src->tvb, edt->tree,
+ add_byte_tab(byte_nb_ptr, get_data_source_name(src), get_data_source_tvb(src), edt->tree,
tree_view);
}
diff --git a/ui/gtk/packet_win.c b/ui/gtk/packet_win.c
index da9183d1b7..522a9e2023 100644
--- a/ui/gtk/packet_win.c
+++ b/ui/gtk/packet_win.c
@@ -814,8 +814,8 @@ edit_pkt_win_key_pressed_cb(GtkWidget *win _U_, GdkEventKey *event, gpointer use
}
for (src_le = DataPtr->edt.pi.data_src; src_le != NULL; src_le = src_le->next) {
- const data_source *src = src_le->data;
- tvbuff_t *tvb = src->tvb;
+ const struct data_source *src = src_le->data;
+ tvbuff_t *tvb = get_data_source_tvb(src);
if (tvb && tvb->real_data == DataPtr->pd) {
ds_tvb = tvb;
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 84a0971608..510029907f 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -282,7 +282,7 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
if (byte_view_tab_ && cfile.edt) {
GSList *src_le;
- data_source *source;
+ struct data_source *source;
// Clear out existing tabs
while (byte_view_tab_->currentWidget()) {
@@ -290,8 +290,8 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
}
for (src_le = cfile.edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
- source = (data_source *)src_le->data;
- byte_view_tab_->addTab(get_data_source_name(source), source->tvb, cfile.edt->tree, proto_tree_, cfile.current_frame->flags.encoding);
+ source = (struct data_source *)src_le->data;
+ byte_view_tab_->addTab(get_data_source_name(source), get_data_source_tvb(source), cfile.edt->tree, proto_tree_, cfile.current_frame->flags.encoding);
}
}