aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorcmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7>2011-05-31 15:31:34 +0000
committercmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7>2011-05-31 15:31:34 +0000
commitc08748cd3694b9a22737d1aa786f5428d39dd277 (patch)
tree9338ab943deddec0f63ece6e9d3bd0b4890e9526 /editcap.c
parente7122920614a8e462c96b6f79ee492e5617eeef8 (diff)
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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@37480 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/editcap.c b/editcap.c
index f8af5e1356..fa053529aa 100644
--- a/editcap.c
+++ b/editcap.c
@@ -662,9 +662,9 @@ usage(gboolean is_error)
fprintf(output, "Editcap %s"
#ifdef SVNVERSION
- " (" SVNVERSION " from " SVNPATH ")"
+ " (" SVNVERSION " from " SVNPATH ")"
#endif
- "\n", VERSION);
+ "\n", VERSION);
fprintf(output, "Edit and/or translate the format of capture files.\n");
fprintf(output, "See http://www.wireshark.org for more information.\n");
fprintf(output, "\n");
@@ -805,7 +805,7 @@ list_encap_types(void) {
static void
failure_message(const char *msg_format _U_, va_list ap _U_)
{
- return;
+ return;
}
#endif
@@ -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;
@@ -902,7 +902,7 @@ main(int argc, char *argv[])
break;
case 'C':
- choplen = strtol(optarg, &p, 10);
+ choplen = strtol(optarg, &p, 10);
if (p == optarg || *p != '\0') {
fprintf(stderr, "editcap: \"%s\" isn't a valid chop length\n",
optarg);
@@ -983,10 +983,10 @@ main(int argc, char *argv[])
case 'T':
out_frame_type = wtap_short_string_to_encap(optarg);
if (out_frame_type < 0) {
- fprintf(stderr, "editcap: \"%s\" isn't a valid encapsulation type\n\n",
- optarg);
+ fprintf(stderr, "editcap: \"%s\" isn't a valid encapsulation type\n\n",
+ optarg);
list_encap_types();
- exit(1);
+ exit(1);
}
break;
@@ -1135,9 +1135,9 @@ 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),
- 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));
@@ -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));
@@ -1229,7 +1231,7 @@ main(int argc, char *argv[])
snap_phdr = *phdr;
snap_phdr.caplen -= choplen;
snap_phdr.len -= choplen;
- buf += choplen;
+ buf += choplen;
phdr = &snap_phdr;
}
@@ -1469,12 +1471,13 @@ 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));
- exit(2);
+ fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
+ wtap_strerror(err));
+ exit(2);
}
}