Fix svn properties where needed:
[metze/wireshark/wip.git] / asn1 / cmip / packet-cmip-template.c
1 /* packet-cmip.c
2  * Routines for X.711 CMIP 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-acse.h"
39 #include "packet-x509if.h"
40 #include "packet-cmip.h"
41
42 #define PNAME  "X711 CMIP"
43 #define PSNAME "CMIP"
44 #define PFNAME "cmip"
45
46 /* XXX some stuff we need until we can get rid of it */
47 #include "packet-ses.h"
48 #include "packet-pres.h"
49
50 /* Initialize the protocol and registered fields */
51 int proto_cmip = -1;
52 static int hf_cmip_actionType_OID = -1;
53 static int hf_cmip_eventType_OID = -1;
54 static int hf_cmip_attributeId_OID = -1;
55 static int hf_cmip_errorId_OID = -1;
56 #include "packet-cmip-hf.c"
57
58 /* Initialize the subtree pointers */
59 static gint ett_cmip = -1;
60 #include "packet-cmip-ett.c"
61
62 static guint32 opcode;
63
64 static int opcode_type;
65 #define OPCODE_INVOKE        1
66 #define OPCODE_RETURN_RESULT 2
67 #define OPCODE_RETURN_ERROR  3
68 #define OPCODE_REJECT        4
69
70 static int attributeform;
71 #define ATTRIBUTE_LOCAL_FORM  0
72 #define ATTRIBUTE_GLOBAL_FORM 1
73 static char attribute_identifier_id[BER_MAX_OID_STR_LEN];
74
75 static char object_identifier_id[BER_MAX_OID_STR_LEN];
76
77 static int objectclassform;
78 #define OBJECTCLASS_LOCAL_FORM  0
79 #define OBJECTCLASS_GLOBAL_FORM 1
80 static char objectclass_identifier_id[BER_MAX_OID_STR_LEN];
81
82 #include "packet-cmip-fn.c"
83
84 /* XXX this one should be broken out later and moved into the conformance file */
85 static void
86 dissect_cmip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
87 {
88         static struct SESSION_DATA_STRUCTURE* session = NULL;
89         proto_item *item = NULL;
90         proto_tree *tree = NULL;
91
92
93         /* do we have spdu type from the session dissector?  */
94         if( !pinfo->private_data ){
95                 if(tree){
96                         proto_tree_add_text(tree, tvb, 0, -1,
97                                 "Internal error:can't get spdu type from session dissector.");
98                         return;
99                 }
100         } else {
101                 session  = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
102                 if(session->spdu_type == 0 ){
103                         if(tree){
104                                 proto_tree_add_text(tree, tvb, 0, -1,
105                                         "Internal error:wrong spdu type %x from session dissector.",session->spdu_type);
106                                 return;
107                         }
108                 }
109         }
110
111         if(parent_tree){
112                 item = proto_tree_add_item(parent_tree, proto_cmip, tvb, 0, -1, FALSE);
113                 tree = proto_item_add_subtree(item, ett_cmip);
114         }
115
116         if (check_col(pinfo->cinfo, COL_PROTOCOL))
117                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMIP");
118         if (check_col(pinfo->cinfo, COL_INFO))
119                 col_clear(pinfo->cinfo, COL_INFO);
120         switch(session->spdu_type){
121                 case SES_CONNECTION_REQUEST:
122                 case SES_CONNECTION_ACCEPT:
123                 case SES_DISCONNECT:
124                 case SES_FINISH:
125                 case SES_REFUSE:
126                         dissect_cmip_CMIPUserInfo(FALSE,tvb,0,pinfo,tree,-1);
127                         break;
128                 case SES_ABORT:
129                         dissect_cmip_CMIPAbortInfo(FALSE,tvb,0,pinfo,tree,-1);
130                         break;
131                 case SES_DATA_TRANSFER:
132                         dissect_cmip_ROS(FALSE,tvb,0,pinfo,tree,-1);
133                         break;
134                 default:
135                         ;
136         }
137 }
138
139 /*--- proto_register_cmip ----------------------------------------------*/
140 void proto_register_cmip(void) {
141
142   /* List of fields */
143   static hf_register_info hf[] = {
144     { &hf_cmip_actionType_OID,
145       { "actionType", "cmip.actionType_OID",
146         FT_STRING, BASE_NONE, NULL, 0,
147         "actionType", HFILL }},
148     { &hf_cmip_eventType_OID,
149       { "eventType", "cmip.eventType_OID",
150         FT_STRING, BASE_NONE, NULL, 0,
151         "eventType", HFILL }},
152     { &hf_cmip_attributeId_OID,
153       { "attributeId", "cmip.attributeId_OID",
154         FT_STRING, BASE_NONE, NULL, 0,
155         "attributeId", HFILL }},
156     { &hf_cmip_errorId_OID,
157       { "errorId", "cmip.errorId_OID",
158         FT_STRING, BASE_NONE, NULL, 0,
159         "errorId", HFILL }},
160 #include "packet-cmip-hfarr.c"
161   };
162
163   /* List of subtrees */
164   static gint *ett[] = {
165     &ett_cmip,
166 #include "packet-cmip-ettarr.c"
167   };
168
169   /* Register protocol */
170   proto_cmip = proto_register_protocol(PNAME, PSNAME, PFNAME);
171
172   /* Register fields and subtrees */
173   proto_register_field_array(proto_cmip, hf, array_length(hf));
174   proto_register_subtree_array(ett, array_length(ett));
175
176 }
177
178
179 /*--- proto_reg_handoff_cmip -------------------------------------------*/
180 void proto_reg_handoff_cmip(void) {
181         register_ber_oid_dissector("2.9.0.0.2", dissect_cmip, proto_cmip, "cmip");
182 }
183