1 /* Do not modify this file. */
2 /* It is created automatically by the ASN.1 to Wireshark dissector compiler */
4 /* ../../tools/asn2wrs.py -b -e -L -k -p idmp -c ./idmp.cnf -s ./packet-idmp-template -D . IDMProtocolSpecification.asn CommonProtocolSpecification.asn */
6 /* Input file: packet-idmp-template.c */
8 #line 1 "packet-idmp-template.c"
10 * Routines for X.519 Internet Directly Mapped Procotol (IDMP) packet dissection
15 * Wireshark - Network traffic analyzer
16 * By Gerald Combs <gerald@wireshark.org>
17 * Copyright 1998 Gerald Combs
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 #include <epan/packet.h>
40 #include <epan/prefs.h>
41 #include <epan/reassemble.h>
42 #include <epan/conversation.h>
43 #include <epan/oids.h>
44 #include <epan/asn1.h>
45 #include <epan/ipproto.h>
47 #include <epan/dissectors/packet-tcp.h>
49 #include "packet-ber.h"
50 #include "packet-ros.h"
51 #include "packet-x509ce.h"
53 #include <epan/strutil.h>
55 #define PNAME "X.519 Internet Directly Mapped Protocol"
59 static gboolean idmp_desegment = TRUE;
60 static guint global_idmp_tcp_port = 1102; /* made up for now */
61 static gboolean idmp_reassemble = TRUE;
62 static guint tcp_port = 0;
63 static dissector_handle_t idmp_handle = NULL;
65 static proto_tree *top_tree = NULL;
66 static struct SESSION_DATA_STRUCTURE* session = NULL;
67 static const char *protocolID = NULL;
68 static const char *saved_protocolID = NULL;
69 static guint32 opcode = -1;
71 void prefs_register_idmp(void); /* forward declaration for use in preferences registration */
73 /* Initialize the protocol and registered fields */
76 static int hf_idmp_version = -1;
77 static int hf_idmp_final = -1;
78 static int hf_idmp_length = -1;
79 static int hf_idmp_PDU = -1;
81 static GHashTable *idmp_segment_table = NULL;
82 static GHashTable *idmp_reassembled_table = NULL;
84 static int hf_idmp_fragments = -1;
85 static int hf_idmp_fragment = -1;
86 static int hf_idmp_fragment_overlap = -1;
87 static int hf_idmp_fragment_overlap_conflicts = -1;
88 static int hf_idmp_fragment_multiple_tails = -1;
89 static int hf_idmp_fragment_too_long_fragment = -1;
90 static int hf_idmp_fragment_error = -1;
91 static int hf_idmp_reassembled_in = -1;
92 static int hf_idmp_reassembled_length = -1;
94 static gint ett_idmp_fragment = -1;
95 static gint ett_idmp_fragments = -1;
97 static const fragment_items idmp_frag_items = {
98 /* Fragment subtrees */
101 /* Fragment fields */
104 &hf_idmp_fragment_overlap,
105 &hf_idmp_fragment_overlap_conflicts,
106 &hf_idmp_fragment_multiple_tails,
107 &hf_idmp_fragment_too_long_fragment,
108 &hf_idmp_fragment_error,
109 /* Reassembled in field */
110 &hf_idmp_reassembled_in,
111 /* Reassembled length field */
112 &hf_idmp_reassembled_length,
118 static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo, int op, proto_tree *tree _U_)
120 struct SESSION_DATA_STRUCTURE *session;
122 if((session = (struct SESSION_DATA_STRUCTURE*)pinfo->private_data) != NULL) {
124 if((!saved_protocolID) && (op == (ROS_OP_BIND | ROS_OP_RESULT))) {
125 /* save for subsequent operations - should be into session data */
126 saved_protocolID = se_strdup(protocolID);
130 session->ros_op = op;
131 offset = call_ros_oid_callback(saved_protocolID ? saved_protocolID : protocolID, tvb, offset, pinfo, top_tree);
139 /*--- Included file: packet-idmp-hf.c ---*/
140 #line 1 "packet-idmp-hf.c"
141 static int hf_idmp_bind = -1; /* IdmBind */
142 static int hf_idmp_bindResult = -1; /* IdmBindResult */
143 static int hf_idmp_bindError = -1; /* IdmBindError */
144 static int hf_idmp_request = -1; /* Request */
145 static int hf_idmp_idm_result = -1; /* IdmResult */
146 static int hf_idmp_idm_error = -1; /* Error */
147 static int hf_idmp_reject = -1; /* IdmReject */
148 static int hf_idmp_unbind = -1; /* Unbind */
149 static int hf_idmp_abort = -1; /* Abort */
150 static int hf_idmp_startTLS = -1; /* StartTLS */
151 static int hf_idmp_tLSResponse = -1; /* TLSResponse */
152 static int hf_idmp_protocolID = -1; /* OBJECT_IDENTIFIER */
153 static int hf_idmp_callingAETitle = -1; /* GeneralName */
154 static int hf_idmp_calledAETitle = -1; /* GeneralName */
155 static int hf_idmp_bind_argument = -1; /* Bind_argument */
156 static int hf_idmp_respondingAETitle = -1; /* GeneralName */
157 static int hf_idmp_bind_result = -1; /* Bind_result */
158 static int hf_idmp_bind_errcode = -1; /* Bind_errcode */
159 static int hf_idmp_aETitleError = -1; /* T_aETitleError */
160 static int hf_idmp_bind_error = -1; /* Bind_error */
161 static int hf_idmp_invokeID = -1; /* INTEGER */
162 static int hf_idmp_opcode = -1; /* Code */
163 static int hf_idmp_argument = -1; /* T_argument */
164 static int hf_idmp_idm_invokeID = -1; /* InvokeId */
165 static int hf_idmp_result = -1; /* T_result */
166 static int hf_idmp_errcode = -1; /* T_errcode */
167 static int hf_idmp_error = -1; /* T_error */
168 static int hf_idmp_reason = -1; /* T_reason */
169 static int hf_idmp_local = -1; /* T_local */
170 static int hf_idmp_global = -1; /* OBJECT_IDENTIFIER */
171 static int hf_idmp_present = -1; /* INTEGER */
172 static int hf_idmp_absent = -1; /* NULL */
174 /*--- End of included file: packet-idmp-hf.c ---*/
175 #line 131 "packet-idmp-template.c"
177 /* Initialize the subtree pointers */
178 static gint ett_idmp = -1;
180 /*--- Included file: packet-idmp-ett.c ---*/
181 #line 1 "packet-idmp-ett.c"
182 static gint ett_idmp_IDM_PDU = -1;
183 static gint ett_idmp_IdmBind = -1;
184 static gint ett_idmp_IdmBindResult = -1;
185 static gint ett_idmp_IdmBindError = -1;
186 static gint ett_idmp_Request = -1;
187 static gint ett_idmp_IdmResult = -1;
188 static gint ett_idmp_Error = -1;
189 static gint ett_idmp_IdmReject = -1;
190 static gint ett_idmp_Code = -1;
191 static gint ett_idmp_InvokeId = -1;
193 /*--- End of included file: packet-idmp-ett.c ---*/
194 #line 135 "packet-idmp-template.c"
197 /*--- Included file: packet-idmp-fn.c ---*/
198 #line 1 "packet-idmp-fn.c"
202 dissect_idmp_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
203 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &protocolID);
211 dissect_idmp_Bind_argument(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
213 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_ARGUMENT), top_tree);
220 static const ber_sequence_t IdmBind_sequence[] = {
221 { &hf_idmp_protocolID , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
222 { &hf_idmp_callingAETitle , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
223 { &hf_idmp_calledAETitle , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
224 { &hf_idmp_bind_argument , BER_CLASS_CON, 2, 0, dissect_idmp_Bind_argument },
225 { NULL, 0, 0, 0, NULL }
229 dissect_idmp_IdmBind(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
230 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
231 IdmBind_sequence, hf_index, ett_idmp_IdmBind);
239 dissect_idmp_Bind_result(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
241 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_RESULT), top_tree);
248 static const ber_sequence_t IdmBindResult_sequence[] = {
249 { &hf_idmp_protocolID , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
250 { &hf_idmp_respondingAETitle, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
251 { &hf_idmp_bind_result , BER_CLASS_CON, 1, 0, dissect_idmp_Bind_result },
252 { NULL, 0, 0, 0, NULL }
256 dissect_idmp_IdmBindResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
257 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
258 IdmBindResult_sequence, hf_index, ett_idmp_IdmBindResult);
266 dissect_idmp_Bind_errcode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
273 static const value_string idmp_T_aETitleError_vals[] = {
274 { 0, "callingAETitleNotAccepted" },
275 { 1, "calledAETitleNotRecognized" },
281 dissect_idmp_T_aETitleError(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
282 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
291 dissect_idmp_Bind_error(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
293 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND| ROS_OP_ERROR), top_tree);
300 static const ber_sequence_t IdmBindError_sequence[] = {
301 { &hf_idmp_protocolID , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
302 { &hf_idmp_bind_errcode , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_Bind_errcode },
303 { &hf_idmp_respondingAETitle, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
304 { &hf_idmp_aETitleError , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_idmp_T_aETitleError },
305 { &hf_idmp_bind_error , BER_CLASS_CON, 1, 0, dissect_idmp_Bind_error },
306 { NULL, 0, 0, 0, NULL }
310 dissect_idmp_IdmBindError(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
311 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
312 IdmBindError_sequence, hf_index, ett_idmp_IdmBindError);
320 dissect_idmp_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
321 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
330 dissect_idmp_T_local(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
331 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
338 static const value_string idmp_Code_vals[] = {
344 static const ber_choice_t Code_choice[] = {
345 { 0, &hf_idmp_local , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_T_local },
346 { 1, &hf_idmp_global , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
347 { 0, NULL, 0, 0, 0, NULL }
351 dissect_idmp_Code(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
352 offset = dissect_ber_choice(actx, tree, tvb, offset,
353 Code_choice, hf_index, ett_idmp_Code,
362 dissect_idmp_T_argument(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
364 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_ARGUMENT | opcode), top_tree);
371 static const ber_sequence_t Request_sequence[] = {
372 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
373 { &hf_idmp_opcode , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_Code },
374 { &hf_idmp_argument , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_argument },
375 { NULL, 0, 0, 0, NULL }
379 dissect_idmp_Request(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
380 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
381 Request_sequence, hf_index, ett_idmp_Request);
389 dissect_idmp_NULL(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
390 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
396 static const value_string idmp_InvokeId_vals[] = {
402 static const ber_choice_t InvokeId_choice[] = {
403 { 0, &hf_idmp_present , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
404 { 1, &hf_idmp_absent , BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_idmp_NULL },
405 { 0, NULL, 0, 0, 0, NULL }
409 dissect_idmp_InvokeId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
410 offset = dissect_ber_choice(actx, tree, tvb, offset,
411 InvokeId_choice, hf_index, ett_idmp_InvokeId,
420 dissect_idmp_T_result(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
422 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_RESULT | opcode), top_tree);
430 static const ber_sequence_t IdmResult_sequence[] = {
431 { &hf_idmp_idm_invokeID , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_InvokeId },
432 { &hf_idmp_opcode , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_Code },
433 { &hf_idmp_result , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_result },
434 { NULL, 0, 0, 0, NULL }
438 dissect_idmp_IdmResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
439 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
440 IdmResult_sequence, hf_index, ett_idmp_IdmResult);
448 dissect_idmp_T_errcode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
457 dissect_idmp_T_error(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
464 static const ber_sequence_t Error_sequence[] = {
465 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
466 { &hf_idmp_errcode , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_errcode },
467 { &hf_idmp_error , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_error },
468 { NULL, 0, 0, 0, NULL }
472 dissect_idmp_Error(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
473 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
474 Error_sequence, hf_index, ett_idmp_Error);
480 static const value_string idmp_T_reason_vals[] = {
481 { 0, "mistypedPDU" },
482 { 1, "duplicateInvokeIDRequest" },
483 { 2, "unsupportedOperationRequest" },
484 { 3, "unknownOperationRequest" },
485 { 4, "mistypedArgumentRequest" },
486 { 5, "resourceLimitationRequest" },
487 { 6, "unknownInvokeIDResult" },
488 { 7, "mistypedResultRequest" },
489 { 8, "unknownInvokeIDError" },
490 { 9, "unknownError" },
491 { 10, "mistypedParameterError" },
497 dissect_idmp_T_reason(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
498 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
505 static const ber_sequence_t IdmReject_sequence[] = {
506 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
507 { &hf_idmp_reason , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_idmp_T_reason },
508 { NULL, 0, 0, 0, NULL }
512 dissect_idmp_IdmReject(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
513 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
514 IdmReject_sequence, hf_index, ett_idmp_IdmReject);
522 dissect_idmp_Unbind(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
523 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
529 static const value_string idmp_Abort_vals[] = {
530 { 0, "mistypedPDU" },
531 { 1, "unboundRequest" },
533 { 3, "resourceLimitation" },
534 { 4, "connectionFailed" },
535 { 5, "invalidProtocol" },
536 { 6, "reasonNotSpecified" },
542 dissect_idmp_Abort(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
543 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
552 dissect_idmp_StartTLS(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
553 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
559 static const value_string idmp_TLSResponse_vals[] = {
561 { 1, "operationsError" },
562 { 2, "protocolError" },
563 { 3, "unavailable" },
569 dissect_idmp_TLSResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
570 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
577 static const value_string idmp_IDM_PDU_vals[] = {
588 { 10, "tLSResponse" },
592 static const ber_choice_t IDM_PDU_choice[] = {
593 { 0, &hf_idmp_bind , BER_CLASS_CON, 0, 0, dissect_idmp_IdmBind },
594 { 1, &hf_idmp_bindResult , BER_CLASS_CON, 1, 0, dissect_idmp_IdmBindResult },
595 { 2, &hf_idmp_bindError , BER_CLASS_CON, 2, 0, dissect_idmp_IdmBindError },
596 { 3, &hf_idmp_request , BER_CLASS_CON, 3, 0, dissect_idmp_Request },
597 { 4, &hf_idmp_idm_result , BER_CLASS_CON, 4, 0, dissect_idmp_IdmResult },
598 { 5, &hf_idmp_idm_error , BER_CLASS_CON, 5, 0, dissect_idmp_Error },
599 { 6, &hf_idmp_reject , BER_CLASS_CON, 6, 0, dissect_idmp_IdmReject },
600 { 7, &hf_idmp_unbind , BER_CLASS_CON, 7, 0, dissect_idmp_Unbind },
601 { 8, &hf_idmp_abort , BER_CLASS_CON, 8, 0, dissect_idmp_Abort },
602 { 9, &hf_idmp_startTLS , BER_CLASS_CON, 9, 0, dissect_idmp_StartTLS },
603 { 10, &hf_idmp_tLSResponse , BER_CLASS_CON, 10, 0, dissect_idmp_TLSResponse },
604 { 0, NULL, 0, 0, 0, NULL }
608 dissect_idmp_IDM_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
609 offset = dissect_ber_choice(actx, tree, tvb, offset,
610 IDM_PDU_choice, hf_index, ett_idmp_IDM_PDU,
617 /*--- End of included file: packet-idmp-fn.c ---*/
618 #line 137 "packet-idmp-template.c"
621 register_idmp_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name)
623 /* just register with ROS for now */
624 register_ros_protocol_info(oid, rinfo, proto, name, FALSE);
628 static int dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
632 proto_item *item=NULL;
633 proto_tree *tree=NULL;
635 void *save_private_data;
636 struct SESSION_DATA_STRUCTURE session;
639 fragment_data *fd_head;
640 conversation_t *conv;
643 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
645 conv = find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
646 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
648 /* Found a conversation, also use index for the generated dst_ref */
649 dst_ref = conv->index;
652 /* save parent_tree so subdissectors can create new top nodes */
653 top_tree=parent_tree;
656 item = proto_tree_add_item(parent_tree, proto_idmp, tvb, 0, -1, FALSE);
657 tree = proto_item_add_subtree(item, ett_idmp);
660 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IDMP");
662 /* now check the segment fields */
664 proto_tree_add_item(tree, hf_idmp_version, tvb, offset, 1, FALSE); offset++;
665 proto_tree_add_item(tree, hf_idmp_final, tvb, offset, 1, FALSE);
666 idmp_final = tvb_get_guint8(tvb, offset); offset++;
667 proto_tree_add_item(tree, hf_idmp_length, tvb, offset, 4, FALSE);
668 idmp_length = tvb_get_ntohl(tvb, offset); offset += 4;
670 if(idmp_reassemble) {
672 pinfo->fragmented = !idmp_final;
674 if (check_col(pinfo->cinfo, COL_INFO))
675 col_append_fstr(pinfo->cinfo, COL_INFO, " [%sIDMP fragment, %u byte%s]",
676 idmp_final ? "Final " : "" ,
677 idmp_length, plurality(idmp_length, "", "s"));
679 fd_head = fragment_add_seq_next(tvb, offset, pinfo, dst_ref,
680 idmp_segment_table, idmp_reassembled_table,
681 idmp_length, !idmp_final);
683 if(fd_head && fd_head->next) {
684 proto_tree_add_text(tree, tvb, offset, (idmp_length) ? -1 : 0,
685 "IDMP segment data (%u byte%s)", idmp_length,
686 plurality(idmp_length, "", "s"));
689 /* This is the last segment */
690 tvb = process_reassembled_data (tvb, offset, pinfo,
691 "Reassembled IDMP", fd_head, &idmp_frag_items, NULL, tree);
693 } else if (pinfo->fd->num != fd_head->reassembled_in) {
694 /* Add a "Reassembled in" link if not reassembled in this frame */
695 proto_tree_add_uint (tree, hf_idmp_reassembled_in,
696 tvb, 0, 0, fd_head->reassembled_in);
703 if (check_col(pinfo->cinfo, COL_INFO))
704 col_append_fstr(pinfo->cinfo, COL_INFO, " [IDMP fragment, %u byte%s, IDMP reassembly not enabled]",
705 idmp_length, plurality(idmp_length, "", "s"));
707 proto_tree_add_text(tree, tvb, offset, (idmp_length) ? -1 : 0,
708 "IDMP segment data (%u byte%s) (IDMP reassembly not enabled)", idmp_length,
709 plurality(idmp_length, "", "s"));
712 /* not reassembling - just dissect */
714 save_private_data = pinfo->private_data;
715 pinfo->private_data = &session;
717 offset = dissect_idmp_IDM_PDU(FALSE, tvb, offset, &asn1_ctx, tree, hf_idmp_PDU);
719 pinfo->private_data = save_private_data;
721 offset = tvb_length(tvb);
727 static guint get_idmp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
731 len = tvb_get_ntohl(tvb, offset + 2);
736 static void dissect_idmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
739 tcp_dissect_pdus(tvb, pinfo, parent_tree, idmp_desegment, 0, get_idmp_pdu_len, dissect_idmp);
743 static void idmp_reassemble_init (void)
745 fragment_table_init (&idmp_segment_table);
746 reassembled_table_init (&idmp_reassembled_table);
748 saved_protocolID = NULL;
751 /*--- proto_register_idmp -------------------------------------------*/
752 void proto_register_idmp(void) {
755 static hf_register_info hf[] =
758 { "version", "idmp.version",
759 FT_INT8, BASE_DEC, NULL, 0,
760 "idmp.INTEGER", HFILL }},
762 { "final", "idmp.final",
763 FT_BOOLEAN, 8, NULL, 0,
764 "idmp.BOOLEAN", HFILL }},
766 { "length", "idmp.length",
767 FT_INT32, BASE_DEC, NULL, 0,
768 "idmp.INTEGER", HFILL }},
770 { "IDM-PDU", "idmp.pdu",
771 FT_UINT32, BASE_DEC, VALS(idmp_IDM_PDU_vals), 0,
772 "idmp.PDU", HFILL }},
773 /* Fragment entries */
774 { &hf_idmp_fragments,
775 { "IDMP fragments", "idmp.fragments", FT_NONE, BASE_NONE,
776 NULL, 0x00, "Message fragments", HFILL } },
778 { "IDMP fragment", "idmp.fragment", FT_FRAMENUM, BASE_NONE,
779 NULL, 0x00, "Message fragment", HFILL } },
780 { &hf_idmp_fragment_overlap,
781 { "IDMP fragment overlap", "idmp.fragment.overlap", FT_BOOLEAN,
782 BASE_NONE, NULL, 0x00, "Message fragment overlap", HFILL } },
783 { &hf_idmp_fragment_overlap_conflicts,
784 { "IDMP fragment overlapping with conflicting data",
785 "idmp.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE, NULL,
786 0x00, "Message fragment overlapping with conflicting data", HFILL } },
787 { &hf_idmp_fragment_multiple_tails,
788 { "IDMP has multiple tail fragments",
789 "idmp.fragment.multiple_tails", FT_BOOLEAN, BASE_NONE,
790 NULL, 0x00, "Message has multiple tail fragments", HFILL } },
791 { &hf_idmp_fragment_too_long_fragment,
792 { "IDMP fragment too long", "idmp.fragment.too_long_fragment",
793 FT_BOOLEAN, BASE_NONE, NULL, 0x00, "Message fragment too long",
795 { &hf_idmp_fragment_error,
796 { "IDMP defragmentation error", "idmp.fragment.error", FT_FRAMENUM,
797 BASE_NONE, NULL, 0x00, "Message defragmentation error", HFILL } },
798 { &hf_idmp_reassembled_in,
799 { "Reassembled IDMP in frame", "idmp.reassembled.in", FT_FRAMENUM, BASE_NONE,
800 NULL, 0x00, "This IDMP packet is reassembled in this frame", HFILL } },
801 { &hf_idmp_reassembled_length,
802 { "Reassembled IDMP length", "idmp.reassembled.length", FT_UINT32, BASE_DEC,
803 NULL, 0x00, "The total length of the reassembled payload", HFILL } },
806 /*--- Included file: packet-idmp-hfarr.c ---*/
807 #line 1 "packet-idmp-hfarr.c"
809 { "bind", "idmp.bind",
810 FT_NONE, BASE_NONE, NULL, 0,
812 { &hf_idmp_bindResult,
813 { "bindResult", "idmp.bindResult",
814 FT_NONE, BASE_NONE, NULL, 0,
815 "IdmBindResult", HFILL }},
816 { &hf_idmp_bindError,
817 { "bindError", "idmp.bindError",
818 FT_NONE, BASE_NONE, NULL, 0,
819 "IdmBindError", HFILL }},
821 { "request", "idmp.request",
822 FT_NONE, BASE_NONE, NULL, 0,
824 { &hf_idmp_idm_result,
825 { "result", "idmp.result",
826 FT_NONE, BASE_NONE, NULL, 0,
827 "IdmResult", HFILL }},
828 { &hf_idmp_idm_error,
829 { "error", "idmp.error",
830 FT_NONE, BASE_NONE, NULL, 0,
833 { "reject", "idmp.reject",
834 FT_NONE, BASE_NONE, NULL, 0,
835 "IdmReject", HFILL }},
837 { "unbind", "idmp.unbind",
838 FT_NONE, BASE_NONE, NULL, 0,
841 { "abort", "idmp.abort",
842 FT_UINT32, BASE_DEC, VALS(idmp_Abort_vals), 0,
845 { "startTLS", "idmp.startTLS",
846 FT_NONE, BASE_NONE, NULL, 0,
848 { &hf_idmp_tLSResponse,
849 { "tLSResponse", "idmp.tLSResponse",
850 FT_UINT32, BASE_DEC, VALS(idmp_TLSResponse_vals), 0,
852 { &hf_idmp_protocolID,
853 { "protocolID", "idmp.protocolID",
854 FT_OID, BASE_NONE, NULL, 0,
855 "OBJECT_IDENTIFIER", HFILL }},
856 { &hf_idmp_callingAETitle,
857 { "callingAETitle", "idmp.callingAETitle",
858 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
859 "GeneralName", HFILL }},
860 { &hf_idmp_calledAETitle,
861 { "calledAETitle", "idmp.calledAETitle",
862 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
863 "GeneralName", HFILL }},
864 { &hf_idmp_bind_argument,
865 { "argument", "idmp.argument",
866 FT_NONE, BASE_NONE, NULL, 0,
867 "Bind_argument", HFILL }},
868 { &hf_idmp_respondingAETitle,
869 { "respondingAETitle", "idmp.respondingAETitle",
870 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
871 "GeneralName", HFILL }},
872 { &hf_idmp_bind_result,
873 { "result", "idmp.result",
874 FT_NONE, BASE_NONE, NULL, 0,
875 "Bind_result", HFILL }},
876 { &hf_idmp_bind_errcode,
877 { "errcode", "idmp.errcode",
878 FT_NONE, BASE_NONE, NULL, 0,
879 "Bind_errcode", HFILL }},
880 { &hf_idmp_aETitleError,
881 { "aETitleError", "idmp.aETitleError",
882 FT_UINT32, BASE_DEC, VALS(idmp_T_aETitleError_vals), 0,
884 { &hf_idmp_bind_error,
885 { "error", "idmp.error",
886 FT_NONE, BASE_NONE, NULL, 0,
887 "Bind_error", HFILL }},
889 { "invokeID", "idmp.invokeID",
890 FT_INT32, BASE_DEC, NULL, 0,
893 { "opcode", "idmp.opcode",
894 FT_UINT32, BASE_DEC, VALS(idmp_Code_vals), 0,
897 { "argument", "idmp.argument",
898 FT_NONE, BASE_NONE, NULL, 0,
900 { &hf_idmp_idm_invokeID,
901 { "invokeID", "idmp.invokeID",
902 FT_UINT32, BASE_DEC, VALS(idmp_InvokeId_vals), 0,
905 { "result", "idmp.result",
906 FT_NONE, BASE_NONE, NULL, 0,
909 { "errcode", "idmp.errcode",
910 FT_NONE, BASE_NONE, NULL, 0,
913 { "error", "idmp.error",
914 FT_NONE, BASE_NONE, NULL, 0,
917 { "reason", "idmp.reason",
918 FT_UINT32, BASE_DEC, VALS(idmp_T_reason_vals), 0,
921 { "local", "idmp.local",
922 FT_INT32, BASE_DEC, NULL, 0,
925 { "global", "idmp.global",
926 FT_OID, BASE_NONE, NULL, 0,
927 "OBJECT_IDENTIFIER", HFILL }},
929 { "present", "idmp.present",
930 FT_INT32, BASE_DEC, NULL, 0,
933 { "absent", "idmp.absent",
934 FT_NONE, BASE_NONE, NULL, 0,
937 /*--- End of included file: packet-idmp-hfarr.c ---*/
938 #line 324 "packet-idmp-template.c"
941 /* List of subtrees */
942 static gint *ett[] = {
947 /*--- Included file: packet-idmp-ettarr.c ---*/
948 #line 1 "packet-idmp-ettarr.c"
951 &ett_idmp_IdmBindResult,
952 &ett_idmp_IdmBindError,
960 /*--- End of included file: packet-idmp-ettarr.c ---*/
961 #line 332 "packet-idmp-template.c"
963 module_t *idmp_module;
965 /* Register protocol */
966 proto_idmp = proto_register_protocol(PNAME, PSNAME, PFNAME);
968 /* Register fields and subtrees */
969 proto_register_field_array(proto_idmp, hf, array_length(hf));
970 proto_register_subtree_array(ett, array_length(ett));
972 register_dissector("idmp", dissect_idmp_tcp, proto_idmp);
974 register_init_routine (&idmp_reassemble_init);
976 /* Register our configuration options for IDMP, particularly our port */
978 idmp_module = prefs_register_protocol_subtree("OSI/X.500", proto_idmp, prefs_register_idmp);
980 prefs_register_bool_preference(idmp_module, "desegment_idmp_messages",
981 "Reassemble IDMP messages spanning multiple TCP segments",
982 "Whether the IDMP dissector should reassemble messages spanning multiple TCP segments."
983 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
986 prefs_register_bool_preference(idmp_module, "reassemble",
987 "Reassemble segmented IDMP datagrams",
988 "Whether segmented IDMP datagrams should be reassembled."
989 " To use this option, you must also enable"
990 " \"Allow subdissectors to reassemble TCP streams\""
991 " in the TCP protocol settings.", &idmp_reassemble);
993 prefs_register_uint_preference(idmp_module, "tcp.port", "IDMP TCP Port",
994 "Set the port for Internet Directly Mapped Protocol requests/responses",
995 10, &global_idmp_tcp_port);
1000 /*--- proto_reg_handoff_idm --- */
1001 void proto_reg_handoff_idm(void) {
1003 /* remember the idm handler for change in preferences */
1004 idmp_handle = find_dissector(PFNAME);
1009 void prefs_register_idmp(void) {
1011 /* de-register the old port */
1012 /* port 102 is registered by TPKT - don't undo this! */
1014 dissector_delete("tcp.port", tcp_port, idmp_handle);
1016 /* Set our port number for future use */
1017 tcp_port = global_idmp_tcp_port;
1019 if((tcp_port > 0) && idmp_handle)
1020 dissector_add("tcp.port", global_idmp_tcp_port, idmp_handle);