aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-02-25 23:24:34 +0000
committerGuy Harris <guy@alum.mit.edu>2012-02-25 23:24:34 +0000
commitb6ff142f60309faceb422e3d3689c7406aca9361 (patch)
treefc06d6f47b4bc726709812f14f7576d1945af5c0 /epan
parente994e7841299a7eb15783ef24f0b1de46218a1b1 (diff)
Add a presence flag field to the packet information structure filled in
by Wiretap, to indicate whether certain fields in that structure actually have data in them. Use the "time stamp present" flag to omit showing time stamp information for packets (and "packets") that don't have time stamps; don't bother working very hard to "fake" a time stamp for data files. Use the "interface ID present" flag to omit the interface ID for packets that don't have an interface ID. We don't use the "captured length, separate from packet length, present" flag to omit the captured length; that flag might be present but equal to the packet length, and if you want to know if a packet was cut short by a snapshot length, comparing the values would be the way to do that. More work is needed to have wiretap/pcapng.c properly report the flags, e.g. reporting no time stamp being present for a Simple Packet Block. svn path=/trunk/; revision=41185
Diffstat (limited to 'epan')
-rw-r--r--epan/column-utils.c120
-rw-r--r--epan/dissectors/packet-frame.c87
-rw-r--r--epan/frame_data.c2
-rw-r--r--epan/frame_data.h2
4 files changed, 128 insertions, 83 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c
index b4b01256cc..d1d5a632a8 100644
--- a/epan/column-utils.c
+++ b/epan/column-utils.c
@@ -626,11 +626,14 @@ set_abs_date_time(const frame_data *fd, gchar *buf, gboolean local)
struct tm *tmp;
time_t then;
- then = fd->abs_ts.secs;
- if (local)
- tmp = localtime(&then);
- else
- tmp = gmtime(&then);
+ if (fd->flags.has_ts) {
+ then = fd->abs_ts.secs;
+ if (local)
+ tmp = localtime(&then);
+ else
+ tmp = gmtime(&then);
+ } else
+ tmp = NULL;
if (tmp != NULL) {
switch(timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
@@ -919,6 +922,10 @@ set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
static void
col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col)
{
+ if (!fd->flags.has_ts) {
+ cinfo->col_buf[col][0] = '\0';
+ return;
+ }
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
set_time_seconds(&fd->rel_ts, cinfo->col_buf[col]);
@@ -960,6 +967,10 @@ col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
static void
col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col)
{
+ if (!fd->flags.has_ts) {
+ cinfo->col_buf[col][0] = '\0';
+ return;
+ }
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
set_time_seconds(&fd->del_dis_ts, cinfo->col_buf[col]);
@@ -984,11 +995,14 @@ set_abs_time(const frame_data *fd, gchar *buf, gboolean local)
struct tm *tmp;
time_t then;
- then = fd->abs_ts.secs;
- if (local)
- tmp = localtime(&then);
- else
- tmp = gmtime(&then);
+ if (fd->flags.has_ts) {
+ then = fd->abs_ts.secs;
+ if (local)
+ tmp = localtime(&then);
+ else
+ tmp = gmtime(&then);
+ } else
+ tmp = NULL;
if (tmp != NULL) {
switch(timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
@@ -1067,9 +1081,13 @@ col_set_utc_time(const frame_data *fd, column_info *cinfo, const int col)
cinfo->col_data[col] = cinfo->col_buf[col];
}
-static gint
+static gboolean
set_epoch_time(const frame_data *fd, gchar *buf)
{
+ if (!fd->flags.has_ts) {
+ buf[0] = '\0';
+ return FALSE;
+ }
switch(timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
case TS_PREC_AUTO_SEC:
@@ -1104,7 +1122,7 @@ set_epoch_time(const frame_data *fd, gchar *buf)
default:
g_assert_not_reached();
}
- return 1;
+ return TRUE;
}
static void
@@ -1131,42 +1149,54 @@ set_fd_time(frame_data *fd, gchar *buf)
break;
case TS_RELATIVE:
- switch (timestamp_get_seconds_type()) {
- case TS_SECONDS_DEFAULT:
- set_time_seconds(&fd->rel_ts, buf);
- break;
- case TS_SECONDS_HOUR_MIN_SEC:
- set_time_seconds(&fd->rel_ts, buf);
- break;
- default:
- g_assert_not_reached();
- }
+ if (fd->flags.has_ts) {
+ switch (timestamp_get_seconds_type()) {
+ case TS_SECONDS_DEFAULT:
+ set_time_seconds(&fd->rel_ts, buf);
+ break;
+ case TS_SECONDS_HOUR_MIN_SEC:
+ set_time_seconds(&fd->rel_ts, buf);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ } else {
+ buf[0] = '\0';
+ }
break;
case TS_DELTA:
- switch (timestamp_get_seconds_type()) {
- case TS_SECONDS_DEFAULT:
- set_time_seconds(&fd->del_cap_ts, buf);
- break;
- case TS_SECONDS_HOUR_MIN_SEC:
- set_time_hour_min_sec(&fd->del_cap_ts, buf);
- break;
- default:
- g_assert_not_reached();
- }
+ if (fd->flags.has_ts) {
+ switch (timestamp_get_seconds_type()) {
+ case TS_SECONDS_DEFAULT:
+ set_time_seconds(&fd->del_cap_ts, buf);
+ break;
+ case TS_SECONDS_HOUR_MIN_SEC:
+ set_time_hour_min_sec(&fd->del_cap_ts, buf);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ } else {
+ buf[0] = '\0';
+ }
break;
case TS_DELTA_DIS:
- switch (timestamp_get_seconds_type()) {
- case TS_SECONDS_DEFAULT:
- set_time_seconds(&fd->del_dis_ts, buf);
- break;
- case TS_SECONDS_HOUR_MIN_SEC:
- set_time_hour_min_sec(&fd->del_dis_ts, buf);
- break;
- default:
- g_assert_not_reached();
- }
+ if (fd->flags.has_ts) {
+ switch (timestamp_get_seconds_type()) {
+ case TS_SECONDS_DEFAULT:
+ set_time_seconds(&fd->del_dis_ts, buf);
+ break;
+ case TS_SECONDS_HOUR_MIN_SEC:
+ set_time_hour_min_sec(&fd->del_dis_ts, buf);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ } else {
+ buf[0] = '\0';
+ }
break;
case TS_EPOCH:
@@ -1182,9 +1212,9 @@ set_fd_time(frame_data *fd, gchar *buf)
break;
case TS_NOT_SET:
- /* code is missing for this case, but I don't know which [jmayer20051219] */
- g_assert(FALSE);
- break;
+ /* code is missing for this case, but I don't know which [jmayer20051219] */
+ g_assert(FALSE);
+ break;
}
}
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index 8bf1436048..db0a157fc8 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -195,9 +195,11 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
generating any tree items. */
if(!proto_field_is_referenced(tree, proto_frame)) {
tree=NULL;
- if(pinfo->fd->abs_ts.nsecs < 0 || pinfo->fd->abs_ts.nsecs >= 1000000000)
- expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_WARN,
- "Arrival Time: Fractional second out of range (0-1000000000)");
+ if(pinfo->fd->flags.has_ts) {
+ if(pinfo->fd->abs_ts.nsecs < 0 || pinfo->fd->abs_ts.nsecs >= 1000000000)
+ expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_WARN,
+ "Arrival Time: Fractional second out of range (0-1000000000)");
+ }
} else {
proto_tree *fh_tree;
gboolean old_visible;
@@ -209,52 +211,61 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
cap_plurality = plurality(cap_len, "", "s");
frame_plurality = plurality(frame_len, "", "s");
+ ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, -1,
+ "Frame %u: %u byte%s on wire",
+ pinfo->fd->num, frame_len, frame_plurality);
if (generate_bits_field)
- ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, -1,
- "Frame %u: %u byte%s on wire (%u bits), %u byte%s captured (%u bits) on interface %u",
- pinfo->fd->num, frame_len, frame_plurality, frame_len * 8,
- cap_len, cap_plurality, cap_len * 8, pinfo->fd->interface_id);
- else
- ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, -1,
- "Frame %u: %u byte%s on wire, %u byte%s captured, on interface %u", pinfo->fd->num,
- frame_len, frame_plurality, cap_len, cap_plurality, pinfo->fd->interface_id);
+ proto_item_append_text(ti, " (%u bits)", frame_len * 8);
+ proto_item_append_text(ti, ", %u byte%s captured",
+ cap_len, cap_plurality);
+ if (generate_bits_field) {
+ proto_item_append_text(ti, " (%u bits)",
+ cap_len * 8);
+ }
+ if (pinfo->fd->flags.has_if_id) {
+ proto_item_append_text(ti, " on interface %u",
+ pinfo->fd->interface_id);
+ }
fh_tree = proto_item_add_subtree(ti, ett_frame);
- proto_tree_add_uint(fh_tree, hf_frame_interface_id, tvb, 0, 0, pinfo->fd->interface_id);
+ if (pinfo->fd->flags.has_if_id)
+ proto_tree_add_uint(fh_tree, hf_frame_interface_id, tvb, 0, 0, pinfo->fd->interface_id);
- proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb,
- 0, 0, &(pinfo->fd->abs_ts));
- if(pinfo->fd->abs_ts.nsecs < 0 || pinfo->fd->abs_ts.nsecs >= 1000000000) {
- item = proto_tree_add_none_format(fh_tree, hf_frame_time_invalid, tvb,
- 0, 0, "Arrival Time: Fractional second %09ld is invalid, the valid range is 0-1000000000", (long) pinfo->fd->abs_ts.nsecs);
+ if (pinfo->fd->flags.has_ts) {
+ proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb,
+ 0, 0, &(pinfo->fd->abs_ts));
+ if(pinfo->fd->abs_ts.nsecs < 0 || pinfo->fd->abs_ts.nsecs >= 1000000000) {
+ item = proto_tree_add_none_format(fh_tree, hf_frame_time_invalid, tvb,
+ 0, 0, "Arrival Time: Fractional second %09ld is invalid, the valid range is 0-1000000000", (long) pinfo->fd->abs_ts.nsecs);
+ PROTO_ITEM_SET_GENERATED(item);
+ expert_add_info_format(pinfo, item, PI_MALFORMED, PI_WARN, "Arrival Time: Fractional second out of range (0-1000000000)");
+ }
+ item = proto_tree_add_time(fh_tree, hf_frame_shift_offset, tvb,
+ 0, 0, &(pinfo->fd->shift_offset));
PROTO_ITEM_SET_GENERATED(item);
- expert_add_info_format(pinfo, item, PI_MALFORMED, PI_WARN, "Arrival Time: Fractional second out of range (0-1000000000)");
- }
- item = proto_tree_add_time(fh_tree, hf_frame_shift_offset, tvb,
- 0, 0, &(pinfo->fd->shift_offset));
- PROTO_ITEM_SET_GENERATED(item);
- if(generate_epoch_time) {
- proto_tree_add_time(fh_tree, hf_frame_arrival_time_epoch, tvb,
- 0, 0, &(pinfo->fd->abs_ts));
- }
+ if(generate_epoch_time) {
+ proto_tree_add_time(fh_tree, hf_frame_arrival_time_epoch, tvb,
+ 0, 0, &(pinfo->fd->abs_ts));
+ }
- item = proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb,
- 0, 0, &(pinfo->fd->del_cap_ts));
- PROTO_ITEM_SET_GENERATED(item);
+ item = proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb,
+ 0, 0, &(pinfo->fd->del_cap_ts));
+ PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_time(fh_tree, hf_frame_time_delta_displayed, tvb,
- 0, 0, &(pinfo->fd->del_dis_ts));
- PROTO_ITEM_SET_GENERATED(item);
+ item = proto_tree_add_time(fh_tree, hf_frame_time_delta_displayed, tvb,
+ 0, 0, &(pinfo->fd->del_dis_ts));
+ PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_time(fh_tree, hf_frame_time_relative, tvb,
- 0, 0, &(pinfo->fd->rel_ts));
- PROTO_ITEM_SET_GENERATED(item);
+ item = proto_tree_add_time(fh_tree, hf_frame_time_relative, tvb,
+ 0, 0, &(pinfo->fd->rel_ts));
+ PROTO_ITEM_SET_GENERATED(item);
- if(pinfo->fd->flags.ref_time){
- ti = proto_tree_add_item(fh_tree, hf_frame_time_reference, tvb, 0, 0, ENC_NA);
- PROTO_ITEM_SET_GENERATED(ti);
+ if(pinfo->fd->flags.ref_time){
+ ti = proto_tree_add_item(fh_tree, hf_frame_time_reference, tvb, 0, 0, ENC_NA);
+ PROTO_ITEM_SET_GENERATED(ti);
+ }
}
proto_tree_add_uint(fh_tree, hf_frame_number, tvb,
diff --git a/epan/frame_data.c b/epan/frame_data.c
index 08609c48f3..c757f9b1a9 100644
--- a/epan/frame_data.c
+++ b/epan/frame_data.c
@@ -212,6 +212,8 @@ frame_data_init(frame_data *fdata, guint32 num,
fdata->flags.marked = 0;
fdata->flags.ref_time = 0;
fdata->flags.ignored = 0;
+ fdata->flags.has_ts = (phdr->presence_flags & WTAP_HAS_TS) ? 1 : 0;
+ fdata->flags.has_if_id = (phdr->presence_flags & WTAP_HAS_INTERFACE_ID) ? 1 : 0;
fdata->color_filter = NULL;
fdata->opt_comment = phdr->opt_comment;
}
diff --git a/epan/frame_data.h b/epan/frame_data.h
index cdf8704ef1..5b25275f35 100644
--- a/epan/frame_data.h
+++ b/epan/frame_data.h
@@ -56,6 +56,8 @@ typedef struct _frame_data {
unsigned int marked : 1; /**< 1 = marked by user, 0 = normal */
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_if_id : 1; /**< 1 = has interface ID, 0 = no interface ID */
} flags;
const void *color_filter; /**< Per-packet matching color_filter_t object */