2 * Routines for X.509 Information Framework packet dissection
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
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
;
60 x509if_frame_end(void)
65 rdn_one_value
= false;
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
)
85 if(idx
< (MAX_FMT_VALS
- 1)) {
87 fmt_vals
[idx
].value
= hf_index
;
88 fmt_vals
[idx
].strptr
= fmt
;
92 fmt_vals
[idx
].value
= 0;
93 fmt_vals
[idx
].strptr
= NULL
;
98 return false; /* couldn't register it */
102 const char * x509if_get_last_ava(void)
107 /*--- proto_register_x509if ----------------------------------------------*/
108 void proto_register_x509if(void) {
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"