Wireshark-dev: Re: [Wireshark-dev] Wmem has reached feature-parity with emem
From: Michal Labedzki <[email protected]>
Date: Wed, 19 Jun 2013 17:30:00 +0200
Hi,
One more thing. What do you think about new API... In Bluetooth dissectors there is a lot of code like this (little simplified):

        k_interface_id = interface_id;
        k_adapter_id   = adapter_id;
        k_chandle      = chandle;
        k_cid          = cid;
        k_frame_number = pinfo->fd->num;

        key[0].length = 1;
        key[0].key    = &k_interface_id;
        key[1].length = 1;
        key[1].key    = &k_adapter_id;
        key[2].length = 1;
        key[2].key    = &k_chandle;
        key[3].length = 1;
        key[3].key    = &k_cid;
        key[4].length = 1;
        key[4].key    = &k_frame_number;
        key[5].length = 0;
        key[5].key    = NULL;

        psm_data = (psm_data_t *) wmem_tree_lookup32_array_le(cid_to_psm_table, key);
        if (!(psm_data && psm_data->interface_id == interface_id &&
                psm_data->adapter_id == adapter_id &&
                psm_data->chandle == chandle &&
                psm_data->scid == (scid | ((pinfo->p2p_dir == P2P_DIR_RECV) ? 0x00000000 : 0x80000000))))
            psm_data = NULL;

So I expected for every key expect last are equal, but last equal or less. Currently I need to check all nodes. Maybe we can create for example:  wmem_tree_lookup32_array_cond() where we can control all the keys conditions, for example:


        key[0].length = 1;
        key[0].key    = &k_interface_id;
        key[0].cond = COND_EQ;
        key[1].length = 1;
        key[1].key    = &k_adapter_id;
        key[1].cond = COND_EQ;
        key[2].length = 1;
        key[2].key    = &k_chandle;
        key[2].cond = COND_EQ;
        key[3].length = 1;
        key[3].key    = &k_cid;
        key[3].cond = COND_EQ; /* or COND_L, COND_G (possible?), COND_GE, COND_NE (not equal)  */
        key[4].length = 1;
        key[4].key    = &k_frame_number;
        key[4].cond = COND_LE;
        key[5].length = 0;
        key[5].key    = NULL;

Or maybe other idea? (pack all session identifiers to one long length identifier?)
By the way.. key can be a string?