#include <stdio.h> not needed.
[obnox/wireshark/wip.git] / epan / dissectors / packet-ns_cert_exts.c
1 /* Do not modify this file.                                                   */
2 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
3 /* packet-ns_cert_exts.c                                                      */
4 /* ../../tools/asn2wrs.py -b -p ns_cert_exts -c ./ns_cert_exts.cnf -s ./packet-ns_cert_exts-template -D . NETSCAPE-CERT-EXTS.asn */
5
6 /* Input file: packet-ns_cert_exts-template.c */
7
8 #line 1 "packet-ns_cert_exts-template.c"
9 /* packet-ns_cert_exts.c
10  * Routines for NetScape Certificate Extensions packet dissection
11  *   Ronnie Sahlberg 2004
12  *
13  * $Id$
14  *
15  * Wireshark - Network traffic analyzer
16  * By Gerald Combs <gerald@wireshark.org>
17  * Copyright 1998 Gerald Combs
18  *
19  * This program is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU General Public License
21  * as published by the Free Software Foundation; either version 2
22  * of the License, or (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program; if not, write to the Free Software
31  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
32  */
33
34 #ifdef HAVE_CONFIG_H
35 # include "config.h"
36 #endif
37
38 #include <glib.h>
39 #include <epan/packet.h>
40
41 #include <string.h>
42
43 #include "packet-ber.h"
44
45 #define PNAME  "NetScape Certificate Extensions"
46 #define PSNAME "NS_CERT_EXTS"
47 #define PFNAME "ns_cert_exts"
48
49 /* Initialize the protocol and registered fields */
50 static int proto_ns_cert_exts = -1;
51
52 /*--- Included file: packet-ns_cert_exts-hf.c ---*/
53 #line 1 "packet-ns_cert_exts-hf.c"
54 static int hf_ns_cert_exts_BaseUrl_PDU = -1;      /* BaseUrl */
55 static int hf_ns_cert_exts_RevocationUrl_PDU = -1;  /* RevocationUrl */
56 static int hf_ns_cert_exts_CaRevocationUrl_PDU = -1;  /* CaRevocationUrl */
57 static int hf_ns_cert_exts_CaPolicyUrl_PDU = -1;  /* CaPolicyUrl */
58 static int hf_ns_cert_exts_Comment_PDU = -1;      /* Comment */
59 static int hf_ns_cert_exts_SslServerName_PDU = -1;  /* SslServerName */
60 static int hf_ns_cert_exts_CertRenewalUrl_PDU = -1;  /* CertRenewalUrl */
61 static int hf_ns_cert_exts_CertType_PDU = -1;     /* CertType */
62 /* named bits */
63 static int hf_ns_cert_exts_CertType_ssl_client = -1;
64 static int hf_ns_cert_exts_CertType_ssl_server = -1;
65 static int hf_ns_cert_exts_CertType_smime = -1;
66 static int hf_ns_cert_exts_CertType_object_signing = -1;
67 static int hf_ns_cert_exts_CertType_ssl_ca = -1;
68 static int hf_ns_cert_exts_CertType_smime_ca = -1;
69 static int hf_ns_cert_exts_CertType_object_signing_ca = -1;
70
71 /*--- End of included file: packet-ns_cert_exts-hf.c ---*/
72 #line 44 "packet-ns_cert_exts-template.c"
73
74 /* Initialize the subtree pointers */
75
76 /*--- Included file: packet-ns_cert_exts-ett.c ---*/
77 #line 1 "packet-ns_cert_exts-ett.c"
78 static gint ett_ns_cert_exts_CertType = -1;
79
80 /*--- End of included file: packet-ns_cert_exts-ett.c ---*/
81 #line 47 "packet-ns_cert_exts-template.c"
82
83
84 /*--- Included file: packet-ns_cert_exts-fn.c ---*/
85 #line 1 "packet-ns_cert_exts-fn.c"
86
87
88 static int
89 dissect_ns_cert_exts_BaseUrl(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
90   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
91                                             actx, tree, tvb, offset, hf_index,
92                                             NULL);
93
94   return offset;
95 }
96
97
98
99 static int
100 dissect_ns_cert_exts_RevocationUrl(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
101   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
102                                             actx, tree, tvb, offset, hf_index,
103                                             NULL);
104
105   return offset;
106 }
107
108
109
110 static int
111 dissect_ns_cert_exts_CaRevocationUrl(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
112   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
113                                             actx, tree, tvb, offset, hf_index,
114                                             NULL);
115
116   return offset;
117 }
118
119
120
121 static int
122 dissect_ns_cert_exts_CaPolicyUrl(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
123   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
124                                             actx, tree, tvb, offset, hf_index,
125                                             NULL);
126
127   return offset;
128 }
129
130
131
132 static int
133 dissect_ns_cert_exts_Comment(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
134   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
135                                             actx, tree, tvb, offset, hf_index,
136                                             NULL);
137
138   return offset;
139 }
140
141
142
143 static int
144 dissect_ns_cert_exts_SslServerName(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
145   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
146                                             actx, tree, tvb, offset, hf_index,
147                                             NULL);
148
149   return offset;
150 }
151
152
153
154 static int
155 dissect_ns_cert_exts_CertRenewalUrl(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
156   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
157                                             actx, tree, tvb, offset, hf_index,
158                                             NULL);
159
160   return offset;
161 }
162
163
164 static const asn_namedbit CertType_bits[] = {
165   {  0, &hf_ns_cert_exts_CertType_ssl_client, -1, -1, "ssl-client", NULL },
166   {  1, &hf_ns_cert_exts_CertType_ssl_server, -1, -1, "ssl-server", NULL },
167   {  2, &hf_ns_cert_exts_CertType_smime, -1, -1, "smime", NULL },
168   {  3, &hf_ns_cert_exts_CertType_object_signing, -1, -1, "object-signing", NULL },
169   {  5, &hf_ns_cert_exts_CertType_ssl_ca, -1, -1, "ssl-ca", NULL },
170   {  6, &hf_ns_cert_exts_CertType_smime_ca, -1, -1, "smime-ca", NULL },
171   {  7, &hf_ns_cert_exts_CertType_object_signing_ca, -1, -1, "object-signing-ca", NULL },
172   { 0, NULL, 0, 0, NULL, NULL }
173 };
174
175 static int
176 dissect_ns_cert_exts_CertType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
177   offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
178                                     CertType_bits, hf_index, ett_ns_cert_exts_CertType,
179                                     NULL);
180
181   return offset;
182 }
183
184 /*--- PDUs ---*/
185
186 static void dissect_BaseUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
187   asn1_ctx_t asn1_ctx;
188   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
189   dissect_ns_cert_exts_BaseUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_BaseUrl_PDU);
190 }
191 static void dissect_RevocationUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
192   asn1_ctx_t asn1_ctx;
193   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
194   dissect_ns_cert_exts_RevocationUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_RevocationUrl_PDU);
195 }
196 static void dissect_CaRevocationUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
197   asn1_ctx_t asn1_ctx;
198   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
199   dissect_ns_cert_exts_CaRevocationUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_CaRevocationUrl_PDU);
200 }
201 static void dissect_CaPolicyUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
202   asn1_ctx_t asn1_ctx;
203   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
204   dissect_ns_cert_exts_CaPolicyUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_CaPolicyUrl_PDU);
205 }
206 static void dissect_Comment_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
207   asn1_ctx_t asn1_ctx;
208   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
209   dissect_ns_cert_exts_Comment(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_Comment_PDU);
210 }
211 static void dissect_SslServerName_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
212   asn1_ctx_t asn1_ctx;
213   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
214   dissect_ns_cert_exts_SslServerName(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_SslServerName_PDU);
215 }
216 static void dissect_CertRenewalUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
217   asn1_ctx_t asn1_ctx;
218   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
219   dissect_ns_cert_exts_CertRenewalUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_CertRenewalUrl_PDU);
220 }
221 static void dissect_CertType_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
222   asn1_ctx_t asn1_ctx;
223   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
224   dissect_ns_cert_exts_CertType(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_CertType_PDU);
225 }
226
227
228 /*--- End of included file: packet-ns_cert_exts-fn.c ---*/
229 #line 49 "packet-ns_cert_exts-template.c"
230
231
232 /*--- proto_register_ns_cert_exts -------------------------------------------*/
233 void proto_register_ns_cert_exts(void) {
234
235   /* List of fields */
236   static hf_register_info hf[] = {
237
238 /*--- Included file: packet-ns_cert_exts-hfarr.c ---*/
239 #line 1 "packet-ns_cert_exts-hfarr.c"
240     { &hf_ns_cert_exts_BaseUrl_PDU,
241       { "BaseUrl", "ns_cert_exts.BaseUrl",
242         FT_STRING, BASE_NONE, NULL, 0,
243         "ns_cert_exts.BaseUrl", HFILL }},
244     { &hf_ns_cert_exts_RevocationUrl_PDU,
245       { "RevocationUrl", "ns_cert_exts.RevocationUrl",
246         FT_STRING, BASE_NONE, NULL, 0,
247         "ns_cert_exts.RevocationUrl", HFILL }},
248     { &hf_ns_cert_exts_CaRevocationUrl_PDU,
249       { "CaRevocationUrl", "ns_cert_exts.CaRevocationUrl",
250         FT_STRING, BASE_NONE, NULL, 0,
251         "ns_cert_exts.CaRevocationUrl", HFILL }},
252     { &hf_ns_cert_exts_CaPolicyUrl_PDU,
253       { "CaPolicyUrl", "ns_cert_exts.CaPolicyUrl",
254         FT_STRING, BASE_NONE, NULL, 0,
255         "ns_cert_exts.CaPolicyUrl", HFILL }},
256     { &hf_ns_cert_exts_Comment_PDU,
257       { "Comment", "ns_cert_exts.Comment",
258         FT_STRING, BASE_NONE, NULL, 0,
259         "ns_cert_exts.Comment", HFILL }},
260     { &hf_ns_cert_exts_SslServerName_PDU,
261       { "SslServerName", "ns_cert_exts.SslServerName",
262         FT_STRING, BASE_NONE, NULL, 0,
263         "ns_cert_exts.SslServerName", HFILL }},
264     { &hf_ns_cert_exts_CertRenewalUrl_PDU,
265       { "CertRenewalUrl", "ns_cert_exts.CertRenewalUrl",
266         FT_STRING, BASE_NONE, NULL, 0,
267         "ns_cert_exts.CertRenewalUrl", HFILL }},
268     { &hf_ns_cert_exts_CertType_PDU,
269       { "CertType", "ns_cert_exts.CertType",
270         FT_BYTES, BASE_NONE, NULL, 0,
271         "ns_cert_exts.CertType", HFILL }},
272     { &hf_ns_cert_exts_CertType_ssl_client,
273       { "ssl-client", "ns_cert_exts.ssl-client",
274         FT_BOOLEAN, 8, NULL, 0x80,
275         NULL, HFILL }},
276     { &hf_ns_cert_exts_CertType_ssl_server,
277       { "ssl-server", "ns_cert_exts.ssl-server",
278         FT_BOOLEAN, 8, NULL, 0x40,
279         NULL, HFILL }},
280     { &hf_ns_cert_exts_CertType_smime,
281       { "smime", "ns_cert_exts.smime",
282         FT_BOOLEAN, 8, NULL, 0x20,
283         NULL, HFILL }},
284     { &hf_ns_cert_exts_CertType_object_signing,
285       { "object-signing", "ns_cert_exts.object-signing",
286         FT_BOOLEAN, 8, NULL, 0x10,
287         NULL, HFILL }},
288     { &hf_ns_cert_exts_CertType_ssl_ca,
289       { "ssl-ca", "ns_cert_exts.ssl-ca",
290         FT_BOOLEAN, 8, NULL, 0x04,
291         NULL, HFILL }},
292     { &hf_ns_cert_exts_CertType_smime_ca,
293       { "smime-ca", "ns_cert_exts.smime-ca",
294         FT_BOOLEAN, 8, NULL, 0x02,
295         NULL, HFILL }},
296     { &hf_ns_cert_exts_CertType_object_signing_ca,
297       { "object-signing-ca", "ns_cert_exts.object-signing-ca",
298         FT_BOOLEAN, 8, NULL, 0x01,
299         NULL, HFILL }},
300
301 /*--- End of included file: packet-ns_cert_exts-hfarr.c ---*/
302 #line 57 "packet-ns_cert_exts-template.c"
303   };
304
305   /* List of subtrees */
306   static gint *ett[] = {
307
308 /*--- Included file: packet-ns_cert_exts-ettarr.c ---*/
309 #line 1 "packet-ns_cert_exts-ettarr.c"
310     &ett_ns_cert_exts_CertType,
311
312 /*--- End of included file: packet-ns_cert_exts-ettarr.c ---*/
313 #line 62 "packet-ns_cert_exts-template.c"
314   };
315
316   /* Register protocol */
317   proto_ns_cert_exts = proto_register_protocol(PNAME, PSNAME, PFNAME);
318
319   /* Register fields and subtrees */
320   proto_register_field_array(proto_ns_cert_exts, hf, array_length(hf));
321   proto_register_subtree_array(ett, array_length(ett));
322
323 }
324
325
326 /*--- proto_reg_handoff_ns_cert_exts ---------------------------------------*/
327 void proto_reg_handoff_ns_cert_exts(void) {
328
329 /*--- Included file: packet-ns_cert_exts-dis-tab.c ---*/
330 #line 1 "packet-ns_cert_exts-dis-tab.c"
331   register_ber_oid_dissector("2.16.840.1.113730.1.1", dissect_CertType_PDU, proto_ns_cert_exts, "ns_cert_exts.cert_type");
332   register_ber_oid_dissector("2.16.840.1.113730.1.2", dissect_BaseUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.base_url");
333   register_ber_oid_dissector("2.16.840.1.113730.1.3", dissect_RevocationUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.revocation-url");
334   register_ber_oid_dissector("2.16.840.1.113730.1.4", dissect_CaRevocationUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.ca-revocation-url");
335   register_ber_oid_dissector("2.16.840.1.113730.1.7", dissect_CertRenewalUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.cert-renewal-url");
336   register_ber_oid_dissector("2.16.840.1.113730.1.8", dissect_CaPolicyUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.ca-policy-url");
337   register_ber_oid_dissector("2.16.840.1.113730.1.12", dissect_SslServerName_PDU, proto_ns_cert_exts, "ns_cert_exts.ssl-server-name");
338   register_ber_oid_dissector("2.16.840.1.113730.1.13", dissect_Comment_PDU, proto_ns_cert_exts, "ns_cert_exts.comment");
339
340
341 /*--- End of included file: packet-ns_cert_exts-dis-tab.c ---*/
342 #line 77 "packet-ns_cert_exts-template.c"
343 }
344