forked from osmocom/wireshark
Instead of using a Boolean for the search direction, use an enum, so
that you can tell from examination whether the search is forward or backward. Make the cf_find_packet routines take the direction as an explicit argument, rather than, in the cases where you don't want to permanently set the direction, saving the direction in the capture_file structure, changing it, doing the search, and restoring the saved direction. Give more information in the Doxygen comments for those routines. Add a cf_find_packet_dfilter_string() routine, which takes a filter string rather than a compiled filter as an argument. Replace find_previous_next_frame_with_filter() with it. Have cf_read_frame_r() and cf_read_frame() pop up the error dialog if the read fails, rather than leaving that up to its caller. That lets us eliminate cf_read_error_message(), by swallowing its code into cf_read_frame_r(). Add Doxygen comments for cf_read_frame_r() and cf_read_frame(). Don't have find_packet() read the packet before calling the callback routine; leave that up to the callback routine. Add cf_find_packet_marked(), to find the next or previous marked packet, and cf_find_packet_time_reference(), to find the next or previous time reference packet. Those routines do *not* need to read the packet data to see if it matches; that lets them run much faster. Clean up indentation. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@33791 f5534014-38df-0310-8fa8-9805f1628bb7
This commit is contained in:
parent
4ed040d60e
commit
f228de72c3
7
cfile.h
7
cfile.h
|
@ -41,6 +41,11 @@ typedef enum {
|
|||
/* add EBCDIC when it's implemented */
|
||||
} search_charset_t;
|
||||
|
||||
typedef enum {
|
||||
SD_FORWARD,
|
||||
SD_BACKWARD
|
||||
} search_direction;
|
||||
|
||||
typedef struct _capture_file {
|
||||
file_state state; /* Current state of capture file */
|
||||
gchar *filename; /* Name of capture file */
|
||||
|
@ -65,7 +70,7 @@ typedef struct _capture_file {
|
|||
gboolean redissecting; /* TRUE if currently redissecting (cf_redissect_packets) */
|
||||
/* search */
|
||||
gchar *sfilter; /* Search filter string */
|
||||
gboolean sbackward; /* TRUE if search is backward, FALSE if forward */
|
||||
search_direction dir; /* Direction in which to do searches */
|
||||
gboolean hex; /* TRUE is raw data search is being performed */
|
||||
gboolean string; /* TRUE is text search is being performed */
|
||||
guint32 search_pos; /* Position of last character found in search */
|
||||
|
|
556
file.c
556
file.c
|
@ -92,24 +92,33 @@ static int read_packet(capture_file *cf, dfilter_t *dfcode,
|
|||
static void rescan_packets(capture_file *cf, const char *action, const char *action_item,
|
||||
gboolean refilter, gboolean redissect);
|
||||
|
||||
static gboolean match_protocol_tree(capture_file *cf, frame_data *fdata,
|
||||
typedef enum {
|
||||
MR_NOTMATCHED,
|
||||
MR_MATCHED,
|
||||
MR_ERROR
|
||||
} match_result;
|
||||
static match_result match_protocol_tree(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static void match_subtree_text(proto_node *node, gpointer data);
|
||||
static gboolean match_summary_line(capture_file *cf, frame_data *fdata,
|
||||
static match_result match_summary_line(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static gboolean match_ascii_and_unicode(capture_file *cf, frame_data *fdata,
|
||||
static match_result match_ascii_and_unicode(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static gboolean match_ascii(capture_file *cf, frame_data *fdata,
|
||||
static match_result match_ascii(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static gboolean match_unicode(capture_file *cf, frame_data *fdata,
|
||||
static match_result match_unicode(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static gboolean match_binary(capture_file *cf, frame_data *fdata,
|
||||
static match_result match_binary(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static gboolean match_dfilter(capture_file *cf, frame_data *fdata,
|
||||
static match_result match_dfilter(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static match_result match_marked(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static match_result match_time_reference(capture_file *cf, frame_data *fdata,
|
||||
void *criterion);
|
||||
static gboolean find_packet(capture_file *cf,
|
||||
gboolean (*match_function)(capture_file *, frame_data *, void *),
|
||||
void *criterion);
|
||||
match_result (*match_function)(capture_file *, frame_data *, void *),
|
||||
void *criterion, search_direction dir);
|
||||
|
||||
static void cf_open_failure_alert_box(const char *filename, int err,
|
||||
gchar *err_info, gboolean for_writing,
|
||||
|
@ -1718,17 +1727,46 @@ cf_redissect_packets(capture_file *cf)
|
|||
|
||||
gboolean
|
||||
cf_read_frame_r(capture_file *cf, frame_data *fdata,
|
||||
union wtap_pseudo_header *pseudo_header, guint8 *pd,
|
||||
int *err, gchar **err_info)
|
||||
union wtap_pseudo_header *pseudo_header, guint8 *pd)
|
||||
{
|
||||
return wtap_seek_read(cf->wth, fdata->file_off, pseudo_header,
|
||||
pd, fdata->cap_len, err, err_info);
|
||||
int err;
|
||||
gchar *err_info;
|
||||
char errmsg_errno[1024+1];
|
||||
|
||||
if (!wtap_seek_read(cf->wth, fdata->file_off, pseudo_header, pd,
|
||||
fdata->cap_len, &err, &err_info)) {
|
||||
switch (err) {
|
||||
|
||||
case WTAP_ERR_UNSUPPORTED_ENCAP:
|
||||
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
|
||||
"The file \"%%s\" has a packet with a network type that Wireshark doesn't support.\n(%s)",
|
||||
err_info);
|
||||
g_free(err_info);
|
||||
break;
|
||||
|
||||
case WTAP_ERR_BAD_RECORD:
|
||||
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
|
||||
"An error occurred while reading from the file \"%%s\": %s.\n(%s)",
|
||||
wtap_strerror(err), err_info);
|
||||
g_free(err_info);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
|
||||
"An error occurred while reading from the file \"%%s\": %s.",
|
||||
wtap_strerror(err));
|
||||
break;
|
||||
}
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, errmsg_errno, cf->filename);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cf_read_frame(capture_file *cf, frame_data *fdata, int *err, gchar **err_info)
|
||||
cf_read_frame(capture_file *cf, frame_data *fdata)
|
||||
{
|
||||
return cf_read_frame_r(cf, fdata, &cf->pseudo_header, cf->pd, err, err_info);
|
||||
return cf_read_frame_r(cf, fdata, &cf->pseudo_header, cf->pd);
|
||||
}
|
||||
|
||||
/* Rescan the list of packets, reconstructing the CList.
|
||||
|
@ -1755,8 +1793,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
|
|||
progdlg_t *progbar = NULL;
|
||||
gboolean stop_flag;
|
||||
int count;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
frame_data *selected_frame, *preceding_frame, *following_frame, *prev_frame;
|
||||
int selected_frame_num, preceding_frame_num, following_frame_num, prev_frame_num;
|
||||
gboolean selected_frame_seen;
|
||||
|
@ -1922,15 +1958,12 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
|
|||
* And after that fdata->col_text (which is allocated using se_alloc0())
|
||||
* no longer points to valid memory.
|
||||
*/
|
||||
fdata->col_text_len = se_alloc0(sizeof(fdata->col_text_len) * (cf->cinfo.num_cols));
|
||||
fdata->col_text = se_alloc0(sizeof(fdata->col_text) * (cf->cinfo.num_cols));
|
||||
fdata->col_text_len = se_alloc0(sizeof(fdata->col_text_len) * (cf->cinfo.num_cols));
|
||||
fdata->col_text = se_alloc0(sizeof(fdata->col_text) * (cf->cinfo.num_cols));
|
||||
}
|
||||
|
||||
if (!cf_read_frame (cf, fdata, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
break;
|
||||
}
|
||||
if (!cf_read_frame(cf, fdata))
|
||||
break; /* error reading the frame */
|
||||
|
||||
/* If the previous frame is displayed, and we haven't yet seen the
|
||||
selected frame, remember that frame - it's the closest one we've
|
||||
|
@ -2229,11 +2262,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
|
|||
frame_data_cleanup(fdata);
|
||||
}
|
||||
|
||||
if (!cf_read_frame (cf, fdata, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
break;
|
||||
}
|
||||
if (!cf_read_frame(cf, fdata))
|
||||
break; /* error reading the frame */
|
||||
|
||||
/* If the previous frame is displayed, and we haven't yet seen the
|
||||
selected frame, remember that frame - it's the closest one we've
|
||||
|
@ -2439,8 +2469,6 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
|
|||
void *callback_args)
|
||||
{
|
||||
frame_data *fdata;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
union wtap_pseudo_header pseudo_header;
|
||||
guint8 pd[WTAP_MAX_PACKET_SIZE+1];
|
||||
psp_return_t ret = PSP_FINISHED;
|
||||
|
@ -2527,10 +2555,8 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
|
|||
}
|
||||
|
||||
/* Get the packet */
|
||||
if (!cf_read_frame_r(cf, fdata, &pseudo_header, pd, &err, &err_info)) {
|
||||
if (!cf_read_frame_r(cf, fdata, &pseudo_header, pd)) {
|
||||
/* Attempt to get the packet failed. */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
ret = PSP_FAILED;
|
||||
break;
|
||||
}
|
||||
|
@ -3372,21 +3398,28 @@ typedef struct {
|
|||
} match_data;
|
||||
|
||||
gboolean
|
||||
cf_find_packet_protocol_tree(capture_file *cf, const char *string)
|
||||
cf_find_packet_protocol_tree(capture_file *cf, const char *string,
|
||||
search_direction dir)
|
||||
{
|
||||
match_data mdata;
|
||||
|
||||
mdata.string = string;
|
||||
mdata.string_len = strlen(string);
|
||||
return find_packet(cf, match_protocol_tree, &mdata);
|
||||
return find_packet(cf, match_protocol_tree, &mdata, dir);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static match_result
|
||||
match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
|
||||
{
|
||||
match_data *mdata = criterion;
|
||||
epan_dissect_t edt;
|
||||
|
||||
/* Load the frame's data. */
|
||||
if (!cf_read_frame(cf, fdata)) {
|
||||
/* Attempt to get the packet failed. */
|
||||
return MR_ERROR;
|
||||
}
|
||||
|
||||
/* Construct the protocol tree, including the displayed text */
|
||||
epan_dissect_init(&edt, TRUE, TRUE);
|
||||
/* We don't need the column information */
|
||||
|
@ -3397,7 +3430,7 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
|
|||
mdata->frame_matched = FALSE;
|
||||
proto_tree_children_foreach(edt.tree, match_subtree_text, mdata);
|
||||
epan_dissect_cleanup(&edt);
|
||||
return mdata->frame_matched;
|
||||
return mdata->frame_matched ? MR_MATCHED : MR_NOTMATCHED;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3405,15 +3438,15 @@ match_subtree_text(proto_node *node, gpointer data)
|
|||
{
|
||||
match_data *mdata = (match_data*) data;
|
||||
const gchar *string = mdata->string;
|
||||
size_t string_len = mdata->string_len;
|
||||
size_t string_len = mdata->string_len;
|
||||
capture_file *cf = mdata->cf;
|
||||
field_info *fi = PNODE_FINFO(node);
|
||||
gchar label_str[ITEM_LABEL_LENGTH];
|
||||
gchar *label_ptr;
|
||||
size_t label_len;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
gchar label_str[ITEM_LABEL_LENGTH];
|
||||
gchar *label_ptr;
|
||||
size_t label_len;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
|
||||
g_assert(fi && "dissection with an invisible proto tree?");
|
||||
|
||||
|
@ -3444,9 +3477,9 @@ match_subtree_text(proto_node *node, gpointer data)
|
|||
if (c_char == string[c_match]) {
|
||||
c_match++;
|
||||
if (c_match == string_len) {
|
||||
/* No need to look further; we have a match */
|
||||
mdata->frame_matched = TRUE;
|
||||
return;
|
||||
/* No need to look further; we have a match */
|
||||
mdata->frame_matched = TRUE;
|
||||
return;
|
||||
}
|
||||
} else
|
||||
c_match = 0;
|
||||
|
@ -3458,29 +3491,36 @@ match_subtree_text(proto_node *node, gpointer data)
|
|||
}
|
||||
|
||||
gboolean
|
||||
cf_find_packet_summary_line(capture_file *cf, const char *string)
|
||||
cf_find_packet_summary_line(capture_file *cf, const char *string,
|
||||
search_direction dir)
|
||||
{
|
||||
match_data mdata;
|
||||
|
||||
mdata.string = string;
|
||||
mdata.string_len = strlen(string);
|
||||
return find_packet(cf, match_summary_line, &mdata);
|
||||
return find_packet(cf, match_summary_line, &mdata, dir);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static match_result
|
||||
match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
|
||||
{
|
||||
match_data *mdata = criterion;
|
||||
const gchar *string = mdata->string;
|
||||
size_t string_len = mdata->string_len;
|
||||
size_t string_len = mdata->string_len;
|
||||
epan_dissect_t edt;
|
||||
const char *info_column;
|
||||
size_t info_column_len;
|
||||
gboolean frame_matched = FALSE;
|
||||
gint colx;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
size_t info_column_len;
|
||||
match_result result = MR_NOTMATCHED;
|
||||
gint colx;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
|
||||
/* Load the frame's data. */
|
||||
if (!cf_read_frame(cf, fdata)) {
|
||||
/* Attempt to get the packet failed. */
|
||||
return MR_ERROR;
|
||||
}
|
||||
|
||||
/* Don't bother constructing the protocol tree */
|
||||
epan_dissect_init(&edt, FALSE, FALSE);
|
||||
|
@ -3494,23 +3534,23 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
|
|||
info_column = edt.pi.cinfo->col_data[colx];
|
||||
info_column_len = strlen(info_column);
|
||||
for (i = 0; i < info_column_len; i++) {
|
||||
c_char = info_column[i];
|
||||
if (cf->case_type)
|
||||
c_char = toupper(c_char);
|
||||
if (c_char == string[c_match]) {
|
||||
c_match++;
|
||||
if (c_match == string_len) {
|
||||
frame_matched = TRUE;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
c_match = 0;
|
||||
c_char = info_column[i];
|
||||
if (cf->case_type)
|
||||
c_char = toupper(c_char);
|
||||
if (c_char == string[c_match]) {
|
||||
c_match++;
|
||||
if (c_match == string_len) {
|
||||
result = MR_MATCHED;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
c_match = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
epan_dissect_cleanup(&edt);
|
||||
return frame_matched;
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -3519,7 +3559,8 @@ typedef struct {
|
|||
} cbs_t; /* "Counted byte string" */
|
||||
|
||||
gboolean
|
||||
cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size)
|
||||
cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size,
|
||||
search_direction dir)
|
||||
{
|
||||
cbs_t info;
|
||||
|
||||
|
@ -3532,35 +3573,41 @@ cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size)
|
|||
switch (cf->scs_type) {
|
||||
|
||||
case SCS_ASCII_AND_UNICODE:
|
||||
return find_packet(cf, match_ascii_and_unicode, &info);
|
||||
return find_packet(cf, match_ascii_and_unicode, &info, dir);
|
||||
|
||||
case SCS_ASCII:
|
||||
return find_packet(cf, match_ascii, &info);
|
||||
return find_packet(cf, match_ascii, &info, dir);
|
||||
|
||||
case SCS_UNICODE:
|
||||
return find_packet(cf, match_unicode, &info);
|
||||
return find_packet(cf, match_unicode, &info, dir);
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
} else
|
||||
return find_packet(cf, match_binary, &info);
|
||||
return find_packet(cf, match_binary, &info, dir);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static match_result
|
||||
match_ascii_and_unicode(capture_file *cf, frame_data *fdata, void *criterion)
|
||||
{
|
||||
cbs_t *info = criterion;
|
||||
const guint8 *ascii_text = info->data;
|
||||
size_t textlen = info->data_len;
|
||||
gboolean frame_matched;
|
||||
guint32 buf_len;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
cbs_t *info = criterion;
|
||||
const guint8 *ascii_text = info->data;
|
||||
size_t textlen = info->data_len;
|
||||
match_result result;
|
||||
guint32 buf_len;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
|
||||
frame_matched = FALSE;
|
||||
/* Load the frame's data. */
|
||||
if (!cf_read_frame(cf, fdata)) {
|
||||
/* Attempt to get the packet failed. */
|
||||
return MR_ERROR;
|
||||
}
|
||||
|
||||
result = MR_NOTMATCHED;
|
||||
buf_len = fdata->pkt_len;
|
||||
for (i = 0; i < buf_len; i++) {
|
||||
c_char = cf->pd[i];
|
||||
|
@ -3568,33 +3615,39 @@ match_ascii_and_unicode(capture_file *cf, frame_data *fdata, void *criterion)
|
|||
c_char = toupper(c_char);
|
||||
if (c_char != 0) {
|
||||
if (c_char == ascii_text[c_match]) {
|
||||
c_match++;
|
||||
if (c_match == textlen) {
|
||||
frame_matched = TRUE;
|
||||
cf->search_pos = i; /* Save the position of the last character
|
||||
for highlighting the field. */
|
||||
break;
|
||||
}
|
||||
c_match++;
|
||||
if (c_match == textlen) {
|
||||
result = MR_MATCHED;
|
||||
cf->search_pos = i; /* Save the position of the last character
|
||||
for highlighting the field. */
|
||||
break;
|
||||
}
|
||||
} else
|
||||
c_match = 0;
|
||||
c_match = 0;
|
||||
}
|
||||
}
|
||||
return frame_matched;
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static match_result
|
||||
match_ascii(capture_file *cf, frame_data *fdata, void *criterion)
|
||||
{
|
||||
cbs_t *info = criterion;
|
||||
const guint8 *ascii_text = info->data;
|
||||
size_t textlen = info->data_len;
|
||||
gboolean frame_matched;
|
||||
guint32 buf_len;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
cbs_t *info = criterion;
|
||||
const guint8 *ascii_text = info->data;
|
||||
size_t textlen = info->data_len;
|
||||
match_result result;
|
||||
guint32 buf_len;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
|
||||
frame_matched = FALSE;
|
||||
/* Load the frame's data. */
|
||||
if (!cf_read_frame(cf, fdata)) {
|
||||
/* Attempt to get the packet failed. */
|
||||
return MR_ERROR;
|
||||
}
|
||||
|
||||
result = MR_NOTMATCHED;
|
||||
buf_len = fdata->pkt_len;
|
||||
for (i = 0; i < buf_len; i++) {
|
||||
c_char = cf->pd[i];
|
||||
|
@ -3603,30 +3656,36 @@ match_ascii(capture_file *cf, frame_data *fdata, void *criterion)
|
|||
if (c_char == ascii_text[c_match]) {
|
||||
c_match++;
|
||||
if (c_match == textlen) {
|
||||
frame_matched = TRUE;
|
||||
cf->search_pos = i; /* Save the position of the last character
|
||||
for highlighting the field. */
|
||||
break;
|
||||
result = MR_MATCHED;
|
||||
cf->search_pos = i; /* Save the position of the last character
|
||||
for highlighting the field. */
|
||||
break;
|
||||
}
|
||||
} else
|
||||
c_match = 0;
|
||||
}
|
||||
return frame_matched;
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static match_result
|
||||
match_unicode(capture_file *cf, frame_data *fdata, void *criterion)
|
||||
{
|
||||
cbs_t *info = criterion;
|
||||
const guint8 *ascii_text = info->data;
|
||||
size_t textlen = info->data_len;
|
||||
gboolean frame_matched;
|
||||
guint32 buf_len;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
cbs_t *info = criterion;
|
||||
const guint8 *ascii_text = info->data;
|
||||
size_t textlen = info->data_len;
|
||||
match_result result;
|
||||
guint32 buf_len;
|
||||
guint32 i;
|
||||
guint8 c_char;
|
||||
size_t c_match = 0;
|
||||
|
||||
frame_matched = FALSE;
|
||||
/* Load the frame's data. */
|
||||
if (!cf_read_frame(cf, fdata)) {
|
||||
/* Attempt to get the packet failed. */
|
||||
return MR_ERROR;
|
||||
}
|
||||
|
||||
result = MR_NOTMATCHED;
|
||||
buf_len = fdata->pkt_len;
|
||||
for (i = 0; i < buf_len; i++) {
|
||||
c_char = cf->pd[i];
|
||||
|
@ -3636,86 +3695,148 @@ match_unicode(capture_file *cf, frame_data *fdata, void *criterion)
|
|||
c_match++;
|
||||
i++;
|
||||
if (c_match == textlen) {
|
||||
frame_matched = TRUE;
|
||||
cf->search_pos = i; /* Save the position of the last character
|
||||
for highlighting the field. */
|
||||
break;
|
||||
result = MR_MATCHED;
|
||||
cf->search_pos = i; /* Save the position of the last character
|
||||
for highlighting the field. */
|
||||
break;
|
||||
}
|
||||
} else
|
||||
c_match = 0;
|
||||
}
|
||||
return frame_matched;
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static match_result
|
||||
match_binary(capture_file *cf, frame_data *fdata, void *criterion)
|
||||
{
|
||||
cbs_t *info = criterion;
|
||||
const guint8 *binary_data = info->data;
|
||||
size_t datalen = info->data_len;
|
||||
gboolean frame_matched;
|
||||
guint32 buf_len;
|
||||
guint32 i;
|
||||
size_t c_match = 0;
|
||||
cbs_t *info = criterion;
|
||||
const guint8 *binary_data = info->data;
|
||||
size_t datalen = info->data_len;
|
||||
match_result result;
|
||||
guint32 buf_len;
|
||||
guint32 i;
|
||||
size_t c_match = 0;
|
||||
|
||||
frame_matched = FALSE;
|
||||
/* Load the frame's data. */
|
||||
if (!cf_read_frame(cf, fdata)) {
|
||||
/* Attempt to get the packet failed. */
|
||||
return MR_ERROR;
|
||||
}
|
||||
|
||||
result = MR_NOTMATCHED;
|
||||
buf_len = fdata->pkt_len;
|
||||
for (i = 0; i < buf_len; i++) {
|
||||
if (cf->pd[i] == binary_data[c_match]) {
|
||||
c_match++;
|
||||
if (c_match == datalen) {
|
||||
frame_matched = TRUE;
|
||||
cf->search_pos = i; /* Save the position of the last character
|
||||
for highlighting the field. */
|
||||
break;
|
||||
result = MR_MATCHED;
|
||||
cf->search_pos = i; /* Save the position of the last character
|
||||
for highlighting the field. */
|
||||
break;
|
||||
}
|
||||
} else
|
||||
c_match = 0;
|
||||
}
|
||||
return frame_matched;
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode)
|
||||
cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode,
|
||||
search_direction dir)
|
||||
{
|
||||
return find_packet(cf, match_dfilter, sfcode);
|
||||
return find_packet(cf, match_dfilter, sfcode, dir);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gboolean
|
||||
cf_find_packet_dfilter_string(capture_file *cf, const char *filter,
|
||||
search_direction dir)
|
||||
{
|
||||
dfilter_t *sfcode;
|
||||
gboolean result;
|
||||
|
||||
if (!dfilter_compile(filter, &sfcode)) {
|
||||
/*
|
||||
* XXX - this shouldn't happen, as the filter string is machine
|
||||
* generated
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
if (sfcode == NULL) {
|
||||
/*
|
||||
* XXX - this shouldn't happen, as the filter string is machine
|
||||
* generated.
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
result = find_packet(cf, match_dfilter, sfcode, dir);
|
||||
dfilter_free(sfcode);
|
||||
return result;
|
||||
}
|
||||
|
||||
static match_result
|
||||
match_dfilter(capture_file *cf, frame_data *fdata, void *criterion)
|
||||
{
|
||||
dfilter_t *sfcode = criterion;
|
||||
epan_dissect_t edt;
|
||||
gboolean frame_matched;
|
||||
dfilter_t *sfcode = criterion;
|
||||
epan_dissect_t edt;
|
||||
match_result result;
|
||||
|
||||
/* Load the frame's data. */
|
||||
if (!cf_read_frame(cf, fdata)) {
|
||||
/* Attempt to get the packet failed. */
|
||||
return MR_ERROR;
|
||||
}
|
||||
|
||||
epan_dissect_init(&edt, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL);
|
||||
frame_matched = dfilter_apply_edt(sfcode, &edt);
|
||||
result = dfilter_apply_edt(sfcode, &edt) ? MR_MATCHED : MR_NOTMATCHED;
|
||||
epan_dissect_cleanup(&edt);
|
||||
return frame_matched;
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cf_find_packet_marked(capture_file *cf, search_direction dir)
|
||||
{
|
||||
return find_packet(cf, match_marked, NULL, dir);
|
||||
}
|
||||
|
||||
static match_result
|
||||
match_marked(capture_file *cf _U_, frame_data *fdata, void *criterion _U_)
|
||||
{
|
||||
return fdata->flags.marked ? MR_MATCHED : MR_NOTMATCHED;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cf_find_packet_time_reference(capture_file *cf, search_direction dir)
|
||||
{
|
||||
return find_packet(cf, match_time_reference, NULL, dir);
|
||||
}
|
||||
|
||||
static match_result
|
||||
match_time_reference(capture_file *cf _U_, frame_data *fdata, void *criterion _U_)
|
||||
{
|
||||
return fdata->flags.ref_time ? MR_MATCHED : MR_NOTMATCHED;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
find_packet(capture_file *cf,
|
||||
gboolean (*match_function)(capture_file *, frame_data *, void *),
|
||||
void *criterion)
|
||||
match_result (*match_function)(capture_file *, frame_data *, void *),
|
||||
void *criterion, search_direction dir)
|
||||
{
|
||||
frame_data *start_fd;
|
||||
frame_data *fdata;
|
||||
frame_data *new_fd = NULL;
|
||||
progdlg_t *progbar = NULL;
|
||||
gboolean stop_flag;
|
||||
int count;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
int row;
|
||||
float progbar_val;
|
||||
GTimeVal start_time;
|
||||
gchar status_str[100];
|
||||
int progbar_nextstep;
|
||||
int progbar_quantum;
|
||||
const char *title;
|
||||
frame_data *start_fd;
|
||||
frame_data *fdata;
|
||||
frame_data *new_fd = NULL;
|
||||
progdlg_t *progbar = NULL;
|
||||
gboolean stop_flag;
|
||||
int count;
|
||||
int row;
|
||||
float progbar_val;
|
||||
GTimeVal start_time;
|
||||
gchar status_str[100];
|
||||
int progbar_nextstep;
|
||||
int progbar_quantum;
|
||||
const char *title;
|
||||
match_result result;
|
||||
|
||||
start_fd = cf->current_frame;
|
||||
if (start_fd != NULL) {
|
||||
|
@ -3778,7 +3899,7 @@ find_packet(capture_file *cf,
|
|||
}
|
||||
|
||||
/* Go past the current frame. */
|
||||
if (cf->sbackward) {
|
||||
if (dir == SD_BACKWARD) {
|
||||
/* Go on to the previous frame. */
|
||||
fdata = fdata->prev;
|
||||
if (fdata == NULL) {
|
||||
|
@ -3822,26 +3943,23 @@ find_packet(capture_file *cf,
|
|||
|
||||
/* Is this packet in the display? */
|
||||
if (fdata->flags.passed_dfilter) {
|
||||
/* Yes. Load its data. */
|
||||
if (!cf_read_frame(cf, fdata, &err, &err_info)) {
|
||||
/* Read error. Report the error, and go back to the frame
|
||||
/* Yes. Does it match the search criterion? */
|
||||
result = (*match_function)(cf, fdata, criterion);
|
||||
if (result == MR_ERROR) {
|
||||
/* Error; our caller has reported the error. Go back to the frame
|
||||
where we started. */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
new_fd = start_fd;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Does it match the search criterion? */
|
||||
if ((*match_function)(cf, fdata, criterion)) {
|
||||
} else if (result == MR_MATCHED) {
|
||||
/* Yes. Go to the new frame. */
|
||||
new_fd = fdata;
|
||||
break; /* found it! */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fdata == start_fd) {
|
||||
/* We're back to the frame we were on originally, and that frame
|
||||
doesn't match the search filter. The search failed. */
|
||||
doesn't match the search filter. The search failed. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3854,21 +3972,21 @@ find_packet(capture_file *cf,
|
|||
|
||||
if (new_fd != NULL) {
|
||||
#ifdef NEW_PACKET_LIST
|
||||
/* Find and select */
|
||||
row = new_packet_list_find_row_from_data(fdata, TRUE);
|
||||
/* Find and select */
|
||||
row = new_packet_list_find_row_from_data(fdata, TRUE);
|
||||
#else
|
||||
/* We found a frame. Find what row it's in. */
|
||||
row = packet_list_find_row_from_data(new_fd);
|
||||
#endif /* NEW_PACKET_LIST */
|
||||
if (row == -1) {
|
||||
/* We didn't find a row even though we know that a frame
|
||||
* exists that satifies the search criteria. This means that the
|
||||
* frame isn't being displayed currently so we can't select it. */
|
||||
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
||||
"%sEnd of capture exceeded!%s\n\n"
|
||||
"The capture file is probably not fully loaded.",
|
||||
simple_dialog_primary_start(), simple_dialog_primary_end());
|
||||
return FALSE;
|
||||
/* We didn't find a row even though we know that a frame
|
||||
* exists that satifies the search criteria. This means that the
|
||||
* frame isn't being displayed currently so we can't select it. */
|
||||
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
||||
"%sEnd of capture exceeded!%s\n\n"
|
||||
"The capture file is probably not fully loaded.",
|
||||
simple_dialog_primary_start(), simple_dialog_primary_end());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef NEW_PACKET_LIST
|
||||
|
@ -4007,8 +4125,6 @@ void
|
|||
cf_select_packet(capture_file *cf, int row)
|
||||
{
|
||||
frame_data *fdata;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
|
||||
/* Get the frame data struct pointer for this frame */
|
||||
#ifdef NEW_PACKET_LIST
|
||||
|
@ -4054,9 +4170,7 @@ cf_select_packet(capture_file *cf, int row)
|
|||
}
|
||||
|
||||
/* Get the data in that frame. */
|
||||
if (!cf_read_frame (cf, fdata, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
if (!cf_read_frame (cf, fdata)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4249,7 +4363,7 @@ cf_save(capture_file *cf, const char *fname, packet_range_t *range, guint save_f
|
|||
if (cf->is_tempfile) {
|
||||
/* The file being saved is a temporary file from a live
|
||||
capture, so it doesn't need to stay around under that name;
|
||||
first, try renaming the capture buffer file to the new name. */
|
||||
first, try renaming the capture buffer file to the new name. */
|
||||
#ifndef _WIN32
|
||||
if (ws_rename(cf->filename, fname) == 0) {
|
||||
/* That succeeded - there's no need to copy the source file. */
|
||||
|
@ -4257,22 +4371,22 @@ cf_save(capture_file *cf, const char *fname, packet_range_t *range, guint save_f
|
|||
do_copy = FALSE;
|
||||
} else {
|
||||
if (errno == EXDEV) {
|
||||
/* They're on different file systems, so we have to copy the
|
||||
file. */
|
||||
do_copy = TRUE;
|
||||
/* They're on different file systems, so we have to copy the
|
||||
file. */
|
||||
do_copy = TRUE;
|
||||
from_filename = cf->filename;
|
||||
} else {
|
||||
/* The rename failed, but not because they're on different
|
||||
file systems - put up an error message. (Or should we
|
||||
just punt and try to copy? The only reason why I'd
|
||||
expect the rename to fail and the copy to succeed would
|
||||
be if we didn't have permission to remove the file from
|
||||
the temporary directory, and that might be fixable - but
|
||||
is it worth requiring the user to go off and fix it?) */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_rename_error_message(errno), fname);
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
/* The rename failed, but not because they're on different
|
||||
file systems - put up an error message. (Or should we
|
||||
just punt and try to copy? The only reason why I'd
|
||||
expect the rename to fail and the copy to succeed would
|
||||
be if we didn't have permission to remove the file from
|
||||
the temporary directory, and that might be fixable - but
|
||||
is it worth requiring the user to go off and fix it?) */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_rename_error_message(errno), fname);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
#else
|
||||
do_copy = TRUE;
|
||||
|
@ -4539,36 +4653,6 @@ file_rename_error_message(int err)
|
|||
return errmsg;
|
||||
}
|
||||
|
||||
char *
|
||||
cf_read_error_message(int err, gchar *err_info)
|
||||
{
|
||||
static char errmsg_errno[1024+1];
|
||||
|
||||
switch (err) {
|
||||
|
||||
case WTAP_ERR_UNSUPPORTED_ENCAP:
|
||||
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
|
||||
"The file \"%%s\" has a packet with a network type that Wireshark doesn't support.\n(%s)",
|
||||
err_info);
|
||||
g_free(err_info);
|
||||
break;
|
||||
|
||||
case WTAP_ERR_BAD_RECORD:
|
||||
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
|
||||
"An error occurred while reading from the file \"%%s\": %s.\n(%s)",
|
||||
wtap_strerror(err), err_info);
|
||||
g_free(err_info);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
|
||||
"An error occurred while reading from the file \"%%s\": %s.",
|
||||
wtap_strerror(err));
|
||||
break;
|
||||
}
|
||||
return errmsg_errno;
|
||||
}
|
||||
|
||||
static void
|
||||
cf_write_failure_alert_box(const char *filename, int err)
|
||||
{
|
||||
|
|
90
file.h
90
file.h
|
@ -110,12 +110,30 @@ void cf_reload(capture_file *cf);
|
|||
*/
|
||||
cf_read_status_t cf_read(capture_file *cf, gboolean from_save);
|
||||
|
||||
/**
|
||||
* Read the pseudo-header and raw data for a packet. It will pop
|
||||
* up an alert box if there's an error.
|
||||
*
|
||||
* @param cf the capture file from which to read the packet
|
||||
* @param fdata the frame_data structure for the packet in question
|
||||
* @param pseudo_header pointer to a wtap_pseudo_header union into
|
||||
* which to read the packet's pseudo-header
|
||||
* @param pd a guin8 array into which to read the packet's raw data
|
||||
* @return TRUE if the read succeeded, FALSE if there was an error
|
||||
*/
|
||||
gboolean cf_read_frame_r(capture_file *cf, frame_data *fdata,
|
||||
union wtap_pseudo_header *pseudo_header, guint8 *pd,
|
||||
int *err, gchar **err_info);
|
||||
union wtap_pseudo_header *pseudo_header, guint8 *pd);
|
||||
|
||||
gboolean cf_read_frame(capture_file *cf, frame_data *fdata,
|
||||
int *err, gchar **err_info);
|
||||
/**
|
||||
* Read the pseudo-header and raw data for a packet into a
|
||||
* capture_file structure's pseudo_header and pd members.
|
||||
* It will pop up an alert box if there's an error.
|
||||
*
|
||||
* @param cf the capture file from which to read the packet
|
||||
* @param fdata the frame_data structure for the packet in question
|
||||
* @return TRUE if the read succeeded, FALSE if there was an error
|
||||
*/
|
||||
gboolean cf_read_frame(capture_file *cf, frame_data *fdata);
|
||||
|
||||
/**
|
||||
* Start reading from the end of a capture file.
|
||||
|
@ -376,42 +394,79 @@ cf_print_status_t cf_write_csv_packets(capture_file *cf, print_args_t *print_arg
|
|||
cf_print_status_t cf_write_carrays_packets(capture_file *cf, print_args_t *print_args);
|
||||
|
||||
/**
|
||||
* Find Packet in protocol tree.
|
||||
* Find packet with a protocol tree item that contains a specified text string.
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @param string the string to find
|
||||
* @param dir direction in which to search
|
||||
* @return TRUE if a packet was found, FALSE otherwise
|
||||
*/
|
||||
gboolean cf_find_packet_protocol_tree(capture_file *cf, const char *string);
|
||||
gboolean cf_find_packet_protocol_tree(capture_file *cf, const char *string,
|
||||
search_direction dir);
|
||||
|
||||
/**
|
||||
* Find Packet in summary line.
|
||||
* Find packet whose summary line contains a specified text string.
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @param string the string to find
|
||||
* @param dir direction in which to search
|
||||
* @return TRUE if a packet was found, FALSE otherwise
|
||||
*/
|
||||
gboolean cf_find_packet_summary_line(capture_file *cf, const char *string);
|
||||
gboolean cf_find_packet_summary_line(capture_file *cf, const char *string,
|
||||
search_direction dir);
|
||||
|
||||
/**
|
||||
* Find Packet in packet data.
|
||||
* Find packet whose data contains a specified byte string.
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @param string the string to find
|
||||
* @param string_size the size of the string to find
|
||||
* @param dir direction in which to search
|
||||
* @return TRUE if a packet was found, FALSE otherwise
|
||||
*/
|
||||
gboolean cf_find_packet_data(capture_file *cf, const guint8 *string,
|
||||
size_t string_size);
|
||||
size_t string_size, search_direction dir);
|
||||
|
||||
/**
|
||||
* Find Packet by display filter.
|
||||
* Find packet that matches a compiled display filter.
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @param sfcode the display filter to find a packet for
|
||||
* @param sfcode the display filter to match
|
||||
* @param dir direction in which to search
|
||||
* @return TRUE if a packet was found, FALSE otherwise
|
||||
*/
|
||||
gboolean cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode);
|
||||
gboolean cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode,
|
||||
search_direction dir);
|
||||
|
||||
/**
|
||||
* Find packet that matches a display filter given as a text string.
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @param filter the display filter to match
|
||||
* @param dir direction in which to search
|
||||
* @return TRUE if a packet was found, FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
cf_find_packet_dfilter_string(capture_file *cf, const char *filter,
|
||||
search_direction dir);
|
||||
|
||||
/**
|
||||
* Find marked packet.
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @param dir direction in which to search
|
||||
* @return TRUE if a packet was found, FALSE otherwise
|
||||
*/
|
||||
gboolean cf_find_packet_marked(capture_file *cf, search_direction dir);
|
||||
|
||||
/**
|
||||
* Find time-reference packet.
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @param dir direction in which to search
|
||||
* @return TRUE if a packet was found, FALSE otherwise
|
||||
*/
|
||||
gboolean cf_find_packet_time_reference(capture_file *cf, search_direction dir);
|
||||
|
||||
/**
|
||||
* GoTo Packet in first row.
|
||||
|
@ -504,15 +559,6 @@ void cf_ignore_frame(capture_file *cf, frame_data *frame);
|
|||
*/
|
||||
void cf_unignore_frame(capture_file *cf, frame_data *frame);
|
||||
|
||||
/**
|
||||
* Convert error number and info to a complete message.
|
||||
*
|
||||
* @param err the error number
|
||||
* @param err_info a string with additional details about this error
|
||||
* @return statically allocated error message
|
||||
*/
|
||||
char *cf_read_error_message(int err, gchar *err_info);
|
||||
|
||||
/**
|
||||
* Merge two (or more) capture files into one.
|
||||
* @todo is this the right place for this function? It doesn't have to do a lot with capture_file.
|
||||
|
|
|
@ -304,7 +304,7 @@ error_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint call
|
|||
else
|
||||
{
|
||||
/* We have an expert item so just continue search without find dialog. */
|
||||
find_previous_next_frame_with_filter(str, FALSE);
|
||||
cf_find_packet_dfilter_string(&cfile, str, SD_FORWARD);
|
||||
}
|
||||
break;
|
||||
case ACTION_FIND_PREVIOUS:
|
||||
|
@ -322,7 +322,7 @@ error_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint call
|
|||
else
|
||||
{
|
||||
/* We have an expert item so just continue search without find dialog. */
|
||||
find_previous_next_frame_with_filter(str, TRUE);
|
||||
cf_find_packet_dfilter_string(&cfile, str, SD_BACKWARD);
|
||||
}
|
||||
break;
|
||||
case ACTION_COLORIZE:
|
||||
|
|
|
@ -94,10 +94,10 @@ apply_selected_filter (guint callback_action, char *filter)
|
|||
find_frame_with_filter(str);
|
||||
break;
|
||||
case ACTION_FIND_NEXT:
|
||||
find_previous_next_frame_with_filter(str, FALSE);
|
||||
cf_find_packet_dfilter_string(&cfile, str, SD_FORWARD);
|
||||
break;
|
||||
case ACTION_FIND_PREVIOUS:
|
||||
find_previous_next_frame_with_filter(str, TRUE);
|
||||
cf_find_packet_dfilter_string(&cfile, str, SD_BACKWARD);
|
||||
break;
|
||||
case ACTION_COLORIZE:
|
||||
color_display_with_filter(str);
|
||||
|
|
|
@ -310,12 +310,12 @@ find_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
gtk_widget_show(direction_vb);
|
||||
|
||||
up_rb = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "_Up");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(up_rb), cfile.sbackward);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(up_rb), cfile.dir == SD_BACKWARD);
|
||||
gtk_box_pack_start(GTK_BOX(direction_vb), up_rb, FALSE, FALSE, 0);
|
||||
gtk_widget_show(up_rb);
|
||||
|
||||
down_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(up_rb), "_Down");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(down_rb), !cfile.sbackward);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(down_rb), cfile.dir == SD_FORWARD);
|
||||
gtk_box_pack_start(GTK_BOX(direction_vb), down_rb, FALSE, FALSE, 0);
|
||||
gtk_widget_show(down_rb);
|
||||
|
||||
|
@ -640,7 +640,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
|||
*/
|
||||
g_free(cfile.sfilter);
|
||||
cfile.sfilter = g_strdup(filter_text);
|
||||
cfile.sbackward = GTK_TOGGLE_BUTTON (up_rb)->active;
|
||||
cfile.dir = GTK_TOGGLE_BUTTON (up_rb)->active ? SD_BACKWARD : SD_FORWARD;
|
||||
cfile.hex = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (hex_rb));
|
||||
cfile.string = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (string_rb));
|
||||
cfile.scs_type = scs_type;
|
||||
|
@ -649,7 +649,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
|||
cfile.summary_data = summary_data;
|
||||
|
||||
if (cfile.hex) {
|
||||
found_packet = cf_find_packet_data(&cfile, bytes, nbytes);
|
||||
found_packet = cf_find_packet_data(&cfile, bytes, nbytes, cfile.dir);
|
||||
g_free(bytes);
|
||||
if (!found_packet) {
|
||||
/* We didn't find a packet */
|
||||
|
@ -661,7 +661,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
|||
if (cfile.decode_data) {
|
||||
/* The text in the protocol tree */
|
||||
if(string){
|
||||
found_packet = cf_find_packet_protocol_tree(&cfile, string);
|
||||
found_packet = cf_find_packet_protocol_tree(&cfile, string, cfile.dir);
|
||||
g_free(string);
|
||||
}
|
||||
if (!found_packet) {
|
||||
|
@ -672,7 +672,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
|||
} else if (cfile.summary_data) {
|
||||
/* The text in the summary line */
|
||||
if(string){
|
||||
found_packet = cf_find_packet_summary_line(&cfile, string);
|
||||
found_packet = cf_find_packet_summary_line(&cfile, string, cfile.dir);
|
||||
g_free(string);
|
||||
}
|
||||
if (!found_packet) {
|
||||
|
@ -686,7 +686,8 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
|||
} else {
|
||||
/* The raw packet data */
|
||||
if(string){
|
||||
found_packet = cf_find_packet_data(&cfile, string, strlen(string));
|
||||
found_packet = cf_find_packet_data(&cfile, string, strlen(string),
|
||||
cfile.dir);
|
||||
g_free(string);
|
||||
}
|
||||
if (!found_packet) {
|
||||
|
@ -696,7 +697,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
found_packet = cf_find_packet_dfilter(&cfile, sfcode);
|
||||
found_packet = cf_find_packet_dfilter(&cfile, sfcode, cfile.dir);
|
||||
dfilter_free(sfcode);
|
||||
if (!found_packet) {
|
||||
/* We didn't find a packet */
|
||||
|
@ -723,7 +724,7 @@ find_frame_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
|||
}
|
||||
|
||||
static void
|
||||
find_previous_next(GtkWidget *w, gpointer d, gboolean sens)
|
||||
find_previous_next(GtkWidget *w, gpointer d, search_direction dir)
|
||||
{
|
||||
guint8 *bytes;
|
||||
size_t nbytes;
|
||||
|
@ -731,7 +732,7 @@ find_previous_next(GtkWidget *w, gpointer d, gboolean sens)
|
|||
dfilter_t *sfcode;
|
||||
|
||||
if (cfile.sfilter) {
|
||||
cfile.sbackward = sens;
|
||||
cfile.dir = dir;
|
||||
if (cfile.hex) {
|
||||
bytes = convert_string_to_hex(cfile.sfilter, &nbytes);
|
||||
if (bytes == NULL) {
|
||||
|
@ -741,20 +742,20 @@ find_previous_next(GtkWidget *w, gpointer d, gboolean sens)
|
|||
*/
|
||||
return;
|
||||
}
|
||||
cf_find_packet_data(&cfile, bytes, nbytes);
|
||||
cf_find_packet_data(&cfile, bytes, nbytes, dir);
|
||||
g_free(bytes);
|
||||
} else if (cfile.string) {
|
||||
string = convert_string_case(cfile.sfilter, cfile.case_type);
|
||||
/* OK, what are we searching? */
|
||||
if (cfile.decode_data) {
|
||||
/* The text in the protocol tree */
|
||||
cf_find_packet_protocol_tree(&cfile, string);
|
||||
cf_find_packet_protocol_tree(&cfile, string, dir);
|
||||
} else if (cfile.summary_data) {
|
||||
/* The text in the summary line */
|
||||
cf_find_packet_summary_line(&cfile, string);
|
||||
cf_find_packet_summary_line(&cfile, string, dir);
|
||||
} else {
|
||||
/* The raw packet data */
|
||||
cf_find_packet_data(&cfile, string, strlen(string));
|
||||
cf_find_packet_data(&cfile, string, strlen(string), dir);
|
||||
}
|
||||
g_free(string);
|
||||
} else {
|
||||
|
@ -772,7 +773,7 @@ find_previous_next(GtkWidget *w, gpointer d, gboolean sens)
|
|||
*/
|
||||
return;
|
||||
}
|
||||
cf_find_packet_dfilter(&cfile, sfcode);
|
||||
cf_find_packet_dfilter(&cfile, sfcode, dir);
|
||||
dfilter_free(sfcode);
|
||||
}
|
||||
} else
|
||||
|
@ -782,41 +783,11 @@ find_previous_next(GtkWidget *w, gpointer d, gboolean sens)
|
|||
void
|
||||
find_next_cb(GtkWidget *w , gpointer d)
|
||||
{
|
||||
find_previous_next(w, d, FALSE);
|
||||
find_previous_next(w, d, SD_FORWARD);
|
||||
}
|
||||
|
||||
void
|
||||
find_previous_cb(GtkWidget *w , gpointer d)
|
||||
{
|
||||
find_previous_next(w, d, TRUE);
|
||||
}
|
||||
|
||||
/* this function jumps to the next packet matching the filter */
|
||||
void
|
||||
find_previous_next_frame_with_filter(const char *filter, gboolean backwards)
|
||||
{
|
||||
dfilter_t *sfcode;
|
||||
gboolean sbackwards_saved;
|
||||
|
||||
/* temporarily set the direction we want to search */
|
||||
sbackwards_saved=cfile.sbackward;
|
||||
cfile.sbackward = backwards;
|
||||
|
||||
if (!dfilter_compile(filter, &sfcode)) {
|
||||
/*
|
||||
* XXX - this shouldn't happen, as the filter string is machine
|
||||
* generated
|
||||
*/
|
||||
return;
|
||||
}
|
||||
if (sfcode == NULL) {
|
||||
/*
|
||||
* XXX - this shouldn't happen, as the filter string is machine
|
||||
* generated.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
cf_find_packet_dfilter(&cfile, sfcode);
|
||||
dfilter_free(sfcode);
|
||||
cfile.sbackward=sbackwards_saved;
|
||||
find_previous_next(w, d, SD_BACKWARD);
|
||||
}
|
||||
|
|
|
@ -58,11 +58,4 @@ extern void find_previous_cb(GtkWidget *widget, gpointer data);
|
|||
*/
|
||||
extern void find_frame_with_filter(char *filter);
|
||||
|
||||
/** Find next/previous frame by filter.
|
||||
*
|
||||
* @param filter the filter string
|
||||
* @param backwards TRUE, if searching should be done backwards
|
||||
*/
|
||||
extern void find_previous_next_frame_with_filter(const char *filter, gboolean backwards);
|
||||
|
||||
#endif /* find_dlg.h */
|
||||
|
|
|
@ -3390,8 +3390,6 @@ static void iax2_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
|
|||
dfilter_t *sfcode;
|
||||
capture_file *cf;
|
||||
epan_dissect_t edt;
|
||||
gint err;
|
||||
gchar *err_info;
|
||||
gboolean frame_matched;
|
||||
frame_data *fdata;
|
||||
GList *strinfo_list;
|
||||
|
@ -3414,11 +3412,8 @@ static void iax2_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
|
|||
return; /* if we exit here it's an error */
|
||||
|
||||
/* dissect the current frame */
|
||||
if (!cf_read_frame(cf, fdata, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
return;
|
||||
}
|
||||
if (!cf_read_frame(cf, fdata))
|
||||
return; /* error reading the frame */
|
||||
epan_dissect_init(&edt, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL);
|
||||
|
|
37
gtk/main.c
37
gtk/main.c
|
@ -532,8 +532,6 @@ get_ip_address_list_from_packet_list_row(gpointer data)
|
|||
gint col;
|
||||
frame_data *fdata;
|
||||
GList *addr_list = NULL;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
|
||||
#ifdef NEW_PACKET_LIST
|
||||
fdata = (frame_data *) new_packet_list_get_row_data(row);
|
||||
|
@ -544,12 +542,8 @@ get_ip_address_list_from_packet_list_row(gpointer data)
|
|||
if (fdata != NULL) {
|
||||
epan_dissect_t edt;
|
||||
|
||||
if (!cf_read_frame (&cfile, fdata, &err, &err_info))
|
||||
{
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cfile.filename);
|
||||
return NULL;
|
||||
}
|
||||
if (!cf_read_frame (&cfile, fdata))
|
||||
return NULL; /* error reading the frame */
|
||||
|
||||
epan_dissect_init(&edt, FALSE, FALSE);
|
||||
col_custom_prime_edt(&edt, &cfile.cinfo);
|
||||
|
@ -586,8 +580,6 @@ get_filter_from_packet_list_row_and_column(gpointer data)
|
|||
#endif
|
||||
frame_data *fdata;
|
||||
gchar *buf=NULL;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
|
||||
#ifdef NEW_PACKET_LIST
|
||||
fdata = (frame_data *) new_packet_list_get_row_data(row);
|
||||
|
@ -598,11 +590,8 @@ get_filter_from_packet_list_row_and_column(gpointer data)
|
|||
if (fdata != NULL) {
|
||||
epan_dissect_t edt;
|
||||
|
||||
if (!cf_read_frame(&cfile, fdata, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cfile.filename);
|
||||
return NULL;
|
||||
}
|
||||
if (!cf_read_frame(&cfile, fdata))
|
||||
return NULL; /* error reading the frame */
|
||||
/* proto tree, visible. We need a proto tree if there's custom columns */
|
||||
epan_dissect_init(&edt, have_custom_cols(&cfile.cinfo), FALSE);
|
||||
col_custom_prime_edt(&edt, &cfile.cinfo);
|
||||
|
@ -769,10 +758,10 @@ reftime_frame_cb(GtkWidget *w _U_, gpointer data _U_, REFTIME_ACTION_E action)
|
|||
}
|
||||
break;
|
||||
case REFTIME_FIND_NEXT:
|
||||
find_previous_next_frame_with_filter("frame.ref_time", FALSE);
|
||||
cf_find_packet_time_reference(&cfile, SD_FORWARD);
|
||||
break;
|
||||
case REFTIME_FIND_PREV:
|
||||
find_previous_next_frame_with_filter("frame.ref_time", TRUE);
|
||||
cf_find_packet_time_reference(&cfile, SD_BACKWARD);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -780,13 +769,13 @@ reftime_frame_cb(GtkWidget *w _U_, gpointer data _U_, REFTIME_ACTION_E action)
|
|||
void
|
||||
find_next_mark_cb(GtkWidget *w _U_, gpointer data _U_, int action _U_)
|
||||
{
|
||||
find_previous_next_frame_with_filter("frame.marked == TRUE", FALSE);
|
||||
cf_find_packet_marked(&cfile, SD_FORWARD);
|
||||
}
|
||||
|
||||
void
|
||||
find_prev_mark_cb(GtkWidget *w _U_, gpointer data _U_, int action _U_)
|
||||
{
|
||||
find_previous_next_frame_with_filter("frame.marked == TRUE", TRUE);
|
||||
cf_find_packet_marked(&cfile, SD_BACKWARD);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2079,7 +2068,7 @@ main(int argc, char *argv[])
|
|||
GtkWidget *splash_win = NULL;
|
||||
GLogLevelFlags log_flags;
|
||||
guint go_to_packet = 0;
|
||||
gboolean jump_backwards = FALSE, saved_bw = FALSE;
|
||||
gboolean jump_backwards = FALSE;
|
||||
dfilter_t *jump_to_filter = NULL;
|
||||
int optind_initial;
|
||||
int status;
|
||||
|
@ -2952,15 +2941,11 @@ main(int argc, char *argv[])
|
|||
/* try to compile given filter */
|
||||
if (!dfilter_compile(jfilter, &jump_to_filter)) {
|
||||
bad_dfilter_alert_box(jfilter);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
/* Filter ok, jump to the first packet matching the filter
|
||||
conditions. Default search direction is forward, but if
|
||||
option d was given, search backwards */
|
||||
saved_bw = cfile.sbackward;
|
||||
cfile.sbackward = jump_backwards;
|
||||
cf_find_packet_dfilter(&cfile, jump_to_filter);
|
||||
cfile.sbackward = saved_bw;
|
||||
cf_find_packet_dfilter(&cfile, jump_to_filter, jump_backwards);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1088,8 +1088,6 @@ static void
|
|||
packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *record, gboolean dissect_columns, gboolean dissect_color)
|
||||
{
|
||||
epan_dissect_t edt;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
frame_data *fdata;
|
||||
column_info *cinfo;
|
||||
gint col;
|
||||
|
@ -1104,11 +1102,8 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
|
|||
else
|
||||
cinfo = NULL;
|
||||
|
||||
if (!cf_read_frame_r(&cfile, fdata, &pseudo_header, pd, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cfile.filename);
|
||||
return;
|
||||
}
|
||||
if (!cf_read_frame_r(&cfile, fdata, &pseudo_header, pd))
|
||||
return; /* error reading the frame */
|
||||
|
||||
create_proto_tree = (color_filters_used() && dissect_color) ||
|
||||
(have_custom_cols(cinfo) && dissect_columns);
|
||||
|
|
|
@ -131,11 +131,6 @@ void new_window_cb(GtkWidget *w _U_)
|
|||
struct PacketWinData *DataPtr;
|
||||
int i;
|
||||
|
||||
#ifdef NEW_PACKET_LIST
|
||||
int err;
|
||||
gchar *err_info;
|
||||
#endif /* NEW_PACKET_LIST */
|
||||
|
||||
if (!cfile.current_frame) {
|
||||
/* nothing has been captured so far */
|
||||
return;
|
||||
|
@ -144,10 +139,9 @@ void new_window_cb(GtkWidget *w _U_)
|
|||
#ifdef NEW_PACKET_LIST
|
||||
|
||||
/* With the new packetlists "lazy columns" it's neccesary to reread the frame */
|
||||
if (!cf_read_frame(&cfile, cfile.current_frame, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cfile.filename);
|
||||
return;
|
||||
if (!cf_read_frame(&cfile, cfile.current_frame)) {
|
||||
/* error reading the frame */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3613,8 +3613,6 @@ static void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
|
|||
dfilter_t *sfcode;
|
||||
capture_file *cf;
|
||||
epan_dissect_t edt;
|
||||
gint err;
|
||||
gchar *err_info;
|
||||
gboolean frame_matched;
|
||||
frame_data *fdata;
|
||||
GList *strinfo_list;
|
||||
|
@ -3637,11 +3635,8 @@ static void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
|
|||
return; /* if we exit here it's an error */
|
||||
|
||||
/* dissect the current frame */
|
||||
if (!cf_read_frame(cf, fdata, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
return;
|
||||
}
|
||||
if (!cf_read_frame(cf, fdata))
|
||||
return; /* error reading the frame */
|
||||
epan_dissect_init(&edt, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL);
|
||||
|
|
|
@ -876,8 +876,6 @@ static void sctp_analyse_cb(struct sctp_analyse* u_data, gboolean ext)
|
|||
dfilter_t *sfcode;
|
||||
capture_file *cf;
|
||||
epan_dissect_t edt;
|
||||
gint err;
|
||||
gchar *err_info;
|
||||
gboolean frame_matched, frame_found = FALSE;
|
||||
frame_data *fdata;
|
||||
gchar filter_text[256];
|
||||
|
@ -899,11 +897,8 @@ static void sctp_analyse_cb(struct sctp_analyse* u_data, gboolean ext)
|
|||
return; /* if we exit here it's an error */
|
||||
|
||||
/* dissect the current frame */
|
||||
if (!cf_read_frame(cf, fdata, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
return;
|
||||
}
|
||||
if (!cf_read_frame(cf, fdata))
|
||||
return; /* error reading the frame */
|
||||
|
||||
epan_dissect_init(&edt, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
|
|
|
@ -1782,8 +1782,6 @@ tap_tcpip_packet(void *pct, packet_info *pinfo _U_, epan_dissect_t *edt _U_, con
|
|||
static struct tcpheader *select_tcpip_session (capture_file *cf, struct segment *hdrs)
|
||||
{
|
||||
frame_data *fdata;
|
||||
gint err;
|
||||
gchar *err_info;
|
||||
epan_dissect_t edt;
|
||||
dfilter_t *sfcode;
|
||||
GString *error_string;
|
||||
|
@ -1798,11 +1796,8 @@ static struct tcpheader *select_tcpip_session (capture_file *cf, struct segment
|
|||
}
|
||||
|
||||
/* dissect the current frame */
|
||||
if (!cf_read_frame(cf, fdata, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cf->filename);
|
||||
return NULL;
|
||||
}
|
||||
if (!cf_read_frame(cf, fdata))
|
||||
return NULL; /* error reading the frame */
|
||||
|
||||
|
||||
error_string=register_tap_listener("tcp", &th, NULL, 0, NULL, tap_tcpip_packet, NULL);
|
||||
|
|
|
@ -144,16 +144,11 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
|
|||
epan_dissect_t edt;
|
||||
union wtap_pseudo_header phdr;
|
||||
guint8 pd[WTAP_MAX_PACKET_SIZE];
|
||||
int err;
|
||||
gchar *err_info;
|
||||
double cur_time;
|
||||
|
||||
/* Load the frame from the capture file */
|
||||
if (!cf_read_frame_r(&cfile, frame, &phdr, pd, &err, &err_info)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
cf_read_error_message(err, err_info), cfile.filename);
|
||||
if (!cf_read_frame_r(&cfile, frame, &phdr, pd))
|
||||
return FALSE; /* failure */
|
||||
}
|
||||
|
||||
/* Dissect the frame tree not visible */
|
||||
epan_dissect_init(&edt, TRUE, FALSE);
|
||||
|
|
Loading…
Reference in New Issue