summaryrefslogtreecommitdiff
path: root/epan/address_types.c
AgeCommit message (Collapse)AuthorFilesLines
2017-06-24addr_types: replace DISSECTOR_ASSERT() with g_assert()Martin Kaiser1-11/+11
DISSECTOR_ASSERT() can be used only when we're in wmem packet scope. It cannot be used during startup when address types are registered. In those cases, we must use g_assert(). If we still use DISSECTOR_ASSERT() and an assert is hit, we'll see a wmem assertion ** ERROR:../epan/wmem/wmem_core.c:52:wmem_alloc: assertion failed: (allocator->in_scope) Aborted instead of the actual assert output. Change-Id: Ife12ca3455d56ba4faa2dd6034df8a091d8641ed Reviewed-on: https://code.wireshark.org/review/22378 Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-08-26Properly end address type search by name (CID-1362742)Jaap Keuter1-3/+3
Search address type by name iterates over an array, but fails to find its end. Therefore it may dereference invalid pointers, or NULL. Add the proper check in the for loop and make sure an end condition is always there in the array searched. Change-Id: I60ade9d438dc394340b6483b4fcb23e5ce432000 Reviewed-on: https://code.wireshark.org/review/17337 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-23Increase MAX_DISSECTOR_ADDR_TYPE.Jens Kilian1-1/+1
With the recent changes causing some address types to be registered by their proper dissectors, I ran into the MAX_DISSECTOR_ADDR_TYPE limit in a new dissector I'm currently writing. Change-Id: I72f521266af9190e8ad198ace4d6608b6b4d2dee Reviewed-on: https://code.wireshark.org/review/16091 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-22Add address_to_bytes API.Michael Mann1-2/+42
This will copy an address's "byte format" into a buffer. The original intended design is for export_pdu functionality, which tries to do this "manually" for many address types (and creates undesired dependencies) The default functionality if a "byte format function" isn't provided (currently the case for all address types) is a memcpy of the address data. Providing "address to byte" functions to aid export PDU functionality will be provided later. Change-Id: I3703f9e617a8cef09165ad53a0f98c6372676b9b Reviewed-on: https://code.wireshark.org/review/16070 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-06-22Move AT_VINES address type to VINES dissector.Michael Mann1-41/+0
proto.c still has to deal with FT_VINES, but maybe that can be refactored to the dissector too. Change-Id: Iee04eed3b75f91cb62bb7b625dd44baeeb9aebb3 Reviewed-on: https://code.wireshark.org/review/16069 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-22Move AT_USB to inside USB dissector.Michael Mann1-39/+0
This required some hacking in the conversation table handling, but still seemed worth it as USB address is not widely used. Maybe a "is_stringlike" property for address types... Change-Id: I628a15c17cb1f595bb292130867adbc5bea0f41a Reviewed-on: https://code.wireshark.org/review/16068 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-06-13Convert AT_SS7PC to a "dissector address type"Michael Mann1-29/+0
The formatting of the address type is determined by a preference in packet-mtp3.c, so just make MTP3 register the address type. Use address_type_get_by_name in other dissectors (and export_pdu) to use the address type. Change-Id: Ifb32d7de27aeaa23cee8e803e25ffb3c905547b5 Reviewed-on: https://code.wireshark.org/review/15856 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-06-13Add address_type_get_by_nameMichael Mann1-0/+16
This allows the decoupling of a dissector registering an address type so it doesn't need to export the returned registered type. Change-Id: I49c913d042e70bd4b7ea1e964ba9511bb27304f5 Reviewed-on: https://code.wireshark.org/review/15855 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-06Move ip6_to_str_buf() to to_str.c and make it take the buffer length.João Valverde1-118/+1
Also make it use ws_inet_ntop6() (rather than implementing the string conversion ourselves). Remove ip6_to_str_buf_len(). Change-Id: I1eff3a8941e00987c2ff0c4dcfda13476af86191 Reviewed-on: https://code.wireshark.org/review/15692 Reviewed-by: João Valverde <j@v6e.pt> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-02-19Add inet_pton/inet_ntop interface to libwsutilJoão Valverde1-14/+2
Change-Id: Ifc344ed33f2f7ca09a6912a5adb49dc35f07c81f Reviewed-on: https://code.wireshark.org/review/13881 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
2015-11-29Make address_to_display() use proper (non-)constnessJoão Valverde1-1/+1
Don't return allocated memory as a const pointer. Fixes multiple [-Wcast-qual] warnings. Change-Id: Ie9ceac27fa2a5eba41a5392ac983ff28c3939239 Reviewed-on: https://code.wireshark.org/review/12267 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-03Remaining ADDRESS macro to address function conversionsJoão Valverde1-3/+3
Change-Id: I8bc9af431e70243b05f4f0ce8c2b8ee451383788 Reviewed-on: https://code.wireshark.org/review/11463 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-09-25Don't display duplicate addresses without name resolution enabledJoão Valverde1-1/+4
Change-Id: Ieb88e2632401cbf50c4ae51768a64df64d54a45d Reviewed-on: https://code.wireshark.org/review/10497 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-03Fix address resolution for columns.Guy Harris1-0/+52
Have address_to_name() be a routine that takes an address and returns a string with a "sufficiently long" lifetime for use in columns, using the address type's addr_name_res_str routine for most address types, rather than having a too-small set of address types wired into it. It replaces both the internal solve_address_to_name() routine and get_addr_name(), and can, for example, handle the special WLAN address types rather than leaving them unresolved even with an ethers file. Change-Id: Id09bc412adf5d2752155650a14a77c5378af2e42 Reviewed-on: https://code.wireshark.org/review/9475 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-03-03Address types: fix no previous prototype for ... [-Wmissing-prototypes]Alexis La Goutte1-6/+6
address_types.c:230:14: warning: no previous prototype for 'ipv4_name_res_str' [-Wmissing-prototypes] address_types.c:237:5: warning: no previous prototype for 'ipv4_name_res_len' [-Wmissing-prototypes] address_types.c:386:14: warning: no previous prototype for 'ipv6_name_res_str' [-Wmissing-prototypes] address_types.c:393:5: warning: no previous prototype for 'ipv6_name_res_len' [-Wmissing-prototypes] address_types.c:509:14: warning: no previous prototype for 'fcwwn_name_res_str' [-Wmissing-prototypes] address_types.c:538:5: warning: no previous prototype for 'fcwwn_name_res_len' [-Wmissing-prototypes] Change-Id: I6cf44b887d9e35fb76bd1840444074c9102b4d2b Reviewed-on: https://code.wireshark.org/review/7508 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-03-02Fix typo caught by Coverity - wrong structure members being tested.Guy Harris1-2/+2
CID 1271732 Change-Id: I12b610a0a28fcc790ffb041ca88624e014f68ab5 Reviewed-on: https://code.wireshark.org/review/7465 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-27address_to_string routines need to remember the beginning of the buffer.Guy Harris1-25/+30
Either they don't have a pointer into the buffer that they advance, in which case strlen(buf)+1 works just fine, or they do, in which case 1) they'd better save the pointer to the beginning of the buffer, so they can figure out how long the string is when they're done and 2) they don't need to use strlen(), they can just subtract the pointers. Bug: 11016 Change-Id: I81ce9d517336a15bd81f0c6225756ce5178ec6cf Reviewed-on: https://code.wireshark.org/review/7424 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-23Fix generation of address-with-resolution strings.Guy Harris1-26/+26
XXX_to_str routines should return the length, in bytes, of the generated string, including the terminating '\0'. As their reutrn values include the terminating '\0', we need to subtract 1 from the return value if, when appending the ")" after the address string, we want to skip past the address string rather than skipping past the terminating '\0'. Change-Id: Ibfd41e6d7152d05070706e6d76fc3e56a097a75b Reviewed-on: https://code.wireshark.org/review/7324 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-22Add tvb_address_with_resolution_to_str.Michael Mann1-0/+26
Convert dissectors to using the API where appropriate. Change-Id: I059582f73a75635d4a0338d02d4c4b212162480b Reviewed-on: https://code.wireshark.org/review/7296 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-20address_types.c: fix a "conditional jump or move depends on uninitialised ↵Pascal Quantin1-1/+1
value" error found by Valgrind Change-Id: Ic752bb6aa1ba56e113895fcbed52f417ac0128f7 Reviewed-on: https://code.wireshark.org/review/7272 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-02-19Add some casts to satisfy the various compilers.AndersBroman1-1/+1
Change-Id: I7687fc0b433774fe447757af00bdaa2fc44ac59d Reviewed-on: https://code.wireshark.org/review/7254 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-19Add name resolution support to address type.Michael Mann1-56/+214
Add address_with_resolution_to_str API that returns address string + name resolution in the format %s (%s), first string is resolved name (if available) and second string is raw address string. Convert AT_FCWWN to using proper name resolution format First use of address_with_resolution_to_str with field types in proto.c Change-Id: I2ae77c29a4ffc30bb919fbec00f06629830898c2 Reviewed-on: https://code.wireshark.org/review/7196 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-16Make get_manuf_name return a const string.Michael Mann1-7/+3
Model get_manuf_name after get_ether_name so that a string (either name resolved or colon-separated bytes) is always stored in a hash table. This will make name resolution of addresses perform a little better because it doesn't have to worry about the wmem_allocator. Change-Id: If976fe7b0c3f9cd053225096c2ac05418f061af6 Reviewed-on: https://code.wireshark.org/review/7081 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-13Replace tabs by spaces when editor modelines has "expandtab"Bill Meier1-4/+4
Change-Id: If7a6f2697be732ae4f94ed8b845fd293c32510f7 Also: tabs-stops should be 8 Reviewed-on: https://code.wireshark.org/review/7100 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-02-12Revert "Make get_manuf_name return a const string."Anders Broman1-3/+7
This reverts commit 797ea88aefc2f45dba7e77d2dcaebe68ac1a4fac. Change-Id: I9bc2cef0051d88c6374c6f1868b0250cba3edbd4 Reviewed-on: https://code.wireshark.org/review/7076 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-12Make get_manuf_name return a const string.Michael Mann1-7/+3
Model get_manuf_name after get_ether_name so that a string (either name resolved or colon-separated bytes) is always stored in a hash table. This will make name resolution of addresses perform a little better because it doesn't have to work about the wmem_allocator. Change-Id: I80f465ae0845290255a659ab63310ac3cc35506e Reviewed-on: https://code.wireshark.org/review/7075 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-02-09Add fixed length function for address types.Michael Mann1-27/+263
This allows for even more cleanup with respect to how address types are handled, including removing address_to_str.c. Most of the functionality was folded into address_types.c, but the remainder was just dispersed because it didn't make sense to keep the file. Change-Id: Id4e9391f0c3c26eff8c27b362e4f7a1970d718b4 Reviewed-on: https://code.wireshark.org/review/7038 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-09Eliminate the hf member out of the address structure.Michael Mann1-5/+5
Using the new address type registration, dissectors can create their own address types with their own (column) filters attached to them, eliminating the need for an address to keep track of a hf_ field. Change-Id: I2bbec256a056f403a7ac9880d5d76a0b2a21b221 Ping-Bug: 7728 Reviewed-on: https://code.wireshark.org/review/7037 Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-09Add "column filter string" support to address types.Michael Mann1-178/+152
Information about dissector (filter) fields should be kept in a dissector as much as possible. Supporting "column filter string" also allows other dissectors to create their own "address types" with different column filters (because AT_ETHER isn't always an "Ethernet" address). This feature also allowed a few "dissector specific" address types to be moved to their own dissector. Change-Id: Ie9024af4db62bc2ee4f8c9d28a1d807f706f45bf Ping-Bug:7728 Reviewed-on: https://code.wireshark.org/review/7029 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-09Add address type registration.Michael Mann1-0/+702
Now address types are setup just like field types and must be registered with a structure that provides its string representation (and more things in the future). Address types that are limited to a single dissector are registered by the dissector. More "common" ones are globally registered. There are still a few that really belong in a dissector, but have other dependencies currently not accounted for in the address type support. Many of the "address to string" conversions that involved g_sprintf have be changed to use more "performance friendly" methods (some at the cost of needing to_str-int.h) Leaving all comments regarding this "solution" in address_to_str.c in until all have been implemented Change-Id: I494f413e016b22859c44675def11135f228796e0 Reviewed-on: https://code.wireshark.org/review/7019 Reviewed-by: Michael Mann <mmann78@netscape.net>