forked from osmocom/wireshark
1514 is a better initial Buffer size than 1500.
Ethernet packets without the CRC are 1514 bytes long, not 1500 bytes long; using 1514 bytes will avoid a reallocation for a full-sized Ethernet packet. Change-Id: Ie8da3f13bf3df07e23e4478b7dcf84f06dec6a9d Reviewed-on: https://code.wireshark.org/review/32761 Reviewed-by: Guy Harris <guy@alum.mit.edu>sylvain/gmr1
parent
f0a2b8303a
commit
937ec02581
|
@ -1166,7 +1166,7 @@ process_cap_file(const char *filename, gboolean need_separator)
|
|||
|
||||
/* Tally up data that we need to parse through the file to find */
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while (wtap_read(wth, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
if (rec.presence_flags & WTAP_HAS_TS) {
|
||||
prev_time = cur_time;
|
||||
|
|
|
@ -50,7 +50,7 @@ void capture_info_new_packets(int to_read, info_data_t* cap_info)
|
|||
/*g_warning("new packets: %u", to_read);*/
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while (to_read > 0) {
|
||||
wtap_cleareof(cap_info->wtap);
|
||||
if (wtap_read(cap_info->wtap, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
|
|
|
@ -1569,7 +1569,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Read all of the packets in turn */
|
||||
wtap_rec_init(&read_rec);
|
||||
ws_buffer_init(&read_buf, 1500);
|
||||
ws_buffer_init(&read_buf, 1514);
|
||||
while (wtap_read(wth, &read_rec, &read_buf, &read_err, &read_err_info, &data_offset)) {
|
||||
if (max_packet_number <= read_count)
|
||||
break;
|
||||
|
|
14
file.c
14
file.c
|
@ -267,7 +267,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
|
||||
/* XXX - we really want to initialize this after we've read all
|
||||
the packets, so we know how much we'll ultimately need. */
|
||||
ws_buffer_init(&cf->buf, 1500);
|
||||
ws_buffer_init(&cf->buf, 1514);
|
||||
|
||||
/* We're about to start reading the file. */
|
||||
cf->state = FILE_READ_IN_PROGRESS;
|
||||
|
@ -586,7 +586,7 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
g_timer_start(prog_timer);
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while ((wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info,
|
||||
&data_offset))) {
|
||||
if (size >= 0) {
|
||||
|
@ -808,7 +808,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
|||
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while (to_read != 0) {
|
||||
wtap_cleareof(cf->provider.wth);
|
||||
if (!wtap_read(cf->provider.wth, &rec, &buf, err, &err_info,
|
||||
|
@ -952,7 +952,7 @@ cf_finish_tail(capture_file *cf, int *err)
|
|||
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while ((wtap_read(cf->provider.wth, &rec, &buf, err, &err_info, &data_offset))) {
|
||||
if (cf->state == FILE_READ_ABORTED) {
|
||||
/* Well, the user decided to abort the read. Break out of the
|
||||
|
@ -2103,7 +2103,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
|
|||
range_process_e process_this;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
g_timer_start(prog_timer);
|
||||
/* Count of packets at which we've looked. */
|
||||
|
@ -3978,7 +3978,7 @@ cf_get_packet_comment(capture_file *cf, const frame_data *fd)
|
|||
Buffer buf; /* Record data */
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
if (!cf_read_record_r(cf, fd, &rec, &buf))
|
||||
{ /* XXX, what we can do here? */ }
|
||||
|
@ -4282,7 +4282,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
|
|||
|
||||
framenum = 0;
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while ((wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info,
|
||||
&data_offset))) {
|
||||
framenum++;
|
||||
|
|
|
@ -933,7 +933,7 @@ load_cap_file(capture_file *cf)
|
|||
epan_dissect_t edt;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Read each frame from infile */
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while (wtap_read(wth, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
FrameRecord_t *newFrameRecord;
|
||||
|
||||
|
@ -320,7 +320,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Write out each sorted frame in turn */
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
for (i = 0; i < frames->len; i++) {
|
||||
FrameRecord_t *frame = (FrameRecord_t *)frames->pdata[i];
|
||||
|
||||
|
|
10
sharkd.c
10
sharkd.c
|
@ -351,7 +351,7 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
}
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
while (wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
if (process_packet(cf, edt, data_offset, &rec, &buf)) {
|
||||
|
@ -536,7 +536,7 @@ sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis
|
|||
return -1;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info)) {
|
||||
wtap_rec_cleanup(&rec);
|
||||
|
@ -596,7 +596,7 @@ sharkd_dissect_columns(frame_data *fdata, guint32 frame_ref_num, guint32 prev_di
|
|||
char *err_info = NULL;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info)) {
|
||||
col_fill_in_error(cinfo, fdata, FALSE, FALSE /* fill_fd_columns */);
|
||||
|
@ -672,7 +672,7 @@ sharkd_retap(void)
|
|||
(have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
epan_dissect_init(&edt, cfile.epan, create_proto_tree, FALSE);
|
||||
|
||||
reset_tap_listeners();
|
||||
|
@ -732,7 +732,7 @@ sharkd_filter(const char *dftext, guint8 **result)
|
|||
frames_count = cfile.count;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
epan_dissect_init(&edt, cfile.epan, TRUE, FALSE);
|
||||
|
||||
passed_bits = 0;
|
||||
|
|
|
@ -1337,7 +1337,7 @@ process_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
|
||||
cf->provider.prev_dis = NULL;
|
||||
cf->provider.prev_cap = NULL;
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
if (do_dissection) {
|
||||
gboolean create_proto_tree;
|
||||
|
|
8
tshark.c
8
tshark.c
|
@ -2737,7 +2737,7 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
|
|||
edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
while (to_read-- && cf->provider.wth) {
|
||||
wtap_cleareof(cf->provider.wth);
|
||||
|
@ -3068,7 +3068,7 @@ process_cap_file_first_pass(capture_file *cf, int max_packet_count,
|
|||
pass_status_t status = PASS_SUCCEEDED;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
/* Allocate a frame_data_sequence for all the frames. */
|
||||
cf->provider.frames = new_frame_data_sequence();
|
||||
|
@ -3242,7 +3242,7 @@ process_cap_file_second_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
pass_status_t status = PASS_SUCCEEDED;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
/* Do we have any tap listeners with filters? */
|
||||
filtering_tap_listeners = have_filtering_tap_listeners();
|
||||
|
@ -3341,7 +3341,7 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
pass_status_t status = PASS_SUCCEEDED;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
framenum = 0;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ get_stats_for_preview(wtap *wth, ws_file_preview_stats *stats,
|
|||
timed_out = FALSE;
|
||||
time(&time_preview);
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while ((wtap_read(wth, &rec, &buf, err, err_info, &data_offset))) {
|
||||
if (rec.presence_flags & WTAP_HAS_TS) {
|
||||
cur_time = nstime_to_sec(&rec.ts);
|
||||
|
|
|
@ -157,7 +157,7 @@ process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats
|
|||
wtap_rec_init(&rec);
|
||||
|
||||
/* Load the record from the capture file */
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
if (!cf_read_record_r(cf, frame, &rec, &buf))
|
||||
return FALSE; /* failure */
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ void PacketListRecord::dissect(capture_file *cap_file, bool dissect_color)
|
|||
}
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
if (!cf_read_record_r(cap_file, fdata_, &rec, &buf)) {
|
||||
/*
|
||||
* Error reading the record.
|
||||
|
|
|
@ -1074,7 +1074,7 @@ QString PacketList::getFilterFromRowAndColumn()
|
|||
Buffer buf; /* Record data */
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
if (!cf_read_record_r(cap_file_, fdata, &rec, &buf)) {
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
|
|
@ -30,7 +30,7 @@ FrameInformation::FrameInformation(CaptureFile * capfile, frame_data * fi, QObje
|
|||
cap_file_(capfile)
|
||||
{
|
||||
wtap_rec_init(&rec_);
|
||||
ws_buffer_init(&buf_, 1500);
|
||||
ws_buffer_init(&buf_, 1514);
|
||||
loadFrameTree();
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ merge_open_in_files(guint in_file_count, const char *const *in_file_names,
|
|||
return FALSE;
|
||||
}
|
||||
wtap_rec_init(&files[i].rec);
|
||||
ws_buffer_init(&files[i].frame_buffer, 1500);
|
||||
ws_buffer_init(&files[i].frame_buffer, 1514);
|
||||
files[i].size = size;
|
||||
files[i].idb_index_map = g_array_new(FALSE, FALSE, sizeof(guint));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue