Commit Graph

162 Commits

Author SHA1 Message Date
Chris Maynard eeba21136c OK, allow either positive or negative offsets no matter if we're chopping from the beginning or the end.
Given the following example, it's now possible to chop the 10 bytes depicted from the 100 byte packet 4 different ways and achieve the exact same results:

    <-------- 100 -------->       Methods:
                                  1) editcap -C 20:10 in.pcap out.pcap
    +------+----+---------+       2) editcap -C -80:10 in.pcap out.pcap
    |  20  | 10 |   70    |       3) editcap -C -70:-10 in.pcap out.pcap
    +------+----+---------+       4) editcap -C 30:-10 in.pcap out.pcap


svn path=/trunk/; revision=51854
2013-09-09 01:04:13 +00:00
Chris Maynard ba3a77bb9a 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
2013-09-08 21:35:24 +00:00
Chris Maynard 54adc0d2ff Allow an optional offset to be specified when chopping bytes from packets.
svn path=/trunk/; revision=51845
2013-09-08 20:29:26 +00:00
Jeff Morriss 2df54da6e2 Move a bunch of the crypt modules and pint.h into wsutil.
This means wsutil now links against libcrypt.

Protect a bunch of the crypt header files from multiple inclusion.

svn path=/trunk/; revision=51100
2013-08-01 23:34:47 +00:00
Jeff Morriss 2d30d5beb1 Move strnatcmp.{h,c} from epan into wsutil: there's nothing epan-specific
there and moving it avoids having to recompile the file for use in editcap
and mergecap (which don't link against libwireshark).

svn path=/trunk/; revision=50650
2013-07-16 01:16:50 +00:00
Jeff Morriss 54bb2e7a5c Move report_err.{h,c} from epan into wsutil: there's nothing epan-specific there and moving it avoids having to recompile the file for use in editcap and capinfos (which don't link against libwireshark).
svn path=/trunk/; revision=50598
2013-07-15 02:48:26 +00:00
Chris Maynard cab1f9fc0c Allow -C <choplen> to be used more than once so it is now possible to chop bytes from both the beginning and end of a packet in a single step.
svn path=/trunk/; revision=50536
2013-07-12 17:14:19 +00:00
Chris Maynard e7a7293bee Add -L option to allow adjustment of original frame length. This change was motivated by a question on ask where the user currently has to jump through hoops to accomplish the same thing which can now be done in 1 step via:
editcap -T wpan -C 16 -L -F libpcap test.pcap test_wpan.pcap

I thought it would be useful enough for others as well.

Ref: http://ask.wireshark.org/questions/22689/problems-with-editcap-and-wpan-encapsulation-option


svn path=/trunk/; revision=50491
2013-07-10 20:02:45 +00:00
Chris Maynard d602662b36 Add strnatcmp by Martin Pool for 'natural order' string comparisons, and make use of it in editcap and mergecap for listing encapsulation types. For example:
Before:
    user0 - USER 0
    user1 - USER 1
    user10 - USER 10
    user11 - USER 11
    user12 - USER 12
    user13 - USER 13
    user14 - USER 14
    user15 - USER 15
    user2 - USER 2
    user3 - USER 3
    user4 - USER 4
    user5 - USER 5
    user6 - USER 6
    user7 - USER 7
    user8 - USER 8
    user9 - USER 9

After:
    user0 - USER 0
    user1 - USER 1
    user2 - USER 2
    user3 - USER 3
    user4 - USER 4
    user5 - USER 5
    user6 - USER 6
    user7 - USER 7
    user8 - USER 8
    user9 - USER 9
    user10 - USER 10
    user11 - USER 11
    user12 - USER 12
    user13 - USER 13
    user14 - USER 14
    user15 - USER 15


svn path=/trunk/; revision=50482
2013-07-10 16:18:37 +00:00
Jeff Morriss a441793cba Move a couple of time-related modules into wsutil.
A bunch of files didn't really need to include these header files so remove
the include line rather than changing it.

svn path=/trunk/; revision=50154
2013-06-25 22:02:20 +00:00
Bill Meier 0df5a9390d From beroset:
remove C++ incompatibilities
 https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 attachment #10397

svn path=/trunk/; revision=48438
2013-03-20 01:18:10 +00:00
Gerald Combs 29ceca1b26 From Balint:
[PATCH 1/2] Revert "Try to fix the "LNK4217: locally defined symbol"
warnings.

This reverts commit r48158.

[PATCH 2/2] Employ small hack in editcap to link with a few objects from
libwireshark properly


From me:

Add the ability to reset symbol exports via ws_symbol_export.h's include
guard and do so in capinfos.c and editcap.c. We include ws_symbol_export.h
in over 200 files so it didn't seem to make sense to remove its include
guard entirely.

svn path=/trunk/; revision=48170
2013-03-07 17:20:12 +00:00
Anders Broman b204e38aef Use explicit casts.
svn path=/trunk/; revision=48108
2013-03-05 22:15:20 +00:00
Gerald Combs bd4cffae58 When any of our executables start on Windows create or open a "Wireshark
is running" mutex. Have the NSIS installer check for this mutex and ask
the user to close Wireshark if it's found. While not perfect this makes
the WinSparkle update process much less annoying.

