Corrected "old-style function definition".
[obnox/wireshark/wip.git] / asn1 / ocsp / packet-ocsp-template.c
1 /* packet-ocsp.c
2  * Routines for Online Certificate Status Protocol (RFC2560) packet dissection
3  *  Ronnie Sahlberg 2004
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
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.
15  *
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.
20  *
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.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <glib.h>
31 #include <epan/packet.h>
32
33 #include <asn1.h>
34
35 #include "packet-ber.h"
36 #include "packet-ocsp.h"
37 #include "packet-x509af.h"
38 #include "packet-x509ce.h"
39 #include "packet-pkix1implicit.h"
40 #include "packet-pkix1explicit.h"
41
42 #define PNAME  "Online Certificate Status Protocol"
43 #define PSNAME "OCSP"
44 #define PFNAME "ocsp"
45
46 /* Initialize the protocol and registered fields */
47 int proto_ocsp = -1;
48 static int hf_ocsp_responseType_id = -1;
49 #include "packet-ocsp-hf.c"
50
51 /* Initialize the subtree pointers */
52 static gint ett_ocsp = -1;
53 #include "packet-ocsp-ett.c"
54
55 static const char *responseType_id;
56
57
58 #include "packet-ocsp-fn.c"
59
60
61 static int
62 dissect_ocsp_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
63 {
64         proto_item *item=NULL;
65         proto_tree *tree=NULL;
66         asn1_ctx_t asn1_ctx;
67         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
68
69         col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCSP");
70
71         col_set_str(pinfo->cinfo, COL_INFO, "Request");
72
73
74         if(parent_tree){
75                 item=proto_tree_add_item(parent_tree, proto_ocsp, tvb, 0, -1, FALSE);
76                 tree = proto_item_add_subtree(item, ett_ocsp);
77         }
78
79         return dissect_ocsp_OCSPRequest(FALSE, tvb, 0, &asn1_ctx, tree, -1);
80 }
81
82
83 static int
84 dissect_ocsp_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
85 {
86         proto_item *item=NULL;
87         proto_tree *tree=NULL;
88         asn1_ctx_t asn1_ctx;
89         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
90
91         col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCSP");
92
93         col_set_str(pinfo->cinfo, COL_INFO, "Response");
94
95
96         if(parent_tree){
97                 item=proto_tree_add_item(parent_tree, proto_ocsp, tvb, 0, -1, FALSE);
98                 tree = proto_item_add_subtree(item, ett_ocsp);
99         }
100
101         return dissect_ocsp_OCSPResponse(FALSE, tvb, 0, &asn1_ctx, tree, -1);
102 }
103
104 /*--- proto_register_ocsp ----------------------------------------------*/
105 void proto_register_ocsp(void) {
106
107   /* List of fields */
108   static hf_register_info hf[] = {
109     { &hf_ocsp_responseType_id,
110       { "ResponseType Id", "x509af.responseType.id",
111         FT_STRING, BASE_NONE, NULL, 0,
112         NULL, HFILL }},
113 #include "packet-ocsp-hfarr.c"
114   };
115
116   /* List of subtrees */
117   static gint *ett[] = {
118     &ett_ocsp,
119 #include "packet-ocsp-ettarr.c"
120   };
121
122   /* Register protocol */
123   proto_ocsp = proto_register_protocol(PNAME, PSNAME, PFNAME);
124
125   /* Register fields and subtrees */
126   proto_register_field_array(proto_ocsp, hf, array_length(hf));
127   proto_register_subtree_array(ett, array_length(ett));
128
129 }
130
131 /*--- proto_reg_handoff_ocsp -------------------------------------------*/
132 void proto_reg_handoff_ocsp(void) {
133         dissector_handle_t ocsp_request_handle;
134         dissector_handle_t ocsp_response_handle;
135
136         ocsp_request_handle = new_create_dissector_handle(dissect_ocsp_request, proto_ocsp);
137         ocsp_response_handle = new_create_dissector_handle(dissect_ocsp_response, proto_ocsp);
138
139         dissector_add_string("media_type", "application/ocsp-request", ocsp_request_handle);
140         dissector_add_string("media_type", "application/ocsp-response", ocsp_response_handle);
141
142 #include "packet-ocsp-dis-tab.c"
143 }
144