30480ffa7898a2c8a49611c05e13f007042d4ec3
[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  * 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 #include <epan/conversation.h>
33 #include <epan/asn1.h>
34
35 #include <stdio.h>
36 #include <string.h>
37
38 #include "packet-ber.h"
39 #include "packet-x509ce.h"
40 #include "packet-x509af.h"
41 #include "packet-x509if.h"
42 #include "packet-x509sat.h"
43 #include "packet-x411.h"
44
45 #define PNAME  "X.509 Certificate Extensions"
46 #define PSNAME "X509CE"
47 #define PFNAME "x509ce"
48
49 /* Initialize the protocol and registered fields */
50 int proto_x509ce = -1;
51 static int hf_x509ce_id_ce_invalidityDate = -1;
52 static int hf_x509ce_id_ce_baseUpdateTime = -1;
53 static int hf_x509ce_object_identifier_id = -1;
54 static int hf_x509ce_IPAddress = -1;
55 #include "packet-x509ce-hf.c"
56
57 /* Initialize the subtree pointers */
58 #include "packet-x509ce-ett.c"
59
60 static const char *object_identifier_id;
61
62 #include "packet-x509ce-fn.c"
63
64
65 static void
66 dissect_x509ce_invalidityDate_callback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
67 {
68         asn1_ctx_t asn1_ctx;
69         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
70
71         dissect_x509ce_GeneralizedTime(FALSE, tvb, 0, &asn1_ctx, tree, hf_x509ce_id_ce_invalidityDate);
72 }
73
74 static void
75 dissect_x509ce_baseUpdateTime_callback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
76 {
77         asn1_ctx_t asn1_ctx;
78         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
79         dissect_x509ce_GeneralizedTime(FALSE, tvb, 0, &asn1_ctx, tree, hf_x509ce_id_ce_baseUpdateTime);
80 }
81
82 /*--- proto_register_x509ce ----------------------------------------------*/
83 void proto_register_x509ce(void) {
84
85   /* List of fields */
86   static hf_register_info hf[] = {
87     { &hf_x509ce_id_ce_baseUpdateTime,
88       { "baseUpdateTime", "x509ce.id_ce_baseUpdateTime",
89         FT_STRING, BASE_NONE, NULL, 0,
90         "baseUpdateTime", HFILL }},
91     { &hf_x509ce_id_ce_invalidityDate,
92       { "invalidityDate", "x509ce.id_ce_invalidityDate",
93         FT_STRING, BASE_NONE, NULL, 0,
94         "invalidityDate", HFILL }},
95     { &hf_x509ce_object_identifier_id, 
96       { "Id", "x509ce.id", FT_OID, BASE_NONE, NULL, 0,
97         "Object identifier Id", HFILL }},
98     { &hf_x509ce_IPAddress,
99       { "iPAddress", "x509ce.IPAddress", FT_IPv4, BASE_NONE, NULL, 0,
100         "IP Address", HFILL }},
101
102 #include "packet-x509ce-hfarr.c"
103   };
104
105   /* List of subtrees */
106   static gint *ett[] = {
107 #include "packet-x509ce-ettarr.c"
108   };
109
110   /* Register protocol */
111   proto_x509ce = proto_register_protocol(PNAME, PSNAME, PFNAME);
112
113   /* Register fields and subtrees */
114   proto_register_field_array(proto_x509ce, hf, array_length(hf));
115   proto_register_subtree_array(ett, array_length(ett));
116
117 }
118
119
120 /*--- proto_reg_handoff_x509ce -------------------------------------------*/
121 void proto_reg_handoff_x509ce(void) {
122 #include "packet-x509ce-dis-tab.c"
123         register_ber_oid_dissector("2.5.29.24", dissect_x509ce_invalidityDate_callback, proto_x509ce, "id-ce-invalidityDate");
124         register_ber_oid_dissector("2.5.29.51", dissect_x509ce_baseUpdateTime_callback, proto_x509ce, "id-ce-baseUpdateTime");
125 }
126