diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-08-01 20:59:38 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-08-01 20:59:38 +0000 |
commit | 08eb36b5af5da365087ea19194a0a00bd1310ce2 (patch) | |
tree | bc8a0b2ba1a0816c79a164025e72873a4cbab715 /epan | |
parent | 6c5e16185dfd4c9e955618f56ac8827ad7eda9e7 (diff) |
Remove fdata->opt_comment, add pkt_comment to pinfo
Original (read from file) comments can be accessed by pkthdr->opt_comment
Keep user comments in seperated BST, add new method for epan session to get it.
svn path=/trunk/; revision=51090
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-frame.c | 8 | ||||
-rw-r--r-- | epan/epan-int.h | 2 | ||||
-rw-r--r-- | epan/epan.c | 9 | ||||
-rw-r--r-- | epan/epan.h | 2 | ||||
-rw-r--r-- | epan/frame_data.c | 7 | ||||
-rw-r--r-- | epan/frame_data.h | 3 | ||||
-rw-r--r-- | epan/packet.c | 6 | ||||
-rw-r--r-- | epan/packet_info.h | 1 | ||||
-rw-r--r-- | epan/wslua/wslua_dumper.c | 6 |
9 files changed, 30 insertions, 14 deletions
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index d5d7f48fff..0eccdba794 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -229,14 +229,14 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } } - if(pinfo->fd->opt_comment){ + if(pinfo->pkt_comment){ item = proto_tree_add_item(tree, proto_pkt_comment, tvb, 0, -1, ENC_NA); comments_tree = proto_item_add_subtree(item, ett_comments); comment_item = proto_tree_add_string_format(comments_tree, hf_comments_text, tvb, 0, -1, - pinfo->fd->opt_comment, "%s", - pinfo->fd->opt_comment); + pinfo->pkt_comment, "%s", + pinfo->pkt_comment); expert_add_info_format_text(pinfo, comment_item, &ei_comments_text, - "%s", pinfo->fd->opt_comment); + "%s", pinfo->pkt_comment); } diff --git a/epan/epan-int.h b/epan/epan-int.h index 0fa38d0427..7890cd51b4 100644 --- a/epan/epan-int.h +++ b/epan/epan-int.h @@ -24,6 +24,7 @@ #ifndef __EPAN_INT_H__ #define __EPAN_INT_H__ +#include <epan/frame_data.h> #include <wsutil/nstime.h> struct epan_session { @@ -31,6 +32,7 @@ struct epan_session { const nstime_t *(*get_frame_ts)(void *data, guint32 frame_num); const char *(*get_interface_name)(void *data, guint32 interface_id); + const char *(*get_user_comment)(void *data, const frame_data *fd); }; #endif diff --git a/epan/epan.c b/epan/epan.c index a18360d370..7d311a1027 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -149,6 +149,15 @@ epan_new(void) } const char * +epan_get_user_comment(const epan_t *session, const frame_data *fd) +{ + if (session->get_user_comment) + return session->get_user_comment(session->data, fd); + + return NULL; +} + +const char * epan_get_interface_name(const epan_t *session, guint32 interface_id) { if (session->get_interface_name) diff --git a/epan/epan.h b/epan/epan.h index 63d1e41828..f022cf2fa6 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -129,6 +129,8 @@ typedef struct epan_session epan_t; WS_DLL_PUBLIC epan_t *epan_new(void); +const char *epan_get_user_comment(const epan_t *session, const frame_data *fd); + const char *epan_get_interface_name(const epan_t *session, guint32 interface_id); const nstime_t *epan_get_frame_ts(const epan_t *session, guint32 frame_num); diff --git a/epan/frame_data.c b/epan/frame_data.c index a7d66c73bf..0b2d8b83bb 100644 --- a/epan/frame_data.c +++ b/epan/frame_data.c @@ -279,6 +279,7 @@ frame_data_init(frame_data *fdata, guint32 num, fdata->flags.ref_time = 0; fdata->flags.ignored = 0; fdata->flags.has_ts = (phdr->presence_flags & WTAP_HAS_TS) ? 1 : 0; + fdata->flags.has_phdr_comment = (phdr->opt_comment != NULL); fdata->color_filter = NULL; fdata->abs_ts.secs = phdr->ts.secs; fdata->abs_ts.nsecs = phdr->ts.nsecs; @@ -286,7 +287,6 @@ frame_data_init(frame_data *fdata, guint32 num, fdata->shift_offset.nsecs = 0; fdata->frame_ref_num = 0; fdata->prev_dis_num = 0; - fdata->opt_comment = phdr->opt_comment; } void @@ -357,11 +357,6 @@ frame_data_destroy(frame_data *fdata) g_slist_free(fdata->pfd); fdata->pfd = NULL; } - - if (fdata->opt_comment) { - g_free(fdata->opt_comment); - fdata->opt_comment = NULL; - } } /* diff --git a/epan/frame_data.h b/epan/frame_data.h index 2545b7577c..57f95e5c0b 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -73,6 +73,8 @@ typedef struct _frame_data { unsigned int ref_time : 1; /**< 1 = marked as a reference time frame, 0 = normal */ unsigned int ignored : 1; /**< 1 = ignore this frame, 0 = normal */ unsigned int has_ts : 1; /**< 1 = has time stamp, 0 = no time stamp */ + unsigned int has_phdr_comment : 1; /** 1 = there's comment for this packet */ + unsigned int has_user_comment : 1; /** 1 = user set (also deleted) comment for this packet */ } flags; const void *color_filter; /**< Per-packet matching color_filter_t object */ @@ -81,7 +83,6 @@ typedef struct _frame_data { nstime_t shift_offset; /**< How much the abs_tm of the frame is shifted */ guint32 frame_ref_num; /**< Previous reference frame (0 if this is one) */ guint32 prev_dis_num; /**< Previous displayed frame (0 if first one) */ - gchar *opt_comment; /**< NULL if not available */ } frame_data; #ifdef WANT_PACKET_EDITOR diff --git a/epan/packet.c b/epan/packet.c index 7680038b58..95f98678bc 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -358,6 +358,12 @@ dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr, frame_delta_abs_time(edt->session, fd, fd->frame_ref_num, &edt->pi.rel_ts); + /* pkt comment use first user, later from phdr */ + if (fd->flags.has_user_comment) + edt->pi.pkt_comment = epan_get_user_comment(edt->session, fd); + else + edt->pi.pkt_comment = phdr->opt_comment; + /* to enable decode as for ethertype=0x0000 (fix for bug 4721) */ edt->pi.ethertype = G_MAXINT; diff --git a/epan/packet_info.h b/epan/packet_info.h index 612c3cd1c2..33c899a429 100644 --- a/epan/packet_info.h +++ b/epan/packet_info.h @@ -227,6 +227,7 @@ typedef struct _packet_info { struct _wmem_allocator_t *pool; /**< Memory pool scoped to the pinfo struct */ struct epan_session *epan; nstime_t rel_ts; /**< Relative timestamp (yes, it can be negative) */ + const gchar *pkt_comment; /**< NULL if not available */ } packet_info; /**< For old code that hasn't yet been changed. */ diff --git a/epan/wslua/wslua_dumper.c b/epan/wslua/wslua_dumper.c index c29cf43d24..d4dd59eff5 100644 --- a/epan/wslua/wslua_dumper.c +++ b/epan/wslua/wslua_dumper.c @@ -317,7 +317,7 @@ WSLUA_METHOD Dumper_dump(lua_State* L) { pkthdr.pkt_encap = DUMPER_ENCAP(d); pkthdr.pseudo_header = *ph->wph; - /* TODO: Can we get access to pinfo->fd->opt_comment here somehow? We + /* TODO: Can we get access to pinfo->pkt_comment here somehow? We * should be copying it to pkthdr.opt_comment if we can. */ if (! wtap_dump(d, &pkthdr, ba->data, &err)) { @@ -409,8 +409,8 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) { pkthdr.pkt_encap = lua_pinfo->fd->lnk_t; pkthdr.pseudo_header = *lua_pinfo->pseudo_header; - if (lua_pinfo->fd->opt_comment) - pkthdr.opt_comment = ep_strdup(lua_pinfo->fd->opt_comment); + if (lua_pinfo->pkt_comment) + pkthdr.opt_comment = ep_strdup(lua_pinfo->pkt_comment); data = (const guchar *)ep_tvb_memdup(tvb,0,pkthdr.caplen); |