diff options
Diffstat (limited to 'epan')
-rw-r--r-- | epan/oid_resolv.c | 174 | ||||
-rw-r--r-- | epan/oid_resolv.h | 100 |
2 files changed, 137 insertions, 137 deletions
diff --git a/epan/oid_resolv.c b/epan/oid_resolv.c index 8b0af44716..5b71ca6f27 100644 --- a/epan/oid_resolv.c +++ b/epan/oid_resolv.c @@ -1,87 +1,87 @@ -/* oid_resolv.c
- * Routines for OBJECT IDENTIFIER name resolution
- *
- * $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 "oid_resolv.h"
-#include "to_str.h"
-#include "strutil.h"
-#include "epan/dissectors/format-oid.h"
-
-static GHashTable *oid_table = NULL;
-
-void oid_resolv_init(void) {
- oid_table = g_hash_table_new(g_str_hash, g_str_equal);
-}
-
-void oid_resolv_cleanup(void) {
- g_hash_table_destroy(oid_table);
- oid_table = NULL;
-}
-
-gboolean oid_resolv_enabled(void) {
- return TRUE;
-}
-
-const gchar *get_oid_name(const guint8 *oid, gint oid_len) {
- const gchar *name;
- subid_t *subid_oid;
- guint subid_oid_length;
- gchar *decoded_oid;
- gchar *non_decoded_oid;
-
- name = g_hash_table_lookup(oid_table, oid_to_str(oid, oid_len));
- if (name) return name;
- subid_oid = g_malloc((oid_len+1) * sizeof(gulong));
- subid_oid_length = oid_to_subid_buf(oid, oid_len, subid_oid, ((oid_len+1) * sizeof(gulong)));
- new_format_oid(subid_oid, subid_oid_length, &non_decoded_oid, &decoded_oid);
- g_free(subid_oid);
- return decoded_oid;
-}
-
-const gchar *get_oid_str_name(const gchar *oid_str) {
- const gchar *name;
- GByteArray *bytes;
- gboolean res;
-
- bytes = g_byte_array_new();
- res = oid_str_to_bytes(oid_str, bytes);
- if (!res) return NULL;
- name = get_oid_name(bytes->data, bytes->len);
- g_byte_array_free(bytes, TRUE);
- return name;
-}
-
-
-extern void add_oid_name(const guint8 *oid, gint oid_len, const gchar *name) {
- add_oid_str_name(oid_to_str(oid, oid_len), name);
-}
-
-extern void add_oid_str_name(const gchar *oid_str, const gchar *name) {
- g_hash_table_insert(oid_table, (gpointer)g_strdup(oid_str), (gpointer)name);
-}
+/* oid_resolv.c + * Routines for OBJECT IDENTIFIER name resolution + * + * $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 "oid_resolv.h" +#include "to_str.h" +#include "strutil.h" +#include "epan/dissectors/format-oid.h" + +static GHashTable *oid_table = NULL; + +void oid_resolv_init(void) { + oid_table = g_hash_table_new(g_str_hash, g_str_equal); +} + +void oid_resolv_cleanup(void) { + g_hash_table_destroy(oid_table); + oid_table = NULL; +} + +gboolean oid_resolv_enabled(void) { + return TRUE; +} + +const gchar *get_oid_name(const guint8 *oid, gint oid_len) { + const gchar *name; + subid_t *subid_oid; + guint subid_oid_length; + gchar *decoded_oid; + gchar *non_decoded_oid; + + name = g_hash_table_lookup(oid_table, oid_to_str(oid, oid_len)); + if (name) return name; + subid_oid = g_malloc((oid_len+1) * sizeof(gulong)); + subid_oid_length = oid_to_subid_buf(oid, oid_len, subid_oid, ((oid_len+1) * sizeof(gulong))); + new_format_oid(subid_oid, subid_oid_length, &non_decoded_oid, &decoded_oid); + g_free(subid_oid); + return decoded_oid; +} + +const gchar *get_oid_str_name(const gchar *oid_str) { + const gchar *name; + GByteArray *bytes; + gboolean res; + + bytes = g_byte_array_new(); + res = oid_str_to_bytes(oid_str, bytes); + if (!res) return NULL; + name = get_oid_name(bytes->data, bytes->len); + g_byte_array_free(bytes, TRUE); + return name; +} + + +extern void add_oid_name(const guint8 *oid, gint oid_len, const gchar *name) { + add_oid_str_name(oid_to_str(oid, oid_len), name); +} + +extern void add_oid_str_name(const gchar *oid_str, const gchar *name) { + g_hash_table_insert(oid_table, (gpointer)g_strdup(oid_str), (gpointer)name); +} diff --git a/epan/oid_resolv.h b/epan/oid_resolv.h index 5c25063daf..7176a65efe 100644 --- a/epan/oid_resolv.h +++ b/epan/oid_resolv.h @@ -1,50 +1,50 @@ -/* oid_resolv.h
- * Definitions for OBJECT IDENTIFIER name resolution
- *
- * $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.
- */
-/* The buffers returned by these functions are all allocated with a
- * packet lifetime or are static buffers and does not have have to be freed.
- * However, take into account that when the packet dissection
- * completes, these buffers will be automatically reclaimed/freed.
- * If you need the buffer to remain for a longer scope than packet lifetime
- * you must copy the content to an se_alloc() buffer.
- */
-
-#ifndef __OID_RESOLV_H__
-#define __OID_RESOLV_H__
-
-/* init and clenup funcions called from epan.h */
-extern void oid_resolv_init(void);
-extern void oid_resolv_cleanup(void);
-
-extern gboolean oid_resolv_enabled(void);
-
-/* get_oid_name returns OID name from oid_table or MIBs database */
-extern const gchar *get_oid_name(const guint8 *oid, gint oid_len);
-extern const gchar *get_oid_str_name(const gchar *oid_str);
-
-/* add OID name into oid_table */
-extern void add_oid_name(const guint8 *oid, gint oid_len, const gchar *name);
-extern void add_oid_str_name(const gchar *oid_str, const gchar *name);
-
-
-#endif /* __OID_RESOLV_H__ */
+/* oid_resolv.h + * Definitions for OBJECT IDENTIFIER name resolution + * + * $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. + */ +/* The buffers returned by these functions are all allocated with a + * packet lifetime or are static buffers and does not have have to be freed. + * However, take into account that when the packet dissection + * completes, these buffers will be automatically reclaimed/freed. + * If you need the buffer to remain for a longer scope than packet lifetime + * you must copy the content to an se_alloc() buffer. + */ + +#ifndef __OID_RESOLV_H__ +#define __OID_RESOLV_H__ + +/* init and clenup funcions called from epan.h */ +extern void oid_resolv_init(void); +extern void oid_resolv_cleanup(void); + +extern gboolean oid_resolv_enabled(void); + +/* get_oid_name returns OID name from oid_table or MIBs database */ +extern const gchar *get_oid_name(const guint8 *oid, gint oid_len); +extern const gchar *get_oid_str_name(const gchar *oid_str); + +/* add OID name into oid_table */ +extern void add_oid_name(const guint8 *oid, gint oid_len, const gchar *name); +extern void add_oid_str_name(const gchar *oid_str, const gchar *name); + + +#endif /* __OID_RESOLV_H__ */ |