From Graeme Lunt:
[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  * 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-acse.h"
39 #include "packet-ros.h"
40
41 #include "packet-x509af.h"
42 #include "packet-x411.h"
43
44 #include "packet-x420.h"
45
46 #define PNAME  "X.420 Information Object"
47 #define PSNAME "X420"
48 #define PFNAME "x420"
49
50 /* Initialize the protocol and registered fields */
51 int proto_x420 = -1;
52
53 static char object_identifier_id[BER_MAX_OID_STR_LEN]; /* content type identifier */
54
55 #include "packet-x420-hf.c"
56
57 /* Initialize the subtree pointers */
58 static gint ett_x420 = -1;
59 #include "packet-x420-ett.c"
60
61 #include "packet-x420-fn.c"
62
63 /*
64 * Dissect X420 PDUs inside a PPDU.
65 */
66 static void
67 dissect_x420(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
68 {
69         int offset = 0;
70         proto_item *item=NULL;
71         proto_tree *tree=NULL;
72
73         if(parent_tree){
74                 item = proto_tree_add_item(parent_tree, proto_x420, tvb, 0, -1, FALSE);
75                 tree = proto_item_add_subtree(item, ett_x420);
76         }
77
78         if (check_col(pinfo->cinfo, COL_PROTOCOL))
79                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "P22");
80         if (check_col(pinfo->cinfo, COL_INFO))
81           col_add_str(pinfo->cinfo, COL_INFO, "InterPersonal");
82
83         dissect_x420_InformationObject(TRUE, tvb, offset, pinfo , tree, -1);
84 }
85
86
87 /*--- proto_register_x420 -------------------------------------------*/
88 void proto_register_x420(void) {
89
90   /* List of fields */
91   static hf_register_info hf[] =
92   {
93 #include "packet-x420-hfarr.c"
94   };
95
96   /* List of subtrees */
97   static gint *ett[] = {
98     &ett_x420,
99 #include "packet-x420-ettarr.c"
100   };
101
102   /* Register protocol */
103   proto_x420 = proto_register_protocol(PNAME, PSNAME, PFNAME);
104   register_dissector("x420", dissect_x420, proto_x420);
105   /* Register fields and subtrees */
106   proto_register_field_array(proto_x420, hf, array_length(hf));
107   proto_register_subtree_array(ett, array_length(ett));
108
109 }
110
111
112 /*--- proto_reg_handoff_x420 --- */
113 void proto_reg_handoff_x420(void) {
114
115 #include "packet-x420-dis-tab.c" 
116
117   register_ber_oid_dissector("2.6.1.10.0", dissect_x420, proto_x420, "InterPersonal Message (1984)");
118   register_ber_oid_dissector("2.6.1.10.1", dissect_x420, proto_x420, "InterPersonal Message (1988)");
119
120
121 }