Commit Graph

245 Commits

Author SHA1 Message Date
Guy Harris 0946518780 Update comments, get rid of IMPORT_MAX_PACKET.
Get rid of the IMPORT_MAX_PACKET #define; just directly use
WTAP_MAX_PACKET_SIZE_STANDARD, to match what text2pcap.c does.

Update comments in text2pcap.c and ui/text_import.c to say the maximum
packet size is WTAP_MAX_PACKET_SIZE_STANDARD.

Change-Id: I34118f76426d1416fccf43b2a356ad8d200de19b
Ping-Bug: 15292
Reviewed-on: https://code.wireshark.org/review/30945
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-06 16:39:17 +00:00
Jaap Keuter 8cee907bbd text2pcap: extend snap length
The snaplength as saved in the capture file is set to the original
PCAP file length of 65535. In reality the package size can grow to
256kiB. Make use of the correct constant when writing the PCAP file.

Bug: 15292
Change-Id: Ib7710e4151cdc712f3344c1436252f9b3bfb556c
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/30923
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-05 18:50:17 +00:00
Jaap Keuter 47cd8c7e8e text2pcap: cleanup type usage
The glib gboolean and integer types are used interchangably,
while a proper use is easily achievable.

While at it, replace the duplicate definition of the IPv4 source
and destination addresses (endian sensitive).

Change-Id: I5378544f370dc41962eb6303ddeeecb184db14f4
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/30770
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-23 22:17:16 +00:00
Jaap Keuter 802d4c0121 text2pcap: make ethernet dummy header direction aware
When giving the command line option '-D' and having 'I' and 'O' markers in
the hexdump to import the IP addresses are adjusted, transport layer ports
are adjusted, the TCP window information is adjusted, but still the frames
originate from the same interface and go to the other interface.

This changes makes it so that the Ethernet destination and source address
is also adjusted with the direction indicated, to match the other adjusted
addressing used.

Bug: 15287
Change-Id: I762f195ece206ed14e6bca1c1160055df7c4dac1
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/30767
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-22 20:59:53 +00:00
Jaap Keuter 36d26b38d7 Update text2pcap documentation
Various parts of the text2pcap documentation need some fixing up.
This change brings them back in line and up to date with current
features.

Change-Id: I038cf5c4943d2a4bbcc3d0fbd8f5e111dcf0d0a9
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/30754
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-21 23:00:31 +00:00
Jaap Keuter 9aa29213f0 text2pcap: consolidate ethernet header protocol determination
With the addition of the IPv6 dummy header the logic to set the
correct ethernet protocol has become scattered across the code
and also poured into the actual packet writing code.
Once command line parsing is completed a consistent set of frame
generating parameters should be established.

This change consolidates the ethernet header protocol
determination to one point, with the added benefit of resolving
a possible duplicate IPv4 / IPv6 paramter setting in the same
manner as is done for other conflicting parameters.

Change-Id: I2c0d3ee8ad5a28b216a374dad807406113200fa2
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/30691
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-19 06:18:21 +00:00
Jaap Keuter 9dad39293e text2pcap: pcapng is an output option
Buried at the end of the help text, in the Miscellaneous section,
is the '-n' option to write pcapng format files. This can hardly
be considered miscellaneous but rather an output option.
Move the option in the help text to the output section.

Change-Id: I3e39b75281091d6d5d9607891ef2f97ba031e48a
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/30690
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-18 21:29:59 +00:00
Jaap Keuter 93361b9977 text2pcap: assure an IP next layer protocol is set
Using -4 or -6 to set an IP address pair to use in the dummy IP
header it is possible to generate a capture in which the next
layer protocol is undefined. Add a check that an next layer
protocol is always set.

Bug: 15275
Change-Id: Ifef54be7f708a0f168d2067f6f691e2611f25428
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/30683
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-18 07:19:00 +00:00
Vasil Velichkov e67eebb70f text2pcap: Fix IPv6 checksum
Add the length field in the IPv6 pseudo header struct and refactor the
pseudo headers initialization

Change-Id: Ie0490dfba051a1112e465aaa6d03909417b2977e
Reviewed-on: https://code.wireshark.org/review/30407
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-10-31 02:45:50 +00:00
Vasil Velichkov 5359a97d43 text2pcap: Fix -i <proto> when IPv6 (-6) is specified
When the -i <proto> option is specified the hdr_ip was always set to
TRUE which resulted in a wrong header length when the IPv6 (-6) option
is specified as well. To resolve this set hdr_ip only when -i is specified
without -4 or -6 options.

Change-Id: I21898f27ceaad603b9275ab6878ff4bd8f9586cd
Reviewed-on: https://code.wireshark.org/review/30411
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-10-31 02:45:27 +00:00
Vasil Velichkov b66a76ae84 text2pcap: Fix IPv6 payload length
According to RFC 8200 the payload length must contain the length of the payload
without the IPv6 header's length

Change-Id: Ibeb18c243edc396eaac6d2ffde73d6c4a6fe75a0
Reviewed-on: https://code.wireshark.org/review/30406
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-30 15:57:02 +00:00
Vasil Velichkov 6c19f98393 text2pcap: Fix TCP, UDP or SCTP headers over IPv6
When the IPv6 (-6) option was specified together with either TCP (-T),
UDP (-u) or SCTP (-s/-S) option the generated packet was invalid because
an IPv4 option was implied an a wrong header was added.

