Commit Graph

179 Commits

Author SHA1 Message Date
Guy Harris 853da2eb9b The "file types" we have are actually combinations of types and
subtypes, e.g. Network Monitor version 1 and Network Monitor version 2
are separate "file types", even though they both come from Network
Monitor.

Rename various functions, #defines, and variables appropriately.

svn path=/trunk/; revision=53166
2013-11-08 09:53:01 +00:00
Guy Harris 640a45d707 Get rid of a redundant check - pcapng_read_packet_block() already checks
whether the (zero-based) interface ID is < the number of interface IDs,
so we don't need to do so in pcapng_read().

Unions are tricky - if the compiler doesn't ensure that the right
component of the union is being used at any given time, various problems
can happen.

Remove some members from the "data" union in the wtapng_block_t
structure, and use a local variable of the specified type.

svn path=/trunk/; revision=52262
2013-09-29 00:37:04 +00:00
Guy Harris 658a16285e The pcap-ng spec says the captured length is the minimum of the
interface snapshot length and the packet length; make it so.

svn path=/trunk/; revision=52253
2013-09-28 21:06:17 +00:00
Guy Harris d399dcb52a Actually, the captured length must be the minimum of:
the number of bytes available for packet data in the block;

	the packet length;

	*and* the snapshot length for the interface.

One more fix for bug 9200, so it should *now* be fixed.

svn path=/trunk/; revision=52250
2013-09-28 20:08:39 +00:00
Guy Harris 1d00d587b4 Fix cut-and-pasteo.
Finishes the fix for bug 9200.

svn path=/trunk/; revision=52247
2013-09-28 19:26:23 +00:00
Guy Harris bdd237863f Correctly calculate the captured length in a Simple Packet Block -
subtract out the minimum SPB size, which includes the length of
*everything* except for the packet data.

Fixes one problem found by the file in bug 9200.

svn path=/trunk/; revision=52244
2013-09-28 18:25:07 +00:00
Guy Harris a582b7201a In a Simple Packet Block, the captured length isn't the block length
minus the lengths of the two length fields and the packet length field,
it's the minimum of that and the packet length, as there might be
padding.

Fixes one problem found by the file in bug 9200.

While we're at it, pcapng_read_packet_block() and
pcapng_read_simple_packet_block() return an integer, not a Boolean;
return 0, not FALSE (they have the same value, but returning 0 makes it
clearer that the return value isn't restricted to TRUE or FALSE).

svn path=/trunk/; revision=52241
2013-09-28 18:03:20 +00:00
Guy Harris 12912b657b There's no interface ID in a Simple Packet Block.
Fixes one problem found by the file in bug 9200.

svn path=/trunk/; revision=52238
2013-09-28 17:44:50 +00:00
Evan Huus d158983d7e Fix some typos, indentation. Don't try to write the NRB if the pointer to our
two lists is itself NULL.

svn path=/trunk/; revision=52181
2013-09-22 20:18:25 +00:00
Evan Huus 6aa5e30ed9 Remove unused parameter.
svn path=/trunk/; revision=52178
2013-09-22 19:58:22 +00:00
Anders Broman a8bd9fb7b6 Turn off debuging.
svn path=/trunk/; revision=52177
2013-09-22 19:43:51 +00:00
Anders Broman 20108d7950 Get rid of struct addrinfo, use the hastables for name resolution instead.
svn path=/trunk/; revision=52176
2013-09-22 19:40:02 +00:00
Alexis La Goutte 25a8c57356 Fix error when enable "debug" in wiretap/pcapng.c file
With gcc :
pcapng.c: In function 'pcapng_read_packet_block':
pcapng.c:1147:9: error: request for member 'pseudo_header' in something not a structure or union

With clang :
pcapng.c:1150:86: error: member reference type 'struct wtap_pkthdr *' is a pointer; maybe you meant to use '->'?
                       pcap_get_phdr_size(int_data.wtap_encap, &wblock->packet_header.pseudo_header));
                                                                ~~~~~~~~~~~~~~~~~~~~~^
                                                                                     ->
(Error message from clang is better...)

svn path=/trunk/; revision=51317
2013-08-12 17:46:04 +00:00
Guy Harris f13ba97806 Fix some pointer-signedness (well, signedness of what the pointer points
to) warnings.

svn path=/trunk/; revision=50104
2013-06-21 02:59:54 +00:00
Guy Harris 8c9edf1280 Have the seek-read routines take a Buffer rather than a guint8 pointer
as the "where to put the packet data" argument.