svn path=/trunk/; revision=47758
2013-02-20 01:19:42 +00:00
Jeff Morriss 664d138ea2 Previous commit put a little too much of the README.developer boilerplate in...
svn path=/trunk/; revision=47065
2013-01-14 15:47:55 +00:00
Jeff Morriss e64d2f9b3f In response to http://ask.wireshark.org/questions/17660/licence-of-editcap
and as per email response from Richard Sharpe, add GPLv2+ boilerplate header
and license.

svn path=/trunk/; revision=47063
2013-01-14 15:25:49 +00:00
Pascal Quantin deb4f08cb2 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8105 :
Allow use of huges values for localtime / ctime / gmtime with MSVC 2008 or later

svn path=/trunk/; revision=46930
2013-01-04 14:56:27 +00:00
Guy Harris 8ed7a73e22 Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +00:00
Jakub Zawadzki 78631020b8 Add wtap_pseudo_header union to wtap_pkthdr structure.
Use pkthdr instead of pseudo_header as argument for dissecting.

svn path=/trunk/; revision=45601
2012-10-16 21:50:57 +00:00
Anders Broman f682f1955b From Jim Young:
Have editcap use modulo when calculating filenum component of fileset name .

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7863

svn path=/trunk/; revision=45556
2012-10-15 08:40:43 +00:00
Anders Broman eb618abad9 From Bill Parker:
Explicitly declare/cast 'unsigned <variable>' as 'unsigned int <variable>'

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7810

svn path=/trunk/; revision=45418
2012-10-09 08:40:02 +00:00
Jeff Morriss 3551a86c36 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45015
2012-09-20 01:29:52 +00:00
Evan Huus 9c0dd8c7dc Make count variable in editcap unsigned, fixes more format string
mismatches.

svn path=/trunk/; revision=44820
2012-09-09 14:23:38 +00:00
Martin Mathieson 3019949943 Fix a copy+paste error ('capinfos' appearing in error string).
svn path=/trunk/; revision=43738
2012-07-16 02:37:42 +00:00
Anders Broman 665b95d154 Try to fix pcap-ng - most files created by editcap -c have no IDB
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7350

By using wtap_dump_open_ng() in all places.

svn path=/trunk/; revision=43271
2012-06-15 12:27:21 +00:00
Jeff Morriss 603b4d4348 Don't free idb_inf in wtap_dump_open_ng(): free it in the callers. This fixes the double-free editcap crashes that the buildbot's been seeing lately.
svn path=/trunk/; revision=41542
2012-03-14 01:08:09 +00:00
Anders Broman 7605b01482 From Jose Pedro Oliveira:
the shb_userappl value wasn't being changed.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6937

svn path=/trunk/; revision=41530
2012-03-13 14:11:08 +00:00
Anders Broman ead0764cd9 A modified version of "pcapng: shd_userappl in newly created files"
to only add the name if no name if there yet. Original patch from
Jose Pedro Oliveira. 

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6937

svn path=/trunk/; revision=41524
2012-03-13 09:13:27 +00:00
Anders Broman 3394b453af Free idb_inf and shb_hdr when done.
svn path=/trunk/; revision=41501
2012-03-12 14:18:04 +00:00
Guy Harris 25ae6ac329 Use wtap_dump_open_ng(), so we preserve all the interfaces in pcap-NG
files.

svn path=/trunk/; revision=41328
2012-03-03 00:14:16 +00:00
Bill Meier 174d06e4c6 Revert SVN #40866 (which used g_fprintf() in place of fprintf()).
Using g_fprintf() fails (crashes) on Windows because the Windows GLib DLL
is linked with (depends upon) MSVCRT while editcap is linked with
(depends upon) MSVCR90.

IOW: "You can't do that ... (on Windows)"

See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6695 (Comment 2)
for some additional information.


svn path=/trunk/; revision=41168
2012-02-24 05:17:46 +00:00
Anders Broman 23928d9923 From Alexander Koeppe:
Eliminate Mixture of libc and glibc in editcap.c

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6695

svn path=/trunk/; revision=40866
2012-02-05 13:25:36 +00:00
Anders Broman e553c70fe8 From Michael Mann:
help page update (pcapng is now the default file format).

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6551

svn path=/trunk/; revision=40658
2012-01-23 07:48:53 +00:00
Jörg Mayer 2097912587 Rename crypt-xxx to xxx
svn path=/trunk/; revision=40511
2012-01-15 12:29:44 +00:00
Guy Harris d94bd07f99 Rename WTAP_ERR_BAD_RECORD to WTAP_ERR_BAD_FILE; it really reports any
form of corruption/bogosity in a file, including in a file header as
well as in records in the file.  Change the error message
wtap_strerror() returns for it to reflect that.

