summaryrefslogtreecommitdiff
path: root/wiretap/wtap.c
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2007-05-04 21:10:55 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2007-05-04 21:10:55 +0000
commit131cecd1e83454db7c614a97ff9a745314746840 (patch)
tree07f982aefa953c272e4c9cf361c9f0bdaf77804a /wiretap/wtap.c
parent334177b09605c99e8fbbd1b952f697a325b38d4c (diff)
downloadwireshark-131cecd1e83454db7c614a97ff9a745314746840.tar.gz
Add a plugin interface to wiretap.
So far I've done only regression testing (the new functionality and what's in wtap-plugins.c has not yet being tested). it is a first step in the way to have lua opening files. svn path=/trunk/; revision=21686
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r--wiretap/wtap.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 206d9e77e9..4f686d7ee1 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -84,10 +84,12 @@ wtap_file_tsprecision(wtap *wth)
}
/* Table of the encapsulation types we know about. */
-static const struct encap_type_info {
+struct encap_type_info {
const char *name;
const char *short_name;
-} encap_table[WTAP_NUM_ENCAP_TYPES] = {
+};
+
+static struct encap_type_info encap_table_base[] = {
/* WTAP_ENCAP_UNKNOWN */
{ "Unknown", NULL },
@@ -377,6 +379,41 @@ static const struct encap_type_info {
{ "MPEG", "mpeg" },
};
+gint wtap_num_encap_types = sizeof(encap_table_base) / sizeof(struct encap_type_info);
+static GArray* encap_table_arr = NULL;
+static const struct encap_type_info* encap_table = NULL;
+
+static void wtap_init_encap_types(void) {
+
+ if (encap_table_arr) return;
+
+ encap_table_arr = g_array_new(FALSE,TRUE,sizeof(struct encap_type_info));
+
+ g_array_append_vals(encap_table_arr,encap_table_base,wtap_num_encap_types);
+
+ encap_table = (void*)encap_table_arr->data;
+}
+
+int wtap_get_num_encap_types(void) {
+ wtap_init_encap_types();
+ return wtap_num_encap_types;
+}
+
+
+int wtap_register_encap_type(char* name, char* short_name) {
+ struct encap_type_info* e = g_malloc(sizeof(struct encap_type_info));
+ wtap_init_encap_types();
+
+ e->name = g_strdup(name);
+ e->short_name = g_strdup(short_name);
+
+ g_array_append_val(encap_table_arr,e);
+
+ encap_table = (void*)encap_table_arr->data;
+ return wtap_num_encap_types++;
+}
+
+
/* Name that should be somewhat descriptive. */
const char
*wtap_encap_string(int encap)