This lets more of the libwiretap code be common between the read and
seek-read code paths, and also allows for more flexibility in the "fill
in the data" path - we can expand the buffer as needed in both cases.

svn path=/trunk/; revision=49949
2013-06-16 00:20:00 +00:00
Guy Harris f4f4e024bc libwireshark's add_new_ipv4() and add_new_ipv6() now silently ignore
requests to add an entry with a zero-length name; we don't have to
ignore them ourselves.

svn path=/trunk/; revision=49854
2013-06-09 06:44:47 +00:00
Guy Harris 9f1f58745c Don't treat zero-length names in the NRB as errors, just silently ignore
them.

Works around the problem reported in bug 8763.

svn path=/trunk/; revision=49851
2013-06-09 02:32:30 +00:00
Guy Harris f86c7712a3 Use g_try_malloc() for some memory allocations, and return an "out of
memory" indication if it fails.

Further fixes bug 8752.

Also, clean up indentation.

svn path=/trunk/; revision=49834
2013-06-07 08:34:44 +00:00
Guy Harris 2429df9c51 Prevent attempts to allocate huge amounts of memory by imposing an
artificial 16MB limit on blocks.

Do some sanity checks when reading options, to make sure we don't read
past the end of the block.

Make some variables unsigned so as not to get inappropriate
sign-extension (which, in practice, should never happen due to the 16MB
block size limit, although if the limit is raised above 2^31-1, the
limit won't protect you).

Fixes bug 8752.

svn path=/trunk/; revision=49833
2013-06-07 08:19:40 +00:00
Guy Harris 33e1232f23 In the pcapng seek-read routine, *don't* fill in wth->phdr; seek-read
routines are passed a separate struct wtap_pkthdr to be filled in.

Get rid of the pseudo_header member of the wblock structure - the
pseudo-header is part of the struct wtap_pkthdr.

Get rid of the union wtap_pseudo_header * argument to
pcap_process_pseudo_header() - it's passed a pointer to a struct
pcap_pkthdr, and that structure contains the union in question.

Have libpcap_read_header() take a FILE_T argument, rather than using
only the "sequential" handle of the wtap it's handed.  Have the libpcap
read routine return the offset of the beginning of the pcap record, and
have the seek-read routine read the header and fill in the struct
wtap_pkthdr handed to it.

svn path=/trunk/; revision=49401
2013-05-18 02:36:00 +00:00
Anders Broman 089dfcd108 From beroset:
remove C++ incompatibilities 
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416

svn path=/trunk/; revision=48424
2013-03-19 19:02:25 +00:00
Guy Harris 88e9d1c1e5 Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").

When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.

For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.

svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
Michael Tüxen ef0282ee9c Fix syntax error showing up when using debug ouput.
svn path=/trunk/; revision=46713
2012-12-23 08:59:30 +00:00
Michael Tüxen 6af6ce5ee0 Add support for writing the packet block flags for pcapng.
While there, do some minor cleanup.

svn path=/trunk/; revision=46699
2012-12-22 20:38:08 +00:00
Guy Harris 5996b49c53 Squelch implicit 64-bit-to-32-bit conversion warnings.
svn path=/trunk/; revision=46650
2012-12-21 03:32:16 +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
Gerald Combs c91c1df500 Use seasonal allocation for name resolution. This effectively scrubs our
resolution information between capture files so that we don't leak host
entries from one file to another (e.g. embarassing-host-name.example.com
from file1.pcapng into a name resolution block in file2.pcapng).

host_name_lookup_cleanup and host_name_lookup_init must now be called
after each call to se_free_all. As a result we now end up reading our
various name resolution files much more than we should.

svn path=/trunk/; revision=45511
2012-10-12 21:37:02 +00:00
Guy Harris 928ebf0ea3 If we see an SHB after we've read the first SHB, report that as an
unsupported feature.

If we see an IDB after all the IDBs at the beginning of the file,
process it.  Fixes bug 7851.

Get rid of unused read_idbs flag in pcapng_t structure.  (Also, as per
the above, just because we've read all the IDBs at the beginning of the
section, that doesn't necessarily mean we've read all the IDBs in the
section.)

Fix some places where we reject SPBs.

svn path=/trunk/; revision=45495
2012-10-12 03:55:10 +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
Michael Tüxen afe900aa9f Avoid a division by zero due to overflow.
This should fix the crash in
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7266

svn path=/trunk/; revision=44141
2012-07-30 20:53:42 +00:00
Michael Tüxen 64ab313254 Some more debug info.
svn path=/trunk/; revision=44076
2012-07-27 19:13:38 +00:00
Michael Tüxen d8c4c4617c Handle the case where no IDB follows the SHB. This fixes part of
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7533
which deals with Div by 0 crash in pcapng_read_packet_block().

svn path=/trunk/; revision=44074
2012-07-27 18:43:53 +00:00
Guy Harris 4de568eb10 Don't ask for information about an interface greater than the maximum
interface for which we have information.

Fixes bug 7467.

Should also cause an error message, rather than an unreadable capture
file, to be produced for the cases in bug 7381.  (This isn't a fix for
bug 7381; it's arguably an improvement, in the sense that a circuit
breaker tripping or a fuse blowing for a short circuit is an improvement
over a fire starting, but it's not a *fix*, any more than a circuit
break or fuse *fixes* the short circuit.)

#BACKPORT

svn path=/trunk/; revision=43657
2012-07-11 03:57:13 +00:00
Guy Harris 8891144224 When writing an EPB, calculate the time stamp based on the resolution
for the interface, not based on the default resolution of 1 microsecond.
Fixes bug 7457.

Fix a comment.

Clean up indentation.

#BACKPORT

svn path=/trunk/; revision=43649
2012-07-10 19:12:37 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Gerald Combs 39dbd45c9f Fix some dead assignments.
svn path=/trunk/; revision=43157
2012-06-08 17:20:44 +00:00
Anders Broman 2bc42dc547 Try to squelch warnings
svn path=/trunk/; revision=42998
2012-06-02 14:13:14 +00:00
Guy Harris 33bb54a945 file_seek() used to be a wrapper around fseek() or gzseek(), both of
which could use lseek() and were thus expensive due to system call
overhead.  To avoid making a system call for every packet on a
sequential read, we maintained a data_offset field in the wtap structure
for sequential reads.

It's now a routine that just returns information from the FILE_T data
structure, so it's cheap.  Use it, rather than maintaining the data_offset
field.

Readers for some file formats need to maintain file offset themselves;
have them do so in their private data structures.

svn path=/trunk/; revision=42423
2012-05-04 16:56:18 +00:00
Michael Tüxen bacf81ff06 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7048
Write timetamps for the interface statistic blocks the way specified
by http://www.winpcap.org/ntar/draft/PCAP-DumpFileFormat.html


svn path=/trunk/; revision=42080
2012-04-15 11:11:36 +00:00
Michael Tüxen 587e0213eb Whitespace cleanup (done while debugging).
svn path=/trunk/; revision=42079
2012-04-15 11:08:40 +00:00
Gerald Combs beee8db906 Print the correct block size in a debug message.
svn path=/trunk/; revision=41773
2012-03-26 19:29:33 +00:00
Anders Broman 63c19bd071 Disable debug.
svn path=/trunk/; revision=41716
2012-03-21 08:58:27 +00:00
Anders Broman 456c7c2dc6 Try to make the buildbot happy.
svn path=/trunk/; revision=41684
2012-03-20 11:58:29 +00:00
Anders Broman 148c8a3a30 Write ISB:s if we have them.
svn path=/trunk/; revision=41683
2012-03-20 11:42:55 +00:00
Guy Harris 8af620acd7 Initialize the new num_stat_entries and interface_statistics members of
a wtapng_if_descr_t, so that we don't crash on a close (as is happening
in the buildbot).

Fix up some 4-space tabs.

svn path=/trunk/; revision=41575
2012-03-15 21:44:54 +00:00
Anders Broman fb0fec7c1c If we have one ISB, display the droped count from it.
svn path=/trunk/; revision=41561
2012-03-15 14:33:04 +00:00
Anders Broman dc674a6043 - Store ISB data.
- free IDB and ISB data when closing.

svn path=/trunk/; revision=41558
2012-03-15 13:46:42 +00:00
Anders Broman 0e4998190f From Jose Pedro Oliveira:
Remove a printf line in wiretap/pcapng.c
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6718

svn path=/trunk/; revision=41534
2012-03-13 15:26:36 +00:00
Anders Broman bb611755e9 Add data structure to hold information from ISB:s
svn path=/trunk/; revision=41522
2012-03-13 08:36:52 +00:00
Anders Broman 35bf2e9619 From Jose Pedro Oliveira:
Enforce the modelines in wiretap/pcapng.c

svn path=/trunk/; revision=41506
2012-03-12 15:43:59 +00:00