Bug: 15194
Change-Id: I5a7b83d8aa3f3ad56f0c8110e598090945e60225
Reviewed-on: https://code.wireshark.org/review/30107
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-10-11 14:01:48 +00:00
Guy Harris bce13644e9 Bring back arg_list_utf_16to8(), but have it just do UTF-16-to-UTF-8 mapping.
Call it from wmain() in the command-line tools, passing it the input
argument count and vector, and call it from main() in Wireshark, after
getting a UTF-16 argument vector from passing the result of
GetCommandLineW() to CommandLineToArgvW().

Change-Id: I0e51703c0a6c92f7892d196e700ab437bd702514
Reviewed-on: https://code.wireshark.org/review/30063
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-08 03:05:45 +00:00
Guy Harris a679ae6f79 Use wsetargv.obj, and wmain() rather than main(), on Windows.
Doing so for command-line programs means that the argument list doesn't
ever get converted to the local code page; converting to the local code
page can mangle file names that *can't* be converted to the local code
page.

Furthermore, code that uses setargv.obj rather than wsetargv.obj has
issues in some versions of Windows 10; see bug 15151.

That means that converting the argument list to UTF-8 is a bit simpler -
we don't need to call GetCommandLineW() or CommandLineToArgvW(), we just
loop over the UTF-16LE argument strings in argv[].

While we're at it, note in Wireshark's main() why we discard argv on
Windows (Qt does the same "convert-to-the-local-code-page" stuff); that
means we *do* need to call GetCommandLineW() and CommandLineToArgvW() in
main() (i.e., we duplicate what Qt's WinMain() does, but converting to
UTF-8 rather than to the local code page).

Change-Id: I35b57c1b658fb3e9b0c685097afe324e9fe98649
Ping-Bug: 15151
Reviewed-on: https://code.wireshark.org/review/30051
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-07 18:57:54 +00:00
Gerald Combs 246f0bc012 Get rid of TestBigEndian and AC_C_BIGENDIAN.
Get rid of CMake's TestBigEndian and Autotools' AC_C_BIGENDIAN checks in
favor of G_BYTE_ORDER. We use G_BYTE_ORDER elsewhere and TestBigEndian
is noticeably slow on Windows.

Change-Id: Idc1326294db9cbee8f6b6b11c2028fc4d19acbf0
Reviewed-on: https://code.wireshark.org/review/26462
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-13 19:09:36 +00:00
Guy Harris 4a69d10920 Squelch redundant declaration warnings.
Have the text-to-pcap scanners define a routine that the main code
calls, which both allocates and destroys the scanner.  Don't declare the
Lex-generated routines in a header file we create, declare that routine,
instead.

Change-Id: Icad6a83db1a0dea8ac390315af72383fc99f8513
Reviewed-on: https://code.wireshark.org/review/25822
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-16 22:40:26 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Guy Harris af0f49e80d Use pcapng as the name of the file format.
At one point, I remember a discussion resulting in the official name of
the next-generation replacement for pcap format being changed to
"pcapng", with no hyphen.

Make Wireshark reflect that.

Change-Id: Ie66fb13a0fe3a8682143106dab601952e9154e2a
Reviewed-on: https://code.wireshark.org/review/25214
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-01-09 00:38:51 +00:00
Gerald Combs 775bbbcded Start using SPDX license identifiers.
A while back Graham pointed out the SPDX project (spdx.org), which is
working on standardizing license specifications:

https://www.wireshark.org/lists/wireshark-dev/201509/msg00119.html

Appendix V of the specification describes a short identifier
(SPDX-License-Identifier) that you can use in place of boilerplate in
your source files:

https://spdx.org/spdx-specification-21-web-version#h.twlc0ztnng3b

Start the conversion process with our top-level C and C++ files.

Change-Id: Iba1d835776714deb6285e2181e8ca17f95221878
Reviewed-on: https://code.wireshark.org/review/24302
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Balint Reczey <balint@balintreczey.hu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-09 20:03:51 +00:00
Guy Harris 458c3c026e Add a ws_in6_addr typedef for struct e_in6_addr.
That allows a parallel typedef of ws_in4_addr for guint32.

Change-Id: I03b230247065e0e3840eb87635315a8e523ef562
Reviewed-on: https://code.wireshark.org/review/24073
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-10-26 08:50:34 +00:00
João Valverde a269ae1b6a Rename "ws_version_info.h", also .c
It's not installed so like most other files it doesn't need or benefit
from the prefix.

Change-Id: I01517e06f12b3101fee21b68cba3bc6842bbef5c
Reviewed-on: https://code.wireshark.org/review/23751
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-26 17:32:08 +00:00
Pascal Quantin 33c00a6741 text2pcap: fix crash when there is no argument
Bug: 14082
Change-Id: Ifd8b2bf9bee817967e3b00e01b8b4ae90970e984
Reviewed-on: https://code.wireshark.org/review/23727
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-09-25 16:29:32 +00:00
Sontol Bonggol 5a0aa773c1 Do not allow -m option to be larger than our allocated buffer
Specifying -m larger than our allocated buffer may result in segfault.
This patch protects it from happening and exits early.

Change-Id: I2197605d90c98fc9d12b69a68fe533aaf6457df2
Reviewed-on: https://code.wireshark.org/review/23044
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-08-11 11:52:19 +00:00
Guy Harris d0865fd619 Allow bigger snapshot lengths for D-Bus captures.
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except
for D-Bus captures.  Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for
them, because that's the largest possible D-Bus message size.  See

	https://bugs.freedesktop.org/show_bug.cgi?id=100220

