diff options
author | Anders Broman <anders.broman@ericsson.com> | 2013-05-15 16:50:37 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2013-05-15 16:50:37 +0000 |
commit | 85ff18cf166fbbfdedf6a6bd80af1635b48e7276 (patch) | |
tree | 40564dee9d96a4bbd99044bb9ecb7be3fde272f3 | |
parent | 5b279569d245c0c2e23588251fb4c951f50c9b36 (diff) |
- Use the key for comparison of per_proto_data.
- Show the number of per-packet-data entries and which protocol has made entries in the frame.
svn path=/trunk/; revision=49313
-rw-r--r-- | epan/dissectors/packet-frame.c | 16 | ||||
-rw-r--r-- | epan/frame_data.c | 25 | ||||
-rw-r--r-- | epan/frame_data.h | 1 | ||||
-rw-r--r-- | epan/packet_info.h | 2 |
4 files changed, 38 insertions, 6 deletions
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index 274d88fe01..5c89a86913 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -81,6 +81,7 @@ static int hf_frame_pack_preamble_error = -1; static int hf_frame_pack_symbol_error = -1; static int hf_frame_wtap_encap = -1; static int hf_comments_text = -1; +static int hf_frame_num_p_prot_data = -1; static gint ett_frame = -1; static gint ett_flags = -1; @@ -415,6 +416,16 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) else pinfo->layer_names = NULL; + if(pinfo->fd->pfd != 0){ + proto_item *item; + guint num_entries = g_slist_length(pinfo->fd->pfd); + guint i; + item = proto_tree_add_uint(fh_tree, hf_frame_num_p_prot_data, tvb, 0, 0, num_entries); + PROTO_ITEM_SET_GENERATED(item); + for(i=0; i<num_entries; i++){ + proto_tree_add_text (fh_tree, tvb, 0, 0, "%s",p_get_proto_name_and_key(pinfo->fd, i)); + } + } /* Check for existences of P2P pseudo header */ if (pinfo->p2p_dir != P2P_DIR_UNKNOWN) { proto_tree_add_int(fh_tree, hf_frame_p2p_dir, tvb, @@ -749,6 +760,11 @@ proto_register_frame(void) { "Comment", "frame.comment", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + + { &hf_frame_num_p_prot_data, + { "Number of per-protocol-data", "frame.p_prot_data", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, }; static hf_register_info hf_encap = diff --git a/epan/frame_data.c b/epan/frame_data.c index 097e6ede92..b489876a8b 100644 --- a/epan/frame_data.c +++ b/epan/frame_data.c @@ -51,13 +51,18 @@ p_compare(gconstpointer a, gconstpointer b) const frame_proto_data *ap = (const frame_proto_data *)a; const frame_proto_data *bp = (const frame_proto_data *)b; - if (ap -> proto > bp -> proto) + if (ap -> proto > bp -> proto){ return 1; - else if (ap -> proto == bp -> proto) - return 0; - else + }else if (ap -> proto == bp -> proto){ + if (ap -> key > bp -> key){ + return 1; + }else if (ap -> key == bp -> key){ + return 0; + } return -1; - + }else{ + return -1; + } } void @@ -114,6 +119,16 @@ p_remove_proto_data(frame_data *fd, int proto, guint8 key) } } +gchar * +p_get_proto_name_and_key(frame_data *fd, guint index){ + frame_proto_data *temp; + + temp = (frame_proto_data*)g_slist_nth_data(fd->pfd, index); + + return ep_strdup_printf("[%s, key %u]",proto_get_protocol_name(temp->proto), temp->key); + +} + #define COMPARE_FRAME_NUM() ((fdata1->num < fdata2->num) ? -1 : \ (fdata1->num > fdata2->num) ? 1 : \ 0) diff --git a/epan/frame_data.h b/epan/frame_data.h index 6710e341f0..37b3e62665 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -93,6 +93,7 @@ typedef struct { WS_DLL_PUBLIC void p_add_proto_data(frame_data *fd, int proto, guint8 key, void *proto_data); WS_DLL_PUBLIC void *p_get_proto_data(frame_data *fd, int proto, guint8 key); void p_remove_proto_data(frame_data *fd, int proto, guint8 key); +gchar *p_get_proto_name_and_key(frame_data *fd, guint index); /** compare two frame_datas */ WS_DLL_PUBLIC gint frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field); diff --git a/epan/packet_info.h b/epan/packet_info.h index e2a242247d..4383505ab1 100644 --- a/epan/packet_info.h +++ b/epan/packet_info.h @@ -183,7 +183,7 @@ typedef struct _packet_info { void *private_data; /**< pointer to data passed from one dissector to another */ GHashTable *private_table; /**< a hash table passed from one dissector to another */ - guint16 curr_layer_num; /**< The current "depth" or layer number in the current frame */ + guint8 curr_layer_num; /**< The current "depth" or layer number in the current frame */ /* TODO: Use emem_strbuf_t instead */ GString *layer_names; /**< layers of each protocol */ guint16 link_number; |