Add PTREE_FINFO and use PITEM_FINFO when possible.
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Sun, 9 Aug 2009 17:57:31 +0000 (17:57 -0000)
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Sun, 9 Aug 2009 17:57:31 +0000 (17:57 -0000)
svn path=/trunk/; revision=29355

asn1/snmp/packet-snmp-template.c
epan/dfilter/dfilter-macro.c
epan/dissectors/packet-diameter.c
epan/dissectors/packet-snmp.c
epan/expert.c
epan/proto.c
epan/proto.h
gtk/expert_comp_table.c
plugins/wimax/packet-wmx.c
plugins/wimax/wimax_harq_map_decoder.c
proto_hier_stats.c

index 90faa70569a0cb1ab15ae6b052f428c045ac1f2b..74ca2d8b304895aa5656c27052214dc7299e37da 100644 (file)
@@ -785,7 +785,7 @@ indexing_done:
 
 
 set_label:
-       if (pi_value) proto_item_fill_label(pi_value->finfo, label);
+       if (pi_value) proto_item_fill_label(PITEM_FINFO(pi_value), label);
 
        if (oid_info && oid_info->name) {
                if (oid_left >= 1) {
index 7e0e336e48fb743875c33f9f7cf9f239974d6ecd..9e90c7ed13575c978b245f949d72f567a3f2bc69 100644 (file)
@@ -67,7 +67,7 @@ static gboolean free_value(gpointer k _U_, gpointer v, gpointer u _U_) {
 }
 
 static gboolean fvt_cache_cb(proto_node * node, gpointer data _U_) {
-       field_info* finfo = node->finfo;
+       field_info* finfo = PNODE_FINFO(node);
        fvt_cache_entry_t* e;
 
        if (!finfo) return FALSE;
index 1ec0250ef3f8d102f65414647a1f5146de5c8e83..d0d5ab1badcf02dcf95e760bc9bff3546520ceaa 100644 (file)
@@ -500,7 +500,7 @@ address_rfc_avp(diam_ctx_t* c, diam_avp_t* a, tvbuff_t* tvb)
                        break;
        }
 
-       proto_item_fill_label(pi->finfo, label);
+       proto_item_fill_label(PITEM_FINFO(pi), label);
        label = strstr(label,": ")+2;
        return label;
 }
@@ -570,7 +570,7 @@ address_v16_avp(diam_ctx_t* c, diam_avp_t* a, tvbuff_t* tvb)
                        break;
        }
 
-       proto_item_fill_label(pi->finfo, label);
+       proto_item_fill_label(PITEM_FINFO(pi), label);
        label = strstr(label,": ")+2;
        return label;
 }
@@ -580,7 +580,7 @@ simple_avp(diam_ctx_t* c, diam_avp_t* a, tvbuff_t* tvb)
 {
        char* label = ep_alloc(ITEM_LABEL_LENGTH+1);
        proto_item* pi = proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_length(tvb),FALSE);
-       proto_item_fill_label(pi->finfo, label);
+       proto_item_fill_label(PITEM_FINFO(pi), label);
        label = strstr(label,": ")+2;
        return label;
 }
@@ -595,7 +595,7 @@ unsigned32_avp(diam_ctx_t* c, diam_avp_t* a, tvbuff_t* tvb)
        gint length = tvb_length_remaining(tvb,0);
        if (length == 4) {
                pi= proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_length_remaining(tvb,0),FALSE);
