From 03d1d962d2609fc586e326be6638093edf939b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Fri, 23 Apr 2010 12:43:14 +0000 Subject: Added a decoding table for ESS Security Category Attributes. svn path=/trunk/; revision=32543 --- asn1/ess/ess.cnf | 54 +++++++++++++++++++ asn1/ess/packet-ess-template.c | 119 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 172 insertions(+), 1 deletion(-) (limited to 'asn1/ess') diff --git a/asn1/ess/ess.cnf b/asn1/ess/ess.cnf index bc449f2411..00eeeadd68 100644 --- a/asn1/ess/ess.cnf +++ b/asn1/ess/ess.cnf @@ -36,6 +36,12 @@ EnumeratedTag B "2.16.840.1.101.2.1.8.3.4" "id-enumeratedRestrictiveAttribu #.FIELD_RENAME SigningCertificateV2/certs certsV2 +RestrictiveTag/tagName restrictiveTagName +RestrictiveTag/attributeFlags restrictiveAttributeFlags +PermissiveTag/tagName permissiveTagName +PermissiveTag/attributeFlags permissiveAttributeFlags +InformativeTag/tagName informativeTagName +FreeFormField/bitSetAttributes informativeAttributeFlags #.FN_PARS SecurityCategory/type FN_VARIANT = _str HF_INDEX = hf_ess_SecurityCategory_type_OID VAL_PTR = &object_identifier_id @@ -43,5 +49,53 @@ SigningCertificateV2/certs certsV2 #.FN_BODY SecurityCategory/value offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree); +#.FN_PARS RestrictiveTag/tagName + FN_VARIANT = _str VAL_PTR = &object_identifier_id + +#.FN_PARS EnumeratedTag/tagName + FN_VARIANT = _str VAL_PTR = &object_identifier_id + +#.FN_PARS PermissiveTag/tagName + FN_VARIANT = _str VAL_PTR = &object_identifier_id + +#.FN_PARS InformativeTag/tagName + FN_VARIANT = _str VAL_PTR = &object_identifier_id + +#.FN_PARS SecurityAttribute + VAL_PTR = &attribute + +#.FN_BODY SecurityAttribute + guint32 attribute; + + %(DEFAULT_BODY)s + ess_dissect_attribute (attribute, actx); + +#.FN_PARS RestrictiveTag/attributeFlags + VAL_PTR = &attributes + +#.FN_BODY RestrictiveTag/attributeFlags + tvbuff_t *attributes; + + %(DEFAULT_BODY)s + ess_dissect_attribute_flags (attributes, actx); + +#.FN_PARS PermissiveTag/attributeFlags + VAL_PTR = &attributes + +#.FN_BODY PermissiveTag/attributeFlags + tvbuff_t *attributes; + + %(DEFAULT_BODY)s + ess_dissect_attribute_flags (attributes, actx); + +#.FN_PARS FreeFormField/bitSetAttributes + VAL_PTR = &attributes + +#.FN_BODY FreeFormField/bitSetAttributes + tvbuff_t *attributes; + + %(DEFAULT_BODY)s + ess_dissect_attribute_flags (attributes, actx); + #.END diff --git a/asn1/ess/packet-ess-template.c b/asn1/ess/packet-ess-template.c index e434a97b18..20d4f4cb9e 100644 --- a/asn1/ess/packet-ess-template.c +++ b/asn1/ess/packet-ess-template.c @@ -29,8 +29,12 @@ #endif #include +#include + #include #include +#include +#include #include "packet-ber.h" #include "packet-ess.h" @@ -42,9 +46,22 @@ #define PSNAME "ESS" #define PFNAME "ess" +typedef struct _ess_category_attributes_t { + char *oid; + guint lacv; + char *name; +} ess_category_attributes_t; + +static ess_category_attributes_t *ess_category_attributes; +static guint num_ess_category_attributes; + /* Initialize the protocol and registered fields */ static int proto_ess = -1; static int hf_ess_SecurityCategory_type_OID = -1; +static int hf_ess_Category_attribute = -1; + +static gint ett_Category_attributes = -1; + #include "packet-ess-hf.c" #include "packet-ess-val.h" @@ -54,8 +71,74 @@ static int hf_ess_SecurityCategory_type_OID = -1; static const char *object_identifier_id; -#include "packet-ess-fn.c" +UAT_CSTRING_CB_DEF(ess_category_attributes, oid, ess_category_attributes_t); +UAT_DEC_CB_DEF(ess_category_attributes, lacv, ess_category_attributes_t); +UAT_CSTRING_CB_DEF(ess_category_attributes, name, ess_category_attributes_t); +static void * +ess_copy_cb(void *dest, const void *orig, unsigned len _U_) +{ + ess_category_attributes_t *u = dest; + const ess_category_attributes_t *o = orig; + + u->oid = g_strdup(o->oid); + u->lacv = o->lacv; + u->name = g_strdup(o->name); + + return dest; +} + +static void +ess_free_cb(void *r) +{ + ess_category_attributes_t *u = r; + + g_free(u->oid); + g_free(u->name); +} + +static void +ess_dissect_attribute (guint32 value, asn1_ctx_t *actx) +{ + guint i; + + for (i = 0; i < num_ess_category_attributes; i++) { + ess_category_attributes_t *u = &(ess_category_attributes[i]); + + if ((strcmp (u->oid, object_identifier_id) == 0) && + (u->lacv == value)) + { + proto_item_append_text (actx->created_item, " (%s)", u->name); + break; + } + } +} + +static void +ess_dissect_attribute_flags (tvbuff_t *tvb, asn1_ctx_t *actx) +{ + proto_tree *tree; + guint8 *value; + guint i; + + tree = proto_item_add_subtree (actx->created_item, ett_Category_attributes); + value = tvb_get_ephemeral_string (tvb, 0, tvb_length (tvb)); + + for (i = 0; i < num_ess_category_attributes; i++) { + ess_category_attributes_t *u = &(ess_category_attributes[i]); + + if ((strcmp (u->oid, object_identifier_id) == 0) && + ((u->lacv / 8) < tvb_length (tvb)) && + (value[u->lacv / 8] & (1 << (8 - (u->lacv % 8))))) + { + proto_tree_add_string_format (tree, hf_ess_Category_attribute, tvb, + u->lacv / 8, 1, u->name, + "%s (%d)", u->name, u->lacv); + } + } +} + +#include "packet-ess-fn.c" /*--- proto_register_ess ----------------------------------------------*/ void proto_register_ess(void) { @@ -65,13 +148,40 @@ void proto_register_ess(void) { { &hf_ess_SecurityCategory_type_OID, { "type", "ess.type_OID", FT_STRING, BASE_NONE, NULL, 0, "Type of Security Category", HFILL }}, + { &hf_ess_Category_attribute, + { "Attribute", "ess.attribute", FT_STRING, BASE_NONE, NULL, 0, + NULL, HFILL }}, #include "packet-ess-hfarr.c" }; /* List of subtrees */ static gint *ett[] = { + &ett_Category_attributes, #include "packet-ess-ettarr.c" }; + + static uat_field_t attributes_flds[] = { + UAT_FLD_CSTRING(ess_category_attributes,oid, "Tag Set", "Category Tag Set (Object Identifier)"), + UAT_FLD_DEC(ess_category_attributes,lacv, "Value", "Label And Cert Value"), + UAT_FLD_CSTRING(ess_category_attributes,name, "Name", "Category Name"), + UAT_END_FIELDS + }; + + uat_t *attributes_uat = uat_new("ESS Category Attributes", + sizeof(ess_category_attributes_t), + "ess_category_attributes", + TRUE, + (void**) &ess_category_attributes, + &num_ess_category_attributes, + UAT_CAT_PORTS, + "ChEssCategoryAttributes", + ess_copy_cb, + NULL, + ess_free_cb, + NULL, + attributes_flds); + + static module_t *ess_module; /* Register protocol */ proto_ess = proto_register_protocol(PNAME, PSNAME, PFNAME); @@ -79,6 +189,13 @@ void proto_register_ess(void) { /* Register fields and subtrees */ proto_register_field_array(proto_ess, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + + ess_module = prefs_register_protocol(proto_ess, NULL); + + prefs_register_uat_preference(ess_module, "attributes_table", + "ESS Category Attributes", + "ESS category attributes translation table", + attributes_uat); } -- cgit v1.2.3