New protocol: RFC2634 ExtendedSecurityServices
[obnox/wireshark/wip.git] / asn1 / x509ce / packet-x509ce-template.c
1 /* packet-x509ce.c
2  * Routines for X.509 Certificate Extensions packet dissection
3  *  Ronnie Sahlberg 2004
4  *
5  * $Id$
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
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 #include <epan/conversation.h>
33
34 #include <stdio.h>
35 #include <string.h>
36
37 #include "packet-ber.h"
38 #include "packet-x509ce.h"
39 #include "packet-x509af.h"
40 #include "packet-x509if.h"
41 #include "packet-x509sat.h"
42
43 #define PNAME  "X.509 Certificate Extensions"
44 #define PSNAME "X509CE"
45 #define PFNAME "x509ce"
46
47 /* Initialize the protocol and registered fields */
48 int proto_x509ce = -1;
49 static int hf_x509ce_id_ce_invalidityDate = -1;
50 static int hf_x509ce_id_ce_baseUpdateTime = -1;
51 static int hf_x509ce_object_identifier_id = -1;
52 #include "packet-x509ce-hf.c"
53
54 /* Initialize the subtree pointers */
55 #include "packet-x509ce-ett.c"
56
57 static char object_identifier_id[64]; /*64 chars should be long enough? */
58
59 #include "packet-x509ce-fn.c"
60
61
62 static void
63 dissect_x509ce_invalidityDate_callback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
64 {
65         dissect_x509ce_GeneralizedTime(FALSE, tvb, 0, pinfo, tree, hf_x509ce_id_ce_invalidityDate);
66 }
67
68 static void
69 dissect_x509ce_baseUpdateTime_callback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
70 {
71         dissect_x509ce_GeneralizedTime(FALSE, tvb, 0, pinfo, tree, hf_x509ce_id_ce_baseUpdateTime);
72 }
73
74 /*--- proto_register_x509ce ----------------------------------------------*/
75 void proto_register_x509ce(void) {
76
77   /* List of fields */
78   static hf_register_info hf[] = {
79     { &hf_x509ce_id_ce_baseUpdateTime,
80       { "baseUpdateTime", "x509ce.id_ce_baseUpdateTime",
81         FT_STRING, BASE_NONE, NULL, 0,
82         "baseUpdateTime", HFILL }},
83     { &hf_x509ce_id_ce_invalidityDate,
84       { "invalidityDate", "x509ce.id_ce_invalidityDate",
85         FT_STRING, BASE_NONE, NULL, 0,
86         "invalidityDate", HFILL }},
87     { &hf_x509ce_object_identifier_id, 
88       { "Id", "x509ce.id", FT_STRING, BASE_NONE, NULL, 0,
89         "Object identifier Id", HFILL }},
90                          
91 #include "packet-x509ce-hfarr.c"
92   };
93
94   /* List of subtrees */
95   static gint *ett[] = {
96 #include "packet-x509ce-ettarr.c"
97   };
98
99   /* Register protocol */
100   proto_x509ce = proto_register_protocol(PNAME, PSNAME, PFNAME);
101
102   /* Register fields and subtrees */
103   proto_register_field_array(proto_x509ce, hf, array_length(hf));
104   proto_register_subtree_array(ett, array_length(ett));
105
106 }
107
108
109 /*--- proto_reg_handoff_x509ce -------------------------------------------*/
110 void proto_reg_handoff_x509ce(void) {
111 #include "packet-x509ce-dis-tab.c"
112         register_ber_oid_dissector("2.5.29.24", dissect_x509ce_invalidityDate_callback, proto_x509ce, "id-ce-invalidityDate");
113         register_ber_oid_dissector("2.5.29.51", dissect_x509ce_baseUpdateTime_callback, proto_x509ce, "id-ce-baseUpdateTime");
114 }
115