When a snaplen is specified using "-s <snaplen", if it's smaller than the

original capture file's snaplen, save the new snaplen in the capture file
header so wireshark and capinfos can report it.

svn path=/trunk/; revision=37480
This commit is contained in:
Chris Maynard 2011-05-31 15:31:34 +00:00
parent 63b50fe2ee
commit ec494af010
1 changed files with 24 additions and 21 deletions

View File

@ -818,7 +818,7 @@ main(int argc, char *argv[])
int opt;
char *p;
unsigned int snaplen = 0; /* No limit */
guint32 snaplen = 0; /* No limit */
int choplen = 0; /* No chop */
wtap_dumper *pdh = NULL;
int count = 1;
@ -1135,8 +1135,8 @@ main(int argc, char *argv[])
} else
filename = g_strdup(argv[optind+1]);
pdh = wtap_dump_open(filename, out_file_type,
out_frame_type, wtap_snapshot_length(wth),
pdh = wtap_dump_open(filename, out_file_type, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
@ -1166,8 +1166,9 @@ main(int argc, char *argv[])
fprintf(stderr, "Continuing writing in file %s\n", filename);
}
pdh = wtap_dump_open(filename, out_file_type,
out_frame_type, wtap_snapshot_length(wth), FALSE /* compressed */, &err);
pdh = wtap_dump_open(filename, out_file_type, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
@ -1196,8 +1197,9 @@ main(int argc, char *argv[])
fprintf(stderr, "Continuing writing in file %s\n", filename);
}
pdh = wtap_dump_open(filename, out_file_type,
out_frame_type, wtap_snapshot_length(wth), FALSE /* compressed */, &err);
pdh = wtap_dump_open(filename, out_file_type, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
wtap_strerror(err));
@ -1469,8 +1471,9 @@ main(int argc, char *argv[])
g_free (filename);
filename = g_strdup(argv[optind+1]);
pdh = wtap_dump_open(filename, out_file_type,
out_frame_type, wtap_snapshot_length(wth), FALSE /* compressed */, &err);
pdh = wtap_dump_open(filename, out_file_type, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)): wtap_snapshot_length(wth),
FALSE /* compressed */, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
wtap_strerror(err));