-               proto_item_fill_label(pi->finfo, label);
+               proto_item_fill_label(PITEM_FINFO(pi), label);
                label = strstr(label,": ")+2;
        }
        else {
index a8948c12f5140374f5c50905dc28f0ae5f436f26..b9cf529113d6b7ca72c42b38dff89bc3210b6fe5 100644 (file)
@@ -887,7 +887,7 @@ indexing_done:
 
 
 set_label:
-       if (pi_value) proto_item_fill_label(pi_value->finfo, label);
+       if (pi_value) proto_item_fill_label(PITEM_FINFO(pi_value), label);
 
        if (oid_info && oid_info->name) {
                if (oid_left >= 1) {
index 240bed7f9e9374cb3e9aa60ed212ab9dc9555e80..bd66d8daaff1058d35a3b581d7f5518310420aeb 100644 (file)
@@ -186,7 +186,7 @@ packet_info *pinfo, proto_item *pi, int group, int severity, const char *format,
        PROTO_ITEM_SET_GENERATED(ti);
 
        /* if we have a proto_item (not a faked item), set expert attributes to it */
-       if(pi != NULL && pi->finfo != NULL) {   
+       if(pi != NULL && PITEM_FINFO(pi) != NULL) {
         ei->pitem       = pi;
                expert_set_item_flags(pi, group, severity);
        }
index 25182b1ec5fe1261f9bf3a47878b935ec49fcfbc..4d89ebceea9ad861b357ebb1587948edc5f2acf9 100644 (file)
@@ -91,14 +91,14 @@ wrs_count_bitshift(guint32 bitmask)
           will still have somewhere to attach to                       \
           or else filtering will not work (they would be ignored since tree\
           would be NULL).                                              \
-          DONT try to fake a node where PITEM_FINFO(pi) is NULL        \
+          DONT try to fake a node where PTREE_FINFO(tree) is NULL      \
           since dissectors that want to do proto_item_set_len() or     \
           other operations that dereference this would crash.          \
           We dont fake FT_PROTOCOL either since these are cheap and    \
           some stuff (proto hier stat) assumes they always exist.      \
        */                                                              \
        if(!(PTREE_DATA(tree)->visible)){                               \
-               if(PITEM_FINFO(tree)){                                  \
+               if(PTREE_FINFO(tree)){                                  \
                        register header_field_info *hfinfo;             \
                        PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo);       \
                        if((hfinfo->ref_count == HF_REF_TYPE_NONE)      \
@@ -2832,13 +2832,13 @@ proto_tree_add_node(proto_tree *tree, field_info *fi)
         * Make sure "tree" is ready to have subtrees under it, by
         * checking whether it's been given an ett_ value.
         *
-        * "tnode->finfo" may be null; that's the case for the root
+        * "PNODE_FINFO(tnode)" may be null; that's the case for the root
         * node of the protocol tree.  That node is not displayed,
         * so it doesn't need an ett_ value to remember whether it
         * was expanded.
         */
        tnode = tree;
-       tfi = tnode->finfo;
+       tfi = PNODE_FINFO(tnode);
        if (tfi != NULL && (tfi->tree_type < 0 || tfi->tree_type >= num_tree_types)) {
                REPORT_DISSECTOR_BUG(ep_strdup_printf("\"%s\" - \"%s\" tfi->tree_type: %u invalid (%s:%u)",
                        fi->hfinfo->name, fi->hfinfo->abbrev, tfi->tree_type, __FILE__, __LINE__));
@@ -2858,7 +2858,7 @@ proto_tree_add_node(proto_tree *tree, field_info *fi)
 
        PROTO_NODE_NEW(pnode);
        pnode->parent = tnode;
-       pnode->finfo = fi;
+       PNODE_FINFO(pnode) = fi;
        pnode->tree_data = PTREE_DATA(tree);
 
        if (tnode->last_child != NULL) {
@@ -3277,13 +3277,13 @@ proto_item_get_len(proto_item *pi)
 gboolean
 proto_item_set_expert_flags(proto_item *pi, int group, guint severity)
 {
-       if(pi == NULL || pi->finfo == NULL)
+       if(pi == NULL || PITEM_FINFO(pi) == NULL)
                return FALSE;
 
        /* only change things if severity is worse or at least equal than before */
-       if(severity >= FI_GET_FLAG(pi->finfo, PI_SEVERITY_MASK)) {
-               FI_REPLACE_FLAGS(pi->finfo, PI_GROUP_MASK, group);
-               FI_REPLACE_FLAGS(pi->finfo, PI_SEVERITY_MASK, severity);
+       if(severity >= FI_GET_FLAG(PITEM_FINFO(pi), PI_SEVERITY_MASK)) {
+               FI_REPLACE_FLAGS(PITEM_FINFO(pi), PI_GROUP_MASK, group);
+               FI_REPLACE_FLAGS(PITEM_FINFO(pi), PI_SEVERITY_MASK, severity);
 
                return TRUE;
        }
@@ -3301,7 +3301,7 @@ proto_tree_create_root(void)
        /* Initialize the proto_node */
        PROTO_NODE_NEW(pnode);
        pnode->parent = NULL;
-       pnode->finfo = NULL;
+       PNODE_FINFO(pnode) = NULL;
        pnode->tree_data = g_new(tree_data_t, 1);
 
        /* Don't initialize the tree_data_t. Wait until we know we need it */
@@ -3460,7 +3460,7 @@ proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, gint length
        if (tree == NULL)
                return;
 
-       fi = tree->finfo;
+       fi = PTREE_FINFO(tree);
        start += TVB_RAW_OFFSET(tvb);
        DISSECTOR_ASSERT(start >= 0);
        DISSECTOR_ASSERT(length >= 0);
index 32e83a0ac26f62ab22f2dadde9f66691fbb01612..e50877537477ed7cd78e3d705f7abc43bb10908e 100644 (file)
@@ -351,6 +351,9 @@ extern void proto_tree_children_foreach(proto_tree *tree,
 /** Retrieve the field_info from a proto_item */
 #define PITEM_FINFO(proto_item)  PNODE_FINFO(proto_item)
 
+/** Retrieve the field_info from a proto_tree */
+#define PTREE_FINFO(proto_tree)  PNODE_FINFO(proto_tree)
+
 /** Retrieve the tree_data_t from a proto_tree */
 #define PTREE_DATA(proto_tree)   ((proto_tree)->tree_data)
 
index da33f53bc074679fd02d35cf1324317cb0694846..420490147d15d6e8b4a08d69efffa02fc9d9a01d 100644 (file)
@@ -562,7 +562,7 @@ init_error_table_row(error_equiv_table *err, const expert_info_t *expert_data)
         if (expert_data->pitem) {
             char *filter;
 
-            filter = proto_construct_match_selected_string(expert_data->pitem->finfo, NULL);
+            filter = proto_construct_match_selected_string(PITEM_FINFO(expert_data->pitem), NULL);
             if (filter != NULL)
                 err->procedures[row].fvalue_value = g_strdup(filter);
         }
index 9866c8ec4111c769b7d8a3433de0cc4ca952caad..5d2f1e9a681bc909b5f0a7acd04bb8004e9a8951 100644 (file)
@@ -643,8 +643,8 @@ proto_tree *add_tlv_subtree(tlv_info_t *this, gint idx, proto_tree *tree, int hf
        /* display the TLV name and display the value in hex. Highlight type, length, and value. */
        tlv_item = proto_tree_add_item(tree, hfindex, tvb, start, tlv_value_length, little_endian);
        /* Correct the highlighting. */
-       tlv_item->finfo->start -= tlv_val_offset;
-       tlv_item->finfo->length += tlv_val_offset;
+       PITEM_FINFO(tlv_item)->start -= tlv_val_offset;
+       PITEM_FINFO(tlv_item)->length += tlv_val_offset;
        /* add TLV subtree to contain the type, length, and value */
        tlv_tree = proto_item_add_subtree(tlv_item, *ett_tlv[tlv_type]);
        /* display the TLV type */
@@ -685,7 +685,7 @@ proto_tree *add_tlv_subtree(tlv_info_t *this, gint idx, proto_tree *tree, int hf
                        break;
        }
        /* Show "TLV value: " */
-       tlv_item = proto_tree_add_text(tlv_tree, tvb, start, tlv_value_length, hex_fmt, tlv_item->finfo->hfinfo->name, tlv_value);
+       tlv_item = proto_tree_add_text(tlv_tree, tvb, start, tlv_value_length, hex_fmt, PITEM_FINFO(tlv_item)->hfinfo->name, tlv_value);
        tlv_tree = proto_item_add_subtree(tlv_item, idx);
 
        /* Return a pointer to the value level */
@@ -734,8 +734,8 @@ proto_tree *add_protocol_subtree(tlv_info_t *this, gint idx, proto_tree *tree, i
        va_end(ap);
        tlv_item = proto_tree_add_protocol_format(tree, hfindex, tvb, start, length, "%s", message);
        /* Correct the highlighting. */
-       tlv_item->finfo->start -= tlv_val_offset;
-       tlv_item->finfo->length += tlv_val_offset;
+       PITEM_FINFO(tlv_item)->start -= tlv_val_offset;
+       PITEM_FINFO(tlv_item)->length += tlv_val_offset;
        /* add TLV subtree to contain the type, length, and value */
        tlv_tree = proto_item_add_subtree(tlv_item, *ett_tlv[tlv_type]);
        /* display the TLV type */
index 75e5c29d6c253c219d46b6e4d60ec42d1801c9f6..cde0c368a15e66599d50d431f1d731fdfa30e10f 100644 (file)
@@ -124,7 +124,7 @@ void dissector_wimax_harq_map_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_t
                dl_ie_count = ((first_24bits & WIMAX_HARQ_MAP_DL_IE_COUNT_MASK) >> WIMAX_HARQ_MAP_DL_IE_COUNT_SHIFT);
                /* get the UL MAP appended */
                ulmap_appended = (first_24bits & WIMAX_HARQ_UL_MAP_APPENDED_MASK);
-               if (parent_item == NULL || parent_item->finfo == NULL)
+               if (parent_item == NULL || PITEM_FINFO(parent_item) == NULL)
                {
                        parent_item = harq_map_item; /* Prevent crash */
                }
index ce3ce1e403fd2cd87dab2f3573483935df655d08..510821da32ebd855683a1b3902cc7ddd82b465f1 100644 (file)
@@ -110,7 +110,7 @@ process_node(proto_node *ptree_node, GNode *parent_stat_node, ph_stats_t *ps, gu
                 * not a normal protocol in the top-level tree.  It was instead
                 * added as a normal tree such as IPv6's Hop-by-hop Option Header and
                 * should be skipped when creating the protocol hierarchy display. */
-               if(strlen(proto_sibling_node->finfo->hfinfo->name) == 0 && ptree_node->next)
+               if(strlen(PNODE_FINFO(proto_sibling_node)->hfinfo->name) == 0 && ptree_node->next)
                        proto_sibling_node = proto_sibling_node->next;
 
                process_node(proto_sibling_node, stat_node, ps, pkt_len);