From Stig Bjorlykke:
[obnox/wireshark/wip.git] / asn1 / x420 / packet-x420-template.c
1 /* packet-x420.c
2  * Routines for X.420 (X.400 Message Transfer)  packet dissection
3  * Graeme Lunt 2005
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/oid_resolv.h>
34 #include <epan/asn1.h>
35
36 #include <stdio.h>
37 #include <string.h>
38
39 #include "packet-ber.h"
40 #include "packet-acse.h"
41 #include "packet-ros.h"
42
43 #include "packet-x509af.h"
44 #include "packet-x509ce.h"
45 #include "packet-ftam.h"
46 #include "packet-x411.h"
47
48 #include "packet-x420.h"
49
50 #define PNAME  "X.420 Information Object"
51 #define PSNAME "X420"
52 #define PFNAME "x420"
53
54 /* Initialize the protocol and registered fields */
55 int proto_x420 = -1;
56
57 static const char *object_identifier_id; /* content type identifier */
58
59 static const value_string charsetreg_vals [] = {
60   { 1, "C0: (ISO/IEC 6429)"},
61   { 6, "G0: ASCII (ISO/IEC 646)"},
62   { 77, "C1: (ISO/IEC 6429)"},
63   { 100, "Gn: Latin Alphabet No.1, Western European Supplementary Set (GR area of ISO-8859-1)"},
64   { 101, "Gn: Latin Alphabet No.2, Central EuropeanSupplementary Set (GR area of ISO-8859-2)"},
65   { 104, "C0: (ISO/IEC 4873)"},
66   { 105, "C1: (ISO/IEC 4873)"},
67   { 106, "C0: Teletex (CCITT T.61)"},
68   { 107, "C1: Teletex (CCITT T.61)"},
69   { 109, "Gn: Latin Alphabet No.3, Southern European Supplementary Set (GR area of ISO-8859-3)"},
70   { 110, "Gn: Latin Alphabet No.4, Baltic Supplementary Set (GR area of ISO-8859-4)"},
71   { 126, "Gn: Greek Supplementary Set (GR area of ISO-8859-7)"},
72   { 127, "Gn: Arabic Supplementary Set (GR area of ISO-8859-6)"},
73   { 138, "Gn: Hebrew Supplementary Set (GR area of ISO-8859-8)"},
74   { 144, "Gn: Cyrillic Supplementary Set (GR area of ISO-8859-5)"},
75   { 148, "Gn: Latin Alphabet No.5, Cyrillic Supplementary Set (GR area of ISO-8859-9)"},
76   { 154, "Gn: Supplementary Set for Latin Alphabets No.1 or No.5, and No.2"},
77   { 157, "Gn: Latin Alphabet No.6, Arabic Supplementary Set (GR area of ISO-8859-10)"},
78   { 158, "Gn: Supplementary Set for Sami (Lappish) to complement Latin Alphabet No.6 (from Annex A  of ISO-8859-10)"},
79   { 166, "Gn: Thai Supplementary Set (GR area of ISO-8859-11)"},
80   { 179, "Gn: Latin Alphabet No.7, Baltic Rim Supplementary Set (GR area of ISO-8859-13)"},
81   { 182, "Gn: Welsh Variant of Latin Alphabet No.1, Supplementary Set (GR area of ISO-8859-1)"},
82   { 197, "Gn: Supplementary Set for Sami to complement Latin Alphabet No.6 (from Annex A  of ISO-8859-10)"},
83   { 199, "Gn: Latin Alphabet No.8, Celtic Supplementary Set (GR area of ISO-8859-14)"},
84   { 203, "Gn: Latin Alphabet No.9, European Rim Supplementary Set (GR area of ISO-8859-15)"},
85   { 0, NULL}
86 };
87
88 #include "packet-x420-hf.c"
89
90 /* Initialize the subtree pointers */
91 static gint ett_x420 = -1;
92 #include "packet-x420-ett.c"
93
94 #include "packet-x420-fn.c"
95
96 /*
97 * Dissect X420 PDUs inside a PPDU.
98 */
99 static void
100 dissect_x420(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
101 {
102         int offset = 0;
103         proto_item *item=NULL;
104         proto_tree *tree=NULL;
105         asn1_ctx_t asn1_ctx;
106         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
107
108         if(parent_tree){
109                 item = proto_tree_add_item(parent_tree, proto_x420, tvb, 0, -1, FALSE);
110                 tree = proto_item_add_subtree(item, ett_x420);
111         }
112
113         if (check_col(pinfo->cinfo, COL_PROTOCOL))
114                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "P22");
115         if (check_col(pinfo->cinfo, COL_INFO))
116           col_add_str(pinfo->cinfo, COL_INFO, "InterPersonal");
117
118         dissect_x420_InformationObject(TRUE, tvb, offset, &asn1_ctx , tree, -1);
119 }
120
121
122 /*--- proto_register_x420 -------------------------------------------*/
123 void proto_register_x420(void) {
124
125   /* List of fields */
126   static hf_register_info hf[] =
127   {
128 #include "packet-x420-hfarr.c"
129   };
130
131   /* List of subtrees */
132   static gint *ett[] = {
133     &ett_x420,
134 #include "packet-x420-ettarr.c"
135   };
136
137   /* Register protocol */
138   proto_x420 = proto_register_protocol(PNAME, PSNAME, PFNAME);
139   register_dissector("x420", dissect_x420, proto_x420);
140   /* Register fields and subtrees */
141   proto_register_field_array(proto_x420, hf, array_length(hf));
142   proto_register_subtree_array(ett, array_length(ett));
143
144 }
145
146
147 /*--- proto_reg_handoff_x420 --- */
148 void proto_reg_handoff_x420(void) {
149
150 #include "packet-x420-dis-tab.c" 
151
152   register_ber_oid_dissector("2.6.1.10.0", dissect_x420, proto_x420, "InterPersonal Message (1984)");
153   register_ber_oid_dissector("2.6.1.10.1", dissect_x420, proto_x420, "InterPersonal Message (1988)");
154
155
156 }