Have a common provider routine to provide time stamps.
Replace various almost-the-same get_frame_ts routines with a common routine.
This commit is contained in:
parent
b8bad2c745
commit
dd6b58fcb8
1
cfile.h
1
cfile.h
|
@ -131,6 +131,7 @@ typedef struct _capture_file {
|
|||
|
||||
extern void cap_file_init(capture_file *cf);
|
||||
|
||||
const nstime_t *cap_file_provider_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num);
|
||||
const char *cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32 interface_id, unsigned section_number);
|
||||
const char *cap_file_provider_get_interface_description(struct packet_provider_data *prov, guint32 interface_id, unsigned section_number);
|
||||
wtap_block_t cap_file_provider_get_modified_block(struct packet_provider_data *prov, const frame_data *fd);
|
||||
|
|
17
file.c
17
file.c
|
@ -227,26 +227,11 @@ compute_elapsed(capture_file *cf, gint64 start_time)
|
|||
cf->computed_elapsed = (gulong) (delta_time / 1000); /* ms */
|
||||
}
|
||||
|
||||
static const nstime_t *
|
||||
ws_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num)
|
||||
{
|
||||
const frame_data *fd = NULL;
|
||||
if (prov->prev_dis && prov->prev_dis->num == frame_num) {
|
||||
fd = prov->prev_dis;
|
||||
} else if (prov->prev_cap && prov->prev_cap->num == frame_num) {
|
||||
fd = prov->prev_cap;
|
||||
} else if (prov->frames) {
|
||||
fd = frame_data_sequence_find(prov->frames, frame_num);
|
||||
}
|
||||
|
||||
return (fd && fd->has_ts) ? &fd->abs_ts : NULL;
|
||||
}
|
||||
|
||||
static epan_t *
|
||||
ws_epan_new(capture_file *cf)
|
||||
{
|
||||
static const struct packet_provider_funcs funcs = {
|
||||
ws_get_frame_ts,
|
||||
cap_file_provider_get_frame_ts,
|
||||
cap_file_provider_get_interface_name,
|
||||
cap_file_provider_get_interface_description,
|
||||
cap_file_provider_get_modified_block
|
||||
|
|
|
@ -13,6 +13,24 @@
|
|||
|
||||
#include "cfile.h"
|
||||
|
||||
const nstime_t *
|
||||
cap_file_provider_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num)
|
||||
{
|
||||
const frame_data *fd = NULL;
|
||||
|
||||
if (prov->ref && prov->ref->num == frame_num) {
|
||||
fd = prov->ref;
|
||||
} else if (prov->prev_dis && prov->prev_dis->num == frame_num) {
|
||||
fd = prov->prev_dis;
|
||||
} else if (prov->prev_cap && prov->prev_cap->num == frame_num) {
|
||||
fd = prov->prev_cap;
|
||||
} else if (prov->frames) {
|
||||
fd = frame_data_sequence_find(prov->frames, frame_num);
|
||||
}
|
||||
|
||||
return (fd && fd->has_ts) ? &fd->abs_ts : NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
frame_cmp(gconstpointer a, gconstpointer b, gpointer user_data _U_)
|
||||
{
|
||||
|
|
17
rawshark.c
17
rawshark.c
|
@ -1412,26 +1412,11 @@ show_print_file_io_error(int err)
|
|||
}
|
||||
}
|
||||
|
||||
static const nstime_t *
|
||||
raw_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num)
|
||||
{
|
||||
const frame_data *ts_fd = NULL;
|
||||
if (prov->ref && prov->ref->num == frame_num) {
|
||||
ts_fd = prov->ref;
|
||||
} else if (prov->prev_dis && prov->prev_dis->num == frame_num) {
|
||||
ts_fd = prov->prev_dis;
|
||||
} else if (prov->prev_cap && prov->prev_cap->num == frame_num) {
|
||||
ts_fd = prov->prev_cap;
|
||||
}
|
||||
|
||||
return (ts_fd && ts_fd->has_ts) ? &ts_fd->abs_ts : NULL;
|
||||
}
|
||||
|
||||
static epan_t *
|
||||
raw_epan_new(capture_file *cf)
|
||||
{
|
||||
static const struct packet_provider_funcs funcs = {
|
||||
raw_get_frame_ts,
|
||||
cap_file_provider_get_frame_ts,
|
||||
cap_file_provider_get_interface_name,
|
||||
cap_file_provider_get_interface_description,
|
||||
NULL,
|
||||
|
|
19
sharkd.c
19
sharkd.c
|
@ -213,28 +213,11 @@ clean_exit:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static const nstime_t *
|
||||
sharkd_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num)
|
||||
{
|
||||
const frame_data *fd = NULL;
|
||||
if (prov->ref && prov->ref->num == frame_num) {
|
||||
fd = prov->ref;
|
||||
} else if (prov->prev_dis && prov->prev_dis->num == frame_num) {
|
||||
fd = prov->prev_dis;
|
||||
} else if (prov->prev_cap && prov->prev_cap->num == frame_num) {
|
||||
fd = prov->prev_cap;
|
||||
} else if (prov->frames) {
|
||||
fd = frame_data_sequence_find(prov->frames, frame_num);
|
||||
}
|
||||
|
||||
return (fd && fd->has_ts) ? &fd->abs_ts : NULL;
|
||||
}
|
||||
|
||||
static epan_t *
|
||||
sharkd_epan_new(capture_file *cf)
|
||||
{
|
||||
static const struct packet_provider_funcs funcs = {
|
||||
sharkd_get_frame_ts,
|
||||
cap_file_provider_get_frame_ts,
|
||||
cap_file_provider_get_interface_name,
|
||||
cap_file_provider_get_interface_description,
|
||||
cap_file_provider_get_modified_block
|
||||
|
|
20
tfshark.c
20
tfshark.c
|
@ -974,23 +974,6 @@ clean_exit:
|
|||
return exit_status;
|
||||
}
|
||||
|
||||
static const nstime_t *
|
||||
tfshark_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num)
|
||||
{
|
||||
const frame_data *fd = NULL;
|
||||
if (prov->ref && prov->ref->num == frame_num) {
|
||||
fd = prov->ref;
|
||||
} else if (prov->prev_dis && prov->prev_dis->num == frame_num) {
|
||||
fd = prov->prev_dis;
|
||||
} else if (prov->prev_cap && prov->prev_cap->num == frame_num) {
|
||||
fd = prov->prev_cap;
|
||||
} else if (prov->frames) {
|
||||
fd = frame_data_sequence_find(prov->frames, frame_num);
|
||||
}
|
||||
|
||||
return (fd && fd->has_ts) ? &fd->abs_ts : NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
no_interface_name(struct packet_provider_data *prov _U_, guint32 interface_id _U_, unsigned section_number _U_)
|
||||
{
|
||||
|
@ -1001,7 +984,8 @@ static epan_t *
|
|||
tfshark_epan_new(capture_file *cf)
|
||||
{
|
||||
static const struct packet_provider_funcs funcs = {
|
||||
tfshark_get_frame_ts,
|
||||
/* XXX - there should be no need for time stamps */
|
||||
cap_file_provider_get_frame_ts,
|
||||
no_interface_name,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
19
tshark.c
19
tshark.c
|
@ -2744,28 +2744,11 @@ clean_exit:
|
|||
gboolean loop_running = FALSE;
|
||||
guint32 packet_count = 0;
|
||||
|
||||
static const nstime_t *
|
||||
tshark_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num)
|
||||
{
|
||||
const frame_data *fd = NULL;
|
||||
if (prov->ref && prov->ref->num == frame_num) {
|
||||
fd = prov->ref;
|
||||
} else if (prov->prev_dis && prov->prev_dis->num == frame_num) {
|
||||
fd = prov->prev_dis;
|
||||
} else if (prov->prev_cap && prov->prev_cap->num == frame_num) {
|
||||
fd = prov->prev_cap;
|
||||
} else if (prov->frames) {
|
||||
fd = frame_data_sequence_find(prov->frames, frame_num);
|
||||
}
|
||||
|
||||
return (fd && fd->has_ts) ? &fd->abs_ts : NULL;
|
||||
}
|
||||
|
||||
static epan_t *
|
||||
tshark_epan_new(capture_file *cf)
|
||||
{
|
||||
static const struct packet_provider_funcs funcs = {
|
||||
tshark_get_frame_ts,
|
||||
cap_file_provider_get_frame_ts,
|
||||
cap_file_provider_get_interface_name,
|
||||
cap_file_provider_get_interface_description,
|
||||
NULL,
|
||||
|
|
Loading…
Reference in New Issue