131136e1f34ddae36910f27987ce9dd965abc6a3
[obnox/wireshark/wip.git] / asn1 / ftam / packet-ftam-template.c
1 /* packet-ftam_asn1.c
2  * Routine to dissect OSI ISO 8571 FTAM Protocol packets
3  * based on the ASN.1 specification from http://www.itu.int/ITU-T/asn1/database/iso/8571-4/1988/
4  *
5  * also based on original handwritten dissector by
6  * Yuriy Sidelnikov <YSidelnikov@hotmail.com>
7  *
8  * Anders Broman and Ronnie Sahlberg 2005 - 2006
9  *
10  * $Id$
11  *
12  * Ethereal - Network traffic analyzer
13  * By Gerald Combs <gerald@ethereal.com>
14  * Copyright 1998 Gerald Combs
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29  */
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <glib.h>
36 #include <epan/packet.h>
37 #include <epan/conversation.h>
38
39 #include <stdio.h>
40 #include <string.h>
41
42 #include "packet-ber.h"
43 #include "packet-acse.h"
44 #include "packet-ftam.h"
45
46 #define PNAME  "ISO 8571 FTAM"
47 #define PSNAME "FTAM"
48 #define PFNAME "ftam"
49
50 /* Initialize the protocol and registered fields */
51 int proto_ftam = -1;
52
53 static const char *object_identifier_id;
54 /* Declare the function to avoid a compiler warning */
55 static int dissect_ftam_OR_Set(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_);
56
57 #include "packet-ftam-hf.c"
58
59 /* Initialize the subtree pointers */
60 static gint ett_ftam = -1;
61 #include "packet-ftam-ett.c"
62
63 #include "packet-ftam-fn.c"
64
65 /*
66 * Dissect FTAM PDUs inside a PPDU.
67 */
68 static void
69 dissect_ftam(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
70 {
71         int offset = 0;
72         int old_offset;
73         proto_item *item=NULL;
74         proto_tree *tree=NULL;
75
76         if(parent_tree){
77                 item = proto_tree_add_item(parent_tree, proto_ftam, tvb, 0, -1, FALSE);
78                 tree = proto_item_add_subtree(item, ett_ftam);
79         }
80         if (check_col(pinfo->cinfo, COL_PROTOCOL))
81                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FTAM");
82         if (check_col(pinfo->cinfo, COL_INFO))
83                 col_clear(pinfo->cinfo, COL_INFO);
84
85         while (tvb_reported_length_remaining(tvb, offset) > 0){
86                 old_offset=offset;
87                 offset=dissect_ftam_PDU(FALSE, tvb, offset, pinfo , tree, -1);
88                 if(offset == old_offset){
89                         proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte FTAM PDU");
90                         offset = tvb_length(tvb);
91                         break;
92                 }
93         }
94 }
95
96
97 /*--- proto_register_ftam -------------------------------------------*/
98 void proto_register_ftam(void) {
99
100   /* List of fields */
101   static hf_register_info hf[] =
102   {
103 #include "packet-ftam-hfarr.c"
104   };
105
106   /* List of subtrees */
107   static gint *ett[] = {
108     &ett_ftam,
109 #include "packet-ftam-ettarr.c"
110   };
111
112   /* Register protocol */
113   proto_ftam = proto_register_protocol(PNAME, PSNAME, PFNAME);
114   register_dissector("ftam", dissect_ftam, proto_ftam);
115   /* Register fields and subtrees */
116   proto_register_field_array(proto_ftam, hf, array_length(hf));
117   proto_register_subtree_array(ett, array_length(ett));
118
119 }
120
121
122 /*--- proto_reg_handoff_ftam --- */
123 void proto_reg_handoff_ftam(void) {
124         register_ber_oid_dissector("1.0.8571.1.1", dissect_ftam, proto_ftam,"iso-ftam(1)");
125         register_ber_oid_dissector("1.0.8571.2.1", dissect_ftam, proto_ftam,"ftam-pci(1)");
126         register_ber_oid_dissector("1.3.14.5.2.2", dissect_ftam, proto_ftam,"NIST file directory entry abstract syntax");
127
128         /* Unstructured text file document type FTAM-1 */
129         register_ber_oid_name("1.0.8571.5.1","ISO FTAM unstructured text");
130         register_ber_oid_name("1.0.8571.5.2","ISO FTAM sequential text");
131         register_ber_oid_name("1.0.8571.2.3","FTAM unstructured text abstract syntax");
132         register_ber_oid_name("1.0.8571.2.4","FTAM sequential text abstract syntax");
133         register_ber_oid_name("1.0.8571.2.5","FTAM simple-hierarchy");
134         register_ber_oid_name("1.0.8571.3.1","FTAM hierarchical file model");
135         register_ber_oid_name("1.0.8571.4.1","FTAM unstructured constraint set");
136
137         /* Unstructured text file document type FTAM-3 */
138         register_ber_oid_name("1.0.8571.5.3","ISO FTAM unstructured binary");
139         register_ber_oid_name("1.0.8571.2.4","FTAM unstructured binary abstract syntax");
140
141         /* Filedirectory file document type NBS-9 */
142         register_ber_oid_name("1.3.14.5.5.9","NBS-9 FTAM file directory file");
143
144         /* Filedirectory file document type NBS-9 (WITH OLD NIST OIDs)*/
145         register_ber_oid_name("1.3.9999.1.5.9","NBS-9-OLD FTAM file directory file");
146         register_ber_oid_name("1.3.9999.1.2.2","NIST file directory entry abstract syntax");
147 }