name change
[obnox/wireshark/wip.git] / asn1 / pkixtsp / packet-pkixtsp-template.c
1 /* packet-pkixtsp.c
2  * Routines for RFC2634 Extended Security Services 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 <stdio.h>
34 #include <string.h>
35
36 #include "packet-ber.h"
37 #include "packet-pkixtsp.h"
38 #include "packet-pkix1explicit.h"
39 #include "packet-pkix1implicit.h"
40 #include "packet-cms.h"
41
42 #define PNAME  "PKIX Time Stamp Protocol"
43 #define PSNAME "PKIXTSP"
44 #define PFNAME "pkixtsp"
45
46 /* Initialize the protocol and registered fields */
47 static int proto_pkixtsp = -1;
48 #include "packet-pkixtsp-hf.c"
49
50 /* Initialize the subtree pointers */
51 static gint ett_pkixtsp = -1;
52 #include "packet-pkixtsp-ett.c"
53
54
55 #include "packet-pkixtsp-fn.c"
56
57
58 static int
59 dissect_timestamp_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
60 {
61         proto_item *item=NULL;
62         proto_tree *tree=NULL;
63
64         if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
65                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKIXTSP");
66
67         if (check_col(pinfo->cinfo, COL_INFO)) {
68                 col_clear(pinfo->cinfo, COL_INFO);
69                 
70                 col_add_fstr(pinfo->cinfo, COL_INFO, "Reply");
71         }
72
73
74         if(parent_tree){
75                 item=proto_tree_add_item(parent_tree, proto_pkixtsp, tvb, 0, -1, FALSE);
76                 tree = proto_item_add_subtree(item, ett_pkixtsp);
77         }
78
79         return dissect_pkixtsp_TimeStampResp(FALSE, tvb, 0, pinfo, tree, -1);
80 }
81
82 static int
83 dissect_timestamp_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
84 {
85         proto_item *item=NULL;
86         proto_tree *tree=NULL;
87
88         if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
89                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKIXTSP");
90
91         if (check_col(pinfo->cinfo, COL_INFO)) {
92                 col_clear(pinfo->cinfo, COL_INFO);
93                 
94                 col_add_fstr(pinfo->cinfo, COL_INFO, "Query");
95         }
96
97
98         if(parent_tree){
99                 item=proto_tree_add_item(parent_tree, proto_pkixtsp, tvb, 0, -1, FALSE);
100                 tree = proto_item_add_subtree(item, ett_pkixtsp);
101         }
102
103         return dissect_pkixtsp_TimeStampReq(FALSE, tvb, 0, pinfo, tree, -1);
104 }
105
106
107 /*--- proto_register_pkixtsp ----------------------------------------------*/
108 void proto_register_pkixtsp(void) {
109
110   /* List of fields */
111   static hf_register_info hf[] = {
112 #include "packet-pkixtsp-hfarr.c"
113   };
114
115   /* List of subtrees */
116   static gint *ett[] = {
117         &ett_pkixtsp,
118 #include "packet-pkixtsp-ettarr.c"
119   };
120
121   /* Register protocol */
122   proto_pkixtsp = proto_register_protocol(PNAME, PSNAME, PFNAME);
123
124   /* Register fields and subtrees */
125   proto_register_field_array(proto_pkixtsp, hf, array_length(hf));
126   proto_register_subtree_array(ett, array_length(ett));
127
128 }
129
130
131 /*--- proto_reg_handoff_pkixtsp -------------------------------------------*/
132 void proto_reg_handoff_pkixtsp(void) {
133         dissector_handle_t timestamp_reply_handle;
134         dissector_handle_t timestamp_query_handle;
135
136         timestamp_reply_handle = new_create_dissector_handle(dissect_timestamp_reply, proto_pkixtsp);
137         dissector_add_string("media_type", "application/timestamp-reply", timestamp_reply_handle);
138
139         timestamp_query_handle = new_create_dissector_handle(dissect_timestamp_query, proto_pkixtsp);
140         dissector_add_string("media_type", "application/timestamp-query", timestamp_query_handle);
141
142 /*#include "packet-pkixtsp-dis-tab.c"*/
143 }
144