2 * Routines for Online Certificate Status Protocol (RFC2560) packet dissection
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
36 #include "packet-ber.h"
37 #include "packet-ocsp.h"
38 #include "packet-x509af.h"
39 #include "packet-x509ce.h"
40 #include "packet-pkix1implicit.h"
41 #include "packet-pkix1explicit.h"
43 #define PNAME "Online Certificate Status Protocol"
47 /* Initialize the protocol and registered fields */
48 static int proto_ocsp = -1;
49 static int hf_ocsp_responseType_id = -1;
50 #include "packet-ocsp-hf.c"
52 /* Initialize the subtree pointers */
53 static gint ett_ocsp = -1;
54 #include "packet-ocsp-ett.c"
56 static const char *responseType_id;
59 #include "packet-ocsp-fn.c"
63 dissect_ocsp_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
65 proto_item *item=NULL;
66 proto_tree *tree=NULL;
68 if (check_col(pinfo->cinfo, COL_PROTOCOL))
69 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCSP");
71 if (check_col(pinfo->cinfo, COL_INFO)) {
72 col_clear(pinfo->cinfo, COL_INFO);
74 col_add_fstr(pinfo->cinfo, COL_INFO, "Request");
79 item=proto_tree_add_item(parent_tree, proto_ocsp, tvb, 0, -1, FALSE);
80 tree = proto_item_add_subtree(item, ett_ocsp);
83 return dissect_ocsp_OCSPRequest(FALSE, tvb, 0, pinfo, tree, -1);
88 dissect_ocsp_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
90 proto_item *item=NULL;
91 proto_tree *tree=NULL;
93 if (check_col(pinfo->cinfo, COL_PROTOCOL))
94 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCSP");
96 if (check_col(pinfo->cinfo, COL_INFO)) {
97 col_clear(pinfo->cinfo, COL_INFO);
99 col_add_fstr(pinfo->cinfo, COL_INFO, "Response");
104 item=proto_tree_add_item(parent_tree, proto_ocsp, tvb, 0, -1, FALSE);
105 tree = proto_item_add_subtree(item, ett_ocsp);
108 return dissect_ocsp_OCSPResponse(FALSE, tvb, 0, pinfo, tree, -1);
111 /*--- proto_register_ocsp ----------------------------------------------*/
112 void proto_register_ocsp(void) {
115 static hf_register_info hf[] = {
116 { &hf_ocsp_responseType_id,
117 { "ResponseType Id", "x509af.responseType.id",
118 FT_STRING, BASE_NONE, NULL, 0,
119 "ResponseType Id", HFILL }},
120 #include "packet-ocsp-hfarr.c"
123 /* List of subtrees */
124 static gint *ett[] = {
126 #include "packet-ocsp-ettarr.c"
129 /* Register protocol */
130 proto_ocsp = proto_register_protocol(PNAME, PSNAME, PFNAME);
132 /* Register fields and subtrees */
133 proto_register_field_array(proto_ocsp, hf, array_length(hf));
134 proto_register_subtree_array(ett, array_length(ett));
138 /*--- proto_reg_handoff_ocsp -------------------------------------------*/
139 void proto_reg_handoff_ocsp(void) {
140 dissector_handle_t ocsp_request_handle;
141 dissector_handle_t ocsp_response_handle;
143 ocsp_request_handle = new_create_dissector_handle(dissect_ocsp_request, proto_ocsp);
144 ocsp_response_handle = new_create_dissector_handle(dissect_ocsp_response, proto_ocsp);
146 dissector_add_string("media_type", "application/ocsp-request", ocsp_request_handle);
147 dissector_add_string("media_type", "application/ocsp-response", ocsp_response_handle);
149 #include "packet-ocsp-dis-tab.c"