aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2012-10-16 21:50:57 +0000
committerJakub Zawadzki <darkjames-ws@darkjames.pl>2012-10-16 21:50:57 +0000
commit78631020b83c7aab12934f0cff72dbb5e3f0ba4a (patch)
tree826f6248fcdb37ec849abebc3bdcc650e0df6c61 /file.c
parentd7ae273d7a2373ab6fcc1c58d235b4a7dc4df0e9 (diff)
Add wtap_pseudo_header union to wtap_pkthdr structure.
Use pkthdr instead of pseudo_header as argument for dissecting. svn path=/trunk/; revision=45601
Diffstat (limited to 'file.c')
-rw-r--r--file.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/file.c b/file.c
index 46c48885de..2318282643 100644
--- a/file.c
+++ b/file.c
@@ -1089,7 +1089,7 @@ static int
add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
dfilter_t *dfcode, gboolean filtering_tap_listeners,
guint tap_flags,
- union wtap_pseudo_header *pseudo_header, const guchar *buf,
+ struct wtap_pkthdr *phdr, const guchar *buf,
gboolean refilter,
gboolean add_to_packet_list)
{
@@ -1124,7 +1124,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
}
tap_queue_init(&edt);
- epan_dissect_run(&edt, pseudo_header, buf, fdata, cinfo);
+ epan_dissect_run(&edt, phdr, buf, fdata, cinfo);
tap_push_tapped_queue(&edt);
/* If we have a display filter, apply it if we're refiltering, otherwise
@@ -1189,8 +1189,7 @@ static int
read_packet(capture_file *cf, dfilter_t *dfcode,
gboolean filtering_tap_listeners, guint tap_flags, gint64 offset)
{
- const struct wtap_pkthdr *phdr = wtap_phdr(cf->wth);
- union wtap_pseudo_header *pseudo_header = wtap_pseudoheader(cf->wth);
+ struct wtap_pkthdr *phdr = wtap_phdr(cf->wth);
const guchar *buf = wtap_buf_ptr(cf->wth);
frame_data fdlocal;
guint32 framenum;
@@ -1217,7 +1216,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
epan_dissect_t edt;
epan_dissect_init(&edt, TRUE, FALSE);
epan_dissect_prime_dfilter(&edt, cf->rfcode);
- epan_dissect_run(&edt, pseudo_header, buf, &fdlocal, NULL);
+ epan_dissect_run(&edt, phdr, buf, &fdlocal, NULL);
passed = dfilter_apply_edt(cf->rfcode, &edt);
epan_dissect_cleanup(&edt);
}
@@ -1234,7 +1233,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
if (!cf->redissecting) {
row = add_packet_to_packet_list(fdata, cf, dfcode,
filtering_tap_listeners, tap_flags,
- pseudo_header, buf, TRUE, TRUE);
+ phdr, buf, TRUE, TRUE);
}
}
@@ -1493,7 +1492,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
phdr->interface_id = in_file->interface_id;
phdr->presence_flags = phdr->presence_flags | WTAP_HAS_INTERFACE_ID;
}
- if (!wtap_dump(pdh, wtap_phdr(in_file->wth), wtap_pseudoheader(in_file->wth),
+ if (!wtap_dump(pdh, wtap_phdr(in_file->wth),
wtap_buf_ptr(in_file->wth), &write_err)) {
got_write_error = TRUE;
break;
@@ -1686,7 +1685,7 @@ 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)
+ struct wtap_pkthdr *phdr, guint8 *pd)
{
int err;
gchar *err_info;
@@ -1702,13 +1701,13 @@ cf_read_frame_r(capture_file *cf, frame_data *fdata,
return FALSE;
}
- *pseudo_header = frame->ph;
+ *phdr = frame->phdr;
memcpy(pd, frame->pd, fdata->cap_len);
return TRUE;
}
#endif
- if (!wtap_seek_read(cf->wth, fdata->file_off, pseudo_header, pd,
+ if (!wtap_seek_read(cf->wth, fdata->file_off, phdr, pd,
fdata->cap_len, &err, &err_info)) {
display_basename = g_filename_display_basename(cf->filename);
switch (err) {
@@ -1740,7 +1739,7 @@ cf_read_frame_r(capture_file *cf, frame_data *fdata,
gboolean
cf_read_frame(capture_file *cf, frame_data *fdata)
{
- return cf_read_frame_r(cf, fdata, &cf->pseudo_header, cf->pd);
+ return cf_read_frame_r(cf, fdata, &cf->phdr, cf->pd);
}
/* Rescan the list of packets, reconstructing the CList.
@@ -1950,7 +1949,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
preceding_frame = prev_frame;
}
add_packet_to_packet_list(fdata, cf, dfcode, filtering_tap_listeners,
- tap_flags, &cf->pseudo_header, cf->pd,
+ tap_flags, &cf->phdr, cf->pd,
refilter,
add_to_packet_list);
@@ -2165,11 +2164,9 @@ static psp_return_t
process_specified_packets(capture_file *cf, packet_range_t *range,
const char *string1, const char *string2, gboolean terminate_is_stop,
gboolean (*callback)(capture_file *, frame_data *,
- union wtap_pseudo_header *, const guint8 *, void *),
+ struct wtap_pkthdr *, const guint8 *, void *),
void *callback_args)
{
- union wtap_pseudo_header pseudo_header;
-
guint32 framenum;
frame_data *fdata;
guint8 pd[WTAP_MAX_PACKET_SIZE+1];
@@ -2184,6 +2181,7 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
int progbar_nextstep;
int progbar_quantum;
range_process_e process_this;
+ struct wtap_pkthdr phdr;
/* Update the progress bar when it gets to this value. */
progbar_nextstep = 0;
@@ -2262,13 +2260,13 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
}
/* Get the packet */
- if (!cf_read_frame_r(cf, fdata, &pseudo_header, pd)) {
+ if (!cf_read_frame_r(cf, fdata, &phdr, pd)) {
/* Attempt to get the packet failed. */
ret = PSP_FAILED;
break;
}
/* Process the packet */
- if (!callback(cf, fdata, &pseudo_header, pd, callback_args)) {
+ if (!callback(cf, fdata, &phdr, pd, callback_args)) {
/* Callback failed. We assume it reported the error appropriately. */
ret = PSP_FAILED;
break;
@@ -2290,7 +2288,7 @@ typedef struct {
static gboolean
retap_packet(capture_file *cf _U_, frame_data *fdata,
- union wtap_pseudo_header *pseudo_header, const guint8 *pd,
+ struct wtap_pkthdr *phdr, const guint8 *pd,
void *argsp)
{
retap_callback_args_t *args = argsp;
@@ -2298,7 +2296,7 @@ retap_packet(capture_file *cf _U_, frame_data *fdata,
epan_dissect_init(&edt, args->construct_protocol_tree, FALSE);
tap_queue_init(&edt);
- epan_dissect_run(&edt, pseudo_header, pd, fdata, args->cinfo);
+ epan_dissect_run(&edt, phdr, pd, fdata, args->cinfo);
tap_push_tapped_queue(&edt);
epan_dissect_cleanup(&edt);
@@ -2370,7 +2368,7 @@ typedef struct {
static gboolean
print_packet(capture_file *cf, frame_data *fdata,
- union wtap_pseudo_header *pseudo_header, const guint8 *pd,
+ struct wtap_pkthdr *phdr, const guint8 *pd,
void *argsp)
{
print_callback_args_t *args = argsp;
@@ -2395,10 +2393,10 @@ print_packet(capture_file *cf, frame_data *fdata,
information. */
if (args->print_args->print_summary) {
col_custom_prime_edt(&edt, &cf->cinfo);
- epan_dissect_run(&edt, pseudo_header, pd, fdata, &cf->cinfo);
+ epan_dissect_run(&edt, phdr, pd, fdata, &cf->cinfo);
epan_dissect_fill_in_columns(&edt, FALSE, TRUE);
} else
- epan_dissect_run(&edt, pseudo_header, pd, fdata, NULL);
+ epan_dissect_run(&edt, phdr, pd, fdata, NULL);
if (args->print_formfeed) {
if (!new_page(args->print_args->stream))
@@ -2680,7 +2678,7 @@ cf_print_packets(capture_file *cf, print_args_t *print_args)
static gboolean
write_pdml_packet(capture_file *cf _U_, frame_data *fdata,
- union wtap_pseudo_header *pseudo_header, const guint8 *pd,
+ struct wtap_pkthdr *phdr, const guint8 *pd,
void *argsp)
{
FILE *fh = argsp;
@@ -2688,7 +2686,7 @@ write_pdml_packet(capture_file *cf _U_, frame_data *fdata,
/* Create the protocol tree, but don't fill in the column information. */
epan_dissect_init(&edt, TRUE, TRUE);
- epan_dissect_run(&edt, pseudo_header, pd, fdata, NULL);
+ epan_dissect_run(&edt, phdr, pd, fdata, NULL);
/* Write out the information in that tree. */
proto_tree_write_pdml(&edt, fh);
@@ -2750,7 +2748,7 @@ cf_write_pdml_packets(capture_file *cf, print_args_t *print_args)
static gboolean
write_psml_packet(capture_file *cf, frame_data *fdata,
- union wtap_pseudo_header *pseudo_header, const guint8 *pd,
+ struct wtap_pkthdr *phdr, const guint8 *pd,
void *argsp)
{
FILE *fh = argsp;
@@ -2762,7 +2760,7 @@ write_psml_packet(capture_file *cf, frame_data *fdata,
proto_tree_needed = have_custom_cols(&cf->cinfo);
epan_dissect_init(&edt, proto_tree_needed, proto_tree_needed);
col_custom_prime_edt(&edt, &cf->cinfo);
- epan_dissect_run(&edt, pseudo_header, pd, fdata, &cf->cinfo);
+ epan_dissect_run(&edt, phdr, pd, fdata, &cf->cinfo);
epan_dissect_fill_in_columns(&edt, FALSE, TRUE);
/* Write out the information in that tree. */
@@ -2825,7 +2823,7 @@ cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
static gboolean
write_csv_packet(capture_file *cf, frame_data *fdata,
- union wtap_pseudo_header *pseudo_header, const guint8 *pd,
+ struct wtap_pkthdr *phdr, const guint8 *pd,
void *argsp)
{
FILE *fh = argsp;
@@ -2837,7 +2835,7 @@ write_csv_packet(capture_file *cf, frame_data *fdata,
proto_tree_needed = have_custom_cols(&cf->cinfo);
epan_dissect_init(&edt, proto_tree_needed, proto_tree_needed);
col_custom_prime_edt(&edt, &cf->cinfo);
- epan_dissect_run(&edt, pseudo_header, pd, fdata, &cf->cinfo);
+ epan_dissect_run(&edt, phdr, pd, fdata, &cf->cinfo);
epan_dissect_fill_in_columns(&edt, FALSE, TRUE);
/* Write out the information in that tree. */
@@ -2900,14 +2898,14 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args)
static gboolean
write_carrays_packet(capture_file *cf _U_, frame_data *fdata,
- union wtap_pseudo_header *pseudo_header,
+ struct wtap_pkthdr *phdr,
const guint8 *pd, void *argsp)
{
FILE *fh = argsp;
epan_dissect_t edt;
epan_dissect_init(&edt, TRUE, TRUE);
- epan_dissect_run(&edt, pseudo_header, pd, fdata, NULL);
+ epan_dissect_run(&edt, phdr, pd, fdata, NULL);
proto_tree_write_carrays(fdata->num, fh, &edt);
epan_dissect_cleanup(&edt);
@@ -3000,7 +2998,7 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
/* Construct the protocol tree, including the displayed text */
epan_dissect_init(&edt, TRUE, TRUE);
/* We don't need the column information */
- epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL);
+ epan_dissect_run(&edt, &cf->phdr, cf->pd, fdata, NULL);
/* Iterate through all the nodes, seeing if they have text that matches. */
mdata->cf = cf;
@@ -3104,7 +3102,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
/* Don't bother constructing the protocol tree */
epan_dissect_init(&edt, FALSE, FALSE);
/* Get the column information */
- epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, &cf->cinfo);
+ epan_dissect_run(&edt, &cf->phdr, cf->pd, fdata, &cf->cinfo);
/* Find the Info column */
for (colx = 0; colx < cf->cinfo.num_cols; colx++) {
@@ -3392,7 +3390,7 @@ match_dfilter(capture_file *cf, frame_data *fdata, void *criterion)
epan_dissect_init(&edt, TRUE, FALSE);
epan_dissect_prime_dfilter(&edt, sfcode);
- epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL);
+ epan_dissect_run(&edt, &cf->phdr, cf->pd, fdata, NULL);
result = dfilter_apply_edt(sfcode, &edt) ? MR_MATCHED : MR_NOTMATCHED;
epan_dissect_cleanup(&edt);
return result;
@@ -3725,7 +3723,7 @@ cf_select_packet(capture_file *cf, int row)
cf->edt = epan_dissect_new(TRUE, TRUE);
tap_build_interesting(cf->edt);
- epan_dissect_run(cf->edt, &cf->pseudo_header, cf->pd, cf->current_frame,
+ epan_dissect_run(cf->edt, &cf->phdr, cf->pd, cf->current_frame,
NULL);
dfilter_macro_build_ftv_cache(cf->edt->tree);
@@ -3909,7 +3907,7 @@ typedef struct {
*/
static gboolean
save_packet(capture_file *cf _U_, frame_data *fdata,
- union wtap_pseudo_header *pseudo_header, const guint8 *pd,
+ struct wtap_pkthdr *phdr, const guint8 *pd,
void *argsp)
{
save_callback_args_t *args = argsp;
@@ -3918,6 +3916,7 @@ save_packet(capture_file *cf _U_, frame_data *fdata,
gchar *display_basename;
/* init the wtap header for saving */
+ /* TODO: reuse phdr */
/* XXX - these are the only flags that correspond to data that we have
in the frame_data structure and that matter on a per-packet basis.
@@ -3943,12 +3942,14 @@ save_packet(capture_file *cf _U_, frame_data *fdata,
hdr.interface_id = fdata->interface_id; /* identifier of the interface. */
/* options */
hdr.opt_comment = fdata->opt_comment; /* NULL if not available */
+ /* pseudo */
+ hdr.pseudo_header = phdr->pseudo_header;
#if 0
hdr.drop_count =
hdr.pack_flags = /* XXX - 0 for now (any value for "we don't have it"?) */
#endif
/* and save the packet */
- if (!wtap_dump(args->pdh, &hdr, pseudo_header, pd, &err)) {
+ if (!wtap_dump(args->pdh, &hdr, pd, &err)) {
if (err < 0) {
/* Wiretap error. */
switch (err) {