Commit Graph

231 Commits

Author SHA1 Message Date
Michael Mann 2209678149 ep_<protocol>_port_to_display -> <protocol>_port_to_display
Adjust any other ep_ related APIs related to the transition.

Change-Id: I961b371c2c4bda557e0f1817705c27eef0dae66c
Reviewed-on: https://code.wireshark.org/review/6388
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-01-08 05:32:32 +00:00
Michael Mann 55de46f317 Replace ep_address_to_str with address_to_str.
Change-Id: I4f1078b20f41800f72a751612703ad0d4c2ae87b
Reviewed-on: https://code.wireshark.org/review/6323
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: Anders Broman <a.broman58@gmail.com>
2015-01-06 07:38:18 +00:00
Michael Mann 22b4ec91c0 Replace ep_display_to_address with wmem equivalent display_to_address.
Almost all instances require using "manual" memory management, but it gets some ep_ calls out of the GUI.

Change-Id: Ifa7303766b08d09442ccf3d7063cbe061578ecd9
Reviewed-on: https://code.wireshark.org/review/6318
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-05 13:55:04 +00:00
Hadriel Kaplan fac8356610 Make all Lua code use wmem not emem
Changed all remaining code in wslua that was using emem, to use wmem or
simpler methods.

Bug: 9927
Change-Id: I3d19a770e0fd77d996bdb6b61a76a722cc2bcd55
Reviewed-on: https://code.wireshark.org/review/6109
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-04 21:02:38 +00:00
Guy Harris 0e57ff2ca1 We no longer do anything signal-related, so don't include <signal.h>.
Update a comment pertaining to that, while we're at it.

Change-Id: Ic0a3f8575f8e98ca6032ed3e06e3dd76055d65a1
Reviewed-on: https://code.wireshark.org/review/6192
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-31 22:47:37 +00:00
Pascal Quantin bd19532bfb Do not use packet scope memory outside packet dissectors
Otherwise it will trigger an assert
Fixes a regression introduced in gf002332

Change-Id: I0cffa2c952b7eff085a1834ebabfec03342095bd
Reviewed-on: https://code.wireshark.org/review/5950
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-12-21 18:30:33 +00:00
Michael Mann f002332d88 Replace ether_to_str with either address_to_str or tvb_ether_to_str.
Change-Id: I8cce9fddbfe950e27e96ea8a5a6d2e0921ff4260
Reviewed-on: https://code.wireshark.org/review/5933
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-21 15:13:30 +00:00
Guy Harris 033f096ee9 Don't use ctype.h routines.
That avoids locale dependency and handles possibly-signed chars (which
we weren't always doing before).

Change-Id: Ieceb93029252f646397b6488f2df8a57c6d2a23d
Reviewed-on: https://code.wireshark.org/review/4794
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-17 23:11:18 +00:00
Pascal Quantin 6e83b38020 Get rid of g_hash_table_lookup asserts when loading an external host file
Only parse the host file syntax without trying to store the names in the hash tables (it will be done later in host_name_lookup_init())

Change-Id: I2b8c7b29220e6413c1b5c0a0fa238ecb5388c962
Reviewed-on: https://code.wireshark.org/review/4309
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-09-27 15:55:07 +00:00
Evan Huus a4a94af0f7 Fix regression introduced by gf3b631668b
I made a stupid when simplifying the bit-twiddling, and accidentally reversed
two of the bytes which completely broke MAC address name resolution.

Bug: 10344
Change-Id: I0720755fb290423150e4d84da9d45cb0b76341e4
Reviewed-on: https://code.wireshark.org/review/3522
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-08-09 17:30:44 +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
Evan Huus a452d16f2c Optimize epan_new/init_dissection
As Anders correctly pointed out in I7d8f84b2e, constantly resetting state will
turn init_dissection into a bit of a hot path. Especially as we will already
bear the overhead of switching files, we don't want to fall any further behind
than we have to.

This change includes three unrelated optimizations that reduce the cost of
init_dissection by about 40% as measured by callgrind:
 - only initialize ares/ADNS if that preference is enabled (this of course only
   applies if you specify -n to tshark or otherwise disable the preference)
 - use memcpy instead of a loop in sigcomp UDVM init
 - use memcpy instead of a loop in bootp dissector

The only remaining obvious hot spot in this path is reassembly_table_init since
it is called by so many dissectors. Suggestions (perhaps to get rid of the
GPtrArray) welcome.

Oh, and one other change to use g_strerror instead of strerror as insisted
upon by the API pre-commit hook.

Change-Id: I18a74f2b64b25498116079bd4e7fc2b335c7703a
Reviewed-on: https://code.wireshark.org/review/2738
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-07-01 04:21:14 +00:00
Evan Huus 5d98ab793e Simplify IPv4 address hashing
Rather than allocate 4 bytes and use g_int_*, use GUINT_TO_POINTER and
g_direct_*. Should save some time/memory.

Change-Id: Ie03d234703f68bb76131c5ddf17953d23bb54a0d
Reviewed-on: https://code.wireshark.org/review/1582
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-11 15:50:46 +00:00
Evan Huus f3b631668b Use a strong hash function for ethernet addresses.
The capture for bug 10078 caused the buildbot to time out; callgrind revealed an
enourmous amount of time being spent looking up ethernet addresses. The previous
code cast each address (6 bytes) to a guint64 (8 bytes) then used the built-in
g_int64_hash. Unfortunately, g_int64_hash is an *awful* hash function - it
produces a 4-byte hash by simply discarding the upper 4 bytes of its input.

For the capture file in question this strategy (which effectively ignores the
upper two bytes of each ethernet address) produced an astounding number of
collisions, leading to the terrible running-time.

Use wmem_strong_hash directly on the 6-byte address instead, which saves us a
bunch of useless casting and bit-twiddling and produces a much better hash
distribution. This shaves 20% off the time to tshark-with-tree the capture file
in question *despite* a substantially more expensive hash function
(wmem_strong_hash is not exactly fast compared to g_int64_hash).

Bug:10078
Change-Id: I8e81cbc478e6394ec3a8efe39eec08f680a55609
Reviewed-on: https://code.wireshark.org/review/1543
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-07 09:00:29 +00:00
Gerald Combs 4628dc0118 Disable transport name resolution by default.
Modern hosts typically open many more TCP and UDP connections than in
years past.  For an example opening a popular news site in a web browser
can easily trigger dozens of separate connections. At the same time our
services file has accumulated a lot of cruft over time. As a result
transport name resolution is a bunch of lies.

Change-Id: Ibbca5b1c7ea1e800fc46dad63b9270128dacd721
Reviewed-on: https://code.wireshark.org/review/1240
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-21 22:13:49 +00:00
Guy Harris d0489f2a12 Clean up white space (replace tabs with 4 spaces).
Change-Id: Id253ddca497ca92272e7317177aae5e5570f4271
Reviewed-on: https://code.wireshark.org/review/1218
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-04-19 19:33:47 +00:00
Guy Harris 97869f2dec More name changes.
Add ep_ to routines that may return ephemeral strings.

Change "get_XXX" to "XXX_to_display" if the routine returns a formatted
string if it can't get a name.

Change-Id: Ia0e82784349752cf4285bf82788316c9588fdd88
Reviewed-on: https://code.wireshark.org/review/1217
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-04-19 19:30:17 +00:00
Guy Harris c8f7e16b57 Some routine name changes.
"get_addr_name()" -> "ep_address_to_display()", to 1) indicate that it
returns a string with ephemeral scope and 2) indicate that it maps an
address to a "displayable" form - a name if possible, an address string
if not.

