Commit Graph

55 Commits

Author SHA1 Message Date
Evan Huus 6e3a30794e Add 64-bit value strings and the appropriate tooling (including yet another
overloaded use of the DISPLAY field). Thanks to Jakub for pointing out I'd done
this wrong the first time (months ago in r49357).

Fixes severity display for collectd protocol, originally filed at:
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8472

svn path=/trunk/; revision=50935
2013-07-26 21:51:39 +00:00
Evan Huus afa7538f12 Revert part of r50415. As pointed out by Jakub, some of the value_string
functions are called when no dissection is going on, and so can't use
wmem_packet_scope().

svn path=/trunk/; revision=50428
2013-07-06 23:53:09 +00:00
Evan Huus bae9597ca7 Wmem-ify value-strings. Another ~10KB gone.
svn path=/trunk/; revision=50415
2013-07-06 18:25:27 +00:00
Evan Huus 178fc8852a Note to self: stop using 'index' as a variable name, it triggers -Wshadow on
some platforms. You'd think I'd have learned by now.

svn path=/trunk/; revision=48646
2013-03-30 00:11:00 +00:00
Evan Huus d155b0da19 Implement str_to_val, opposite of val_to_str for value_strings.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8467

svn path=/trunk/; revision=48645
2013-03-29 23:23:28 +00:00
Evan Huus a0d107beec Remove decode_enumerated_bitfield and decode_enumerated_bitfield_shifted.
Effectively inline the only remain call (and replace a static buffer with ep
memory). Much of the NFS dissector needs to be converted to use named fields
at which point this code can go away, but that's a much bigger job.

Also, add modelines to packet-nfs.c and mark some internal value_string
functions as WS_DLL_LOCAL.

svn path=/trunk/; revision=48635
2013-03-29 02:34:23 +00:00
Evan Huus 37600a157b Rename value string (and similar) functions to use a consistent pattern. This
was done using textual search+replace, not anything syntax-aware, so presumably
it got most comments as well (except where there were typos).

Use a consistent coding style, and make proper use of the WS_DLL_* defines.

Group the functions appropriately in the header.

I ended up getting rid of most of the explanatory comments since many of them
duplicated what was in the value_string.c file (and were out of sync with the
recent updates I made to those in r48633). Presumably most of the comments
should be in the .h file not the .c file, but there's enough churn ahead that
it's not worth fixing yet.

Part of https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8467

svn path=/trunk/; revision=48634
2013-03-29 00:26:23 +00:00
Evan Huus 6f19d87f4e Greatly clean up value_string.c
- use consistent indentation and coding style
 - add modelines
 - replace some g_assert calls with DISSECTOR_ASSERT where it makes sense
 - group related functions together and simplify many comments by referring to
   the 'normal' value_string as the canonical version

svn path=/trunk/; revision=48633
2013-03-28 22:02:04 +00:00
Guy Harris 94af602582 Give better diagnostics for "Extended value string XXX forced to fall
back to linear search", to make it easier to find the out-of-order
entries.

svn path=/trunk/; revision=48555
2013-03-26 00:37:03 +00:00
Bill Meier 0df5a9390d From beroset:
remove C++ incompatibilities
 https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 attachment #10397

svn path=/trunk/; revision=48438
2013-03-20 01:18:10 +00:00
Evan Huus 1a684e6adf Warn if an extended value string falls back to linear search.
See https://www.wireshark.org/lists/wireshark-dev/201303/msg00179.html

svn path=/trunk/; revision=48415
2013-03-19 14:53:44 +00:00
Evan Huus 574d1ceec3 Revert warning that seems to have been accidentally included in r48319.
svn path=/trunk/; revision=48323
2013-03-15 17:56:27 +00:00
Anders Broman 54eb4a6cec [-Wmissing-prototypes]
Use explicit casts.

svn path=/trunk/; revision=48319
2013-03-15 16:39:30 +00:00
Jakub Zawadzki c5a71b1006 String passed to val_to_str() must have int format specifier (%u, %d, %x, and so on...).
Fix some cases (easy to grep) by call to val_to_str_const().

svn path=/trunk/; revision=47807
2013-02-21 21:04:59 +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
Jeff Morriss 7033cc7220 Fix some indentation.
svn path=/trunk/; revision=46512
2012-12-12 01:50:44 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Bill Meier 0035a9076b Force extended value string linear search (not binary search) in one case:
Fixed: { -2, -1, 0, 1, 3} (note gap) used a binary search (which would fail);

 Note:  { -2, -1, 0, 1, 2 ,3 } (no gap) allowed; will still do a direct access;

