Kerberos: add kerberos_inject_longterm_key() helper function
[wireshark-sm.git] / epan / dissectors / asn1 / ocsp / packet-ocsp-template.c
blob7564309637d08a82a47a7b90259b3587d5d5aaad
1 /* packet-ocsp.c
2 * Routines for Online Certificate Status Protocol (RFC2560) 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 <wsutil/array.h>
17 #include <asn1.h>
19 #include "packet-ber.h"
20 #include "packet-ocsp.h"
21 #include "packet-x509af.h"
22 #include "packet-x509ce.h"
23 #include "packet-pkix1implicit.h"
24 #include "packet-pkix1explicit.h"
26 #define PNAME "Online Certificate Status Protocol"
27 #define PSNAME "OCSP"
28 #define PFNAME "ocsp"
30 void proto_register_ocsp(void);
31 void proto_reg_handoff_ocsp(void);
33 static dissector_handle_t ocsp_request_handle;
34 static dissector_handle_t ocsp_response_handle;
36 /* Initialize the protocol and registered fields */
37 int proto_ocsp;
38 static int hf_ocsp_responseType_id;
39 #include "packet-ocsp-hf.c"
41 /* Initialize the subtree pointers */
42 static int ett_ocsp;
43 #include "packet-ocsp-ett.c"
45 #include "packet-ocsp-fn.c"
48 static int
49 dissect_ocsp_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
51 proto_item *item=NULL;
52 proto_tree *tree=NULL;
53 asn1_ctx_t asn1_ctx;
54 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
56 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCSP");
58 col_set_str(pinfo->cinfo, COL_INFO, "Request");
61 if(parent_tree){
62 item=proto_tree_add_item(parent_tree, proto_ocsp, tvb, 0, -1, ENC_NA);
63 tree = proto_item_add_subtree(item, ett_ocsp);
66 return dissect_ocsp_OCSPRequest(false, tvb, 0, &asn1_ctx, tree, -1);
70 static int
71 dissect_ocsp_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
73 proto_item *item=NULL;
74 proto_tree *tree=NULL;
75 asn1_ctx_t asn1_ctx;
76 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
78 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCSP");
80 col_set_str(pinfo->cinfo, COL_INFO, "Response");
83 if(parent_tree){
84 item=proto_tree_add_item(parent_tree, proto_ocsp, tvb, 0, -1, ENC_NA);
85 tree = proto_item_add_subtree(item, ett_ocsp);
88 return dissect_ocsp_OCSPResponse(false, tvb, 0, &asn1_ctx, tree, -1);
91 /*--- proto_register_ocsp ----------------------------------------------*/
92 void proto_register_ocsp(void) {
94 /* List of fields */
95 static hf_register_info hf[] = {
96 { &hf_ocsp_responseType_id,
97 { "ResponseType Id", "ocsp.responseType.id",
98 FT_STRING, BASE_NONE, NULL, 0,
99 NULL, HFILL }},
100 #include "packet-ocsp-hfarr.c"
103 /* List of subtrees */
104 static int *ett[] = {
105 &ett_ocsp,
106 #include "packet-ocsp-ettarr.c"
109 /* Register protocol */
110 proto_ocsp = proto_register_protocol(PNAME, PSNAME, PFNAME);
112 /* Register fields and subtrees */
113 proto_register_field_array(proto_ocsp, hf, array_length(hf));
114 proto_register_subtree_array(ett, array_length(ett));
116 /* Register dissectors */
117 ocsp_request_handle = register_dissector(PFNAME "_req", dissect_ocsp_request, proto_ocsp);
118 ocsp_response_handle = register_dissector(PFNAME "_res", dissect_ocsp_response, proto_ocsp);
121 /*--- proto_reg_handoff_ocsp -------------------------------------------*/
122 void proto_reg_handoff_ocsp(void) {
123 dissector_add_string("media_type", "application/ocsp-request", ocsp_request_handle);
124 dissector_add_string("media_type", "application/ocsp-response", ocsp_response_handle);
126 #include "packet-ocsp-dis-tab.c"