for an example of the problems caused by limiting the snapshot length to
256KB for D-Bus.

Have a snapshot length of 0 in a capture_file structure mean "there is
no snapshot length for the file"; we don't need the has_snap field in
that case, a value of 0 mean "no, we don't have a snapshot length".

In dumpcap, start out with a pipe buffer size of 2KB, and grow it as
necessary.  When checking for a too-big packet from a pipe, check
against the appropriate maximum - 128MB for DLT_DBUS, 256KB for
everything else.

Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20
Reviewed-on: https://code.wireshark.org/review/21952
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-05 05:28:26 +00:00
Guy Harris 630b5a8165 Check for localtime() failing.
It "shouldn't happen", but at least this squelches a Coverity complaint,
CID 1394503.

Change-Id: I40af10d47c1d1b026f6b40ef68b139e6bf246109
Reviewed-on: https://code.wireshark.org/review/20774
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-29 01:42:14 +00:00
Pascal Quantin bd486eb9b1 text2pcap: define max packet size to WTAP_MAX_PACKET_SIZE
Change-Id: I73ab87032e4a0c0259227622412be36aaf66a9d6
Reviewed-on: https://code.wireshark.org/review/20758
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-28 10:32:53 +00:00
Dario Lombardo 146b6b824d text2pcap: free memory on exit.
Make also text2pcap_lex_destroy() public to be called from main.

Change-Id: I360c3dd3991d027afe6e4542ea5f9680e92f92cf
Reviewed-on: https://code.wireshark.org/review/20226
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-28 14:56:36 +00:00
Peter Wu 220772dc19 text2pcap: fix -Wmacro-redefined warning
With flex 2.6.3, this warning is observed (which causes a build failure
when -Werror is not disabled:

    text2pcap-scanner.c:398:9: warning: 'yywrap' macro redefined [-Wmacro-redefined]
    #define yywrap() (/*CONSTCOND*/1)
            ^
    text2pcap-scanner.c:76:13: note: previous definition is here
        #define yywrap yywrap

Issue is specific to flex 2.6.3 and resolved upstream at
https://github.com/westes/flex/issues/162

Change-Id: I861565f5080f87a9457427e7a63b5d9256c49e85
Reviewed-on: https://code.wireshark.org/review/20294
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-27 12:52:36 +00:00
Dario Lombardo 513eed6871 text2pcap: check return values of functions and use a single exit point.
This is going to check every function for success and following patches
will free allocated memory in clean_exit.

Change-Id: I7ba7a53eae8a37a4c25e56369af20e575c3489fb
Reviewed-on: https://code.wireshark.org/review/20225
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-27 00:51:37 +00:00
Guy Harris 6930ded24a Include <io.h> and <fcntl.h> for _setmode().
Change-Id: I1910275653ef4a985e9894f01cf5cb5fa33070d4
Reviewed-on: https://code.wireshark.org/review/18928
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-11-22 19:40:21 +00:00
Guy Harris f4d6c7abbc On Windows, put the standard output in binary mode if we're writing the capture file to it.
While we're at it, explicitly compare the restult of strcmp() against 0,
to make it clearer that it's testing for the argument *not* being equal
to "-".

Bug: 13165
Change-Id: Ic63085abb2de5f5c60d2101d19c1a269b7e0c9d7
Reviewed-on: https://code.wireshark.org/review/18924
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-11-22 18:39:35 +00:00
Guy Harris 10ca4c7527 More checks for localtime() and gmtime() returning NULL.
And some comments in the case where we're converting the result of
time() - if your machine's idea of time predates January 1, 1970,
00:00:00 UTC, it'll crash on Windows, but that's not a case where a
*file* can cause the problem due either to a bad file time stamp or bad
time stamps in the file.

Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498
Reviewed-on: https://code.wireshark.org/review/18369
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-22 02:27:32 +00:00
Peter Wu e5fef1d73e Fix version-string releated memleak for some CLI tools
These programs resulted on a memleak report on exit.

Change-Id: I630618f50d723b7af4cb00ba29671d4e7c6fcdc2
Reviewed-on: https://code.wireshark.org/review/17623
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-10 13:00:22 +00:00
João Valverde 3db13a7fc9 Link version code statically again
This allows keeping the code-sharing with the static linking.

This "fixes" a hypothetical ABI mismatch with wsutil and avoids pulling more
external dependencies to wsutil than strictly necessary.

A nice side-effect is that libwsutil no longer depends on version.h.

Follow up to f95976eefc.

Change-Id: I8f0d6a557ab3f7ce6f0e2c269124c89f29d6ad23
Reviewed-on: https://code.wireshark.org/review/15002
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-04-21 18:59:56 +00:00
João Valverde ecb4dc396e Include ws_diag_control.h in config.h
Change-Id: Ia394071710ecda3b0e6686a51fbca45a8ff20317
Reviewed-on: https://code.wireshark.org/review/14749
Petri-Dish: João Valverde <j@v6e.pt>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-04-04 23:05:31 +00:00
João Valverde f95976eefc Move zlib version check to wsutil
Change-Id: I0950f61e90af5bb21c0017204de0c0b509616e5c
Reviewed-on: https://code.wireshark.org/review/14747
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-03 02:58:04 +00:00
Guy Harris a4aa8930bb Put pcapio.c into a writecap library, and use it.
Change-Id: Ib89f345c072a38bc01f0513366a4bdae3bf6f08e
Reviewed-on: https://code.wireshark.org/review/14615
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-24 20:49:37 +00:00
João Valverde 8bee8bad81 Add inet_pton/inet_ntop interface to libwsutil
Change-Id: Ifc344ed33f2f7ca09a6912a5adb49dc35f07c81f
Reviewed-on: https://code.wireshark.org/review/13881
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-19 15:55:09 +00:00
João Valverde 2e85975fee Just #include wsutil/inet_aton.h
No need for platform-specific system header boilerplate.

Change-Id: I5387a0005ddb0d7aab3c5b9f28d6282053c1b0fd
Reviewed-on: https://code.wireshark.org/review/13865
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-13 23:51:53 +00:00
Joerg Mayer c0bdaf15e2 Fix an indentation to get rid of
text2pcap.c:1254:17: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]

