2 * Routines for RFC5035 Extended Security Services packet dissection
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/packet.h>
35 #include <epan/asn1.h>
36 #include <epan/prefs.h>
39 #include "packet-ber.h"
40 #include "packet-ess.h"
41 #include "packet-cms.h"
42 #include "packet-x509ce.h"
43 #include "packet-x509af.h"
45 #define PNAME "Extended Security Services"
49 typedef struct _ess_category_attributes_t {
53 } ess_category_attributes_t;
55 static ess_category_attributes_t *ess_category_attributes;
56 static guint num_ess_category_attributes;
58 /* Initialize the protocol and registered fields */
59 static int proto_ess = -1;
60 static int hf_ess_SecurityCategory_type_OID = -1;
61 static int hf_ess_Category_attribute = -1;
63 static gint ett_Category_attributes = -1;
65 #include "packet-ess-hf.c"
67 #include "packet-ess-val.h"
69 /* Initialize the subtree pointers */
70 #include "packet-ess-ett.c"
72 static const char *object_identifier_id;
74 UAT_CSTRING_CB_DEF(ess_category_attributes, oid, ess_category_attributes_t);
75 UAT_DEC_CB_DEF(ess_category_attributes, lacv, ess_category_attributes_t);
76 UAT_CSTRING_CB_DEF(ess_category_attributes, name, ess_category_attributes_t);
79 ess_copy_cb(void *dest, const void *orig, size_t len _U_)
81 ess_category_attributes_t *u = dest;
82 const ess_category_attributes_t *o = orig;
84 u->oid = g_strdup(o->oid);
86 u->name = g_strdup(o->name);
94 ess_category_attributes_t *u = r;
101 ess_dissect_attribute (guint32 value, asn1_ctx_t *actx)
105 for (i = 0; i < num_ess_category_attributes; i++) {
106 ess_category_attributes_t *u = &(ess_category_attributes[i]);
108 if ((strcmp (u->oid, object_identifier_id) == 0) &&
111 proto_item_append_text (actx->created_item, " (%s)", u->name);
118 ess_dissect_attribute_flags (tvbuff_t *tvb, asn1_ctx_t *actx)
124 tree = proto_item_add_subtree (actx->created_item, ett_Category_attributes);
125 value = tvb_get_ephemeral_string (tvb, 0, tvb_length (tvb));
127 for (i = 0; i < num_ess_category_attributes; i++) {
128 ess_category_attributes_t *u = &(ess_category_attributes[i]);
130 if ((strcmp (u->oid, object_identifier_id) == 0) &&
131 ((u->lacv / 8) < tvb_length (tvb)) &&
132 (value[u->lacv / 8] & (1 << (7 - (u->lacv % 8)))))
134 proto_tree_add_string_format (tree, hf_ess_Category_attribute, tvb,
135 u->lacv / 8, 1, u->name,
136 "%s (%d)", u->name, u->lacv);
141 #include "packet-ess-fn.c"
143 /*--- proto_register_ess ----------------------------------------------*/
144 void proto_register_ess(void) {
147 static hf_register_info hf[] = {
148 { &hf_ess_SecurityCategory_type_OID,
149 { "type", "ess.type_OID", FT_STRING, BASE_NONE, NULL, 0,
150 "Type of Security Category", HFILL }},
151 { &hf_ess_Category_attribute,
152 { "Attribute", "ess.attribute", FT_STRING, BASE_NONE, NULL, 0,
154 #include "packet-ess-hfarr.c"
157 /* List of subtrees */
158 static gint *ett[] = {
159 &ett_Category_attributes,
160 #include "packet-ess-ettarr.c"
163 static uat_field_t attributes_flds[] = {
164 UAT_FLD_CSTRING(ess_category_attributes,oid, "Tag Set", "Category Tag Set (Object Identifier)"),
165 UAT_FLD_DEC(ess_category_attributes,lacv, "Value", "Label And Cert Value"),
166 UAT_FLD_CSTRING(ess_category_attributes,name, "Name", "Category Name"),
170 uat_t *attributes_uat = uat_new("ESS Category Attributes",
171 sizeof(ess_category_attributes_t),
172 "ess_category_attributes",
174 (void*) &ess_category_attributes,
175 &num_ess_category_attributes,
177 "ChEssCategoryAttributes",
184 static module_t *ess_module;
186 /* Register protocol */
187 proto_ess = proto_register_protocol(PNAME, PSNAME, PFNAME);
189 /* Register fields and subtrees */
190 proto_register_field_array(proto_ess, hf, array_length(hf));
191 proto_register_subtree_array(ett, array_length(ett));
193 ess_module = prefs_register_protocol(proto_ess, NULL);
195 prefs_register_uat_preference(ess_module, "attributes_table",
196 "ESS Category Attributes",
197 "ESS category attributes translation table",
203 /*--- proto_reg_handoff_ess -------------------------------------------*/
204 void proto_reg_handoff_ess(void) {
205 #include "packet-ess-dis-tab.c"