/* packet-x509if.c
* Routines for X.509 Information Framework packet dissection
+ * Ronnie Sahlberg 2004
*
* $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
#include <glib.h>
#include <epan/packet.h>
-#include <epan/conversation.h>
-
-#include <stdio.h>
-#include <string.h>
+#include <epan/oids.h>
+#include <epan/asn1.h>
#include "packet-ber.h"
+#include "packet-dap.h"
#include "packet-x509if.h"
+#include "packet-x509sat.h"
+#include <epan/strutil.h>
#define PNAME "X.509 Information Framework"
#define PSNAME "X509IF"
#define PFNAME "x509if"
/* Initialize the protocol and registered fields */
-int proto_x509if = -1;
-int hf_x509if_ATADV_attribute_id = -1;
+static int proto_x509if = -1;
+static int hf_x509if_object_identifier_id = -1;
+static int hf_x509if_any_string = -1;
#include "packet-x509if-hf.c"
/* Initialize the subtree pointers */
-static gint ett_x509if_Attribute = -1;
#include "packet-x509if-ett.c"
+static const char *object_identifier_id;
+static proto_tree *top_of_dn = NULL;
+static proto_tree *top_of_rdn = NULL;
-static ber_sequence Attribute_sequence[] = {
- /* { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_hf_x509if_type },*/
- /*XXX missing stuff here */
- { 0, 0, 0, NULL }
-};
+static gboolean rdn_one_value = FALSE; /* have we seen one value in an RDN yet */
+static gboolean dn_one_rdn = FALSE; /* have we seen one RDN in a DN yet */
+static gboolean doing_dn = TRUE;
+static gboolean doing_attr = FALSE;
-int
-dissect_x509if_Attribute(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
- offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
- Attribute_sequence, hf_index, ett_x509if_Attribute);
+#define MAX_RDN_STR_LEN 64
+#define MAX_DN_STR_LEN (20 * MAX_RDN_STR_LEN)
- return offset;
-}
+static char *last_dn = NULL;
+static char *last_rdn = NULL;
+static int ava_hf_index;
+#define MAX_FMT_VALS 32
+static value_string fmt_vals[MAX_FMT_VALS];
+#define MAX_AVA_STR_LEN 64
+static char *last_ava = NULL;
+#include "packet-x509if-fn.c"
-static char ATADV_attribute_id[64]; /*64 chars should be long enough? */
-static int
-dissect_hf_x509if_ATADV_attribute_id(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset)
+const char * x509if_get_last_dn(void)
{
- offset = dissect_ber_object_identifier(FALSE, pinfo, tree, tvb, offset,
- hf_x509if_ATADV_attribute_id, ATADV_attribute_id);
- return offset;
+ return last_dn;
}
-static int
-dissect_hf_x509if_ATADV_attribute_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset)
+
+gboolean x509if_register_fmt(int hf_index, const gchar *fmt)
{
- offset=call_ber_oid_callback(ATADV_attribute_id, tvb, offset, pinfo, tree);
- return offset;
-}
+ static int idx = 0;
-static ber_sequence AttributeTypeAndDistinguishedValue_sequence[] = {
- { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_hf_x509if_ATADV_attribute_id },
- { BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_hf_x509if_ATADV_attribute_value },
- /*XXX missing stuff here */
- { 0, 0, 0, NULL }
-};
+ if(idx < (MAX_FMT_VALS - 1)) {
-static int
-dissect_x509if_AttributeTypeAndDistinguishedValue(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
- offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
- AttributeTypeAndDistinguishedValue_sequence, hf_index, ett_x509if_AttributeTypeAndDistinguishedValue);
+ fmt_vals[idx].value = hf_index;
+ fmt_vals[idx].strptr = fmt;
- return offset;
-}
+ idx++;
-#include "packet-x509if-fn.c"
+ fmt_vals[idx].value = 0;
+ fmt_vals[idx].strptr = NULL;
+ return TRUE;
+
+ } else
+ return FALSE; /* couldn't register it */
+
+}
+
+const char * x509if_get_last_ava(void)
+{
+ return last_ava;
+}
/*--- proto_register_x509if ----------------------------------------------*/
void proto_register_x509if(void) {
/* List of fields */
static hf_register_info hf[] = {
- { &hf_x509if_ATADV_attribute_id,
- { "Attribute Id", "x509if.attribute.id",
- FT_STRING, BASE_NONE, NULL, 0,
- "Attribute Id", HFILL }},
+ { &hf_x509if_object_identifier_id,
+ { "Id", "x509if.id", FT_OID, BASE_NONE, NULL, 0,
+ "Object identifier Id", HFILL }},
+ { &hf_x509if_any_string,
+ { "AnyString", "x509if.any.String", FT_BYTES, BASE_NONE,
+ NULL, 0, "This is any String", HFILL }},
+
#include "packet-x509if-hfarr.c"
};
/* List of subtrees */
static gint *ett[] = {
- &ett_x509if_Attribute,
#include "packet-x509if-ettarr.c"
};
proto_register_field_array(proto_x509if, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+ /* initialise array */
+ fmt_vals[0].value = 0;
+ fmt_vals[0].strptr = NULL;
+
}
/*--- proto_reg_handoff_x509if -------------------------------------------*/
void proto_reg_handoff_x509if(void) {
+#include "packet-x509if-dis-tab.c"
}