"se_get_addr_name()" -> "get_addr_name()", to indicate that its strings
have the same scope as "get_ether_name()", "get_hostname()", and
"get_hostname6()".

Change-Id: If2ab776395c7a4a163fef031d92b7757b5d23838
Reviewed-on: https://code.wireshark.org/review/1216
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-04-19 19:07:06 +00:00
Guy Harris 80011ec03c Don't se_ allocate strings when mapping addresses to column strings.
This should significantly reduce memory usage, without increasing the
CPU time required to process a capture file in TShark or Wireshark.

As a result, se_address_to_str() is no longer used; eliminate it.

Fixes bug #9949.

Change-Id: I65a112a426c82cc73a957b81384c765c3d14f2c3
Reviewed-on: https://code.wireshark.org/review/1213
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-19 14:20:06 +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
Bill Meier 11b5c15fdb Remove trailing whitespace
Change-Id: I8116f63ff88687c8db3fd6e8e23b22ab2f759af0
Reviewed-on: https://code.wireshark.org/review/385
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
2014-02-25 20:46:49 +00:00
Jakub Zawadzki 3d6fdc55d0 New functions: str_to_ip6(), str_to_ip()
This way we can avoid including lot of system header files in some dissectors
and it might fix bug #9581

svn path=/trunk/; revision=54330
2013-12-21 16:16:56 +00:00
Guy Harris 1cf2e46426 bytes_to_hexstr_punct() does not add a null terminator, so we must add
it ourselves.

svn path=/trunk/; revision=54288
2013-12-20 10:08:35 +00:00
Anders Broman 5fbfa6c351 Fix [-Wmissing-prototypes]
svn path=/trunk/; revision=54280
2013-12-20 06:30:13 +00:00
Evan Huus 6be37815a1 Add bytestring_to_str() which takes a wmem scope and is otherwise identical to
bytestring_to_ep_str (now deprecated). Use the new one in a few obvious places.

Also just print directly to the buffer when loading ethernet addresses for
resolution. The straight-to-buffer bytes_to_hexstr seems useful, maybe it
shouldn't be in a private header...

svn path=/trunk/; revision=54270
2013-12-19 20:53:44 +00:00
Evan Huus a6415ece0a Rename a couple of to_str functions to have ep_ in the name. This makes it
obvious that the returned string is ephemeral, and opens up the original names
in the API for versions that take a wmem pool (and thus can work in any scope).

