fix usage of "if(tree) {" to display the right things, even if no coloring rule is set
[obnox/wireshark/wip.git] / epan / dissectors / packet-pkixtsp.c
1 /* Do not modify this file.                                                   */
2 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
3 /* ./packet-pkixtsp.c                                                         */
4 /* ../../tools/asn2eth.py -X -b -e -p pkixtsp -c pkixtsp.cnf -s packet-pkixtsp-template PKIXTSP.asn */
5
6 /* Input file: packet-pkixtsp-template.c */
7
8 /* packet-pkixtsp.c
9  * Routines for RFC2634 Extended Security Services packet dissection
10  *   Ronnie Sahlberg 2004
11  *
12  * $Id: packet-pkixtsp-template.c 12438 2004-10-30 02:36:58Z sahlberg $
13  *
14  * Ethereal - Network traffic analyzer
15  * By Gerald Combs <gerald@ethereal.com>
16  * Copyright 1998 Gerald Combs
17  *
18  * This program is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU General Public License
20  * as published by the Free Software Foundation; either version 2
21  * of the License, or (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
31  */
32
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include <glib.h>
38 #include <epan/packet.h>
39
40 #include <stdio.h>
41 #include <string.h>
42
43 #include "packet-ber.h"
44 #include "packet-pkixtsp.h"
45 #include "packet-pkix1explicit.h"
46 #include "packet-pkix1implicit.h"
47 #include "packet-cms.h"
48
49 #define PNAME  "PKIX Time Stamp Protocol"
50 #define PSNAME "PKIXTSP"
51 #define PFNAME "pkixtsp"
52
53 /* Initialize the protocol and registered fields */
54 static int proto_pkixtsp = -1;
55
56 /*--- Included file: packet-pkixtsp-hf.c ---*/
57
58 static int hf_pkixtsp_version = -1;               /* T_version */
59 static int hf_pkixtsp_messageImprint = -1;        /* MessageImprint */
60 static int hf_pkixtsp_reqPolicy = -1;             /* TSAPolicyId */
61 static int hf_pkixtsp_nonce = -1;                 /* INTEGER */
62 static int hf_pkixtsp_certReq = -1;               /* BOOLEAN */
63 static int hf_pkixtsp_extensions = -1;            /* Extensions */
64 static int hf_pkixtsp_hashAlgorithm = -1;         /* AlgorithmIdentifier */
65 static int hf_pkixtsp_hashedMessage = -1;         /* OCTET_STRING */
66 static int hf_pkixtsp_status = -1;                /* PKIStatusInfo */
67 static int hf_pkixtsp_timeStampToken = -1;        /* TimeStampToken */
68 static int hf_pkixtsp_pki_status = -1;            /* PKIStatus */
69 static int hf_pkixtsp_failInfo = -1;              /* PKIFailureInfo */
70 static int hf_pkixtsp_tst_version = -1;           /* tst_version */
71 static int hf_pkixtsp_policy = -1;                /* TSAPolicyId */
72 static int hf_pkixtsp_serialNumber = -1;          /* INTEGER */
73 static int hf_pkixtsp_genTime = -1;               /* GeneralizedTime */
74 static int hf_pkixtsp_accuracy = -1;              /* Accuracy */
75 static int hf_pkixtsp_ordering = -1;              /* BOOLEAN */
76 static int hf_pkixtsp_tsa = -1;                   /* GeneralName */
77 static int hf_pkixtsp_seconds = -1;               /* INTEGER */
78 static int hf_pkixtsp_millis = -1;                /* INTEGER_1_999 */
79 static int hf_pkixtsp_micros = -1;                /* INTEGER_1_999 */
80 /* named bits */
81 static int hf_pkixtsp_PKIFailureInfo_badAlg = -1;
82 static int hf_pkixtsp_PKIFailureInfo_badRequest = -1;
83 static int hf_pkixtsp_PKIFailureInfo_badDataFormat = -1;
84 static int hf_pkixtsp_PKIFailureInfo_timeNotAvailable = -1;
85 static int hf_pkixtsp_PKIFailureInfo_unacceptedPolicy = -1;
86 static int hf_pkixtsp_PKIFailureInfo_unacceptedExtension = -1;
87 static int hf_pkixtsp_PKIFailureInfo_addInfoNotAvailable = -1;
88 static int hf_pkixtsp_PKIFailureInfo_systemFailure = -1;
89
90 /*--- End of included file: packet-pkixtsp-hf.c ---*/
91
92
93 /* Initialize the subtree pointers */
94 static gint ett_pkixtsp = -1;
95
96 /*--- Included file: packet-pkixtsp-ett.c ---*/
97
98 static gint ett_pkixtsp_TimeStampReq = -1;
99 static gint ett_pkixtsp_MessageImprint = -1;
100 static gint ett_pkixtsp_TimeStampResp = -1;
101 static gint ett_pkixtsp_PKIStatusInfo = -1;
102 static gint ett_pkixtsp_PKIFailureInfo = -1;
103 static gint ett_pkixtsp_TSTInfo = -1;
104 static gint ett_pkixtsp_Accuracy = -1;
105
106 /*--- End of included file: packet-pkixtsp-ett.c ---*/
107
108
109
110
111 /*--- Included file: packet-pkixtsp-fn.c ---*/
112
113 /*--- Fields for imported types ---*/
114
115 static int dissect_extensions_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
116   return dissect_pkix1explicit_Extensions(TRUE, tvb, offset, pinfo, tree, hf_pkixtsp_extensions);
117 }
118 static int dissect_hashAlgorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
119   return dissect_pkix1explicit_AlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_hashAlgorithm);
120 }
121 static int dissect_tsa_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
122   return dissect_pkix1implicit_GeneralName(TRUE, tvb, offset, pinfo, tree, hf_pkixtsp_tsa);
123 }
124
125
126 static const value_string T_version_vals[] = {
127   {   1, "v1" },
128   { 0, NULL }
129 };
130
131
132 static int
133 dissect_pkixtsp_T_version(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
134   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL);
135
136   return offset;
137 }
138 static int dissect_version(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
139   return dissect_pkixtsp_T_version(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_version);
140 }
141
142
143 static int
144 dissect_pkixtsp_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
145   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
146                                     NULL);
147
148   return offset;
149 }
150 static int dissect_hashedMessage(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
151   return dissect_pkixtsp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_hashedMessage);
152 }
153
154 static const ber_sequence_t MessageImprint_sequence[] = {
155   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_hashAlgorithm },
156   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_hashedMessage },
157   { 0, 0, 0, NULL }
158 };
159
160 static int
161 dissect_pkixtsp_MessageImprint(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
162   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
163                                 MessageImprint_sequence, hf_index, ett_pkixtsp_MessageImprint);
164
165   return offset;
166 }
167 static int dissect_messageImprint(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
168   return dissect_pkixtsp_MessageImprint(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_messageImprint);
169 }
170
171
172 static int
173 dissect_pkixtsp_TSAPolicyId(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
174   offset = dissect_ber_object_identifier(implicit_tag, pinfo, tree, tvb, offset,
175                                          hf_index, NULL);
176
177   return offset;
178 }
179 static int dissect_reqPolicy(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
180   return dissect_pkixtsp_TSAPolicyId(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_reqPolicy);
181 }
182 static int dissect_policy(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
183   return dissect_pkixtsp_TSAPolicyId(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_policy);
184 }
185
186
187
188 static int
189 dissect_pkixtsp_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
190   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL);
191
192   return offset;
193 }
194 static int dissect_nonce(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
195   return dissect_pkixtsp_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_nonce);
196 }
197 static int dissect_serialNumber(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
198   return dissect_pkixtsp_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_serialNumber);
199 }
200 static int dissect_seconds(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
201   return dissect_pkixtsp_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_seconds);
202 }
203
204
205 static int
206 dissect_pkixtsp_BOOLEAN(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
207   offset = dissect_ber_boolean(pinfo, tree, tvb, offset, hf_index);
208
209   return offset;
210 }
211 static int dissect_certReq(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
212   return dissect_pkixtsp_BOOLEAN(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_certReq);
213 }
214 static int dissect_ordering(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
215   return dissect_pkixtsp_BOOLEAN(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_ordering);
216 }
217
218 static const ber_sequence_t TimeStampReq_sequence[] = {
219   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
220   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_messageImprint },
221   { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_reqPolicy },
222   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_nonce },
223   { BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_certReq },
224   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_extensions_impl },
225   { 0, 0, 0, NULL }
226 };
227
228 static int
229 dissect_pkixtsp_TimeStampReq(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
230   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
231                                 TimeStampReq_sequence, hf_index, ett_pkixtsp_TimeStampReq);
232
233   return offset;
234 }
235
236
237 static const value_string PKIStatus_vals[] = {
238   {   0, "granted" },
239   {   1, "grantedWithMods" },
240   {   2, "rejection" },
241   {   3, "waiting" },
242   {   4, "revocationWarning" },
243   {   5, "revocationNotification" },
244   { 0, NULL }
245 };
246
247
248 static int
249 dissect_pkixtsp_PKIStatus(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
250   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL);
251
252   return offset;
253 }
254 static int dissect_pki_status(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
255   return dissect_pkixtsp_PKIStatus(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_pki_status);
256 }
257
258 static const asn_namedbit PKIFailureInfo_bits[] = {
259   {  0, &hf_pkixtsp_PKIFailureInfo_badAlg, -1, -1, NULL, NULL },
260   {  2, &hf_pkixtsp_PKIFailureInfo_badRequest, -1, -1, NULL, NULL },
261   {  5, &hf_pkixtsp_PKIFailureInfo_badDataFormat, -1, -1, NULL, NULL },
262   { 14, &hf_pkixtsp_PKIFailureInfo_timeNotAvailable, -1, -1, NULL, NULL },
263   { 15, &hf_pkixtsp_PKIFailureInfo_unacceptedPolicy, -1, -1, NULL, NULL },
264   { 16, &hf_pkixtsp_PKIFailureInfo_unacceptedExtension, -1, -1, NULL, NULL },
265   { 17, &hf_pkixtsp_PKIFailureInfo_addInfoNotAvailable, -1, -1, NULL, NULL },
266   { 25, &hf_pkixtsp_PKIFailureInfo_systemFailure, -1, -1, NULL, NULL },
267   { 0, NULL, 0, 0, NULL, NULL }
268 };
269
270 static int
271 dissect_pkixtsp_PKIFailureInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
272   offset = dissect_ber_bitstring(implicit_tag, pinfo, tree, tvb, offset,
273                                  PKIFailureInfo_bits, hf_index, ett_pkixtsp_PKIFailureInfo,
274                                  NULL);
275
276   return offset;
277 }
278 static int dissect_failInfo(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
279   return dissect_pkixtsp_PKIFailureInfo(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_failInfo);
280 }
281
282 static const ber_sequence_t PKIStatusInfo_sequence[] = {
283   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pki_status },
284   { BER_CLASS_UNI, BER_UNI_TAG_BITSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_failInfo },
285   { 0, 0, 0, NULL }
286 };
287
288 static int
289 dissect_pkixtsp_PKIStatusInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
290   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
291                                 PKIStatusInfo_sequence, hf_index, ett_pkixtsp_PKIStatusInfo);
292
293   return offset;
294 }
295 static int dissect_status(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
296   return dissect_pkixtsp_PKIStatusInfo(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_status);
297 }
298
299
300 static int
301 dissect_pkixtsp_TimeStampToken(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
302   offset = dissect_cms_ContentInfo(implicit_tag, tvb, offset, pinfo, tree, hf_index);
303
304   return offset;
305 }
306 static int dissect_timeStampToken(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
307   return dissect_pkixtsp_TimeStampToken(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_timeStampToken);
308 }
309
310 static const ber_sequence_t TimeStampResp_sequence[] = {
311   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_status },
312   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_timeStampToken },
313   { 0, 0, 0, NULL }
314 };
315
316 static int
317 dissect_pkixtsp_TimeStampResp(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
318   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
319                                 TimeStampResp_sequence, hf_index, ett_pkixtsp_TimeStampResp);
320
321   return offset;
322 }
323
324
325 static const value_string tst_version_vals[] = {
326   {   1, "v1" },
327   { 0, NULL }
328 };
329
330
331 static int
332 dissect_pkixtsp_tst_version(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
333   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL);
334
335   return offset;
336 }
337 static int dissect_tst_version(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
338   return dissect_pkixtsp_tst_version(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_tst_version);
339 }
340
341
342 static int
343 dissect_pkixtsp_GeneralizedTime(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
344   offset = dissect_ber_GeneralizedTime(implicit_tag, pinfo, tree, tvb, offset, hf_index);
345
346   return offset;
347 }
348 static int dissect_genTime(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
349   return dissect_pkixtsp_GeneralizedTime(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_genTime);
350 }
351
352
353
354 static int
355 dissect_pkixtsp_INTEGER_1_999(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
356   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL);
357
358   return offset;
359 }
360 static int dissect_millis_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
361   return dissect_pkixtsp_INTEGER_1_999(TRUE, tvb, offset, pinfo, tree, hf_pkixtsp_millis);
362 }
363 static int dissect_micros_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
364   return dissect_pkixtsp_INTEGER_1_999(TRUE, tvb, offset, pinfo, tree, hf_pkixtsp_micros);
365 }
366
367 static const ber_sequence_t Accuracy_sequence[] = {
368   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_seconds },
369   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_millis_impl },
370   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_micros_impl },
371   { 0, 0, 0, NULL }
372 };
373
374 static int
375 dissect_pkixtsp_Accuracy(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
376   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
377                                 Accuracy_sequence, hf_index, ett_pkixtsp_Accuracy);
378
379   return offset;
380 }
381 static int dissect_accuracy(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
382   return dissect_pkixtsp_Accuracy(FALSE, tvb, offset, pinfo, tree, hf_pkixtsp_accuracy);
383 }
384
385 static const ber_sequence_t TSTInfo_sequence[] = {
386   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_tst_version },
387   { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_policy },
388   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_messageImprint },
389   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_serialNumber },
390   { BER_CLASS_UNI, BER_UNI_TAG_GeneralizedTime, BER_FLAGS_NOOWNTAG, dissect_genTime },
391   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_accuracy },
392   { BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ordering },
393   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_nonce },
394   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tsa_impl },
395   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_extensions_impl },
396   { 0, 0, 0, NULL }
397 };
398
399 static int
400 dissect_pkixtsp_TSTInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
401   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
402                                 TSTInfo_sequence, hf_index, ett_pkixtsp_TSTInfo);
403
404   return offset;
405 }
406
407
408 /*--- End of included file: packet-pkixtsp-fn.c ---*/
409
410
411
412 static int
413 dissect_timestamp_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
414 {
415         proto_item *item=NULL;
416         proto_tree *tree=NULL;
417
418         if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
419                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKIXTSP");
420
421         if (check_col(pinfo->cinfo, COL_INFO)) {
422                 col_clear(pinfo->cinfo, COL_INFO);
423                 
424                 col_add_fstr(pinfo->cinfo, COL_INFO, "Reply");
425         }
426
427
428         if(parent_tree){
429                 item=proto_tree_add_item(parent_tree, proto_pkixtsp, tvb, 0, -1, FALSE);
430                 tree = proto_item_add_subtree(item, ett_pkixtsp);
431         }
432
433         return dissect_pkixtsp_TimeStampResp(FALSE, tvb, 0, pinfo, tree, -1);
434 }
435
436 static int
437 dissect_timestamp_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
438 {
439         proto_item *item=NULL;
440         proto_tree *tree=NULL;
441
442         if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
443                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKIXTSP");
444
445         if (check_col(pinfo->cinfo, COL_INFO)) {
446                 col_clear(pinfo->cinfo, COL_INFO);
447                 
448                 col_add_fstr(pinfo->cinfo, COL_INFO, "Query");
449         }
450
451
452         if(parent_tree){
453                 item=proto_tree_add_item(parent_tree, proto_pkixtsp, tvb, 0, -1, FALSE);
454                 tree = proto_item_add_subtree(item, ett_pkixtsp);
455         }
456
457         return dissect_pkixtsp_TimeStampReq(FALSE, tvb, 0, pinfo, tree, -1);
458 }
459
460
461 /*--- proto_register_pkixtsp ----------------------------------------------*/
462 void proto_register_pkixtsp(void) {
463
464   /* List of fields */
465   static hf_register_info hf[] = {
466
467 /*--- Included file: packet-pkixtsp-hfarr.c ---*/
468
469     { &hf_pkixtsp_version,
470       { "version", "pkixtsp.version",
471         FT_INT32, BASE_DEC, VALS(T_version_vals), 0,
472         "TimeStampReq/version", HFILL }},
473     { &hf_pkixtsp_messageImprint,
474       { "messageImprint", "pkixtsp.messageImprint",
475         FT_NONE, BASE_NONE, NULL, 0,
476         "", HFILL }},
477     { &hf_pkixtsp_reqPolicy,
478       { "reqPolicy", "pkixtsp.reqPolicy",
479         FT_STRING, BASE_NONE, NULL, 0,
480         "TimeStampReq/reqPolicy", HFILL }},
481     { &hf_pkixtsp_nonce,
482       { "nonce", "pkixtsp.nonce",
483         FT_INT32, BASE_DEC, NULL, 0,
484         "", HFILL }},
485     { &hf_pkixtsp_certReq,
486       { "certReq", "pkixtsp.certReq",
487         FT_BOOLEAN, 8, NULL, 0,
488         "TimeStampReq/certReq", HFILL }},
489     { &hf_pkixtsp_extensions,
490       { "extensions", "pkixtsp.extensions",
491         FT_UINT32, BASE_DEC, NULL, 0,
492         "", HFILL }},
493     { &hf_pkixtsp_hashAlgorithm,
494       { "hashAlgorithm", "pkixtsp.hashAlgorithm",
495         FT_NONE, BASE_NONE, NULL, 0,
496         "MessageImprint/hashAlgorithm", HFILL }},
497     { &hf_pkixtsp_hashedMessage,
498       { "hashedMessage", "pkixtsp.hashedMessage",
499         FT_BYTES, BASE_HEX, NULL, 0,
500         "MessageImprint/hashedMessage", HFILL }},
501     { &hf_pkixtsp_status,
502       { "status", "pkixtsp.status",
503         FT_NONE, BASE_NONE, NULL, 0,
504         "TimeStampResp/status", HFILL }},
505     { &hf_pkixtsp_timeStampToken,
506       { "timeStampToken", "pkixtsp.timeStampToken",
507         FT_NONE, BASE_NONE, NULL, 0,
508         "TimeStampResp/timeStampToken", HFILL }},
509     { &hf_pkixtsp_pki_status,
510       { "status", "pkixtsp.status",
511         FT_INT32, BASE_DEC, VALS(PKIStatus_vals), 0,
512         "PKIStatusInfo/status", HFILL }},
513     { &hf_pkixtsp_failInfo,
514       { "failInfo", "pkixtsp.failInfo",
515         FT_BYTES, BASE_HEX, NULL, 0,
516         "PKIStatusInfo/failInfo", HFILL }},
517     { &hf_pkixtsp_tst_version,
518       { "version", "pkixtsp.version",
519         FT_INT32, BASE_DEC, VALS(tst_version_vals), 0,
520         "TSTInfo/version", HFILL }},
521     { &hf_pkixtsp_policy,
522       { "policy", "pkixtsp.policy",
523         FT_STRING, BASE_NONE, NULL, 0,
524         "TSTInfo/policy", HFILL }},
525     { &hf_pkixtsp_serialNumber,
526       { "serialNumber", "pkixtsp.serialNumber",
527         FT_INT32, BASE_DEC, NULL, 0,
528         "TSTInfo/serialNumber", HFILL }},
529     { &hf_pkixtsp_genTime,
530       { "genTime", "pkixtsp.genTime",
531         FT_STRING, BASE_NONE, NULL, 0,
532         "TSTInfo/genTime", HFILL }},
533     { &hf_pkixtsp_accuracy,
534       { "accuracy", "pkixtsp.accuracy",
535         FT_NONE, BASE_NONE, NULL, 0,
536         "TSTInfo/accuracy", HFILL }},
537     { &hf_pkixtsp_ordering,
538       { "ordering", "pkixtsp.ordering",
539         FT_BOOLEAN, 8, NULL, 0,
540         "TSTInfo/ordering", HFILL }},
541     { &hf_pkixtsp_tsa,
542       { "tsa", "pkixtsp.tsa",
543         FT_UINT32, BASE_DEC, NULL, 0,
544         "TSTInfo/tsa", HFILL }},
545     { &hf_pkixtsp_seconds,
546       { "seconds", "pkixtsp.seconds",
547         FT_INT32, BASE_DEC, NULL, 0,
548         "Accuracy/seconds", HFILL }},
549     { &hf_pkixtsp_millis,
550       { "millis", "pkixtsp.millis",
551         FT_UINT32, BASE_DEC, NULL, 0,
552         "Accuracy/millis", HFILL }},
553     { &hf_pkixtsp_micros,
554       { "micros", "pkixtsp.micros",
555         FT_UINT32, BASE_DEC, NULL, 0,
556         "Accuracy/micros", HFILL }},
557     { &hf_pkixtsp_PKIFailureInfo_badAlg,
558       { "badAlg", "pkixtsp.badAlg",
559         FT_BOOLEAN, 8, NULL, 0x80,
560         "", HFILL }},
561     { &hf_pkixtsp_PKIFailureInfo_badRequest,
562       { "badRequest", "pkixtsp.badRequest",
563         FT_BOOLEAN, 8, NULL, 0x20,
564         "", HFILL }},
565     { &hf_pkixtsp_PKIFailureInfo_badDataFormat,
566       { "badDataFormat", "pkixtsp.badDataFormat",
567         FT_BOOLEAN, 8, NULL, 0x04,
568         "", HFILL }},
569     { &hf_pkixtsp_PKIFailureInfo_timeNotAvailable,
570       { "timeNotAvailable", "pkixtsp.timeNotAvailable",
571         FT_BOOLEAN, 8, NULL, 0x02,
572         "", HFILL }},
573     { &hf_pkixtsp_PKIFailureInfo_unacceptedPolicy,
574       { "unacceptedPolicy", "pkixtsp.unacceptedPolicy",
575         FT_BOOLEAN, 8, NULL, 0x01,
576         "", HFILL }},
577     { &hf_pkixtsp_PKIFailureInfo_unacceptedExtension,
578       { "unacceptedExtension", "pkixtsp.unacceptedExtension",
579         FT_BOOLEAN, 8, NULL, 0x80,
580         "", HFILL }},
581     { &hf_pkixtsp_PKIFailureInfo_addInfoNotAvailable,
582       { "addInfoNotAvailable", "pkixtsp.addInfoNotAvailable",
583         FT_BOOLEAN, 8, NULL, 0x40,
584         "", HFILL }},
585     { &hf_pkixtsp_PKIFailureInfo_systemFailure,
586       { "systemFailure", "pkixtsp.systemFailure",
587         FT_BOOLEAN, 8, NULL, 0x40,
588         "", HFILL }},
589
590 /*--- End of included file: packet-pkixtsp-hfarr.c ---*/
591
592   };
593
594   /* List of subtrees */
595   static gint *ett[] = {
596         &ett_pkixtsp,
597
598 /*--- Included file: packet-pkixtsp-ettarr.c ---*/
599
600     &ett_pkixtsp_TimeStampReq,
601     &ett_pkixtsp_MessageImprint,
602     &ett_pkixtsp_TimeStampResp,
603     &ett_pkixtsp_PKIStatusInfo,
604     &ett_pkixtsp_PKIFailureInfo,
605     &ett_pkixtsp_TSTInfo,
606     &ett_pkixtsp_Accuracy,
607
608 /*--- End of included file: packet-pkixtsp-ettarr.c ---*/
609
610   };
611
612   /* Register protocol */
613   proto_pkixtsp = proto_register_protocol(PNAME, PSNAME, PFNAME);
614
615   /* Register fields and subtrees */
616   proto_register_field_array(proto_pkixtsp, hf, array_length(hf));
617   proto_register_subtree_array(ett, array_length(ett));
618
619 }
620
621
622 /*--- proto_reg_handoff_pkixtsp -------------------------------------------*/
623 void proto_reg_handoff_pkixtsp(void) {
624         dissector_handle_t timestamp_reply_handle;
625         dissector_handle_t timestamp_query_handle;
626
627         timestamp_reply_handle = new_create_dissector_handle(dissect_timestamp_reply, proto_pkixtsp);
628         dissector_add_string("media_type", "application/timestamp-reply", timestamp_reply_handle);
629
630         timestamp_query_handle = new_create_dissector_handle(dissect_timestamp_query, proto_pkixtsp);
631         dissector_add_string("media_type", "application/timestamp-query", timestamp_query_handle);
632
633 /*#include "packet-pkixtsp-dis-tab.c"*/
634 }
635