Also: Add a comment to README.developer extended value string section.

svn path=/trunk/; revision=44659
2012-08-24 20:44:33 +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
Bill Meier b017f7c22d Fix a typo.
svn path=/trunk/; revision=42201
2012-04-23 02:37:35 +00:00
Jakub Zawadzki 6aa7c2d371 Try to fix:
value_string.c(175) : warning C4244: '=' : conversion from '__int64' to 'gint', possible loss of data

svn path=/trunk/; revision=36931
2011-04-28 11:53:29 +00:00
Jakub Zawadzki 1ea1e9fef2 Change value_string_ext->_vs_match to return value_string struct (instead of strptr),
Now index can be easily calculated so remove idx pointer from all match functions.

Just in case change names if someone is using wireshark internals.

svn path=/trunk/; revision=36930
2011-04-28 11:15:46 +00:00
Jeff Morriss 45920c1e15 Fix the fuzz failure in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5574 :
The first time a value_string_ext() is accessed, _match_strval_ext_init() is
used before the real match function is called.  This function was not expanded
to take an idx parameter (in rev 35451).  It compiled only because the function:
  a) previously did not match _value_string_match_t
  b) and the difference was being cast away when assigning _match_strval to it
     (So the fact that the index parameter was not added was also ignored.)

To fix the problem, give _match_strval_ext_init() and index parameter and use
it instead of a dummy variable when calling the real match function.  That way
the first call to match_strval_ext_idx() will return an actual (initialized)
index.

To prevent the problem in the future, make the vse argument to
_match_strval_ext_init() const *and then cast away the constness* so the
function can modify the vse.

svn path=/trunk/; revision=35508
2011-01-12 17:20:52 +00:00
Anders Broman 6404b4437a Introduce match_strval_idx_ext()
svn path=/trunk/; revision=35451
2011-01-10 14:31:33 +00:00
Bill Meier a7063f9cc8 'tshark -G values' - Validate (somewhat) value_string_ext before use to prevent a crash.
svn path=/trunk/; revision=34869
2010-11-14 16:30:56 +00:00
Bill Meier cfdd78166f Enhance 'tshark -G values': Add info about extended value strings (including acess method).
svn path=/trunk/; revision=34854
2010-11-12 19:48:30 +00:00
Bill Meier e21ca35116 Improve g_warning text slightly.
svn path=/trunk/; revision=34697
2010-10-29 22:01:29 +00:00
Bill Meier 15851701e8 Rework "extended value strings":
- Allow direct access when a range of values begins with a value other than 0;
- Provide value_string_ext_new() for creating extended value strings at runtime;
- Do access to value_string_ext members via a macro (all but value_string.c);
- Update documentation.

svn path=/trunk/; revision=34514
2010-10-14 17:50:35 +00:00
Bill Meier 7219ee2a49 Use val_to_str_ext() & friends to access sminmpec_values[];
Also: packet-nhrp.c: #include sminmpec.h not req'd;

svn path=/trunk/; revision=34143
2010-09-17 04:51:21 +00:00
Gerasimos Dimitriadis df3a43e0e5 Remove debugging printf from match_strval_ext_init()
svn path=/trunk/; revision=32903
2010-05-19 22:09:07 +00:00
Anders Broman ab825ec9d9 From Jakub Zawadzki:
- use function pointers instead of switch.
 - initalize ->match_type during first use of match_str() func.

svn path=/trunk/; revision=32576
2010-04-27 12:38:49 +00:00
Anders Broman fab55e4772 From Jakub Zawadzki:
Itroduce value_string_ext for faster value matching in value_strings.

svn path=/trunk/; revision=32574
2010-04-27 10:32:34 +00:00
Bill Meier 6812b68eb1 From Yaniv Kaul: constify parameters
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422

 From me: Fix a number of instances where the function prototype or
  the function definition wasn't changed so there was a mismatch 
  thus causing Windows (but not gcc) compilation errors.

svn path=/trunk/; revision=32365
2010-04-03 18:18:50 +00:00
Bill Meier d32b4c0758 Revert SVN #32360 until Windows compilation errors corrected.
svn path=/trunk/; revision=32361
2010-04-02 15:18:03 +00:00
Bill Meier 049f9eac85 From Yaniv Kaul: constify parameters
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422

