2 * Routines for packet disassembly
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #include "frame_data.h"
36 /* Protocol-specific data attached to a frame_data structure - protocol
37 index and opaque pointer. */
38 typedef struct _frame_proto_data {
43 /* XXX - I declared this static, because it only seems to be used by
44 * p_get_proto_data and p_add_proto_data
46 static gint p_compare(gconstpointer a, gconstpointer b)
48 const frame_proto_data *ap = (const frame_proto_data *)a;
49 const frame_proto_data *bp = (const frame_proto_data *)b;
51 if (ap -> proto > bp -> proto)
53 else if (ap -> proto == bp -> proto)
62 p_add_proto_data(frame_data *fd, int proto, void *proto_data)
64 frame_proto_data *p1 = se_alloc(sizeof(frame_proto_data));
69 p1 -> proto_data = proto_data;
71 /* Add it to the GSLIST */
73 fd -> pfd = g_slist_insert_sorted(fd -> pfd,
80 p_get_proto_data(frame_data *fd, int proto)
82 frame_proto_data temp, *p1;
86 temp.proto_data = NULL;
88 item = g_slist_find_custom(fd->pfd, (gpointer *)&temp, p_compare);
91 p1 = (frame_proto_data *)item->data;
92 return p1->proto_data;
100 p_remove_proto_data(frame_data *fd, int proto)
102 frame_proto_data temp;
106 temp.proto_data = NULL;
108 item = g_slist_find_custom(fd->pfd, (gpointer *)&temp, p_compare);
111 fd->pfd = g_slist_remove(fd->pfd, item->data);