aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorLars Roland <Lars.Roland@gmx.net>2005-02-08 19:36:20 +0000
committerLars Roland <Lars.Roland@gmx.net>2005-02-08 19:36:20 +0000
commitfe83d6527b4133f3de367e35cc73ee602354e126 (patch)
tree7d5f8f6122ca1112b06b7b6910f79889f0b19082 /epan
parent8b1d64e0f2c2509de69a865673fa5bf6cb991040 (diff)
Move h225-persistentdata.[ch] to epan,
as its code is linked into libethereal.dll. svn path=/trunk/; revision=13354
Diffstat (limited to 'epan')
-rw-r--r--epan/Makefile.common3
-rw-r--r--epan/dissectors/packet-h225.c2
-rw-r--r--epan/h225-persistentdata.c174
-rw-r--r--epan/h225-persistentdata.h62
4 files changed, 239 insertions, 2 deletions
diff --git a/epan/Makefile.common b/epan/Makefile.common
index 88244e1ad3..f6d7e22526 100644
--- a/epan/Makefile.common
+++ b/epan/Makefile.common
@@ -46,6 +46,7 @@ LIBETHEREAL_SRC = \
except.c \
filesystem.c \
frame_data.c \
+ h225-persistentdata.c \
in_cksum.c \
ipproto.c \
ipv4.c \
@@ -99,6 +100,7 @@ LIBETHEREAL_INCLUDES = \
filesystem.h \
frame_data.h \
gdebug.h \
+ h225-persistentdata.h \
in_cksum.h \
ipproto.h \
ipv4.h \
@@ -134,7 +136,6 @@ LIBETHEREAL_INCLUDES = \
DISSECTOR_SUPPORT_SRC = \
../asn1.c \
../follow.c \
- ../h225-persistentdata.c \
../ptvcursor.c \
../reassemble.c \
../xmlstub.c
diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c
index 169bdc6e0e..8da617f4b6 100644
--- a/epan/dissectors/packet-h225.c
+++ b/epan/dissectors/packet-h225.c
@@ -56,7 +56,7 @@
#include "packet-per.h"
#include "packet-h225.h"
#include <epan/t35.h>
-#include "h225-persistentdata.h"
+#include <epan/h225-persistentdata.h>
#include "packet-ber.h"
#include "packet-h235.h"
#include "packet-h245.h"
diff --git a/epan/h225-persistentdata.c b/epan/h225-persistentdata.c
new file mode 100644
index 0000000000..4cb1d6f3bc
--- /dev/null
+++ b/epan/h225-persistentdata.c
@@ -0,0 +1,174 @@
+/*
+ * h225-persistentdata.c
+ * Source for lists and hash tables used in ethereal's h225 dissector
+ * for calculation of delays in h225-calls
+ *
+ * Copyright 2003 Lars Roland
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <epan/packet.h>
+#include <epan/conversation.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "h225-persistentdata.h"
+
+/* Global Memory Chunks for lists and Global hash tables*/
+
+static GMemChunk *h225ras_call_info_key_chunk = NULL;
+static GMemChunk *h225ras_call_info_value_chunk = NULL;
+
+static GHashTable *ras_calls[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+
+/*
+ * Functions needed for Ras-Hash-Table
+ */
+
+/* compare 2 keys */
+static gint h225ras_call_equal(gconstpointer k1, gconstpointer k2)
+{
+ const h225ras_call_info_key* key1 = (const h225ras_call_info_key*) k1;
+ const h225ras_call_info_key* key2 = (const h225ras_call_info_key*) k2;
+
+ return (key1->reqSeqNum == key2->reqSeqNum &&
+ key1->conversation == key2->conversation);
+}
+
+/* calculate a hash key */
+static guint h225ras_call_hash(gconstpointer k)
+{
+ const h225ras_call_info_key* key = (const h225ras_call_info_key*) k;
+
+ return key->reqSeqNum + GPOINTER_TO_UINT(key->conversation);
+}
+
+
+h225ras_call_t * find_h225ras_call(h225ras_call_info_key *h225ras_call_key ,int category)
+{
+ h225ras_call_t *h225ras_call = NULL;
+ h225ras_call = (h225ras_call_t *)g_hash_table_lookup(ras_calls[category], h225ras_call_key);
+
+ return h225ras_call;
+}
+
+h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packet_info *pinfo, guint8 *guid, int category)
+{
+ h225ras_call_info_key *new_h225ras_call_key;
+ h225ras_call_t *h225ras_call = NULL;
+
+
+ /* Prepare the value data.
+ "req_num" and "rsp_num" are frame numbers;
+ frame numbers are 1-origin, so we use 0
+ to mean "we don't yet know in which frame
+ the reply for this call appears". */
+ new_h225ras_call_key = (h225ras_call_info_key *)g_mem_chunk_alloc(h225ras_call_info_key_chunk);
+ new_h225ras_call_key->reqSeqNum = h225ras_call_key->reqSeqNum;
+ new_h225ras_call_key->conversation = h225ras_call_key->conversation;
+ h225ras_call = (h225ras_call_t *)g_mem_chunk_alloc(h225ras_call_info_value_chunk);
+ h225ras_call->req_num = pinfo->fd->num;
+ h225ras_call->rsp_num = 0;
+ h225ras_call->requestSeqNum = h225ras_call_key->reqSeqNum;
+ h225ras_call->responded = FALSE;
+ h225ras_call->next_call = NULL;
+ h225ras_call->req_time.secs=pinfo->fd->abs_secs;
+ h225ras_call->req_time.nsecs=pinfo->fd->abs_usecs*1000;
+ memcpy(h225ras_call->guid, guid,16);
+ /* store it */
+ g_hash_table_insert(ras_calls[category], new_h225ras_call_key, h225ras_call);
+
+ return h225ras_call;
+}
+
+h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pinfo, guint8 *guid, int category _U_)
+{
+ h225ras_call_t *h225ras_call = NULL;
+
+ /* Prepare the value data.
+ "req_num" and "rsp_num" are frame numbers;
+ frame numbers are 1-origin, so we use 0
+ to mean "we don't yet know in which frame
+ the reply for this call appears". */
+ h225ras_call = (h225ras_call_t *)g_mem_chunk_alloc(h225ras_call_info_value_chunk);
+ h225ras_call->req_num = pinfo->fd->num;
+ h225ras_call->rsp_num = 0;
+ h225ras_call->requestSeqNum = prev_call->requestSeqNum;
+ h225ras_call->responded = FALSE;
+ h225ras_call->next_call = NULL;
+ h225ras_call->req_time.secs=pinfo->fd->abs_secs;
+ h225ras_call->req_time.nsecs=pinfo->fd->abs_usecs*1000;
+ memcpy(h225ras_call->guid, guid,16);
+
+ prev_call->next_call = h225ras_call;
+ return h225ras_call;
+}
+
+
+/* Init routine for hash tables and delay calculation
+ This routine will be called by Ethereal, before it
+ is (re-)dissecting a trace file from beginning.
+ We need to discard and init any state we've saved */
+
+void
+h225_init_routine(void)
+{
+ int i;
+
+ /* free hash-tables and mem_chunks for RAS SRT */
+ for(i=0;i<7;i++) {
+ if (ras_calls[i] != NULL) {
+ g_hash_table_destroy(ras_calls[i]);
+ ras_calls[i] = NULL;
+ }
+ }
+
+ if (h225ras_call_info_key_chunk != NULL) {
+ g_mem_chunk_destroy(h225ras_call_info_key_chunk);
+ h225ras_call_info_key_chunk = NULL;
+ }
+ if (h225ras_call_info_value_chunk != NULL) {
+ g_mem_chunk_destroy(h225ras_call_info_value_chunk);
+ h225ras_call_info_value_chunk = NULL;
+ }
+
+ /* create new hash-tables and mem_chunks for RAS SRT */
+
+ for(i=0;i<7;i++) {
+ ras_calls[i] = g_hash_table_new(h225ras_call_hash, h225ras_call_equal);
+ }
+
+ h225ras_call_info_key_chunk = g_mem_chunk_new("call_info_key_chunk",
+ sizeof(h225ras_call_info_key),
+ 400 * sizeof(h225ras_call_info_key),
+ G_ALLOC_ONLY);
+ h225ras_call_info_value_chunk = g_mem_chunk_new("call_info_value_chunk",
+ sizeof(h225ras_call_t),
+ 400 * sizeof(h225ras_call_t),
+ G_ALLOC_ONLY);
+}
diff --git a/epan/h225-persistentdata.h b/epan/h225-persistentdata.h
new file mode 100644
index 0000000000..aed7972c5f
--- /dev/null
+++ b/epan/h225-persistentdata.h
@@ -0,0 +1,62 @@
+/*
+ * h225-persistentdata.h
+ * Definitions for lists and hash tables used in ethereal's h225 dissector
+ * for calculation of delays in h225-calls
+ *
+ * Copyright 2003 Lars Roland
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __h225_HASH__
+#define __h225_HASH__
+
+#include <glib.h>
+#include <epan/packet.h>
+#include <epan/conversation.h>
+
+
+/* Item of ras request list*/
+typedef struct _h225ras_call_t {
+ guint32 requestSeqNum;
+ guint8 guid[16];
+ guint32 req_num; /* frame number request seen */
+ guint32 rsp_num; /* frame number response seen */
+ nstime_t req_time; /* arrival time of request */
+ gboolean responded; /* true, if request has been responded */
+ struct _h225ras_call_t *next_call; /* pointer to next ras request with same SequenceNumber and conversation handle */
+} h225ras_call_t;
+
+
+/* Item of ras-request key list*/
+typedef struct _h225ras_call_info_key {
+ guint reqSeqNum;
+ conversation_t *conversation;
+} h225ras_call_info_key;
+
+/* functions, needed using ras-request and halfcall matching*/
+h225ras_call_t * find_h225ras_call(h225ras_call_info_key *h225ras_call_key ,int category);
+h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packet_info *pinfo, guint8 *guid, int category);
+h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pinfo, guint8 *guid, int category);
+
+void h225_init_routine(void); /* init routine, used by ethereal */
+
+#endif /* __h225_HASH__*/