aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes
AgeCommit message (Collapse)AuthorFilesLines
2023-11-09tshark: Escape delimiter separated value in compliant waysJohn Thacker1-0/+3
If the quote character appears in a field value, then escape it by printing the character twice. When escaping whitespace with the backslash character, also escape the backslash character itself. Add a ws_escape_csv function to wsutil and use it for tshark. Adopt the existing static escape_string_len function so that ws_escape_csv can use it while maintaining the same output for the other ws_escape_ functions. Fix #10284
2023-10-31wsutil: Rename inet_netw.[ch]João Valverde3-3/+3
inet_netw.c -> inet_cidr.c inet_netw.h -> inet_cidr.h
2023-10-31epan: Move tvbuff functions to tvbuff.cJoão Valverde1-1/+0
2023-10-31wsutil: Move and consolidate CIDR codeJoão Valverde3-6/+5
Consolidate code to handle CIDR network addresses in inet_netw.[ch].
2023-10-29wsutil/to_str: Deprecate ip_to_str() for endian-explicit versionsJoão Valverde1-2/+1
ip_to_str() forces the caller to cast the argument and it's not obvious at all that the input should be in network-byte order for IPv4 addresses. Deprecated the function and add endian-explicit substitutes (number vs address).
2023-10-27ftypes: Add IPv4 setter/getterJoão Valverde4-17/+46
Do not allow "fvalue_set_uinteger" and "fvalue_get_uinteger" with FT_IPv4. Use "fvalue_set_ipv4" and "fvalue_get_ipv4" intead. Fix incorrect usage of fvalue_*_uinteger with FT_IPv4, hopefully I caught all of them.
2023-10-26dfilter: Add WS_DLL_PUBLIC to more functionsJoão Valverde1-0/+53
For the benefit of plugins.
2023-10-23dfilter: Add back check for division by zeroJoão Valverde1-0/+8
2023-10-22dfilter: Use better assertions for invalid enumsJoão Valverde14-97/+108
Remove name static storage and use a switch to map enums to names. This allows mapping names all names, even those that are not instantiated as objects. Rewrite some assertions using ws_error() for detailed error messages.
2023-10-22dfilter: Add time multiplication by scalar floatsJoão Valverde3-20/+49
Extend the time arithmetic to support multiplication and division with floating point numbers. In this case the multiplier/divisor is parsed according to its lexical number type. Fixes #19150.
2023-10-22dfilter: Add number lexical typeJoão Valverde14-209/+644
Add a lexical type for numbers, consisting of integers and floats. Because the float is represented internally as an IEEE 754 double and that is a lossy representation, we still need to parse numbers from strings sometimes. One sematic change instroduced is that integers on the RHS of a relation with bytes are interpreted as decimals instead of hexadecimals without a 0x prefix in the representation. This is a net win, in line with the goal of being explicit writing literal values in display filter expressions.
2023-10-22dfilter: Add time multiplication by scalar integersJoão Valverde1-11/+66
The multiplication of two time values is not well-defined, because time is represented internally as a vector. Add a scalar multiplication/division for time values using integer numbers. The scalar multiplier must appear on the RHS of the operation. (This limitation mat be removed in the future.) This is useful to compare relative time values. The operation is also allowed for absolute date and time values because it is mathematically consistent but that is probably less useful in practice. Related to #19150.
2023-10-13ftype: Clean up IPv6 interfaceJoão Valverde4-14/+12
Rename a typedef and use an address and mask as the method interface.
2023-10-13ftypes: Rename comparison methodsJoão Valverde2-24/+24
2023-10-09ftypes: Use 64-bit integers only internallyJoão Valverde2-624/+275
Remove code duplication for 32-bit and 64-bit integers. Use 64-bit for everything and cast to 32-bit to implement getters for 32-bit numbers.
2023-09-29Tools: Add constant conversions to convert-glib-typesGerald Combs1-6/+6
Add conversions from G_GINT64_CONSTANT to INT64_C and G_GUINT64_CONSTANT to UINT64_C to convert-glib-types. Convert instances in epan/ftypes and wsutil.
2023-09-27Revert changes to JSON boolean formatJoão Valverde4-6/+19
We should represent JSON values in JSON, such as booleans using true/false. The changes in cdc8e2f5119a20e905b60d2afab66114a86b45c9 didn't actually fix anything for JSON output in that regard, they just replace one string representation with a different incorrect representation, so revert the part affecting JSON to avoid inconveniencing users without sufficient justification.
2023-09-24ftypes: Fix hash calculation to use 128 bits of the address (CID 1524736)Jaap Keuter1-1/+1
2023-09-22Convert epan/ftypes to C99 typesGerald Combs13-762/+762
Ping #19116
2023-09-22dfilter: Change default boolean representation to True/FalseJoão Valverde1-2/+2
2023-09-22Make tfs_true_false the default for booleansJoão Valverde1-1/+18
Instead of adding a TFS(&tfs_true_false) to every boolean field, make it the default if "strings" is NULL. This seems to match the already existing documentation: If the Boolean field is to be displayed as "False" or "True", the 'strings' field would be set to NULL.
2023-09-10Change what iso8601_to_nstime() and unix_epoch_to_nstime() return.Guy Harris1-2/+4
Instead of rturning an 8-bit(!) integer giving the number of characters parsed, have them return a pointer to the first character *after* the string that was parsed, similarly to what strto*() (and Wireshark's wrappers for them in wsutil) and strptime() return. This cleans up some code that uses those routines. For the 3GPP 32.423 trace files, we also reject files where there isn't an ISO 8601-format time where we expect there to be one. (Having the string-format date/time routines return NULL on an error means you have to think about what to do on failure.)
2023-09-08dfilter: Extend support for timezones in filter expressionsJoão Valverde1-29/+85
Extends the dfilter syntax with more the timezones supported by ws_strptime(). We remove the handling of tm_gmtoff and tm_zone in struct tm, because it is more trouble than it is worth due to platform incompatibilites, and instead use an extra arguments to pass these two non-standard fields. Remove a test that is no longer relevant (we do not need to assert that WET in particular is not supported).
2023-09-06dfilter: Fix printing of nanosecond fractions of time.João Valverde1-6/+1
The code is incorrectly also omitting zeros that are significant from the representation of fractional values of absolute time in display filters (with FTREPR_DFILTER). Instead of fixing the representation just remove the buggy code and include all 9 digits of fractional seconds, including trailing zeros to the right of the decimal point, which in this case can be inferred to indicate the precision (to the nanosecond).
2023-09-05Revert "dfilter: Clean up absolute_val_to_repr()"João Valverde1-11/+23
This reverts commit 8c113b9db93b1da7804a7890249975b8a161476b. The behaviour of the new code is not exactly the same as the old and that is apparently causing some failures in the test suite.
2023-09-05dfilter: Clean up absolute_val_to_repr()João Valverde1-23/+11
2023-09-04dfilter: Cleanup parsing of some time literalsJoão Valverde1-37/+22
2023-09-04dfilter: Fix parsing a time format with "UTC"João Valverde1-9/+14
Before: Filter: frame.time <= "2002-12-31 13:56:31.3 UTC" Error: Unexpected data after time value. frame.time <= "2002-12-31 13:56:31.3 UTC" After: Filter: frame.time <= "2002-12-31 13:56:31.3 UTC" Instructions: 0000 READ_TREE frame.time -> R0 0001 IF_FALSE_GOTO 3 0002 ANY_LE R0 <= "2002-12-31 13:56:31.3+0000" 0003 RETURN
2023-09-03Build with NetBSD's strptime()João Valverde1-0/+1
Replace our strptime code, which is from gnulib, with the simpler and better NetBSD implementation. This changes the ws_strptime() stub to unconditionally use the internal implementation. Previously it would use the system implementation of available. This is still possible but is opt-in, i.e., code should add the necessary #ifdefs and assume responsability for handling non-portable formats or providing limited functionality on some platforms. Text import allows the user to specify the strptime() format freely, so in that case it makes sense to use the system's implementation, and pass the responsability for understanding the implementation and the supported specifiers to the user. Only fall back to our implementation if the system libc lacks a strptime().
2023-09-01dfilter: Do not parse booleans as a value stringJoão Valverde1-4/+14
When parsing an expression such as Filter: _ws.ftypes.boolean == true Instructions: 0000 READ_TREE _ws.ftypes.boolean <FT_BOOLEAN> -> R0 0001 IF_FALSE_GOTO 3 0002 ANY_EQ R0 == 1 <FT_UINT64> 0003 RETURN it gives the wrong type. Conceptually there is no reason a boolean should be a value string. This commit also fixes the error message to avoid calling invalid boolean tokens "invalid numbers" when parsing booleans. The code now use g_ascii_strcasecmp() to accept true, True, trUE, etc. Initially the intention was to require non-numeric literals to start with an upper-case letter, to reserve lower-case for protocol names, but since "true" and "false" have been accepted as integers for a long time via value strings, that intention is dropped. As a consequence true/false are added to reserved keywords. After this change: Filter: _ws.ftypes.boolean == true Instructions: 0000 READ_TREE _ws.ftypes.boolean <FT_BOOLEAN> -> R0 0001 IF_FALSE_GOTO 3 0002 ANY_EQ R0 == 1 <FT_BOOLEAN> 0003 RETURN
2023-07-03Add Unix time support for absolute time field typeJoão Valverde1-11/+25
Add ABSOLUTE_TIME_UNIX absolute time type, to allow date and time values to be represented in Unix time, besides other existing formats.
2023-07-03dfilter: Add some arithmetic to FT_ABSOLUTE_TIMEJoão Valverde1-4/+4
FT_ABSOLUTE_TIME Hhas the same arithmetic properties as FT_RELATIVE_TIME. Give it the same methods.
2023-06-27dfilter: Use safe-math.h with time ftypesJoão Valverde1-4/+46
2023-06-26Don't include errno.h if we don't use errno or errno value definitions.Guy Harris1-1/+0
2023-06-26dfilter: Make string slices a return an FT_STRINGJoão Valverde7-45/+82
Allow string slices (indexing) to work with internationalized strings. The old behavior of indexing on byte boundaries can be obtained using raw slices.
2023-06-26Compute slice ranges in a separate procedureJoão Valverde1-24/+31
Modularize the code to allow re-use.
2023-06-26dflter: Fix semantics of fvalue lengthJoão Valverde4-13/+38
Do not mix wire size, a protocol property, with fvalue length, a property of certain types of objects (sequences). Rename ftype_length() to ftype_wire_size(). Do not return wire_size with fvalue_length() (use ftype_wire_size() instead). Make the semantic check reject taking the len() of objects that are not arrays or lists. If the (fixed) len() of a number is somehow useful we can add a different function for that.
2023-06-20ftypes: Rename IS_FT_* macrosJoão Valverde2-12/+16
Rename IS_FT_*() to FT_IS_*(). I find it to be more natural and a better namespace for a public interface.
2023-05-08epan: Show our ftype integer sizes in bitsGerald Combs1-17/+17
2023-04-22ftypes: Fix memory leakJoão Valverde1-3/+7
Need to decrement reference counter after calling fvalue_get_bytes().
2023-04-22ftypes: Add fvalue_set_bytes_data() helperJoão Valverde2-3/+14
2023-04-19ftypes: Fix assertionJoão Valverde1-0/+1
Fixes #19012.
2023-04-19ftypes: Add a hash/equal methodJoão Valverde14-9/+186
Add methods to make fvalues hashable with GHashTable.
2023-04-19ftypes: Hide fvalue implementationJoão Valverde2-20/+22
Exposing the fvalue_t implementation is exposing internal details of the implementation. Fix that by making the fvalue_t internal to the ftypes implementation and using setters/getters where necessary.
2023-04-19ftypes: Replace GByteArray with GBytesJoão Valverde4-147/+166
Fvalues are immutable objects. This isn't strictly true in the case of FT_BYTES because of widespread use of proto_item_set_len() but that can be worked around and using GBytes should be more convenient for callers and make some aspects of the implementation simplers (others not).
2023-04-19ftypes: Add a setter/getter for FT_IPv6João Valverde4-12/+39
2023-01-18CMake: Require explicit installation of development headersJoão Valverde1-0/+2
Develpment headers are a sizeable part of the binary installation and most users won't ever require them. It's recommended to package them separately in a devel package or SDK. Create a CMake installation component for development headers and add the EXCLUDE_FROM_ALL property. Headers can be installed using the invocation: cmake --install <dir> --component Development
2023-01-06dfilter: Print CIDR mask for IPv4/IPv6 field types.João Valverde2-2/+23
2023-01-02dfilter: Tweak representation for length-1 byte arrayJoão Valverde3-8/+38
Make dfilter byte representation always use ':' for consistency. Make 1 byte be represented as "XX:" with the colon suffix to make it nonambiguous that is is a byte and not other type, like a protocol. The difference is can be seen in the following programs. In the before representation it is not obvious at all that the second "fc" value is a literal bytes value and not the value of the protocol "fc", although it can be inferred from the lack of a READ_TREE instruction. In the After we know that "fc:" must be bytes and not a protocol. Note that a leading colon is a syntactical expedient to say "this value with any type is a literal value and not a protocol field." A terminating colon is just a part of the dfilter literal bytes syntax. Before: Filter: fc == :fc Syntax tree: 0 TEST_ANY_EQ: 1 FIELD(fc <FT_PROTOCOL>) 1 FVALUE(fc <FT_PROTOCOL>) Instructions: 00000 READ_TREE fc <FT_PROTOCOL> -> reg#0 00001 IF_FALSE_GOTO 3 00002 ANY_EQ reg#0 == fc <FT_PROTOCOL> After: Filter: fc == :fc Syntax tree: 0 TEST_ANY_EQ: 1 FIELD(fc <FT_PROTOCOL>) 1 FVALUE(fc: <FT_PROTOCOL>) Instructions: 00000 READ_TREE fc <FT_PROTOCOL> -> reg#0 00001 IF_FALSE_GOTO 3 00002 ANY_EQ reg#0 == fc: <FT_PROTOCOL>
2022-10-26ftypes: Do not sanitize strings for UTF-8 errorsJoão Valverde1-2/+0
The ftype itself is encoding agnostic. In the case of literal display filter strings it is possible and legal to contain invalid UTF-8. Maybe it shouldn't be but that requires a user-friendly diagnostic message, not silently sanitizing the string as is done currently (only a debug message is printed in that case). Do the debug checks in proto_tree_set_string() instead. That still detects dissector code that might need fixing, which was the purpose for this check. Improve documentation and add admonition for proto_tree_add_string(). Ping #18521.