Change-Id: Ifa031f5faad3445bcd3ab893d83c5dc6386fe3a2
Reviewed-on: https://code.wireshark.org/review/13927
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2016-02-13 19:54:02 +00:00
Guy Harris 6f61a85267 Don't write out statistics if we don't have any.
We don't know when the capture started or ended (the time stamps of the
first and last packets aren't necessarily the time when the capture
started or ended), we don't know how many packets were dropped in the
capture process, and we don't know how many packets were seen in various
stages before they were received by whatever software dumped them out as
text, so we have no statistics to report.

Change-Id: Ia8bface63a95f925a6ccb19c32d188055809f203
Reviewed-on: https://code.wireshark.org/review/12812
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-21 22:01:52 +00:00
Alexis La Goutte 526dcce74d text2pcap: fix There are identical sub-expressions 'num_packets_written' to the left and to the right of the '-' operator found by PVS Studio (V501)
Change-Id: Ib3fb73f6cc3dba549bd3104e9227f4e4a6e3b08c
Reviewed-on: https://code.wireshark.org/review/12310
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-21 15:30:06 +00:00
João Valverde 2aab706c5a Remove -Wwrite-strings compiler flag
The "-Wwrite-strings" flag produces nuisance warnings. These warnings are
not useful, they're impossible to fix in a sane way and therefore are being
handled with casts of static strings to (char *).

This just moves the warning to [-Wcast-qual] and a compiler pragma is
in turn required (and used) to squelch that warning.

Remove the Wwrite-strings warning. Let that responsibility fall on the
programmer (as is done by casting).

Change-Id: I5a44dfd9decd6d80797a521a3373593074962fb5
Reviewed-on: https://code.wireshark.org/review/12162
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-12 16:21:19 +00:00
Pascal Quantin fb3d38225e Update user guide for development release
Change-Id: I9b4c5ab2e98ad6daa618bcda20b53a23467e16e0
Reviewed-on: https://code.wireshark.org/review/11734
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-11-11 17:31:31 +00:00
Guy Harris 0162e54075 Clean up includes of unistd.h, fcntl.h, and sys/stat.h.
Have wsutil/file_util.h include them on UN*X, just as it includes io.h
on Windows, so we can have a rule of "if you do file operations, include
<wsutil/file_util.h> and use the routines in it".

Remove includes of unistd.h, fcntl.h, and sys/stat.h that aren't
necessary (whether because of the addition of them to wsutil/file_util.h
or because they weren't needed in the first place).

Change-Id: Ie241dd74deff284e39a5f690a297dbb6e1dc485f
Reviewed-on: https://code.wireshark.org/review/11619
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-07 21:52:23 +00:00
Gerald Combs 95382c3afb Suppress a bunch of cast-qual warnings.
Squelch

    warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]

similar to g630f54f.

Change strtod to g_ascii_strtod to squelch a checkAPIs error.

Change-Id: Ib2d26ef89f08827a5adc07e35eaf876cd7b8d14e
Reviewed-on: https://code.wireshark.org/review/7269
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-02-20 04:04:15 +00:00
Bill Meier e88a11f5c9 (Trivial) Fix printf-related 'Mismatch on sign' warnings
Found by MSVC2013 Code Analysis

Change-Id: I58063946dd558e98308c87b36eeac0ddbe1a6e79
Reviewed-on: https://code.wireshark.org/review/7045
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-02-09 18:57:14 +00:00
Guy Harris dfa50e6bd8 Use get_ws_vcs_version() to generate the version string.
That's what we do in, for example, dumpcap.

Also, use g_strdup_printf() for the strings, rather than using
fixed-length arrays.

Change-Id: I36ad201e3eda903ef3a089bafb09df0581efe512
Reviewed-on: https://code.wireshark.org/review/6284
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-03 21:36:47 +00:00
Pascal Quantin 7d943e11a4 Add back "version.h" inclusion
It got removed by the automatic include cleaning scripts
Also add it to text2pcap.c as it is used to get the version when writing a pcapng file

Change-Id: I3d56985fa1d04bcb066fe015a588c24cf3cb7267
Reviewed-on: https://code.wireshark.org/review/6248
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-01-02 18:24:55 +00:00
Guy Harris 27be466c9b Do the full string in get_{compiled,runtime}_version_info().
Have them start the string with "Compiled" or "Running on", and return
the string when done.

