aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cops.c
AgeCommit message (Collapse)AuthorFilesLines
2017-10-26Add a ws_in6_addr typedef for struct e_in6_addr.Guy Harris1-1/+1
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-01-31Add format_text_wmem.Michael Mann1-7/+0
This allows for a wmem_allocator for users of format_text who want it (dissectors for wmem_packet_scope()). This lessens the role of current format_text functionality in hopes that it will eventually be replaced. Change-Id: I970557a65e32aa79634a3fcc654ab641b871178e Reviewed-on: https://code.wireshark.org/review/19855 Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-31Dissectors don't need a journey of self discovery.Michael Mann1-4/+3
They already know who they are when they register themselves. Saving the handle then to avoid finding it later. Not sure if this will increase unnecessary register_dissector functions (instead of using create_dissector_handle in proto_reg_handoff function) when other dissectors copy/paste, but it should make startup time a few microseconds better. Change-Id: I3839be791b32b84887ac51a6a65fb5733e9f1f43 Reviewed-on: https://code.wireshark.org/review/19481 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>
2016-12-08Fix a mis-merging.Guy Harris1-16/+22
Also, remove the "make sure we're not fetching a bogus structure" tests. Add a comment explaining how a compiler bug where it's overly optimizing a combination of tests could cause the valgrind errors we were seeing, so we're zeroing the entire structure, padding included, to avoid that. Change-Id: I24f94b2cbceec5234c1da82b891f609648075839 Reviewed-on: https://code.wireshark.org/review/19149 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-07Revert "Temporarily break up complicated expression into a bunch of separate ↵Peter Wu1-63/+0
ifs." This reverts commit db7c6286169015a727024e86eb270722127125bb. As pointed out in bug 13044, the warning is really coming from checking "cops_call->solicited", no need to expand the whole expression. Ping-Bug: 13044 Change-Id: Ib376ce6d0ec9fcf896e6081adae7664f19d9f759 Reviewed-on: https://code.wireshark.org/review/19115 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-07Throw in another tweak to check for uninitialized cops_call_t structures.Guy Harris1-0/+16
Temporariy add a "magic" field, initialize it when we allocate it, and whenever we fetch a structure from the array, make sure the "magic" field has the right value. (If this all turns out to be a valgrind bug, I'm not going to be very happy.) Change-Id: I29becc715367fdc305504b38d48be05dc516132a Reviewed-on: https://code.wireshark.org/review/19128 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-07cops: try to avoid uninitialized warning errorPeter Wu1-1/+1
Valgrind 3.11.0 on the Ubuntu 16.04 buildbot reports that cops_call->solicited is not initialized: pdus_array = (GPtrArray *)wmem_map_lookup(cops_conv_info->pdus_tree, GUINT_TO_POINTER(handle_value)); /* ... */ for (i=0; i < pdus_array->len; i++) { cops_call = (cops_call_t*)g_ptr_array_index(pdus_array, i); if ( /* ... */ ( (cops_call->op_code == COPS_MSG_KA && !(cops_call->solicited)) && ^^^^^^^^^^^^^^^^^^^^ which is clearly bogus since the only place where cops_call could be created is a few lines up: ver_flags = tvb_get_guint8(tvb, offset); is_solicited = (lo_nibble(ver_flags) == 0x01); /* ... */ pdus_array = (GPtrArray *)wmem_map_lookup(cops_conv_info->pdus_tree, GUINT_TO_POINTER(handle_value)); if (pdus_array == NULL) { pdus_array = g_ptr_array_new(); wmem_map_insert(cops_conv_info->pdus_tree, GUINT_TO_POINTER(handle_value), pdus_array); } /* ... */ cops_call = wmem_new(wmem_file_scope(), cops_call_t); cops_call->op_code = op_code; cops_call->solicited = is_solicited; /* ... */ g_ptr_array_add(pdus_array, cops_call); Try to zero the whole structure to avoid this bogus warning. Change-Id: I1ec4d23e99c987849af580a1c8134610c383e55e Ping-Bug: 13044 Ping-Bug: 13203 Reviewed-on: https://code.wireshark.org/review/19119 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-12-03Temporarily break up complicated expression into a bunch of separate ifs.Guy Harris1-0/+63
Maybe this way we can identify which *particular* test is, according to Valgrind, looking at uninitialized data; there's nothing obvious that shows up from inspecting the code, and neither of our static analyzers seem to have found anything. Change-Id: I80f6bb8e6fa92decfe195c01766330b97e980821 Reviewed-on: https://code.wireshark.org/review/19049 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-08Combine Decode As and port preferences for tcp.port dissector table.Michael Mann1-24/+10
This patch introduces new APIs to allow dissectors to have a preference for a (TCP) port, but the underlying data is actually part of Decode As functionality. For now the APIs are intentionally separate from the regular APIs that register a dissector within a dissector table. It may be possible to eventually combine the two so that all dissectors that register with a dissector table have an opportunity to "automatically" have a preference to adjust the "table value" through the preferences dialog. The tcp.port dissector table was used as the guinea pig. This will eventually be expanded to other dissector tables as well (most notably UDP ports). Some dissectors that "shared" a TCP/UDP port preference were also converted. It also removed the need for some preference callback functions (mostly when the callback function was the proto_reg_handoff function) so there is cleanup around that. Dissectors that has a port preference whose default was 0 were switched to using the dissector_add_for_decode_as_with_preference API rather than dissector_add_uint_with_preference Also added comments for TCP ports used that aren't IANA registered. Change-Id: I99604f95d426ad345f4b494598d94178b886eb67 Reviewed-on: https://code.wireshark.org/review/17724 Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-05Fix expert_info errors found by new and improved checkhfs.pl.Michael Mann1-1/+3
Change-Id: I30f1b92ee438361c3bd58743f7d1ae8d5ffc96f0 Reviewed-on: https://code.wireshark.org/review/15718 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-01-24Add the packet number to the packet_info structure, and use it.Guy Harris1-4/+4
That removes most of the uses of the frame number field in the frame_data structure. Change-Id: Ie22e4533e87f8360d7c0a61ca6ffb796cc233f22 Reviewed-on: https://code.wireshark.org/review/13509 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-23Add more fields to packet_info structure and use them.Guy Harris1-3/+3
Add fields for the absolute time stamp (and another field for a presence flag for the absolute time stamp) and the packet encapsulation for the packet. This lets us remove the field for the packet encapsulation in the frame_data structure; do so. Change-Id: Ifb910a9a192414e2a53086f3f7b97f39ed36aa39 Reviewed-on: https://code.wireshark.org/review/13499 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-09new_register_dissector -> register_dissector for dissector directory.Michael Mann1-1/+1
Change-Id: Ie39ef054a4a942687bd079f3a4d8c2cc55d5f22c Reviewed-on: https://code.wireshark.org/review/12485 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-04Don't include "file.h" if you don't need it.Guy Harris1-1/+3
It ends up dragging in libwireshark headers, which programs not linking with libwireshark shouldn't do. In particular, including <epan/address.h> causes some functions that refer to libwireshark functions to be defined if the compiler doesn't handle "static inline" the way GCC does, and you end up requiring libwireshark even though you shouldn't require it. Move plurality() to wsutil/str_util.h, so that non-libwireshark code can get it without include epan/packet.h. Fix includes as necessary. Change-Id: Ie4819719da4c2b349f61445112aa419e99b977d3 Reviewed-on: https://code.wireshark.org/review/11545 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-04Eliminate proto_tree_add_text from a few dissectors.Michael Mann1-30/+43
Change-Id: Ia6b62fae76ae76a2859ec47229e1c299bddb5a31 Reviewed-on: https://code.wireshark.org/review/8749 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-04-16Replace deprecated tvb_length APIsAndersBroman1-6/+6
Change-Id: Idfd3bed012e823de544fe4de483c8f095fc7c65d Reviewed-on: https://code.wireshark.org/review/8086 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-03-18Eliminate decode_bitfield_value from dissectors.Michael Mann1-57/+102
Change-Id: I37f5dbd5e88fd4dd8f736b014d36aae926082d1f Reviewed-on: https://code.wireshark.org/review/7735 Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-27Lua: Expose tcp_dissect_pdus() to LuaHadriel Kaplan1-1/+1
Provide a way for Lua-based dissectors to invoke tcp_dissect_pdus() to make TCP-based dissection easier. Bug: 9851 Change-Id: I91630ebf1f1fc1964118b6750cc34238e18a8ad3 Reviewed-on: https://code.wireshark.org/review/6778 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-01-19Convert OID APIs to use wmem.Michael Mann1-3/+3
There are a few oid functions that are only called in oids_test.c. I'll presume the APIs are used in proprietary dissectors rather than just remove them. Change-Id: I4595e00f93bf9ab8cf2493fe0432b91960f55a3f Reviewed-on: https://code.wireshark.org/review/6592 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-22First batch of unincludes. Last attempt...Martin Mathieson1-4/+0
Change-Id: I3681462aeb98ca62ed3ec5eb226b2553317391a9 Reviewed-on: https://code.wireshark.org/review/5997 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2014-12-21Cleanup use of #includes in non-generated epan/dissector/*.cBill Meier1-4/+0
Specifically: - Set packet.h to be the first wireshark #include after config.h and "system" #includes. packet.h added as an #include in some cases when missing. - Remove some #includes included (directly/indirectly) in packet.h. E.g., glib.h. (Done only for those files including packet.h). - As needed, move "system" #includes to be after config.h and before wireshark #includes. - Rework various #include file specifications for consistency. - Misc. Change-Id: Ifaa1a14b50b69fbad38ea4838a49dfe595c54c95 Reviewed-on: https://code.wireshark.org/review/5923 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-12-13Use ENC_BIG_ENDIAN when fetching FT_U?INT8 fields ...Bill Meier1-12/+12
(for some dissectors which fetch all other integral fields using ENC_BIG_ENDIAN). Change-Id: Ic18e3172aad76af12b12d6732c88497be22aed56 Reviewed-on: https://code.wireshark.org/review/5748 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-19Do encoding-arg changes (all benign)Bill Meier1-1/+1
For: - FT_BYTES: Always use just ENC_NA - integral/floating (other than FT_[U]INT8): Do ENC_NA --> ENC_BIG_ENDIAN Also: - FT_UINT... --> FT_UINT8 in a few cases (to match proto_tree_add_item...) - Change one case of incorrect '||' to '|' Change-Id: I427e0e61618ff8faf55691c8a695930f67d455b0 Reviewed-on: https://code.wireshark.org/review/4184 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-06-24convert to proto_tree_add_subtree[_format]Michael Mann1-151/+86
Change-Id: I5f573dffabb8685a8e5a334ff2bfb24d9838daa6 Reviewed-on: https://code.wireshark.org/review/2601 Tested-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-19Revert "Fixup: tvb_* -> tvb_captured"Michael Mann1-6/+6
https://www.wireshark.org/lists/wireshark-dev/201406/msg00131.html This reverts commit 246fe2ca4c67d8c98caa84e2f57694f6322e2f96. Change-Id: Ib24bae0198c13a84bd7f731bf4af921212109a8f Reviewed-on: https://code.wireshark.org/review/2430 Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-18Fixup: tvb_* -> tvb_capturedDario Lombardo1-6/+6
Change-Id: I9209c1271967405c34c1b6fa43e1726a4d3a5a3f Reviewed-on: https://code.wireshark.org/review/2377 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-06-18Fixup: tvb_get_string(z) -> tvb_get_string(z)_encDario Lombardo1-1/+1
Change-Id: I63a3704effe3fcab01a193dc39b6a22e9f1cf3fe Reviewed-on: https://code.wireshark.org/review/2376 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-28Minor: use VALS macro (as per convention); Add editor modelines; Do ↵Bill Meier1-5/+18
whitespace changes. Change-Id: I6007c1b2098d06e4a892474dd07f06a7538f94ef Reviewed-on: https://code.wireshark.org/review/1843 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-04-29Convert a few dissectors with simple request/response tracking from ↵Pascal Quantin1-5/+5
red/black tree to hash map Update the readme file accordingly Change-Id: I056d1ab1f77df641b83fa9b3618b6c25d66e1a83 Reviewed-on: https://code.wireshark.org/review/1420 Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(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>
2013-11-09Add data parameter to tcp_dissect_pdus() as well as convert it to using ↵Michael Mann1-20/+17
"new" style dissectors. Now that "bytes consumed" can be determined, should tcp_dissect_pdus() take advantage of that? Should tcp_dissect_pdus return length (bytes consumed)? There are many dissectors that just call tcp_dissect_pdus() then return tvb_length(tvb). Seems like that could all be rolled into one. svn path=/trunk/; revision=53198
2013-10-29From didier gautheron: remove redundant or use faster col_xxx functionsBill Meier1-2/+0
- when the text parameter is constant col_add_str() and col_set_str() are equivalent but col_set_str() is faster. - same for replace col_append_fstr and col_append_str - remove col_clear() when it's redundant: + before a col_set/col_add if the dissector can't throw an exception. - replace col_append() after a col_clear() with faster col_add... or col_set https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9344 svn path=/trunk/; revision=52948
2013-10-23#if 0 numerous "unused const variables" (mostly value-string-arrays);Bill Meier1-0/+2
Also; fix a few "set but not used" warnings. svn path=/trunk/; revision=52780
2013-10-13whitespace fixes; mostly: remove trailing blanksBill Meier1-1/+1
svn path=/trunk/; revision=52591
2013-09-23Tiny indentation fix.Evan Huus1-2/+2
svn path=/trunk/; revision=52188
2013-09-22emem -> wmem conversion:Pascal Quantin1-3/+3
- ep_tvb_get_bits() -> wmem_packet_tvb_get_bits() - tvb_g_memdup()/ep_tvb_memdup() -> tvb_memdup() - tvb_fake_unicode()/tvb_get_ephemeral_faked_unicode() -> tvb_get_faked_unicode() - tvb_get_g_string()/tvb_get_ephemeral_string()/tvb_get_seasonal_string() -> tvb_get_string() - tvb_get_g_unicode_string()/tvb_get_ephemeral_unicode_string() -> tvb_get_unicode_string() - tvb_get_ephemeral_string_enc() -> tvb_get_string_enc() - update docs accordingly svn path=/trunk/; revision=52172
2013-09-13Convert a few more dissectors to wmemPascal Quantin1-2/+2
svn path=/trunk/; revision=52013
2013-09-13Fix a bug (caught by Pascal) where a tree was being explicitly cast to emem_treeEvan Huus1-2/+2
for some reason, and thus the compiler hadn't flagged a type mismatch when the tree was converted to wmem. svn path=/trunk/; revision=52010
2013-09-09expert_add_info_format_text -> expert_add_info_formatMichael Mann1-2/+2
svn path=/trunk/; revision=51852
2013-09-02Fix some Dead Store (Dead assignement/Dead increment) Warning found by ClangAlexis La Goutte1-1/+0
svn path=/trunk/; revision=51653
2013-08-24From Simon Zhong: Convert several proto_tree_add_text into filterable expert ↵Michael Mann1-81/+104
info. From me: Make "Reserved" fields filterable. This was enough to pacify checkAPIs.pl, but part of the reason it was complaining in the first place is that many hf items are passed into info_to_display, which will end up calling a proto_tree_add_xxx function, rather than calling a proto_tree_add_xxx function directly. Cursory glance says info_to_display could probably just be replaced with direct proto_tree_add_xxx calls. svn path=/trunk/; revision=51504
2013-07-30Add request/response tracking to COPS dissector. Bug 8947 ↵Michael Mann1-6/+200
(https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8947). From Simon Zhong svn path=/trunk/; revision=51026
2013-05-25Batch of filterable expert_infos.Michael Mann1-5/+12
svn path=/trunk/; revision=49581
2013-03-15[-Wmissing-prototypes]Anders Broman1-7/+9
Use explicit casts. svn path=/trunk/; revision=48319
2013-01-31Comment out unused hf[] entries & etc.Bill Meier1-2/+6
(found by checkhf) svn path=/trunk/; revision=47389
2012-12-26Fix a bunch of warnings.Guy Harris1-4/+4
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-09-23Fix some unused variable warnings from GCC.Evan Huus1-2/+0
svn path=/trunk/; revision=45064
2012-09-23replaced decode_boolean_bitfield calls with itemized filtersMichael Mann1-6/+19
svn path=/trunk/; revision=45059
2012-09-20We always HAVE_CONFIG_H so don't bother checking whether we have it or not.Jeff Morriss1-3/+1
svn path=/trunk/; revision=45017
2012-08-10Use val_to_str_const() where appropriate;Bill Meier1-21/+21
Also (for a few files): - create/use some extended value strings; - remove unneeded #include files; - remove unneeded variable initialization; - re-order fcns slightly so prefs_reg_handoff...() at end, etc svn path=/trunk/; revision=44438