Use it for some file header problems for which it wasn't already being
used - WTAP_ERR_UNSUPPORTED shouldn't be used for that, it should only
be used for files that we have no reason to believe are invalid but that
have a version number we don't know about or some other
non-link-layer-encapsulation-type value we don't know about.

svn path=/trunk/; revision=40175
2011-12-13 09:53:50 +00:00
Guy Harris 2929c93ea2 When reporting "sorry, *this* packet can't be written to a file of that
type" when writing out a capture file (i.e., writing a
per-packet-encapsulation capture to a file type that supports it but
doesn't support one of the packet's encapsulations), report the packet
number and, when doing this in a merge operation, report the file from
which it came.

When reporting "sorry, that file can't be written to a file of that
type, period", show the file type rather than the input file link-layer
type that causes the problem.  (We could show both.  We could be
*really* ambitious and iterate through all possible file types and show
the ones that will or at least might work....)

file_write_error_message() is documented as handling only UNIX-style
errnos, and libwireshark should be usable without libwiretap, so leave
it up to its callers to handle Wiretap errors such as
WTAP_ERR_SHORT_WRITE.

Clean up indentation.

svn path=/trunk/; revision=39949
2011-11-19 20:18:01 +00:00
Jeff Morriss bf95c7b5e4 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5608 :
getopt() can/should normally be found in unistd.h, so:

- When testing for getopt(), define that we HAVE_GETOPT instead of
  HAVE_GETOPT_H (to avoid confusion).
- Don't attempt to include getopt.h: not all OS's have it (for example,
  Solaris 9 does not).
- (All the places which need getopt already include unistd.h (if we have it).)

If this breaks things on some OS, we might need (a real) HAVE_GETOPT_H check.

svn path=/trunk/; revision=38437
2011-08-09 21:02:10 +00:00
Jeff Morriss 8589a0eb1d Remove the snaplen check added in r37633: the change in r37634 makes it
unnecessary.

svn path=/trunk/; revision=38155
2011-07-21 21:19:18 +00:00
Martin Mathieson 3a88c5c7dd Don't sanity-check snaplen against frame length if snaplen is 0.
svn path=/trunk/; revision=38132
2011-07-20 12:24:41 +00:00
Stig Bjørlykke 7da7f34750 Prohibited APIs: strncpy -> g_strlcpy.
svn path=/trunk/; revision=37768
2011-06-23 13:50:07 +00:00
Gerald Combs 4d603719d0 Have mergecap, tshark, and editcap write pcap-ng files by default. This
is mainly an attempt to fix the currently-broken "test.sh" step on the
XP buildbot. If this causes too many problems we might want to have
suite-capture.sh:capture_step_snapshot pass "-P" to dumpcap instead.

svn path=/trunk/; revision=37736
2011-06-20 23:31:26 +00:00
Guy Harris f783d2d904 See if this squelches some compiler warnings.
svn path=/trunk/; revision=37669
2011-06-15 19:23:58 +00:00
Jeff Morriss 90e539b55f Simplify timestamp checking: only check the packet's timestamp if
check_startstop is set.

Refuse to write packets that do not fit in the file type we're writing.  This
allows fuzz testing to be done on JPEGs without generating bogus files (with
packets bigger than the maximum packet size).  This fixes
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6010 .

Note that this is only a problem with editcap is run with -T to force the
encapsulation type.

Maybe this needs a more generic solution (e.g., should this check be done in
the wiretap routines?), but at least for now it'll pacify the buildbot.

svn path=/trunk/; revision=37633
2011-06-09 18:27:11 +00:00
Chris Maynard 91bd619c64 Handle snaplen before choplen for consistency. Also, if chopping more bytes
than present, just chop all by setting caplen to 0.  In all cases, don't touch
len.  In other words, change incl_len but leave orig_len alone.

svn path=/trunk/; revision=37488
2011-05-31 20:24:26 +00:00
Chris Maynard ec494af010 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
2011-05-31 15:31:34 +00:00
Gerald Combs a24687ce8e Move the Windows argument list conversion code to a common routine.
svn path=/trunk/; revision=37372
2011-05-24 00:07:56 +00:00
Chris Maynard 1914330274 Don't bother to strcpy() an empty string; just set buf[0] = '\0': Coverity 626
svn path=/trunk/; revision=36601
2011-04-12 18:43:44 +00:00
Sake Blok b723ee91a0 From Jason Masker (bug 5240):
`
Allow editcap to chop from beginning of packet for decapsulation


svn path=/trunk/; revision=35832
2011-02-04 21:09:55 +00:00
Gerald Combs 3bc1fc3802 On Windows, convert all of our command-line arguments from UTF-16 to
UTF-8 where we don't already do so. In Wireshark use g_utf16_to_utf8
instead of utf_16to8. This should fix bug 5520.

svn path=/trunk/; revision=35411
2011-01-06 23:28:58 +00:00
Bill Meier 03b57df5a0 Fix various typos and spelling errors.
svn path=/trunk/; revision=35126
2010-12-06 01:34:58 +00:00