Change-Id: Ic4d290c963621fa0385dc5aab766fd4ad31d3810
Reviewed-on: https://code.wireshark.org/review/6155
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-31 06:29:11 +00:00
Guy Harris c1f30471ca Move the version_info.c stuff to wsutil/ws_version_info.c.
Change-Id: I3a5c7e219974bfb924819b43b4d445eaf00e5bde
Reviewed-on: https://code.wireshark.org/review/6153
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-31 03:41:02 +00:00
Guy Harris 120628e5f4 Don't check the same character twice in a row, check it and the next character.
Fixes Coverity CID 1260460.

Change-Id: Ic9ed109a863bcf20a5e67e4f52d628011f5e9ba5
Reviewed-on: https://code.wireshark.org/review/6087
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-28 10:19:27 +00:00
Guy Harris e08eba9b9e Only include <wsutil/os_version_info.h> if we need it.
Change-Id: Idee0e7205969ac2e7b33c4748a1463a0bfffe0a6
Reviewed-on: https://code.wireshark.org/review/6051
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-25 21:03:45 +00:00
Guy Harris 20503c7047 Check for getopt_long(), not getopt().
We support three types of platforms:

	1) UN*Xes that have both getopt() and getopt_long();

	2) UN*Xes that have getopt() but not getopt_long();

	3) Windows, which has neither.

Checking for getopt_long() lets us distinguish between 1) and 2) and
build getopt_long() for them.

Change-Id: Iaf0f142f9bebaa2eed2128d544ec9786711def45
Reviewed-on: https://code.wireshark.org/review/6045
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-25 01:11:10 +00:00
Stephen Fisher 2d8ec49ffa Move twelve show_version() functions from the varoius programs and
Wireshark UI files into a single one in wsutil.