svn path=/trunk/; revision=32360
2010-04-02 14:37:49 +00:00
Kovarththanan Rajaratnam 6fe1060cd1 Don't pass ep_alloc()'ed strings to col_set_str().
Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3984

svn path=/trunk/; revision=29726
2009-09-06 04:26:50 +00:00
Gerald Combs 8a6daf2a1c From Didier Gautheron via bug 3052:
Add:
- FIX 4.0 to 4.4 fields, auto generated with XSLT stylesheets applied on
http://www.quickfixengine.org/ xml files (not included quickfixengine code is
BSD but xml files have no copyright).

- value_string functions for string keys, added to value_string.c.

- FIX desegmentation, it doesn't work well with malformed FIX PDU.

svn path=/trunk/; revision=28478
2009-05-26 00:49:38 +00:00
Gerald Combs c2ae798ae2 More size_t fixes.
svn path=/trunk/; revision=28000
2009-04-08 17:31:12 +00:00
Jaap Keuter c1484a08df Allow for dynamic value string array selection.
svn path=/trunk/; revision=23149
2007-10-11 19:40:58 +00:00
Stephen Fisher c980cede98 From Francesco Fondelli:
I defined a range_string struct. It's like value_string
but stores range <-> string pairs.
Moreover I wrote rval_to_str(), match_strrval_idx()
match_strrval() which are behaving exactly as
val_to_str(), match_strval_idx() and match_strval().


svn path=/trunk/; revision=20061
2006-12-07 20:29:40 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Guy Harris 995aa3f43b Get rid of a no-longer-used variable.
svn path=/trunk/; revision=15816
2005-09-15 09:09:00 +00:00
Guy Harris 1bac10d41d Use ep_strdup_printf() to generate the "not found in value_string table"
string for val_to_str().

svn path=/trunk/; revision=15814
2005-09-15 08:55:43 +00:00
Ronnie Sahlberg a34e7e3d03 removal of even more sprintf
svn path=/trunk/; revision=15457
2005-08-20 02:33:33 +00:00
Ronnie Sahlberg 19e3bae487 fix some more silly rotating buffers
svn path=/trunk/; revision=15385
2005-08-17 09:28:24 +00:00
Ulf Lamping 0dc9fb3d4a various code cleanup:
-use g_snprintf instead of sprintf and snprintf
-use g_strdup_printf where appropriate
-remove #include "snprintf.h" (as only g_snprintf should be used)
-replace some more alloc/realloc/calloc/free with their glib pendants

svn path=/trunk/; revision=15264
2005-08-08 18:50:39 +00:00
Guy Harris ab797734dd Get rid of the private "my_match_strval()" routine in many dissectors;
add a "match_strval_idx()" routine that does the same thing, and have
"match_strval()" call it.

Make those routines, and "val_to_str()", return a "const" pointer. 
Update dissectors as necessary to squelch compiler warnings produced by
that.

Use "val_to_str()" rather than using "match_strval()" and then, if the
result is null, substituting a specific string.  Clean up some other
"match_strval()"/"val_to_str()" usages.

Add a null pointer check in the NDPS dissector's "attribute_value()"
routine, as it's not clear that "global_attribute_name" won't be null at
that point.

Make some global variables in the AFS4INT dissector local.

Make some routines not used outside the module they're in static.

Make some tables "static const".

Clean up white space.

Fix Gerald's address in some files.

svn path=/trunk/; revision=14786
2005-06-26 19:56:52 +00:00
Ulf Lamping 6c3b559e21 value_string.c(71) : warning C4090: 'return' : different 'const' qualifiers
svn path=/trunk/; revision=14784
2005-06-26 11:40:26 +00:00
Gerald Combs 7a412fadf3 Force the "fmt" argument of val_to_str() to be non-null. Change the 9P
dissector to use a non-null format.  Fixes bug 70.

Fix the line endings in the 9P dissector, and set its SVN properties.

svn path=/trunk/; revision=14127
2005-04-18 16:16:57 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
they have LF at the end of the line on UN*X and CR/LF on Windows;
hopefully this means that if a CR/LF version is checked in on Windows,
the CRs will be stripped so that they show up only when checked out on
Windows, not on UN*X.

svn path=/trunk/; revision=11400
2004-07-18 00:24:25 +00:00