2 * Routines for X.411 (X.400 Message Transfer) packet dissection
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
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.
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.
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.
31 #include <epan/packet.h>
32 #include <epan/conversation.h>
37 #include "packet-ber.h"
38 #include "packet-acse.h"
39 #include "packet-ros.h"
40 #include "packet-rtse.h"
42 #include "packet-x509af.h"
43 #include "packet-x509ce.h"
44 #include "packet-x509if.h"
45 #include "packet-x509sat.h"
47 #include "packet-x411.h"
48 #include <epan/emem.h>
49 #include <epan/strutil.h>
51 #define PNAME "X.411 Message Transfer Service"
55 /* Initialize the protocol and registered fields */
58 static struct SESSION_DATA_STRUCTURE* session = NULL;
59 static int extension_id = -1; /* integer extension id */
60 static const char *object_identifier_id; /* extensions identifier */
61 static const char *content_type_id; /* content type identifier */
63 #define MAX_ORA_STR_LEN 256
64 static char *oraddress = NULL;
65 static gboolean doing_address=FALSE;
66 static proto_item *address_item;
68 static proto_tree *top_tree=NULL;
71 call_x411_oid_callback(char *base_oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
73 #include "packet-x411-hf.c"
75 /* Initialize the subtree pointers */
76 static gint ett_x411 = -1;
77 #include "packet-x411-ett.c"
79 #include "packet-x411-fn.c"
82 call_x411_oid_callback(char *base_oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
84 const char *name = NULL;
85 char extension_oid[BER_MAX_OID_STR_LEN];
87 sprintf(extension_oid, "%s.%d", base_oid, extension_id);
89 name = get_ber_oid_name(extension_oid);
90 proto_item_append_text(tree, " (%s)", name ? name : extension_oid);
92 return call_ber_oid_callback(extension_oid, tvb, offset, pinfo, tree);
98 * Dissect X411 MTS APDU
101 dissect_x411_mts_apdu (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
103 proto_item *item=NULL;
104 proto_tree *tree=NULL;
106 /* save parent_tree so subdissectors can create new top nodes */
107 top_tree=parent_tree;
110 item = proto_tree_add_item(parent_tree, proto_x411, tvb, 0, -1, FALSE);
111 tree = proto_item_add_subtree(item, ett_x411);
114 if (check_col(pinfo->cinfo, COL_PROTOCOL))
115 col_set_str(pinfo->cinfo, COL_PROTOCOL, "P1");
116 if (check_col(pinfo->cinfo, COL_INFO))
117 col_set_str(pinfo->cinfo, COL_INFO, "Transfer");
119 return dissect_x411_MTS_APDU (FALSE, tvb, 0, pinfo, tree, hf_x411_MTS_APDU_PDU);
123 * Dissect X411 PDUs inside a PPDU.
126 dissect_x411(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
130 proto_item *item=NULL;
131 proto_tree *tree=NULL;
132 int (*x411_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) = NULL;
136 /* save parent_tree so subdissectors can create new top nodes */
137 top_tree=parent_tree;
139 /* do we have operation information from the ROS dissector? */
140 if( !pinfo->private_data ){
142 proto_tree_add_text(parent_tree, tvb, offset, -1,
143 "Internal error: can't get operation information from ROS dissector.");
147 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
151 item = proto_tree_add_item(parent_tree, proto_x411, tvb, 0, -1, FALSE);
152 tree = proto_item_add_subtree(item, ett_x411);
154 if (check_col(pinfo->cinfo, COL_PROTOCOL))
155 col_set_str(pinfo->cinfo, COL_PROTOCOL, "P1");
156 if (check_col(pinfo->cinfo, COL_INFO))
157 col_clear(pinfo->cinfo, COL_INFO);
159 switch(session->ros_op & ROS_OP_MASK) {
160 case (ROS_OP_BIND | ROS_OP_ARGUMENT): /* BindInvoke */
161 x411_dissector = dissect_x411_MTABindArgument;
162 x411_op_name = "Bind-Argument";
163 hf_x411_index = hf_x411_MTABindArgument_PDU;
165 case (ROS_OP_BIND | ROS_OP_RESULT): /* BindResult */
166 x411_dissector = dissect_x411_MTABindResult;
167 x411_op_name = "Bind-Result";
168 hf_x411_index = hf_x411_MTABindResult_PDU;
170 case (ROS_OP_BIND | ROS_OP_ERROR): /* BindError */
171 x411_dissector = dissect_x411_MTABindError;
172 x411_op_name = "Bind-Error";
173 hf_x411_index = hf_x411_MTABindError_PDU;
175 case (ROS_OP_INVOKE | ROS_OP_ARGUMENT): /* Invoke Argument */
176 x411_dissector = dissect_x411_MTS_APDU;
177 x411_op_name = "Transfer";
178 hf_x411_index = hf_x411_MTS_APDU_PDU;
181 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported X411 PDU");
185 if (check_col(pinfo->cinfo, COL_INFO))
186 col_add_str(pinfo->cinfo, COL_INFO, x411_op_name);
188 while (tvb_reported_length_remaining(tvb, offset) > 0){
190 offset=(*x411_dissector)(FALSE, tvb, offset, pinfo , tree, hf_x411_index);
191 if(offset == old_offset){
192 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte X411 PDU");
193 offset = tvb_length(tvb);
200 /*--- proto_register_x411 -------------------------------------------*/
201 void proto_register_x411(void) {
204 static hf_register_info hf[] =
206 #include "packet-x411-hfarr.c"
209 /* List of subtrees */
210 static gint *ett[] = {
212 #include "packet-x411-ettarr.c"
215 /* Register protocol */
216 proto_x411 = proto_register_protocol(PNAME, PSNAME, PFNAME);
217 register_dissector("x411", dissect_x411, proto_x411);
218 /* Register fields and subtrees */
219 proto_register_field_array(proto_x411, hf, array_length(hf));
220 proto_register_subtree_array(ett, array_length(ett));
225 /*--- proto_reg_handoff_x411 --- */
226 void proto_reg_handoff_x411(void) {
227 dissector_handle_t handle = NULL;
229 #include "packet-x411-dis-tab.c"
231 /* APPLICATION CONTEXT */
233 register_ber_oid_name("2.6.0.1.6", "id-ac-mts-transfer");
235 /* ABSTRACT SYNTAXES */
237 if((handle = find_dissector("x411")) != NULL) {
238 register_rtse_oid_dissector_handle("2.6.0.2.12", handle, 0, "id-as-mta-rtse", TRUE);
239 register_rtse_oid_dissector_handle("2.6.0.2.7", handle, 0, "id-as-mtse", FALSE);
241 register_rtse_oid_dissector_handle("applicationProtocol.1", handle, 0, "mts-transfer-protocol-1984", FALSE);
242 register_rtse_oid_dissector_handle("applicationProtocol.12", handle, 0, "mta-transfer-protocol", FALSE);