Specify the optional offset as a positive value, regardless of chopping from packet beginning or packet end. I *think* this will be easier syntax to remember.

svn path=/trunk/; revision=51848
This commit is contained in:
Chris Maynard 2013-09-08 21:35:24 +00:00
parent f54441c125
commit ba3a77bb9a
2 changed files with 11 additions and 9 deletions

View File

@ -95,9 +95,9 @@ Sets the chop length to use when writing the packet data. Each packet is
chopped by <choplen> bytes of data. Positive values chop at the packet
beginning while negative values chop at the packet end.
If the optional offset precedes the <choplen>, then the bytes chopped will be
offset from that value. Positve offsets are from the packet beginning, while
negative offsets are from the packet end.
If an optional offset precedes the <choplen>, then the bytes chopped will be
offset from that value. Offsets are expected to be positive values, regardless
of chopping from packet beginning or packet end.
This is useful for chopping headers for decapsulation of an entire capture,
removing tunneling headers, or in the rare case that the conversion between two

View File

@ -734,9 +734,9 @@ usage(gboolean is_error)
fprintf(output, " chop at the packet beginning, negative values at the\n");
fprintf(output, " packet end. If an optional offset precedes the length,\n");
fprintf(output, " then the bytes chopped will be offset from that value.\n");
fprintf(output, " Positve offsets are from the packet beginning,\n");
fprintf(output, " negative offsets are from the packet end. You can use\n");
fprintf(output, " this option more than once.\n");
fprintf(output, " Offsets are expected to be positive values, regardless\n");
fprintf(output, " of chopping from packet beginning or packet end. You\n");
fprintf(output, " can use this option more than once.\n");
fprintf(output, " -L adjust the frame length when chopping and/or snapping\n");
fprintf(output, " -t <time adjustment> adjust the timestamp of each packet;\n");
fprintf(output, " <time adjustment> is in relative seconds (e.g. -0.5).\n");
@ -976,13 +976,15 @@ main(int argc, char *argv[])
chopoff = 0;
break;
case 2: /* both an offset and chop length was specified */
/* While the following would technically not be a problem, it's
* probably not what the user wanted, so treat it as an error */
if ((choplen > 0 && chopoff < 0) || (choplen < 0 && chopoff > 0)) {
if (chopoff < 0) {
fprintf(stderr, "editcap: \"%s\" isn't a valid chop offset:length\n",
optarg);
exit(1);
}
if (choplen < 0) {
chopoff = -chopoff;
}
break;
default:
fprintf(stderr, "editcap: \"%s\" isn't a valid chop length or offset:length\n",