05f70a61c0b47d87eb9ce663b8bd334f177edd8d
[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 -e -p ns_cert_exts -c ns_cert_exts.cnf -s packet-ns_cert_exts-template 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 #include <epan/conversation.h>
41
42 #include <stdio.h>
43 #include <string.h>
44
45 #include "packet-ber.h"
46
47 #define PNAME  "NetScape Certificate Extensions"
48 #define PSNAME "NS_CERT_EXTS"
49 #define PFNAME "ns_cert_exts"
50
51 /* Initialize the protocol and registered fields */
52 int proto_ns_cert_exts = -1;
53
54 /*--- Included file: packet-ns_cert_exts-hf.c ---*/
55 #line 1 "packet-ns_cert_exts-hf.c"
56 static int hf_ns_cert_exts_BaseUrl_PDU = -1;      /* BaseUrl */
57 static int hf_ns_cert_exts_RevocationUrl_PDU = -1;  /* RevocationUrl */
58 static int hf_ns_cert_exts_CaRevocationUrl_PDU = -1;  /* CaRevocationUrl */
59 static int hf_ns_cert_exts_CaPolicyUrl_PDU = -1;  /* CaPolicyUrl */
60 static int hf_ns_cert_exts_Comment_PDU = -1;      /* Comment */
61 static int hf_ns_cert_exts_SslServerName_PDU = -1;  /* SslServerName */
62 static int hf_ns_cert_exts_CertRenewalUrl_PDU = -1;  /* CertRenewalUrl */
63 static int hf_ns_cert_exts_CertType_PDU = -1;     /* CertType */
64 /* named bits */
65 static int hf_ns_cert_exts_CertType_client = -1;
66 static int hf_ns_cert_exts_CertType_server = -1;
67 static int hf_ns_cert_exts_CertType_ca = -1;
68
69 /*--- End of included file: packet-ns_cert_exts-hf.c ---*/
70 #line 46 "packet-ns_cert_exts-template.c"
71
72 /* Initialize the subtree pointers */
73
74 /*--- Included file: packet-ns_cert_exts-ett.c ---*/
75 #line 1 "packet-ns_cert_exts-ett.c"
76 static gint ett_ns_cert_exts_CertType = -1;
77
78 /*--- End of included file: packet-ns_cert_exts-ett.c ---*/
79 #line 49 "packet-ns_cert_exts-template.c"
80
81
82 /*--- Included file: packet-ns_cert_exts-fn.c ---*/
83 #line 1 "packet-ns_cert_exts-fn.c"
84 /*--- Fields for imported types ---*/
85
86
87
88
89 static int
90 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_) {
91   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
92                                             actx, tree, tvb, offset, hf_index,
93                                             NULL);
94
95   return offset;
96 }
97
98
99
100 static int
101 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_) {
102   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
103                                             actx, tree, tvb, offset, hf_index,
104                                             NULL);
105
106   return offset;
107 }
108
109
110
111 static int
112 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_) {
113   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
114                                             actx, tree, tvb, offset, hf_index,
115                                             NULL);
116
117   return offset;
118 }
119
120
121
122 static int
123 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_) {
124   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
125                                             actx, tree, tvb, offset, hf_index,
126                                             NULL);
127
128   return offset;
129 }
130
131
132
133 static int
134 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_) {
135   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
136                                             actx, tree, tvb, offset, hf_index,
137                                             NULL);
138
139   return offset;
140 }
141
142
143
144 static int
145 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_) {
146   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
147                                             actx, tree, tvb, offset, hf_index,
148                                             NULL);
149
150   return offset;
151 }
152
153
154
155 static int
156 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_) {
157   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
158                                             actx, tree, tvb, offset, hf_index,
159                                             NULL);
160
161   return offset;
162 }
163
164
165 static const asn_namedbit CertType_bits[] = {
166   {  0, &hf_ns_cert_exts_CertType_client, -1, -1, "client", NULL },
167   {  1, &hf_ns_cert_exts_CertType_server, -1, -1, "server", NULL },
168   {  5, &hf_ns_cert_exts_CertType_ca, -1, -1, "ca", NULL },
169   { 0, NULL, 0, 0, NULL, NULL }
170 };
171
172 static int
173 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_) {
174   offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
175                                     CertType_bits, hf_index, ett_ns_cert_exts_CertType,
176                                     NULL);
177
178   return offset;
179 }
180
181 /*--- PDUs ---*/
182
183 static void dissect_BaseUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
184   asn1_ctx_t asn1_ctx;
185   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
186   dissect_ns_cert_exts_BaseUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_BaseUrl_PDU);
187 }
188 static void dissect_RevocationUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
189   asn1_ctx_t asn1_ctx;
190   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
191   dissect_ns_cert_exts_RevocationUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_RevocationUrl_PDU);
192 }
193 static void dissect_CaRevocationUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
194   asn1_ctx_t asn1_ctx;
195   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
196   dissect_ns_cert_exts_CaRevocationUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_CaRevocationUrl_PDU);
197 }
198 static void dissect_CaPolicyUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
199   asn1_ctx_t asn1_ctx;
200   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
201   dissect_ns_cert_exts_CaPolicyUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_CaPolicyUrl_PDU);
202 }
203 static void dissect_Comment_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
204   asn1_ctx_t asn1_ctx;
205   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
206   dissect_ns_cert_exts_Comment(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_Comment_PDU);
207 }
208 static void dissect_SslServerName_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
209   asn1_ctx_t asn1_ctx;
210   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
211   dissect_ns_cert_exts_SslServerName(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_SslServerName_PDU);
212 }
213 static void dissect_CertRenewalUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
214   asn1_ctx_t asn1_ctx;
215   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
216   dissect_ns_cert_exts_CertRenewalUrl(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_CertRenewalUrl_PDU);
217 }
218 static void dissect_CertType_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
219   asn1_ctx_t asn1_ctx;
220   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
221   dissect_ns_cert_exts_CertType(FALSE, tvb, 0, &asn1_ctx, tree, hf_ns_cert_exts_CertType_PDU);
222 }
223
224
225 /*--- End of included file: packet-ns_cert_exts-fn.c ---*/
226 #line 51 "packet-ns_cert_exts-template.c"
227
228
229 /*--- proto_register_ns_cert_exts -------------------------------------------*/
230 void proto_register_ns_cert_exts(void) {
231
232   /* List of fields */
233   static hf_register_info hf[] = {
234
235 /*--- Included file: packet-ns_cert_exts-hfarr.c ---*/
236 #line 1 "packet-ns_cert_exts-hfarr.c"
237     { &hf_ns_cert_exts_BaseUrl_PDU,
238       { "BaseUrl", "ns_cert_exts.BaseUrl",
239         FT_STRING, BASE_NONE, NULL, 0,
240         "ns_cert_exts.BaseUrl", HFILL }},
241     { &hf_ns_cert_exts_RevocationUrl_PDU,
242       { "RevocationUrl", "ns_cert_exts.RevocationUrl",
243         FT_STRING, BASE_NONE, NULL, 0,
244         "ns_cert_exts.RevocationUrl", HFILL }},
245     { &hf_ns_cert_exts_CaRevocationUrl_PDU,
246       { "CaRevocationUrl", "ns_cert_exts.CaRevocationUrl",
247         FT_STRING, BASE_NONE, NULL, 0,
248         "ns_cert_exts.CaRevocationUrl", HFILL }},
249     { &hf_ns_cert_exts_CaPolicyUrl_PDU,
250       { "CaPolicyUrl", "ns_cert_exts.CaPolicyUrl",
251         FT_STRING, BASE_NONE, NULL, 0,
252         "ns_cert_exts.CaPolicyUrl", HFILL }},
253     { &hf_ns_cert_exts_Comment_PDU,
254       { "Comment", "ns_cert_exts.Comment",
255         FT_STRING, BASE_NONE, NULL, 0,
256         "ns_cert_exts.Comment", HFILL }},
257     { &hf_ns_cert_exts_SslServerName_PDU,
258       { "SslServerName", "ns_cert_exts.SslServerName",
259         FT_STRING, BASE_NONE, NULL, 0,
260         "ns_cert_exts.SslServerName", HFILL }},
261     { &hf_ns_cert_exts_CertRenewalUrl_PDU,
262       { "CertRenewalUrl", "ns_cert_exts.CertRenewalUrl",
263         FT_STRING, BASE_NONE, NULL, 0,
264         "ns_cert_exts.CertRenewalUrl", HFILL }},
265     { &hf_ns_cert_exts_CertType_PDU,
266       { "CertType", "ns_cert_exts.CertType",
267         FT_BYTES, BASE_HEX, NULL, 0,
268         "ns_cert_exts.CertType", HFILL }},
269     { &hf_ns_cert_exts_CertType_client,
270       { "client", "ns_cert_exts.client",
271         FT_BOOLEAN, 8, NULL, 0x80,
272         "", HFILL }},
273     { &hf_ns_cert_exts_CertType_server,
274       { "server", "ns_cert_exts.server",
275         FT_BOOLEAN, 8, NULL, 0x40,
276         "", HFILL }},
277     { &hf_ns_cert_exts_CertType_ca,
278       { "ca", "ns_cert_exts.ca",
279         FT_BOOLEAN, 8, NULL, 0x04,
280         "", HFILL }},
281
282 /*--- End of included file: packet-ns_cert_exts-hfarr.c ---*/
283 #line 59 "packet-ns_cert_exts-template.c"
284   };
285
286   /* List of subtrees */
287   static gint *ett[] = {
288
289 /*--- Included file: packet-ns_cert_exts-ettarr.c ---*/
290 #line 1 "packet-ns_cert_exts-ettarr.c"
291     &ett_ns_cert_exts_CertType,
292
293 /*--- End of included file: packet-ns_cert_exts-ettarr.c ---*/
294 #line 64 "packet-ns_cert_exts-template.c"
295   };
296
297   /* Register protocol */
298   proto_ns_cert_exts = proto_register_protocol(PNAME, PSNAME, PFNAME);
299
300   /* Register fields and subtrees */
301   proto_register_field_array(proto_ns_cert_exts, hf, array_length(hf));
302   proto_register_subtree_array(ett, array_length(ett));
303
304 }
305
306
307 /*--- proto_reg_handoff_ns_cert_exts ---------------------------------------*/
308 void proto_reg_handoff_ns_cert_exts(void) {
309
310 /*--- Included file: packet-ns_cert_exts-dis-tab.c ---*/
311 #line 1 "packet-ns_cert_exts-dis-tab.c"
312   register_ber_oid_dissector("2.16.840.1.113730.1.1", dissect_CertType_PDU, proto_ns_cert_exts, "ns-cert-exts.cert_type");
313   register_ber_oid_dissector("2.16.840.1.113730.1.2", dissect_BaseUrl_PDU, proto_ns_cert_exts, "ns-cert-exts.base_url");
314   register_ber_oid_dissector("2.16.840.1.113730.1.3", dissect_RevocationUrl_PDU, proto_ns_cert_exts, "ns-cert-exts.revocation-url");
315   register_ber_oid_dissector("2.16.840.1.113730.1.4", dissect_CaRevocationUrl_PDU, proto_ns_cert_exts, "ns-cert-exts.ca-revocation-url");
316   register_ber_oid_dissector("2.16.840.1.113730.1.7", dissect_CertRenewalUrl_PDU, proto_ns_cert_exts, "ns-cert-exts.cert-renewal-url");
317   register_ber_oid_dissector("2.16.840.1.113730.1.8", dissect_CaPolicyUrl_PDU, proto_ns_cert_exts, "ns-cert-exts.ca-policy-url");
318   register_ber_oid_dissector("2.16.840.1.113730.1.12", dissect_SslServerName_PDU, proto_ns_cert_exts, "ns-cert-exts.ssl-server-name");
319   register_ber_oid_dissector("2.16.840.1.113730.1.13", dissect_Comment_PDU, proto_ns_cert_exts, "ns-cert-exts.comment");
320
321
322 /*--- End of included file: packet-ns_cert_exts-dis-tab.c ---*/
323 #line 79 "packet-ns_cert_exts-template.c"
324 }
325