summaryrefslogtreecommitdiff
path: root/epan/dfilter/dfilter-macro.c
AgeCommit message (Collapse)AuthorFilesLines
2017-02-03dfilter-macro: add cleanup routine.Dario Lombardo1-0/+5
Change-Id: I3de59c0366e9bec058de144eb136abaca24b5911 Reviewed-on: https://code.wireshark.org/review/19918 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-12uat: add a reset callback.Dario Lombardo1-0/+1
This function will free the resources allocated by the caller. Change-Id: Ib486c14e4fd3c321662fb71f7fd06733ce9a64a4 Reviewed-on: https://code.wireshark.org/review/19375 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-25Fix checkAPI.pl warnings about printfMichael Mann1-30/+31
Many of the complaints from checkAPI.pl for use of printf are when its embedded in an #ifdef and checkAPI isn't smart enough to figure that out. The other (non-ifdef) use is dumping internal structures (which is a type of debug functionality) Add a "ws_debug_printf" macro for printf to pacify the warnings. Change-Id: I63610e1adbbaf2feffb4ec9d4f817247d833f7fd Reviewed-on: https://code.wireshark.org/review/16623 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>
2016-05-10Have fvalue_to_string_repr always return an (wmem) allocated buffer.Michael Mann1-2/+2
Previous patches converted all fvalue_to_string_repr calls to expect an allocated buffer (and not a passed in one). Now changing signature to force an allocated buffer. Added wmem in case that can be taken advantage of within epan (and since the function signature was changing anyway). Change-Id: Ica1ac4a9a182ce0e73303856329e198d9d525b7b Reviewed-on: https://code.wireshark.org/review/15343 Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-05Type cleanups.Guy Harris1-4/+4
dfilter_macro_apply_recurse() returns either NULL or a pointer to freshly-allocated memory, so it doesn't return a const pointer. dfilter_macro_apply() calls dfilter_macro_apply_recurse(), so it doesn't return a const pointer, either. In dfilter_compile(), have separate variables for the filter handed in and the macro-expanded filter, the former being const gchar * and the latter being gchar *. Change-Id: I191549bf0ff6c09c1278a98432a907c93d5e0e74 Reviewed-on: https://code.wireshark.org/review/12446 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-08This doesn't need <wsutil/file_util.h>.Guy Harris1-1/+0
The only file system operations it does are printing of debugging output to the standard output, so it doesn't need <wsutil/file_util.h>. Change-Id: Ia5caf62a3aab418f039669aa0b54e163e54d0d21 Reviewed-on: https://code.wireshark.org/review/11635 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-07Remove some unnecessary includes.Guy Harris1-1/+2
Either remove them completely, or put them inside an #ifdef. Change-Id: Iceff4909e250c17812f38d94e067f7c37ab72e1b Reviewed-on: https://code.wireshark.org/review/11630 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-08-22Add the display filter macros dialog.Gerald Combs1-62/+4
Add some missing functionality to UatDialog. Remove what appears to be unused dfilter macro code. Change-Id: I8a8d6358523f24d5ddfe953d7741fe9af25d98eb Reviewed-on: https://code.wireshark.org/review/10187 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-02-18Make UAT record update callbacks return a success/failure indication.Guy Harris1-2/+2
Have them return TRUE on success and FALSE on failure. Check the return value rather than whether the error string pointer is null or not. Change-Id: I800a03bcd70a6bbb7b217cf7c4800e9cdcf2189c Reviewed-on: https://code.wireshark.org/review/7222 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-17Make it a bit more like the way it was before all these changes.Guy Harris1-2/+2
Change-Id: I9fc0ef50574a7e068c32e3f6ffeb3634df9474d4 Reviewed-on: https://code.wireshark.org/review/7212 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-17A UAT's update is expected to set *error; do so.Guy Harris1-1/+3
Its callers treat a non-null error pointer as a failure and a null error pointer as a success, so it has to set *error, even if it's only setting it to NULL. Change-Id: I48b2faa4bc013e4a754180dfae487829c8fe35a6 Reviewed-on: https://code.wireshark.org/review/7211 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-16Revert "Revert "Fix duplicate Display Filter Macro check""Guy Harris1-15/+20
This reverts commit 876c322df8b6a944cb4358c313c4fc46afe99719. Wrong branch. It builds in master; it does *not* build in 1.12 or 1.10. Change-Id: I3a2409d5a37f08965d6caac64dc97a48a1c5d1b8 Reviewed-on: https://code.wireshark.org/review/7152 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-16Revert "Fix duplicate Display Filter Macro check"Guy Harris1-20/+15
This reverts commit f5902a677e24ff96869d3c335f4fb8aaa6d0e543. This is not a simple cherry-pick; backporting this fix will have to be done manually. Change-Id: I53efc06a8e35c6b1aa793edf4e702cabee2e929b Reviewed-on: https://code.wireshark.org/review/7151 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-15Fix duplicate Display Filter Macro checkPeter Wu1-15/+20
Since commit 4a1bd75b60171d781dc9f2d3ffd6d498acc74b1a (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7471), the data pointer does not match anything from the macros array. This patch fixes a false warning by checking for duplicates before the name is committed. Bug: 10957 Change-Id: Id61110bf63de1de80b85524705a2df6a5e7be33a Reviewed-on: https://code.wireshark.org/review/7119 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-13epan/dfilter/*.c: As needed: Add editor modelines & Fix indentationBill Meier1-2/+14
Change-Id: I410839329a98bd806c60961dfb9693d5eeeeb702 Reviewed-on: https://code.wireshark.org/review/7104 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-01-18Clean up ftype-conversion and dfilter error message string handling.Guy Harris1-16/+31
Have dfilter_compile() take an additional gchar ** argument, pointing to a gchar * item that, on error, gets set to point to a g_malloc()ed error string. That removes one bit of global state from the display filter parser, and doesn't impose a fixed limit on the error message strings. Have fvalue_from_string() and fvalue_from_unparsed() take a gchar ** argument, pointer to a gchar * item, rather than an error-reporting function, and set the gchar * item to point to a g_malloc()ed error string on an error. Allow either gchar ** argument to be null; if the argument is null, no error message is allocated or provided. Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c Reviewed-on: https://code.wireshark.org/review/6608 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18Trim down the use of ep_ memory in the display filter code.Michael Mann1-19/+21
Couldn't quite eliminate it completely, but it's much improved. Need to figure out where/when to free dfilter_error_msg. Change-Id: I10216e9546d38e83f69991ded8ec0b3fc8472035 Reviewed-on: https://code.wireshark.org/review/6591 Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-13Consistently use the "g_string_free returns a C string pointer" idiom.Guy Harris1-4/+2
g_string_free(str, FALSE) frees the GString container but not the underlying g_malloc()ed string; instead, it returns a pointer to the g_malloc()ed string. Fix those places that didn't already get the string pointer from g_string_free() to do so rather than manually extracting the string themselves. And fix one place that didn't even need to use a string - it was just scanning a C string without even modifying it. Change-Id: Ibbf4872bf5b9935b9907f539b6edb1013f3053a5 Reviewed-on: https://code.wireshark.org/review/6532 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-13UAT error string pointers should not be const pointers.Guy Harris1-2/+2
UAT error strings are usually allocated by g_strdup() or g_strdup_printf(), and must ultimately be freed by the caller. Make the pointer-to-error-string-pointer arguments to various functions be "char **", not "const char **". Fix cases that finds where a raw string was being used, as that won't work if you try to free it; g_strdup() it instead. Add a missing free of an error string. Remove some no-longer-necessary casts. Remove some unnecessary g_strdup()s (the string being handed to it was already g_malloc()ated). Change some variable declarations to match. Put in XXX comments for some cases where the error string is just freed, without being shown to the user. Change-Id: I40297746a2ef729c56763baeddbb0842386fa0d0 Reviewed-on: https://code.wireshark.org/review/6525 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-12Remove emem APIs from UAT functionality.Michael Mann1-2/+2
Change-Id: I009c09f25d170e5c9aaaef713eaacb3252817856 Reviewed-on: https://code.wireshark.org/review/6460 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Evan Huus <eapache@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-04Create BASE_DOT, BASE_DASH, and BASE_SEMICOLON types for the FT_BYTES field ↵Michael Mann1-1/+1
type. These "bases" will put a ".", "-", or ":" respectively between hexidecimal bytes in the field in packet view and display filter. FT_BYTES with BASE_NONE will have no separator in the packet view, but continue to have the ':' as a separator in the display filter. Converted the "string" hf_ entries that used tvb_fc_to_str as a string to use proto_tree_add_item with FT_BYTES/BASE_DOT type. Converted applicable tvb_bytes_to_ep_str_punct() calls to use the new BASE values. Change-Id: I2442185bb314d04a3ff2ba57883652ecd738b5f9 Reviewed-on: https://code.wireshark.org/review/6098 Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-10-16Use g_ascii_isalnum() rather than isalnum().Guy Harris1-3/+2
That way, we don't have to worry about casting the argument (which, in one place, was done wrong - casting to int preserves the sign-extension done with signed chars), and don't have to worry about a locale in which particular 8-bit byte values are considered alphanumeric characters. Change-Id: I129b4bfdad70ade4ab6e0a1d2c13d59ae9e6f524 Reviewed-on: https://code.wireshark.org/review/4751 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-16Don't use __func__, use G_STRFUNC.Guy Harris1-1/+1
Not all compilers we use support __func__. Change-Id: I61194e1073c87e67f821e14698ea21b73d63983c Reviewed-on: https://code.wireshark.org/review/3071 Reviewed-by: Guy Harris <guy@alum.mit.edu>
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>
2014-02-03Fix all -fstrict-alias warnings found by gcc 4.1.2Gilbert Ramirez1-1/+1
The majority of the fixes are for calls to uat_new(). Instead of having each caller cast its private data to (void**), we use void* in the uat_new() API itself. Inside uat_new(), we cast the void* to void**. Some dissectors use val64_string arrays, so a VALS64() macro was added for those, to avoid using VALS(), which is useful only for value_string arrays. packet-mq.c was changed because dissect_nt_sid() requires a char**, not a guint**. All other callers of dissect_nt_sid() use char*'s (and take the address of it) for their local storage. So, this was changed to follow the other practices. A confusion between gint and absolute_time_display_e in packet-time.c was cleared up. The ugliest fix is the addition of ip6_guint8_to_str(), for exactly one caller. The caller uses one type of ip6 address byte array, while ip6_to_str() expects another. This new function is in place until the various address implementations can be consolidated. Add VALS64() to the developer documentation. Change-Id: If93ff5c6c8c7cc3c9510d7fb78fa9108e4552805 Reviewed-on: https://code.wireshark.org/review/48 Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2013-11-10Move struct _ftype_t + callback typedefs + free macro to ftypes-int.hJakub Zawadzki1-0/+1
svn path=/trunk/; revision=53223
2013-10-25Add a very small hack to make the UAT update callback error string freeable, andEvan Huus1-1/+1
convert all existing UAT update callbacks to use glib memory instead of ephemeral memory for that string. UAT code paths are entirely distinct from packet dissection, so using ephemeral memory was the wrong choice, because there was no guarantees about when it would be freed. The move away from emem still needs to be propogated deeper into the UAT code itself at some point. Net effect: remove another bunch of emem calls from dissectors, where replacing with wmem would have caused assertions. svn path=/trunk/; revision=52854
2013-07-15Move report_err.{h,c} from epan into wsutil: there's nothing epan-specific ↵Jeff Morriss1-1/+0
there and moving it avoids having to recompile the file for use in editcap and capinfos (which don't link against libwireshark). svn path=/trunk/; revision=50598
2013-06-19Add a comment about how it would nice for display filter macro fieldsMartin Mathieson1-1/+4
to use auto-completion, but that it won't work because the string contains the $1, etc placeholders... svn path=/trunk/; revision=50038
2013-03-17From beroset:Anders Broman1-1/+1
remove C++ incompatibilities https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 svn path=/trunk/; revision=48355
2013-01-04replace "unsigned" datatype with "guint". Some mpeg files needed "unsigned ↵Michael Mann1-1/+1
int" instead. bugs 7825-7827 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7825) svn path=/trunk/; revision=46928
2012-12-26Fix a bunch of warnings.Guy Harris1-8/+8
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-20We always HAVE_CONFIG_H so don't bother checking whether we have it or not.Jeff Morriss1-2/+0
svn path=/trunk/; revision=45016
2012-07-08UATs could be put into "categories". The categories were defined onlyGuy Harris1-1/+1
implicitly by the #define name and string they were defined to; not all UATs neatly fit into any of the categories, so some of them were put into categories that weren't obviously correct for them, and one - the display filter macro UAT - wasn't put into any category at all (which caused crashes when editing them, as the GUI code that handled UAT changes from a dialog assumed the category field was non-null). The category was, in practice, used only to decide, in the aforementioned GUI code, whether the packet summary pane needed to be updated or not. It also offered no option of "don't update the packet summary pane *and* don't redissect anything", which is what would be appropriate for the display filter macro UAT. Replace the category with a set of fields indicating what the UAT affects; we currently offer "dissection", which applies to most UATs (any UAT in libwireshark presumably affects dissection at a minimum) and "the set of named fields that exist". Changing any UAT that affects dissection requires a redissection; changing any UAT that affects the set of named fields that exist requires a redissection *and* rebuilding the packet summary pane. Perhaps we also need "filtering", so that if you change a display filter macro, we re-filter, in case the display is currently filtered with a display filter that uses a macro that changed. svn path=/trunk/; revision=43603
2012-06-28Update Free Software Foundation address.Jakub Zawadzki1-1/+1
(COPYING will be updated in next commit) svn path=/trunk/; revision=43536
2012-06-03Try to squelch warningsAnders Broman1-1/+1
svn path=/trunk/; revision=43019
2012-06-02Try to squelch warningsAnders Broman1-15/+15
svn path=/trunk/; revision=43002
2011-11-15Get rid of the depth argument to dfilter_macro_apply(); have an internalGuy Harris1-112/+118
routine that does all the work and that takes a depth argumen, and an external routine that calls that internal routine with a depth argument of 0. The depth is only of use internally, to avoid infinite recursion. When recursing with that routine, pass depth+1 as the depth value, rather than passing depth and incrementing it afterwards; the latter doesn't prevent infinite recursion. (Thanks and a tip of the hat to Clang Cat for catching this.) Squelch some other (harmless) warnings from Clang Cat. Clean up indentation. svn path=/trunk/; revision=39838
2011-06-28Replace all strerror() with g_strerror().Stig Bjørlykke1-1/+1
Remove our local strerror implementation. Mark strerror as locale unsafe API. This fixes bug 5715. svn path=/trunk/; revision=37812
2011-02-17Oops, wrong pointer comparison.Guy Harris1-2/+3
svn path=/trunk/; revision=35976
2011-02-17OK, let's try a couple more explicit checks against NULL, to see whetherGuy Harris1-1/+1
that de-confuses Microsoft's code analyzer. svn path=/trunk/; revision=35975
2010-10-29Make the third argument to a UAT copy callback a size_t (not that any ofGuy Harris1-1/+1
the callbacks we have use that argument - is it really needed?). svn path=/trunk/; revision=34694
2010-08-30Call dfilter_macro_uat->post_update_cb instead of using cfile.Stig Bjørlykke1-4/+3
svn path=/trunk/; revision=34012
2010-08-30Always update the display filter when changing a display filter macroStig Bjørlykke1-1/+6
and when changing profile. Not sure why I have to invalidate cfile.dfilter in macro_update(), because this will be done in macros_post_update(), but unless this we get a crash when renaming a macro... This is a fix for bug 5002. svn path=/trunk/; revision=34011
2010-03-04From LEGO via bug 3459:Stig Bjørlykke1-0/+1
Add a callback to UAT to be called after the table has being updated, use it to renew the snmp_ue_cache. svn path=/trunk/; revision=32112
2009-08-09Add PTREE_FINFO and use PITEM_FINFO when possible.Kovarththanan Rajaratnam1-1/+1
svn path=/trunk/; revision=29355
2009-04-22Clean up some 64-bit issues.Guy Harris1-2/+2
svn path=/trunk/; revision=28117
2009-04-20Constify some items to squelch some compiler warnings in the WindowsGuy Harris1-1/+1
buildbot; based on a patch from Chris Maynard, with some additional changes to squelch GCC warnings on UN*X. svn path=/trunk/; revision=28093
2009-03-13From Jakub Zawadzki (bug 3331):Stig Bjørlykke1-5/+3
g_free() is NULL safe, so we don't need check against it. svn path=/trunk/; revision=27718
2009-02-16Add an additional "title" attribute for UAT fields; that's what'sGuy Harris1-2/+2
displayed to the user. svn path=/trunk/; revision=27462