aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
Diffstat (limited to 'epan')
-rw-r--r--epan/Makefile.common1
-rw-r--r--epan/column-utils.c13
-rw-r--r--epan/column-utils.h4
-rw-r--r--epan/column_info.h1
-rw-r--r--epan/dissectors/packet-frame.c4
-rw-r--r--epan/epan-int.h6
-rw-r--r--epan/epan.c14
-rw-r--r--epan/epan.h2
-rw-r--r--epan/frame_data.c39
-rw-r--r--epan/frame_data.h15
-rw-r--r--epan/packet.c3
-rw-r--r--epan/packet_info.h1
-rw-r--r--epan/wslua/wslua_pinfo.c8
13 files changed, 68 insertions, 43 deletions
diff --git a/epan/Makefile.common b/epan/Makefile.common
index 480f16ce22..7ca9b04dd6 100644
--- a/epan/Makefile.common
+++ b/epan/Makefile.common
@@ -178,6 +178,7 @@ LIBWIRESHARK_INCLUDES = \
dtd_parse.h \
eap.h \
emem.h \
+ epan-int.h \
epan.h \
epan_dissect.h \
etypes.h \
diff --git a/epan/column-utils.c b/epan/column-utils.c
index 3e93858879..6b25b7e97c 100644
--- a/epan/column-utils.c
+++ b/epan/column-utils.c
@@ -104,7 +104,7 @@ col_cleanup(column_info *cinfo)
/* Initialize the data structures for constructing column data. */
void
-col_init(column_info *cinfo)
+col_init(column_info *cinfo, const struct epan_session *epan)
{
int i;
@@ -119,6 +119,7 @@ col_init(column_info *cinfo)
cinfo->col_expr.col_expr_val[i][0] = '\0';
}
cinfo->writable = TRUE;
+ cinfo->epan = epan;
}
#define COL_GET_WRITABLE(cinfo) (cinfo ? cinfo->writable : FALSE)
@@ -996,7 +997,7 @@ col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
{
nstime_t del_cap_ts;
- frame_delta_abs_time(fd, fd->prev_cap, &del_cap_ts);
+ frame_delta_abs_time(cinfo->epan, fd, fd->num - 1, &del_cap_ts);
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
@@ -1026,7 +1027,7 @@ col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col)
return;
}
- frame_delta_abs_time(fd, fd->prev_dis, &del_dis_ts);
+ frame_delta_abs_time(cinfo->epan, fd, fd->prev_dis_num, &del_dis_ts);
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
@@ -1193,7 +1194,7 @@ col_set_epoch_time(const frame_data *fd, column_info *cinfo, const int col)
}
void
-set_fd_time(frame_data *fd, gchar *buf)
+set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
{
switch (timestamp_get_type()) {
@@ -1226,7 +1227,7 @@ set_fd_time(frame_data *fd, gchar *buf)
if (fd->flags.has_ts) {
nstime_t del_cap_ts;
- frame_delta_abs_time(fd, fd->prev_cap, &del_cap_ts);
+ frame_delta_abs_time(epan, fd, fd->num - 1, &del_cap_ts);
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
@@ -1247,7 +1248,7 @@ set_fd_time(frame_data *fd, gchar *buf)
if (fd->flags.has_ts) {
nstime_t del_dis_ts;
- frame_delta_abs_time(fd, fd->prev_dis, &del_dis_ts);
+ frame_delta_abs_time(epan, fd, fd->prev_dis_num, &del_dis_ts);
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
diff --git a/epan/column-utils.h b/epan/column-utils.h
index 2ede25f9ad..e903314691 100644
--- a/epan/column-utils.h
+++ b/epan/column-utils.h
@@ -58,7 +58,7 @@ WS_DLL_PUBLIC void col_cleanup(column_info *cinfo);
*
* Internal, don't use this in dissectors!
*/
-extern void col_init(column_info *cinfo);
+extern void col_init(column_info *cinfo, const struct epan_session *epan);
/** Fill in all columns of the given packet which are based on values from frame_data.
*
@@ -262,7 +262,7 @@ WS_DLL_PUBLIC void col_append_sep_fstr(column_info *cinfo, const gint col, const
WS_DLL_PUBLIC void col_set_time(column_info *cinfo, const int col,
const nstime_t *ts, const char *fieldname);
-WS_DLL_PUBLIC void set_fd_time(frame_data *fd, gchar *buf);
+WS_DLL_PUBLIC void set_fd_time(const struct epan_session *epan, frame_data *fd, gchar *buf);
#ifdef __cplusplus
}
diff --git a/epan/column_info.h b/epan/column_info.h
index c9e70b1554..5e5c151b9f 100644
--- a/epan/column_info.h
+++ b/epan/column_info.h
@@ -46,6 +46,7 @@ typedef struct {
/** Column info */
typedef struct _column_info {
+ const struct epan_session *epan;
gint num_cols; /**< Number of columns */
gint *col_fmt; /**< Format of column */
gboolean **fmt_matx; /**< Specifies which formats apply to a column */
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index 8064e12109..2cafc0d51e 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -334,7 +334,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
if (proto_field_is_referenced(tree, hf_frame_time_delta)) {
nstime_t del_cap_ts;
- frame_delta_abs_time(pinfo->fd, pinfo->fd->prev_cap, &del_cap_ts);
+ frame_delta_abs_time(pinfo->epan, pinfo->fd, pinfo->fd->num - 1, &del_cap_ts);
item = proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb,
0, 0, &(del_cap_ts));
@@ -344,7 +344,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
if (proto_field_is_referenced(tree, hf_frame_time_delta_displayed)) {
nstime_t del_dis_ts;
- frame_delta_abs_time(pinfo->fd, pinfo->fd->prev_dis, &del_dis_ts);
+ frame_delta_abs_time(pinfo->epan, pinfo->fd, pinfo->fd->prev_dis_num, &del_dis_ts);
item = proto_tree_add_time(fh_tree, hf_frame_time_delta_displayed, tvb,
0, 0, &(del_dis_ts));
diff --git a/epan/epan-int.h b/epan/epan-int.h
index aa5aa16c5c..6580c55c26 100644
--- a/epan/epan-int.h
+++ b/epan/epan-int.h
@@ -24,8 +24,12 @@
#ifndef __EPAN_INT_H__
#define __EPAN_INT_H__
+#include <wsutil/nstime.h>
+
struct epan_session {
- void *reserved;
+ void *data;
+
+ const nstime_t *(*get_frame_ts)(void *data, guint32 frame_num);
};
#endif
diff --git a/epan/epan.c b/epan/epan.c
index 276caf6a68..e3a0b2bb17 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -146,6 +146,20 @@ epan_new(void)
return session;
}
+const nstime_t *
+epan_get_frame_ts(const epan_t *session, guint32 frame_num)
+{
+ nstime_t *abs_ts = NULL;
+
+ if (session->get_frame_ts)
+ abs_ts = session->get_frame_ts(session->data, frame_num);
+
+ if (!abs_ts)
+ g_warning("!!! couldn't get frame ts for %u !!!\n", frame_num);
+
+ return abs_ts;
+}
+
void
epan_free(epan_t *session)
{
diff --git a/epan/epan.h b/epan/epan.h
index 263a80f353..252d748ee8 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 nstime_t *epan_get_frame_ts(const epan_t *session, guint32 frame_num);
+
WS_DLL_PUBLIC void epan_free(epan_t *session);
WS_DLL_PUBLIC const gchar*
diff --git a/epan/frame_data.c b/epan/frame_data.c
index 63d980592b..8dec16cd47 100644
--- a/epan/frame_data.c
+++ b/epan/frame_data.c
@@ -154,10 +154,12 @@ p_get_proto_name_and_key(frame_data *fd, guint pfd_index){
#define COMPARE_TS(ts) COMPARE_TS_REAL(fdata1->ts, fdata2->ts)
void
-frame_delta_abs_time(const frame_data *fdata, const frame_data *prev, nstime_t *delta)
+frame_delta_abs_time(const struct epan_session *epan, const frame_data *fdata, guint32 prev_num, nstime_t *delta)
{
- if (prev) {
- nstime_delta(delta, &fdata->abs_ts, &prev->abs_ts);
+ const nstime_t *prev_abs_ts = (prev_num) ? epan_get_frame_ts(epan, prev_num) : NULL;
+
+ if (prev_abs_ts) {
+ nstime_delta(delta, &fdata->abs_ts, prev_abs_ts);
} else {
/* If we don't have the time stamp of the previous packet,
it's because we have no displayed/captured packets prior to this.
@@ -167,29 +169,29 @@ frame_delta_abs_time(const frame_data *fdata, const frame_data *prev, nstime_t *
}
static gint
-frame_data_time_delta_compare(const frame_data *fdata1, const frame_data *fdata2)
+frame_data_time_delta_compare(const struct epan_session *epan, const frame_data *fdata1, const frame_data *fdata2)
{
nstime_t del_cap_ts1, del_cap_ts2;
- frame_delta_abs_time(fdata1, fdata1->prev_cap, &del_cap_ts1);
- frame_delta_abs_time(fdata2, fdata2->prev_cap, &del_cap_ts2);
+ frame_delta_abs_time(epan, fdata1, fdata1->num - 1, &del_cap_ts1);
+ frame_delta_abs_time(epan, fdata2, fdata2->num - 1, &del_cap_ts2);
return COMPARE_TS_REAL(del_cap_ts1, del_cap_ts2);
}
static gint
-frame_data_time_delta_dis_compare(const frame_data *fdata1, const frame_data *fdata2)
+frame_data_time_delta_dis_compare(const struct epan_session *epan, const frame_data *fdata1, const frame_data *fdata2)
{
nstime_t del_dis_ts1, del_dis_ts2;
- frame_delta_abs_time(fdata1, fdata1->prev_dis, &del_dis_ts1);
- frame_delta_abs_time(fdata2, fdata2->prev_dis, &del_dis_ts2);
+ frame_delta_abs_time(epan, fdata1, fdata1->prev_dis_num, &del_dis_ts1);
+ frame_delta_abs_time(epan, fdata2, fdata2->prev_dis_num, &del_dis_ts2);
return COMPARE_TS_REAL(del_dis_ts1, del_dis_ts2);
}
gint
-frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field)
+frame_data_compare(const struct epan_session *epan, const frame_data *fdata1, const frame_data *fdata2, int field)
{
switch (field) {
case COL_NUMBER:
@@ -208,10 +210,10 @@ frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field
return COMPARE_TS(rel_ts);
case TS_DELTA:
- return frame_data_time_delta_compare(fdata1, fdata2);
+ return frame_data_time_delta_compare(epan, fdata1, fdata2);
case TS_DELTA_DIS:
- return frame_data_time_delta_dis_compare(fdata1, fdata2);
+ return frame_data_time_delta_dis_compare(epan, fdata1, fdata2);
case TS_NOT_SET:
return 0;
@@ -228,10 +230,10 @@ frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field
return COMPARE_TS(rel_ts);
case COL_DELTA_TIME:
- return frame_data_time_delta_compare(fdata1, fdata2);
+ return frame_data_time_delta_compare(epan, fdata1, fdata2);
case COL_DELTA_TIME_DIS:
- return frame_data_time_delta_dis_compare(fdata1, fdata2);
+ return frame_data_time_delta_dis_compare(epan, fdata1, fdata2);
case COL_PACKET_LENGTH:
return COMPARE_NUM(pkt_len);
@@ -277,8 +279,7 @@ frame_data_init(frame_data *fdata, guint32 num,
fdata->shift_offset.nsecs = 0;
fdata->rel_ts.secs = 0;
fdata->rel_ts.nsecs = 0;
- fdata->prev_dis = NULL;
- fdata->prev_cap = NULL;
+ fdata->prev_dis_num = 0;
fdata->opt_comment = phdr->opt_comment;
}
@@ -286,8 +287,7 @@ void
frame_data_set_before_dissect(frame_data *fdata,
nstime_t *elapsed_time,
nstime_t *first_ts,
- const frame_data *prev_dis,
- const frame_data *prev_cap)
+ const frame_data *prev_dis)
{
/* If we don't have the time stamp of the first packet in the
capture, it's because this is the first packet. Save the time
@@ -311,8 +311,7 @@ frame_data_set_before_dissect(frame_data *fdata,
*elapsed_time = fdata->rel_ts;
}
- fdata->prev_dis = prev_dis;
- fdata->prev_cap = prev_cap;
+ fdata->prev_dis_num = (prev_dis) ? prev_dis->num : 0;
}
void
diff --git a/epan/frame_data.h b/epan/frame_data.h
index 2efdb39ab4..2328bb870b 100644
--- a/epan/frame_data.h
+++ b/epan/frame_data.h
@@ -84,8 +84,7 @@ typedef struct _frame_data {
nstime_t abs_ts; /**< Absolute timestamp */
nstime_t shift_offset; /**< How much the abs_tm of the frame is shifted */
nstime_t rel_ts; /**< Relative timestamp (yes, it can be negative) */
- const struct _frame_data *prev_dis; /**< Previous displayed frame */
- const struct _frame_data *prev_cap; /**< Previous captured frame */
+ guint32 prev_dis_num; /**< Previous displayed frame (0 if first one) */
gchar *opt_comment; /**< NULL if not available */
} frame_data;
@@ -104,8 +103,11 @@ WS_DLL_PUBLIC void *p_get_proto_data(frame_data *fd, int proto, guint8 key);
void p_remove_proto_data(frame_data *fd, int proto, guint8 key);
gchar *p_get_proto_name_and_key(frame_data *fd, guint pfd_index);
+/* no sense to include epan.h + dependencies for opaque epan session type */
+struct epan_session;
+
/** compare two frame_datas */
-WS_DLL_PUBLIC gint frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field);
+WS_DLL_PUBLIC gint frame_data_compare(const struct epan_session *epan, const frame_data *fdata1, const frame_data *fdata2, int field);
WS_DLL_PUBLIC void frame_data_reset(frame_data *fdata);
@@ -115,16 +117,15 @@ WS_DLL_PUBLIC void frame_data_init(frame_data *fdata, guint32 num,
const struct wtap_pkthdr *phdr, gint64 offset,
guint32 cum_bytes);
-extern void frame_delta_abs_time(const frame_data *fdata,
- const frame_data *prev, nstime_t *delta);
+extern void frame_delta_abs_time(const struct epan_session *epan, const frame_data *fdata,
+ guint32 prev_num, nstime_t *delta);
/**
* Sets the frame data struct values before dissection.
*/
WS_DLL_PUBLIC void frame_data_set_before_dissect(frame_data *fdata,
nstime_t *elapsed_time,
nstime_t *first_ts,
- const frame_data *prev_dis,
- const frame_data *prev_cap);
+ const frame_data *prev_dis);
WS_DLL_PUBLIC void frame_data_set_after_dissect(frame_data *fdata,
guint32 *cum_bytes);
diff --git a/epan/packet.c b/epan/packet.c
index 43f15d89e2..8e37c4a938 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -326,8 +326,9 @@ dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
wmem_allocator_t *tmp = edt->pi.pool;
if (cinfo != NULL)
- col_init(cinfo);
+ col_init(cinfo, edt->session);
memset(&edt->pi, 0, sizeof(edt->pi));
+ edt->pi.epan = edt->session;
edt->pi.pool = tmp;
edt->pi.current_proto = "<Missing Protocol Name>";
edt->pi.cinfo = cinfo;
diff --git a/epan/packet_info.h b/epan/packet_info.h
index 178a2ad615..635aee0b38 100644
--- a/epan/packet_info.h
+++ b/epan/packet_info.h
@@ -225,6 +225,7 @@ typedef struct _packet_info {
GSList *frame_end_routines;
struct _wmem_allocator_t *pool; /**< Memory pool scoped to the pinfo struct */
+ struct epan_session *epan;
} packet_info;
/**< For old code that hasn't yet been changed. */
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c
index 6bea086517..f542e46047 100644
--- a/epan/wslua/wslua_pinfo.c
+++ b/epan/wslua/wslua_pinfo.c
@@ -1006,11 +1006,11 @@ lua_nstime_to_sec(const nstime_t *nstime)
}
static double
-lua_delta_nstime_to_sec(const frame_data *fd, const frame_data *prev)
+lua_delta_nstime_to_sec(const Pinfo pinfo, const frame_data *fd, guint32 prev_num)
{
nstime_t del;
- frame_delta_abs_time(fd, prev, &del);
+ frame_delta_abs_time(pinfo->ws_pinfo->epan, fd, prev_num, &del);
return lua_nstime_to_sec(&del);
}
@@ -1023,8 +1023,8 @@ PINFO_GET_NUMBER(Pinfo_len,pinfo->ws_pinfo->fd->pkt_len)
PINFO_GET_NUMBER(Pinfo_caplen,pinfo->ws_pinfo->fd->cap_len)
PINFO_GET_NUMBER(Pinfo_abs_ts,lua_nstime_to_sec(&pinfo->ws_pinfo->fd->abs_ts))
PINFO_GET_NUMBER(Pinfo_rel_ts,lua_nstime_to_sec(&pinfo->ws_pinfo->fd->rel_ts))
-PINFO_GET_NUMBER(Pinfo_delta_ts,lua_delta_nstime_to_sec(pinfo->ws_pinfo->fd, pinfo->ws_pinfo->fd->prev_cap))
-PINFO_GET_NUMBER(Pinfo_delta_dis_ts,lua_delta_nstime_to_sec(pinfo->ws_pinfo->fd, pinfo->ws_pinfo->fd->prev_dis))
+PINFO_GET_NUMBER(Pinfo_delta_ts,lua_delta_nstime_to_sec(pinfo, pinfo->ws_pinfo->fd, pinfo->ws_pinfo->fd->num - 1))
+PINFO_GET_NUMBER(Pinfo_delta_dis_ts,lua_delta_nstime_to_sec(pinfo, pinfo->ws_pinfo->fd, pinfo->ws_pinfo->fd->prev_dis_num))
PINFO_GET_NUMBER(Pinfo_ipproto,pinfo->ws_pinfo->ipproto)
PINFO_GET_NUMBER(Pinfo_circuit_id,pinfo->ws_pinfo->circuit_id)
PINFO_GET_NUMBER(Pinfo_desegment_len,pinfo->ws_pinfo->desegment_len)