Skip to content
  • DaanDeMeyer's avatar
    Add --no-duplicate-keys tshark option. · 07f576ff
    DaanDeMeyer authored and AndersBroman's avatar AndersBroman committed
    Adds the --no-duplicate-keys option to tshark. If -T json is specified,
    this option can be specified in order to transform the duplicate keys
    produced by -T json into single keys with as value a json array of all
    separate values.
    
    Specifying --no-duplicate-keys changes the function which groups node
    children that is passed to write_json_proto_tree. Instead of a function
    that puts each node in a separate group (proto_node_group_children_by_unique)
    a function is passed that groups children that have the same json key
    together (proto_node_group_children_by_json_key). This will lead to
    some groups having multiple values. Groups with multiple values are
    written to the output as a json array. This includes normal json keys
    but also keys with the "_raw" and "_tree" suffix.
    
    If --no-duplicate-keys is specified with an option other than "-T json"
    or "-T jsonraw" or without -T an error is shown and tshark will exit.
    
    "Export Packet Dissections -> As JSON" in the GUI is hardcoded to use
    the duplicated keys format.
    
    Fixes one regression in the output where a filtered json key (-j) with
    both a value and children would not have the "_tree" suffix added to the
    json key containing the children.
    
    Includes a little code cleanup (removes one instance of code
    duplication and simplifies a while loop).
    
    Fixes a memory leak (I thought this fix was already included in the
    previous refactor patch but something must have gone wrong when updating
    the patch so I'm including it again in this patch).
    
    Bug: 12958
    Change-Id: I401f8fc877b5c590686567c3c44cdb832e9e7dfe
    Reviewed-on: https://code.wireshark.org/review/22166
    
    
    Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
    Tested-by: default avatarPetri Dish Buildbot <buildbot-no-reply@wireshark.org>
    Reviewed-by: default avatarAnders Broman <a.broman58@gmail.com>
    07f576ff