diff options
Diffstat (limited to 'epan/frame_data.c')
-rw-r--r-- | epan/frame_data.c | 125 |
1 files changed, 1 insertions, 124 deletions
diff --git a/epan/frame_data.c b/epan/frame_data.c index 3108d35774..f9bb8b47b5 100644 --- a/epan/frame_data.c +++ b/epan/frame_data.c @@ -28,131 +28,8 @@ #include <epan/epan.h> #include <wiretap/wtap.h> #include <epan/frame_data.h> -#include <epan/packet.h> -#include <epan/wmem/wmem.h> +#include <epan/column-utils.h> #include <epan/timestamp.h> -#include <epan/packet_info.h> - - -/* Protocol-specific data attached to a frame_data structure - protocol - index and opaque pointer. */ -typedef struct _frame_proto_data { - int proto; - guint32 key; - void *proto_data; -} frame_proto_data; - -/* XXX - I declared this static, because it only seems to be used by - * p_get_proto_data and p_add_proto_data - */ -static gint -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){ - return 1; - }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 -p_add_proto_data(wmem_allocator_t *tmp_scope, struct _packet_info* pinfo, int proto, guint32 key, void *proto_data) -{ - frame_proto_data *p1; - GSList** proto_list; - wmem_allocator_t *scope; - - if (tmp_scope == pinfo->pool) { - scope = tmp_scope; - proto_list = &pinfo->proto_data; - } else { - scope = wmem_file_scope(); - proto_list = &pinfo->fd->pfd; - } - - p1 = (frame_proto_data *)wmem_alloc(scope, sizeof(frame_proto_data)); - - p1->proto = proto; - p1->key = key; - p1->proto_data = proto_data; - - /* Add it to the GSLIST */ - *proto_list = g_slist_prepend(*proto_list, - (gpointer *)p1); -} - -void * -p_get_proto_data(wmem_allocator_t *scope, struct _packet_info* pinfo, int proto, guint32 key) -{ - frame_proto_data temp, *p1; - GSList *item; - - temp.proto = proto; - temp.key = key; - temp.proto_data = NULL; - - if (scope == pinfo->pool) { - item = g_slist_find_custom(pinfo->proto_data, (gpointer *)&temp, p_compare); - } else { - item = g_slist_find_custom(pinfo->fd->pfd, (gpointer *)&temp, p_compare); - } - - if (item) { - p1 = (frame_proto_data *)item->data; - return p1->proto_data; - } - - return NULL; - -} - -void -p_remove_proto_data(wmem_allocator_t *scope, struct _packet_info* pinfo, int proto, guint32 key) -{ - frame_proto_data temp; - GSList *item; - GSList** proto_list; - - temp.proto = proto; - temp.key = key; - temp.proto_data = NULL; - - if (scope == pinfo->pool) { - item = g_slist_find_custom(pinfo->fd->pfd, (gpointer *)&temp, p_compare); - proto_list = &pinfo->proto_data; - } else { - item = g_slist_find_custom(pinfo->fd->pfd, (gpointer *)&temp, p_compare); - proto_list = &pinfo->fd->pfd; - } - - if (item) { - *proto_list = g_slist_remove(*proto_list, item->data); - } - -} - -gchar * -p_get_proto_name_and_key(wmem_allocator_t *scope, struct _packet_info* pinfo, guint pfd_index){ - frame_proto_data *temp; - - if (scope == pinfo->pool) { - temp = (frame_proto_data*)g_slist_nth_data(pinfo->proto_data, pfd_index); - } else { - temp = (frame_proto_data*)g_slist_nth_data(pinfo->fd->pfd, pfd_index); - } - - return wmem_strdup_printf(wmem_packet_scope(),"[%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 : \ |