Change-Id: I0a64f0cc8106bd681bd185289c36272c4c43baad
Reviewed-on: https://code.wireshark.org/review/6026
Reviewed-by: Stephen Fisher <sfisher@sdf.org>
2014-12-24 16:51:45 +00:00
Guy Harris a91799ebfa Don't use ctype.h routines.
That avoids locale dependency and handles possibly-signed chars(which
we weren't always doing before).

Change-Id: I89e50678abb8c3e535081c92ca25bc1bab672c68
Reviewed-on: https://code.wireshark.org/review/4798
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-17 23:43:09 +00:00
Guy Harris 34fc1145d4 Support nanosecond-resolution time stamps when writing pcap-ng files.
Pcap-ng files have supported variable time stamp resolutions since Day
One, and any code that reads those files but can't handle
nanosecond-resolution time stamps is broken.

Pcap files got a separate magic number for nanosecond-resolution files
relatively recently, and not all code that reads pcap files handles that
magic number, so we don't support it for pcap files.

Based on https://code.wireshark.org/review/#/c/4304/ from Peter Hatina.

Change-Id: I4f4e3b5ca0ba4fe9394765edb54bb77a4a776237
Reviewed-on: https://code.wireshark.org/review/4358
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-28 23:54:32 +00:00
Guy Harris f415e1c348 Remove some unnecessary definitions.
text2pcap.c uses pcapio.c to write pcap files, so it doesn't itself need
to know what those files look like.

Change-Id: I013d0c094c27515af91f352b565bc9a8bad3e842
Reviewed-on: https://code.wireshark.org/review/3927
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-08-30 23:21:37 +00:00
Graham Bloice 97546165fa Modify includes of config.h so that out-of-tree builds, i.e. CMake
don't pick up the in-tree copy.

Change-Id: I7ec473876cdba1a025c52362d7f6adc62d24ce71
Reviewed-on: https://code.wireshark.org/review/3798
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
2014-08-24 08:04:08 +00:00
Bill Meier f3dd7fe1eb Fix whitespace/indentation to match editor modelines.
Change-Id: I3445ae22f10584582d465bf632942e016f5f70ca
Reviewed-on: https://code.wireshark.org/review/3452
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-08-05 20:42:21 +00:00
Evan Huus 005fd7eefd Rename variable to avoid -Wshadow on mac buildbots
Change-Id: I13d591248718fcc36cd300bf28f779e2d9e0265a
Reviewed-on: https://code.wireshark.org/review/3339
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-08-02 01:12:50 +00:00
Guy Harris 5bfc21cf9e Clean up handling of missing functions.
With autotools, CMake, and nmake, if we have a function, #define
HAVE_{function_name_in_all_caps}, otherwise don't #define it.

If we provide our own version of a function in libwsutil, make sure we
have a header that declares it, and *ONLY* include that header if
HAVE_{function_name_in_all_caps} is *NOT* defined, so that we don't have
the system declaration and our declaration colliding.

Check for inet_aton, strncasecmp, and strptime with CMake, just as we do
with autotools.

Simplify the addition of {function_name_in_all_caps}_LO to libwsutil in
autotools.

Change-Id: Id5be5c73f79f81919a3a865324e400eca7b88889
Reviewed-on: https://code.wireshark.org/review/2903
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-06 21:03:09 +00:00
Guy Harris b4ce352539 Make --help and --version information a bit more uniform.
Have --version print the version number, the copyright information, the
"compiled with" information, the "running on/with" information, and the
compiler information.

Have --help print the version number, a one-line summary of what the
program does, a reference to http://www.wireshark.org for more
information, a Usage: line, and a list of command-line options.

This means programs doing that don't need to include version.h; that's
left up to get_ws_vcs_version_info() to do.

Change-Id: Idac641bc10e4dfd04c9914d379b3a3e0cc5ca8cb
Reviewed-on: https://code.wireshark.org/review/2794
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-03 08:46:01 +00:00
Guy Harris 8afe331369 More getopt_long, to add --help and --version support.
Change-Id: I946067b972a70154f02ab561bc0fd029a7a5abc4
Reviewed-on: https://code.wireshark.org/review/2791
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-03 04:51:20 +00:00
Jeff Morriss 3773a7561c Add command-line argument to request the version to a number of the utilities.
In some cases "-v" was already used so "-V" is the option.
Note that the version information in these utilities is much shorter than what
is presented by the big programs.

As requested by https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5804

Bug: 5804
Change-Id: I35db35a4eace2797afd895f9be7322ef39928480
Reviewed-on: https://code.wireshark.org/review/2489
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-21 01:05:02 +00:00
Alexis La Goutte 2414d9df46 Fix Argument with 'nonnull' attribute passed null found by Clang
Change-Id: If1c907308a7c776a6198530663f8dce03839d43b
Reviewed-on: https://code.wireshark.org/review/1098
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-14 11:52:35 +00:00
Graham Bloice 93d996ba38 Enhanced text2pcap so that if direction is specified on the command line, "-D",
and a direction indicator added to the start of each packet in the text file,
"I" or "O", then the ip source and destination addresses and udp, tcp and sctp
ports are swapped for an inbound packet.
Tcp sequence numbers and ack sequence numbers are updated accordingly.

Change-Id: Iec2c0fd68d80aad8842b7513fdd30bae6806b96a
Reviewed-on: https://code.wireshark.org/review/801
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-03-24 15:52:16 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Hadriel Kaplan 9c62ea46cd Fix text2pcap.c: Argument with 'nonnull' attribute passed null (clang analyzer)
Clang scan analysis reports API error for text2pcap.c.

Change-Id: Ie0861d75888e258d9fd928d5d7441e1e3a8279ba
Reviewed-on: https://code.wireshark.org/review/367
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-02 02:56:17 +00:00
Gerald Combs f966980937 Replace "svn" with "git" all over the place.
Rename "SVNPATH" to "GITBRANCH" since that seems more appropriate.
Rename "svnversion.h" to "version.h" as Evan suggested. Update some
URLs. In make-version.pl, make sure we don't set an improper upstream
branch name. Use the number of commits + short hash from `git describe`
for package names by default.

Change-Id: I922bba8d83eabdf49284a119f55b4076bc469b96
Reviewed-on: https://code.wireshark.org/review/139
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-02-07 23:03:03 +00:00
Bill Meier 1b180b3f47 Use the normal convention for exit status and output file descriptors:
Changes:
 - exit(1) if error (not exit(-1));
 - for -h: output to stdout & exit(0);

Also:
 - editor modelines: set tab-width=8;
 - use a consistent whitespace & formatting style;

svn path=/trunk/; revision=54512
2013-12-31 15:10:51 +00:00
Bill Meier 523abb73f8 'L' constant modifier not needed.
svn path=/trunk/; revision=54362
2013-12-22 15:31:42 +00:00
Bill Meier 6a0b02c26b 'guint32 crc_c[256]' array initializer constants should be unsigned 32bit; Replace 'L' by 'U'.
(not that it makes any difference in this case).

(I note that in https://tools.ietf.org/id/draft-ietf-tsvwg-sctpcsum-01.txt
the definition was 'unsigned long crc_c[256] = {0x...L, ...} presumably from
the days when LP32 was still in use.



svn path=/trunk/; revision=54308
2013-12-20 16:42:06 +00:00
Jörg Mayer 07a5c7442f Invert NEED_INET_ATON_H to HAVE_INET_ATON_H
Remove unused NEED_G_ASCII_STRTOULL_H

svn path=/trunk/; revision=52385
2013-10-05 21:56:23 +00:00
Guy Harris b06876390d Rename routines that write pcap-ng files to "pcapng_xxx" rather than
"libpcap_xxx".

Rename the low-level write routine in pcapio.c to write_to_file(), as
it's used for both pcap and pcap-ng files.

svn path=/trunk/; revision=52275
2013-09-29 20:53:13 +00:00
Guy Harris c42263f28a We always write to a FILE *, so:
make libpcap_write_to_file() static;

	don't pass it as an argument to write routines, just have them
	call it directly;

	make the handle argument a FILE *.

Make the data length argument to libpcap_write_to_file() a size_t, as
that's what, for example, fwrite() takes as a size argument.

svn path=/trunk/; revision=52274
2013-09-29 20:26:25 +00:00
Chris Maynard faad753c65 The 'a' option doesn't take an argument. Fix bug introduced by r49964.
svn path=/trunk/; revision=51803
2013-09-06 20:40:54 +00:00
Guy Harris 2bf78ceca9 In the comments for pcap_link_type, point to
http://www.tcpdump.org/linktypes.html for the details, rather than to
some particular OS's net/bpf.h (assuming it even has one), and speak of
it as a LINKTYPE_ value rather than a DLT_ value (in those cases where
the LINKTYPE_ value for a given link-layer header type is different from
the DLT_ value, it's the LINKTYPE_ value that should be passed to
text2pcap, as it's what gets written to the file, and those should be
the always-platform-independent LINKTYPE_ values rather than the
possibly-platform-dependent DLT_ values).

svn path=/trunk/; revision=51008
2013-07-29 08:37:18 +00:00
Gerald Combs 03febfc819 From Dirk Jagdmann: Use a guint32 for IPv4 addresses. Fixes compilation
on OS X + Cmake.

svn path=/trunk/; revision=50139
2013-06-25 13:31:19 +00:00
Stephen Fisher eeaba530ac AF_INET and AF_INET6 undefined in textpcap.c when compiling on FreeBSD
9.1-RELEASE with non-standard gcc 4.6, so pull in sys/socket.h when available.


svn path=/trunk/; revision=50110
2013-06-21 22:43:24 +00:00
Jörg Mayer 99e1ad5443 Fix compile error:
[ 79%] Building C object CMakeFiles/text2pcap.dir/text2pcap.c.o
In file included from /usr/include/glib-2.0/glib/galloca.h:34:0,
                 from /usr/include/glib-2.0/glib.h:32,
                 from /home/jmayer/work/wireshark/svn/trunk/wsutil/file_util.h:34,
                 from /home/jmayer/work/wireshark/svn/trunk/text2pcap.c:116:
/home/jmayer/work/wireshark/svn/trunk/text2pcap.c: In function ‘write_current_packet’:
/usr/include/glib-2.0/glib/gtypes.h:186:22: error: declaration of ‘__v’ shadows a previous local [-Werror=shadow]
  ({ register guint16 __v, __x = ((guint16) (val)); \
                      ^
/usr/include/glib-2.0/glib/gtypes.h:237:38: note: in expansion of macro ‘GUINT16_SWAP_LE_BE_IA32’
 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
                                      ^
/usr/lib/glib-2.0/include/glibconfig.h:192:29: note: in expansion of macro ‘GUINT16_SWAP_LE_BE’
 #define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
                             ^
/usr/include/glib-2.0/glib/gtypes.h:359:23: note: in expansion of macro ‘GUINT16_TO_BE’
 #define g_htons(val) (GUINT16_TO_BE (val))
                       ^
/home/jmayer/work/wireshark/svn/trunk/text2pcap.c:705:35: note: in expansion of macro ‘g_htons’
             pseudoh.length      = g_htons(length - g_ntohs(HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen) + sizeof(HDR_UDP));
                                   ^
/usr/include/glib-2.0/glib/gtypes.h:237:38: note: in expansion of macro ‘GUINT16_SWAP_LE_BE_IA32’
 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
                                      ^
/usr/lib/glib-2.0/include/glibconfig.h:192:29: note: in expansion of macro ‘GUINT16_SWAP_LE_BE’
 #define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
                             ^
/usr/include/glib-2.0/glib/gtypes.h:327:31: note: in expansion of macro ‘GUINT16_TO_BE’
 #define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val))
                               ^
/usr/include/glib-2.0/glib/gtypes.h:357:23: note: in expansion of macro ‘GUINT16_FROM_BE’
 #define g_ntohs(val) (GUINT16_FROM_BE (val))
                       ^
/home/jmayer/work/wireshark/svn/trunk/text2pcap.c:705:52: note: in expansion of macro ‘g_ntohs’
             pseudoh.length      = g_htons(length - g_ntohs(HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen) + sizeof(HDR_UDP));
                                                    ^
/usr/include/glib-2.0/glib/gtypes.h:186:22: error: shadowed declaration is here [-Werror=shadow]
  ({ register guint16 __v, __x = ((guint16) (val)); \
                      ^
/usr/include/glib-2.0/glib/gtypes.h:237:38: note: in expansion of macro ‘GUINT16_SWAP_LE_BE_IA32’
 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
                                      ^
/usr/lib/glib-2.0/include/glibconfig.h:192:29: note: in expansion of macro ‘GUINT16_SWAP_LE_BE’
 #define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
                             ^
/usr/include/glib-2.0/glib/gtypes.h:359:23: note: in expansion of macro ‘GUINT16_TO_BE’
 #define g_htons(val) (GUINT16_TO_BE (val))
                       ^
/home/jmayer/work/wireshark/svn/trunk/text2pcap.c:705:35: note: in expansion of macro ‘g_htons’
             pseudoh.length      = g_htons(length - g_ntohs(HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen) + sizeof(HDR_UDP));
                                   ^
/usr/include/glib-2.0/glib/gtypes.h:186:27: error: declaration of ‘__x’ shadows a previous local [-Werror=shadow]
  ({ register guint16 __v, __x = ((guint16) (val)); \
                           ^
/usr/include/glib-2.0/glib/gtypes.h:237:38: note: in expansion of macro ‘GUINT16_SWAP_LE_BE_IA32’
 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
                                      ^
/usr/lib/glib-2.0/include/glibconfig.h:192:29: note: in expansion of macro ‘GUINT16_SWAP_LE_BE’
 #define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
                             ^
/usr/include/glib-2.0/glib/gtypes.h:359:23: note: in expansion of macro ‘GUINT16_TO_BE’
 #define g_htons(val) (GUINT16_TO_BE (val))
                       ^
/home/jmayer/work/wireshark/svn/trunk/text2pcap.c:705:35: note: in expansion of macro ‘g_htons’
             pseudoh.length      = g_htons(length - g_ntohs(HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen) + sizeof(HDR_UDP));
                                   ^
/usr/include/glib-2.0/glib/gtypes.h:237:38: note: in expansion of macro ‘GUINT16_SWAP_LE_BE_IA32’
 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
                                      ^
/usr/lib/glib-2.0/include/glibconfig.h:192:29: note: in expansion of macro ‘GUINT16_SWAP_LE_BE’
 #define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
                             ^
/usr/include/glib-2.0/glib/gtypes.h:327:31: note: in expansion of macro ‘GUINT16_TO_BE’
 #define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val))
                               ^
/usr/include/glib-2.0/glib/gtypes.h:357:23: note: in expansion of macro ‘GUINT16_FROM_BE’
 #define g_ntohs(val) (GUINT16_FROM_BE (val))
                       ^
/home/jmayer/work/wireshark/svn/trunk/text2pcap.c:705:52: note: in expansion of macro ‘g_ntohs’
             pseudoh.length      = g_htons(length - g_ntohs(HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen) + sizeof(HDR_UDP));
                                                    ^
/usr/include/glib-2.0/glib/gtypes.h:186:27: error: shadowed declaration is here [-Werror=shadow]
  ({ register guint16 __v, __x = ((guint16) (val)); \
                           ^
/usr/include/glib-2.0/glib/gtypes.h:237:38: note: in expansion of macro ‘GUINT16_SWAP_LE_BE_IA32’
 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
                                      ^
/usr/lib/glib-2.0/include/glibconfig.h:192:29: note: in expansion of macro ‘GUINT16_SWAP_LE_BE’
 #define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
                             ^
/usr/include/glib-2.0/glib/gtypes.h:359:23: note: in expansion of macro ‘GUINT16_TO_BE’
 #define g_htons(val) (GUINT16_TO_BE (val))
                       ^
/home/jmayer/work/wireshark/svn/trunk/text2pcap.c:705:35: note: in expansion of macro ‘g_htons’
             pseudoh.length      = g_htons(length - g_ntohs(HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen) + sizeof(HDR_UDP));
                                   ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/text2pcap.dir/text2pcap.c.o] Error 1


Feel free to choose a less offensive variable name

svn path=/trunk/; revision=50005
2013-06-18 12:22:40 +00:00
Michael Mann 75420f4ab2 Prepend custom Destination IP and Source IP (ipv4 or ipv6) in the pcap. Bug 5650 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5650)
svn path=/trunk/; revision=49964
2013-06-16 16:50:17 +00:00
Michael Tüxen a88e677724 Don't forget to move the trailing '\0'.
svn path=/trunk/; revision=48746
2013-04-05 09:56:11 +00:00
Chris Maynard 2239e7618d As forewarned at http://www.wireshark.org/lists/wireshark-dev/201304/msg00009.html, change the default snaplen to 65KiB-1. While we're at it, push the max packet size to that value as well.
Also: convert the few tabs to spaces and add modelines.


svn path=/trunk/; revision=48738
2013-04-04 19:48:20 +00:00
Anders Broman f92bd64966 [-Wmissing-prototypes]
Use explicit casts.

svn path=/trunk/; revision=48439
2013-03-20 05:59:22 +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
Chris Maynard 619c6e20a0 Usage formatting changes:
-> Wrap all text at column 80
-> Reference http://www.tcpdump.org/linktypes.html instead of net/bpf.h
-> Other misc. wording changes.

svn path=/trunk/; revision=47234
2013-01-23 21:16:42 +00:00
Michael Tüxen 674567df8a Cleanup error handling when processing preamble.
svn path=/trunk/; revision=46911
2013-01-03 09:51:51 +00:00
Michael Tüxen 441b5b1bb5 Don't try to process timestamp without the format being
specified.

svn path=/trunk/; revision=46910
2013-01-03 09:23:43 +00:00
Michael Tüxen 6e77aef946 Fix indentation.
svn path=/trunk/; revision=46901
2013-01-02 17:43:28 +00:00
Michael Tüxen c2fb93c0de Also print number of bytes written.
svn path=/trunk/; revision=46900
2013-01-02 17:42:16 +00:00
Michael Mann 18580d6703 Allow pcap/pcapng format to be written to more than just a file (FILE*). Gives more flexibility if needed.
WRITE_DATA macro replaced and applied consistently throughout pcapio.c

svn path=/trunk/; revision=46891
2013-01-02 04:01:22 +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
Michael Tüxen 22df071cef Add support for -D option. The preamble will start with
an I or O indicating the direction of the packet. This
will be stored in the generated file if the pcap-ng
format is used.
Thanks to Jaap for suggesting to integrate this into
the preamble!

svn path=/trunk/; revision=46744
2012-12-25 22:37:40 +00:00
Michael Tüxen 6329407d9a Remove current version of -D option, because:
* it is off by default
* not documented
* makes text2pcap to coredump when used
* its goal is not clear (to me).
I'm willing to reimplement it under a different option name
if I understand what it should do. Then I can fix and test it.


svn path=/trunk/; revision=46741
2012-12-25 19:53:04 +00:00
Michael Tüxen 05827f38ab Add some debug output regarding preamble processing.
svn path=/trunk/; revision=46740
2012-12-25 19:16:28 +00:00
Michael Tüxen 4abfc13149 Clear preamble if no timespec is given.
svn path=/trunk/; revision=46738
2012-12-25 17:45:04 +00:00
Michael Tüxen f8d48662c8 Add support of -m option for SCTP.
svn path=/trunk/; revision=46737
2012-12-25 17:32:30 +00:00
Michael Tüxen dcd2b0614b Fix SCTP packet generation if DATA chunk headers need
to be generated.

svn path=/trunk/; revision=46736
2012-12-25 14:34:24 +00:00
Michael Tüxen 4aa19ce98f Fix bugs I introduced. Now
od -Ax -tx1 -v stream | text2pcap -m1460 -T1234,1234 - stream.pcap
does work again.

svn path=/trunk/; revision=46734
2012-12-25 12:02:39 +00:00