Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / asn1 / x509if / packet-x509if-template.c
blobaa8e2797cac35332934618bdeeab4fa1c3627dc9
1 /* packet-x509if.c
2 * Routines for X.509 Information Framework packet dissection
3 * Ronnie Sahlberg 2004
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/oids.h>
16 #include <epan/asn1.h>
17 #include <epan/proto_data.h>
18 #include <epan/strutil.h>
19 #include <wsutil/array.h>
21 #include "packet-ber.h"
22 #include "packet-dap.h"
23 #include "packet-x509if.h"
24 #include "packet-x509sat.h"
25 #include "packet-frame.h"
27 #define PNAME "X.509 Information Framework"
28 #define PSNAME "X509IF"
29 #define PFNAME "x509if"
31 void proto_register_x509if(void);
32 void proto_reg_handoff_x509if(void);
34 /* Initialize the protocol and registered fields */
35 static int proto_x509if;
36 static int hf_x509if_object_identifier_id;
37 static int hf_x509if_any_string;
38 #include "packet-x509if-hf.c"
40 /* Initialize the subtree pointers */
41 #include "packet-x509if-ett.c"
43 static proto_tree *top_of_dn;
44 static proto_tree *top_of_rdn;
46 static bool rdn_one_value; /* have we seen one value in an RDN yet */
47 static bool dn_one_rdn; /* have we seen one RDN in a DN yet */
48 static bool doing_attr;
50 static wmem_strbuf_t *last_dn_buf;
51 static wmem_strbuf_t *last_rdn_buf;
53 static int ava_hf_index;
54 #define MAX_FMT_VALS 32
55 static value_string fmt_vals[MAX_FMT_VALS];
56 #define MAX_AVA_STR_LEN 64
57 static char *last_ava;
59 static void
60 x509if_frame_end(void)
62 top_of_dn = NULL;
63 top_of_rdn = NULL;
65 rdn_one_value = false;
66 dn_one_rdn = false;
67 doing_attr = false;
69 last_dn_buf = NULL;
70 last_rdn_buf = NULL;
71 last_ava = NULL;
74 #include "packet-x509if-fn.c"
76 const char * x509if_get_last_dn(void)
78 return last_dn_buf ? wmem_strbuf_get_str(last_dn_buf) : NULL;
81 bool x509if_register_fmt(int hf_index, const char *fmt)
83 static int idx = 0;
85 if(idx < (MAX_FMT_VALS - 1)) {
87 fmt_vals[idx].value = hf_index;
88 fmt_vals[idx].strptr = fmt;
90 idx++;
92 fmt_vals[idx].value = 0;
93 fmt_vals[idx].strptr = NULL;
95 return true;
97 } else
98 return false; /* couldn't register it */
102 const char * x509if_get_last_ava(void)
104 return last_ava;
107 /*--- proto_register_x509if ----------------------------------------------*/
108 void proto_register_x509if(void) {
110 /* List of fields */
111 static hf_register_info hf[] = {
112 { &hf_x509if_object_identifier_id,
113 { "Object Id", "x509if.oid", FT_OID, BASE_NONE, NULL, 0,
114 "Object identifier Id", HFILL }},
115 { &hf_x509if_any_string,
116 { "AnyString", "x509if.any.String", FT_BYTES, BASE_NONE,
117 NULL, 0, "This is any String", HFILL }},
119 #include "packet-x509if-hfarr.c"
122 /* List of subtrees */
123 static int *ett[] = {
124 #include "packet-x509if-ettarr.c"
127 /* Register protocol */
128 proto_x509if = proto_register_protocol(PNAME, PSNAME, PFNAME);
130 /* Register fields and subtrees */
131 proto_register_field_array(proto_x509if, hf, array_length(hf));
132 proto_register_subtree_array(ett, array_length(ett));
134 /* initialise array */
135 fmt_vals[0].value = 0;
136 fmt_vals[0].strptr = NULL;
141 /*--- proto_reg_handoff_x509if -------------------------------------------*/
142 void proto_reg_handoff_x509if(void) {
143 #include "packet-x509if-dis-tab.c"