If all interfaces use the same encapsulation, use

this a the file encapsulation.

This fixes a bug where you can not save a file
in libpcap format when you captured it as a
pcapng one.

This fix will be scheduled for Wireshark 1.2.1
and higher.

svn path=/trunk/; revision=28858
This commit is contained in:
Michael Tüxen 2009-06-27 12:14:18 +00:00
parent 267df8e183
commit 11a65d398b
1 changed files with 18 additions and 7 deletions

View File

@ -482,7 +482,7 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh,
/* "Interface Description Block" */
static int
pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
wtapng_block_t *wblock, int *err, gchar **err_info _U_)
{
guint64 time_units_per_second;
@ -492,6 +492,7 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
pcapng_interface_description_block_t idb;
pcapng_option_header_t oh;
interface_data_t int_data;
gint encap;
char option_content[100]; /* XXX - size might need to be increased, if we see longer options */
@ -663,7 +664,17 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
oh.option_code, oh.option_length);
}
}
int_data.wtab_encap = wtap_pcap_encap_to_wtap_encap(wblock->data.if_descr.link_type);
encap = wtap_pcap_encap_to_wtap_encap(wblock->data.if_descr.link_type);
if (wth->file_encap == WTAP_ENCAP_UNKNOWN) {
wth->file_encap = encap;
} else {
if (wth->file_encap != encap) {
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
}
int_data.wtab_encap = encap;
int_data.time_units_per_second = time_units_per_second;
g_array_append_val(pn->interface_data, int_data);
pn->number_of_interfaces++;
@ -1142,7 +1153,7 @@ pcapng_read_block(wtap *wth, FILE_T fh, pcapng_t *pn, wtapng_block_t *wblock, in
bytes_read = pcapng_read_section_header_block(fh, &bh, pn, wblock, err, err_info);
break;
case(BLOCK_TYPE_IDB):
bytes_read = pcapng_read_if_descr_block(fh, &bh, pn, wblock, err, err_info);
bytes_read = pcapng_read_if_descr_block(wth, fh, &bh, pn, wblock, err, err_info);
break;
case(BLOCK_TYPE_PB):
bytes_read = pcapng_read_packet_block(wth, fh, &bh, pn, wblock, err, err_info, FALSE);
@ -1235,7 +1246,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
return 0;
}
wth->file_encap = WTAP_ENCAP_PER_PACKET;
wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->capture.pcapng = g_malloc(sizeof(pcapng_t));