Ethereal-dev: [Ethereal-dev] A question about the proto_tree_add_XXX

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Kelvin You <kelvin.sdc@xxxxxxxxx>
Date: Fri, 9 Dec 2005 17:24:42 +0800
Hi, All
 
 We use
        proto_tree_add_text(tree, tvb, offset,  6,  "MAC Address %d: %s",  index, ether_to_str(src_addr));
 to add a formated text to the tree item.
 
 Also we can use:
...
    static hf_register_info hf[] =
    {
        /* ----------     Demultiplex Layer    ------------- */
        { &hf_xxx_macaddr,
            { "MAC Address",          "xxx.macaddr",
            FT_ETHER, BASE_NONE, NULL, 0x00,
            "", HFILL }
        },
 
proto_tree_add_ether_format(tree, hf_xxx_macaddr, tvb, offset,  6,  ether_to_str(src_addr), "MAC Address %d: %s",  index, ether_to_str(src_addr));
 
what's the difference between the two way?
It seems the the second method have more redundancy. why not substitute the second way with the first one always ?