svn path=/trunk/; revision=54249
2013-12-19 15:49:09 +00:00
Guy Harris db25270df8 Move the epan/filesystem.c routines to wsutil; they're not specific to
packet dissection, they're specific to the entire Wireshark suite of
programs.

svn path=/trunk/; revision=53377
2013-11-17 02:55:14 +00:00
Jakub Zawadzki c9b2ee3768 include <wsutil/pint.h> only when needed.
svn path=/trunk/; revision=53196
2013-11-09 15:44:29 +00:00
Anders Broman b8003ea06e g_slist_free_full() is glib 2.28
Fix spelling.

svn path=/trunk/; revision=52787
2013-10-23 14:04:19 +00:00
Anders Broman e717ca06bd Make manual address resolution work again by putting the addresses
in a separate list and add that list when address resolution is rebuilt
during rescan of packets.

svn path=/trunk/; revision=52785
2013-10-23 12:02:15 +00:00
Anders Broman d038be780b Flag the addresses used in the trace which has been resolved and only add those to the list used to create the NRB.
svn path=/trunk/; revision=52504
2013-10-10 19:17:48 +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
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 1210a335ab Fix -Wshadow, indentation
svn path=/trunk/; revision=52179
2013-09-22 20:01:32 +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
Anders Broman e7290ae53e Don't call gethostbyaddr() we have already read the local hosts file, settle for that.
svn path=/trunk/; revision=52115
2013-09-17 04:55:29 +00:00
Anders Broman 038d3b0a56 Read the local services file.
svn path=/trunk/; revision=52104
2013-09-16 18:36:50 +00:00
Anders Broman 1821ed0404 Don't call getservbyport() on unresolved ports - it's expensive.
We should read the services file in initialize_services instead.

svn path=/trunk/; revision=52103
2013-09-16 17:53:41 +00:00
Anders Broman ae83d08f30 Revert revision=51577.
Ref https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9082
Since this commit the IP (source and destination) address in the GUI will be
replaced with some date after I click on the entry, reverting this commit fixes
the problem.


This looks like a memory corruption. I imported an older pcap file.

svn path=/trunk/; revision=51579
2013-08-29 22:08:23 +00:00
Anders Broman 39a61a1680 Don't store address in the hastable when name resolution is off.
svn path=/trunk/; revision=51577
2013-08-29 18:59:49 +00:00
Evan Huus 21ad5c11b2 Clean-up ipxnet hash table in host_name_lookup_cleanup. Should fix the buildbot
test suite failures.

svn path=/trunk/; revision=51447
2013-08-20 22:41:49 +00:00
Jörg Mayer 0f74dff2f9 Fix for
[  6%] Building C object epan/CMakeFiles/epan.dir/addr_resolv.c.o
/home/jmayer/work/wireshark/svn/trunk/epan/addr_resolv.c:1927:1: error: unused function
      'get_ipxnetbyname' [-Werror,-Wunused-function]
get_ipxnetbyname(const gchar *name)
^
/home/jmayer/work/wireshark/svn/trunk/epan/addr_resolv.c:2009:1: error: unused function
      'add_ipxnet_name' [-Werror,-Wunused-function]

by #if 0/#endif the functions. If they really are not needed any more
they should be removed.

svn path=/trunk/; revision=51438
2013-08-20 06:35:45 +00:00
Anders Broman cb1bd182f2 Mark an unused parameter.
svn path=/trunk/; revision=51437
2013-08-20 05:27:48 +00:00
Anders Broman 4e63bb5ec5 Use g_hash_table() for ipxnet name resolution.
svn path=/trunk/; revision=51436
2013-08-20 05:06:26 +00:00
Anders Broman ccb96fd73a Use g_hastable() for IPv6 name reslution.
svn path=/trunk/; revision=51415
2013-08-18 19:02:48 +00:00
Evan Huus 2048ac8ae1 Split the code to convert an ethernet address into an int64 into a function
since it's used in several places. Don't allocate a key just to do a hash-table
lookup, we only need to do that if we're actually inserting. Fixes another ~1KB
of leaks.

svn path=/trunk/; revision=51364
2013-08-15 02:45:58 +00:00
Evan Huus 4577d39122 Free the old name before we add the new one in case the services file has
duplicates (it does). Fixes about 2KB of leaks.

svn path=/trunk/; revision=51363
2013-08-15 02:38:00 +00:00
Evan Huus 7292140b9c Fix name resolution tests:
- if we find a name during lookup, return it even if it's not a dummy
- read personal hosts after global hosts so that they take precedence

Neither of these problems appear to be new - the recent work did not change this
logic, so I have no idea how come name resolution wasn't failing before, but I
guess the old hash table was weirder than I thought...

svn path=/trunk/; revision=51326
2013-08-13 01:41:51 +00:00
Anders Broman 1ef4ba5e32 Move initalisation of IPv4 hastable to the host_name_lookup_init() rotine.
svn path=/trunk/; revision=51319
2013-08-12 18:33:08 +00:00
Anders Broman 93c9c4b0ff Use g_hashtable for IPv4 name resolution.
svn path=/trunk/; revision=51301
2013-08-11 19:02:26 +00:00