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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include <epan/packet.h>
33 #include <epan/asn1.h>
34 #include <epan/prefs.h>
37 #include "packet-ber.h"
38 #include "packet-ess.h"
39 #include "packet-cms.h"
40 #include "packet-x509ce.h"
41 #include "packet-x509af.h"
43 #define PNAME "Extended Security Services"
47 typedef struct _ess_category_attributes_t {
51 } ess_category_attributes_t;
53 static ess_category_attributes_t *ess_category_attributes;
54 static guint num_ess_category_attributes;
56 /* Initialize the protocol and registered fields */
57 static int proto_ess = -1;
58 static int hf_ess_SecurityCategory_type_OID = -1;
59 static int hf_ess_Category_attribute = -1;
61 static gint ett_Category_attributes = -1;
63 #include "packet-ess-hf.c"
65 #include "packet-ess-val.h"
67 /* Initialize the subtree pointers */
68 #include "packet-ess-ett.c"
70 static const char *object_identifier_id;
72 UAT_CSTRING_CB_DEF(ess_category_attributes, oid, ess_category_attributes_t);
73 UAT_DEC_CB_DEF(ess_category_attributes, lacv, ess_category_attributes_t);
74 UAT_CSTRING_CB_DEF(ess_category_attributes, name, ess_category_attributes_t);
77 ess_copy_cb(void *dest, const void *orig, size_t len _U_)
79 ess_category_attributes_t *u = dest;
80 const ess_category_attributes_t *o = orig;
82 u->oid = g_strdup(o->oid);
84 u->name = g_strdup(o->name);
92 ess_category_attributes_t *u = r;
99 ess_dissect_attribute (guint32 value, asn1_ctx_t *actx)
103 for (i = 0; i < num_ess_category_attributes; i++) {
104 ess_category_attributes_t *u = &(ess_category_attributes[i]);
106 if ((strcmp (u->oid, object_identifier_id) == 0) &&
109 proto_item_append_text (actx->created_item, " (%s)", u->name);
116 ess_dissect_attribute_flags (tvbuff_t *tvb, asn1_ctx_t *actx)
122 tree = proto_item_add_subtree (actx->created_item, ett_Category_attributes);
123 value = tvb_get_ephemeral_string (tvb, 0, tvb_length (tvb));
125 for (i = 0; i < num_ess_category_attributes; i++) {
126 ess_category_attributes_t *u = &(ess_category_attributes[i]);
128 if ((strcmp (u->oid, object_identifier_id) == 0) &&
129 ((u->lacv / 8) < tvb_length (tvb)) &&
130 (value[u->lacv / 8] & (1 << (7 - (u->lacv % 8)))))
132 proto_tree_add_string_format (tree, hf_ess_Category_attribute, tvb,
133 u->lacv / 8, 1, u->name,
134 "%s (%d)", u->name, u->lacv);
139 #include "packet-ess-fn.c"
141 /*--- proto_register_ess ----------------------------------------------*/
142 void proto_register_ess(void) {
145 static hf_register_info hf[] = {
146 { &hf_ess_SecurityCategory_type_OID,
147 { "type", "ess.type_OID", FT_STRING, BASE_NONE, NULL, 0,
148 "Type of Security Category", HFILL }},
149 { &hf_ess_Category_attribute,
150 { "Attribute", "ess.attribute", FT_STRING, BASE_NONE, NULL, 0,
152 #include "packet-ess-hfarr.c"
155 /* List of subtrees */
156 static gint *ett[] = {
157 &ett_Category_attributes,
158 #include "packet-ess-ettarr.c"
161 static uat_field_t attributes_flds[] = {
162 UAT_FLD_CSTRING(ess_category_attributes,oid, "Tag Set", "Category Tag Set (Object Identifier)"),
163 UAT_FLD_DEC(ess_category_attributes,lacv, "Value", "Label And Cert Value"),
164 UAT_FLD_CSTRING(ess_category_attributes,name, "Name", "Category Name"),
168 uat_t *attributes_uat = uat_new("ESS Category Attributes",
169 sizeof(ess_category_attributes_t),
170 "ess_category_attributes",
172 (void*) &ess_category_attributes,
173 &num_ess_category_attributes,
174 UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
175 "ChEssCategoryAttributes",
182 static module_t *ess_module;
184 /* Register protocol */
185 proto_ess = proto_register_protocol(PNAME, PSNAME, PFNAME);
187 /* Register fields and subtrees */
188 proto_register_field_array(proto_ess, hf, array_length(hf));
189 proto_register_subtree_array(ett, array_length(ett));
191 ess_module = prefs_register_protocol(proto_ess, NULL);
193 prefs_register_uat_preference(ess_module, "attributes_table",
194 "ESS Category Attributes",
195 "ESS category attributes translation table",
201 /*--- proto_reg_handoff_ess -------------------------------------------*/
202 void proto_reg_handoff_ess(void) {
203 #include "packet-ess-dis-tab.c"