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 -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 const char *protocolID = NULL;
67 static const char *saved_protocolID = NULL;
68 static guint32 opcode = -1;
70 static void prefs_register_idmp(void); /* forward declaration for use in preferences registration */
72 /* Initialize the protocol and registered fields */
75 static int hf_idmp_version = -1;
76 static int hf_idmp_final = -1;
77 static int hf_idmp_length = -1;
78 static int hf_idmp_PDU = -1;
80 static GHashTable *idmp_segment_table = NULL;
81 static GHashTable *idmp_reassembled_table = NULL;
83 static int hf_idmp_fragments = -1;
84 static int hf_idmp_fragment = -1;
85 static int hf_idmp_fragment_overlap = -1;
86 static int hf_idmp_fragment_overlap_conflicts = -1;
87 static int hf_idmp_fragment_multiple_tails = -1;
88 static int hf_idmp_fragment_too_long_fragment = -1;
89 static int hf_idmp_fragment_error = -1;
90 static int hf_idmp_reassembled_in = -1;
91 static int hf_idmp_reassembled_length = -1;
93 static gint ett_idmp_fragment = -1;
94 static gint ett_idmp_fragments = -1;
96 static const fragment_items idmp_frag_items = {
97 /* Fragment subtrees */
100 /* Fragment fields */
103 &hf_idmp_fragment_overlap,
104 &hf_idmp_fragment_overlap_conflicts,
105 &hf_idmp_fragment_multiple_tails,
106 &hf_idmp_fragment_too_long_fragment,
107 &hf_idmp_fragment_error,
108 /* Reassembled in field */
109 &hf_idmp_reassembled_in,
110 /* Reassembled length field */
111 &hf_idmp_reassembled_length,
117 static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo, int op, proto_tree *tree _U_)
119 struct SESSION_DATA_STRUCTURE *session;
121 if((session = (struct SESSION_DATA_STRUCTURE*)pinfo->private_data) != NULL) {
123 if((!saved_protocolID) && (op == (ROS_OP_BIND | ROS_OP_RESULT))) {
124 /* save for subsequent operations - should be into session data */
125 saved_protocolID = se_strdup(protocolID);
129 session->ros_op = op;
130 offset = call_ros_oid_callback(saved_protocolID ? saved_protocolID : protocolID, tvb, offset, pinfo, top_tree);
138 /*--- Included file: packet-idmp-hf.c ---*/
139 #line 1 "packet-idmp-hf.c"
140 static int hf_idmp_bind = -1; /* IdmBind */
141 static int hf_idmp_bindResult = -1; /* IdmBindResult */
142 static int hf_idmp_bindError = -1; /* IdmBindError */
143 static int hf_idmp_request = -1; /* Request */
144 static int hf_idmp_idm_result = -1; /* IdmResult */
145 static int hf_idmp_idm_error = -1; /* Error */
146 static int hf_idmp_reject = -1; /* IdmReject */
147 static int hf_idmp_unbind = -1; /* Unbind */
148 static int hf_idmp_abort = -1; /* Abort */
149 static int hf_idmp_startTLS = -1; /* StartTLS */
150 static int hf_idmp_tLSResponse = -1; /* TLSResponse */
151 static int hf_idmp_protocolID = -1; /* OBJECT_IDENTIFIER */
152 static int hf_idmp_callingAETitle = -1; /* GeneralName */
153 static int hf_idmp_calledAETitle = -1; /* GeneralName */
154 static int hf_idmp_bind_argument = -1; /* Bind_argument */
155 static int hf_idmp_respondingAETitle = -1; /* GeneralName */
156 static int hf_idmp_bind_result = -1; /* Bind_result */
157 static int hf_idmp_bind_errcode = -1; /* Bind_errcode */
158 static int hf_idmp_aETitleError = -1; /* T_aETitleError */
159 static int hf_idmp_bind_error = -1; /* Bind_error */
160 static int hf_idmp_invokeID = -1; /* INTEGER */
161 static int hf_idmp_opcode = -1; /* Code */
162 static int hf_idmp_argument = -1; /* T_argument */
163 static int hf_idmp_idm_invokeID = -1; /* InvokeId */
164 static int hf_idmp_result = -1; /* T_result */
165 static int hf_idmp_errcode = -1; /* T_errcode */
166 static int hf_idmp_error = -1; /* T_error */
167 static int hf_idmp_reason = -1; /* T_reason */
168 static int hf_idmp_local = -1; /* T_local */
169 static int hf_idmp_global = -1; /* OBJECT_IDENTIFIER */
170 static int hf_idmp_present = -1; /* INTEGER */
171 static int hf_idmp_absent = -1; /* NULL */
173 /*--- End of included file: packet-idmp-hf.c ---*/
174 #line 130 "packet-idmp-template.c"
176 /* Initialize the subtree pointers */
177 static gint ett_idmp = -1;
179 /*--- Included file: packet-idmp-ett.c ---*/
180 #line 1 "packet-idmp-ett.c"
181 static gint ett_idmp_IDM_PDU = -1;
182 static gint ett_idmp_IdmBind = -1;
183 static gint ett_idmp_IdmBindResult = -1;
184 static gint ett_idmp_IdmBindError = -1;
185 static gint ett_idmp_Request = -1;
186 static gint ett_idmp_IdmResult = -1;
187 static gint ett_idmp_Error = -1;
188 static gint ett_idmp_IdmReject = -1;
189 static gint ett_idmp_Code = -1;
190 static gint ett_idmp_InvokeId = -1;
192 /*--- End of included file: packet-idmp-ett.c ---*/
193 #line 134 "packet-idmp-template.c"
196 /*--- Included file: packet-idmp-fn.c ---*/
197 #line 1 "packet-idmp-fn.c"
201 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_) {
202 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &protocolID);
210 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_) {
212 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_ARGUMENT), top_tree);
219 static const ber_sequence_t IdmBind_sequence[] = {
220 { &hf_idmp_protocolID , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
221 { &hf_idmp_callingAETitle , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
222 { &hf_idmp_calledAETitle , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
223 { &hf_idmp_bind_argument , BER_CLASS_CON, 2, 0, dissect_idmp_Bind_argument },
224 { NULL, 0, 0, 0, NULL }
228 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_) {
229 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
230 IdmBind_sequence, hf_index, ett_idmp_IdmBind);
238 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_) {
240 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_RESULT), top_tree);
247 static const ber_sequence_t IdmBindResult_sequence[] = {
248 { &hf_idmp_protocolID , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
249 { &hf_idmp_respondingAETitle, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
250 { &hf_idmp_bind_result , BER_CLASS_CON, 1, 0, dissect_idmp_Bind_result },
251 { NULL, 0, 0, 0, NULL }
255 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_) {
256 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
257 IdmBindResult_sequence, hf_index, ett_idmp_IdmBindResult);
265 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_) {
272 static const value_string idmp_T_aETitleError_vals[] = {
273 { 0, "callingAETitleNotAccepted" },
274 { 1, "calledAETitleNotRecognized" },
280 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_) {
281 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
290 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_) {
292 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND| ROS_OP_ERROR), top_tree);
299 static const ber_sequence_t IdmBindError_sequence[] = {
300 { &hf_idmp_protocolID , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
301 { &hf_idmp_bind_errcode , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_Bind_errcode },
302 { &hf_idmp_respondingAETitle, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
303 { &hf_idmp_aETitleError , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_idmp_T_aETitleError },
304 { &hf_idmp_bind_error , BER_CLASS_CON, 1, 0, dissect_idmp_Bind_error },
305 { NULL, 0, 0, 0, NULL }
309 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_) {
310 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
311 IdmBindError_sequence, hf_index, ett_idmp_IdmBindError);
319 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_) {
320 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
329 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_) {
330 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
337 static const value_string idmp_Code_vals[] = {
343 static const ber_choice_t Code_choice[] = {
344 { 0, &hf_idmp_local , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_T_local },
345 { 1, &hf_idmp_global , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
346 { 0, NULL, 0, 0, 0, NULL }
350 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_) {
351 offset = dissect_ber_choice(actx, tree, tvb, offset,
352 Code_choice, hf_index, ett_idmp_Code,
361 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_) {
363 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_ARGUMENT | opcode), top_tree);
370 static const ber_sequence_t Request_sequence[] = {
371 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
372 { &hf_idmp_opcode , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_Code },
373 { &hf_idmp_argument , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_argument },
374 { NULL, 0, 0, 0, NULL }
378 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_) {
379 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
380 Request_sequence, hf_index, ett_idmp_Request);
388 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_) {
389 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
395 static const value_string idmp_InvokeId_vals[] = {
401 static const ber_choice_t InvokeId_choice[] = {
402 { 0, &hf_idmp_present , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
403 { 1, &hf_idmp_absent , BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_idmp_NULL },
404 { 0, NULL, 0, 0, 0, NULL }
408 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_) {
409 offset = dissect_ber_choice(actx, tree, tvb, offset,
410 InvokeId_choice, hf_index, ett_idmp_InvokeId,
419 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_) {
421 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_RESULT | opcode), top_tree);
429 static const ber_sequence_t IdmResult_sequence[] = {
430 { &hf_idmp_idm_invokeID , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_InvokeId },
431 { &hf_idmp_opcode , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_Code },
432 { &hf_idmp_result , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_result },
433 { NULL, 0, 0, 0, NULL }
437 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_) {
438 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
439 IdmResult_sequence, hf_index, ett_idmp_IdmResult);
447 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_) {
456 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_) {
463 static const ber_sequence_t Error_sequence[] = {
464 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
465 { &hf_idmp_errcode , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_errcode },
466 { &hf_idmp_error , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_error },
467 { NULL, 0, 0, 0, NULL }
471 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_) {
472 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
473 Error_sequence, hf_index, ett_idmp_Error);
479 static const value_string idmp_T_reason_vals[] = {
480 { 0, "mistypedPDU" },
481 { 1, "duplicateInvokeIDRequest" },
482 { 2, "unsupportedOperationRequest" },
483 { 3, "unknownOperationRequest" },
484 { 4, "mistypedArgumentRequest" },
485 { 5, "resourceLimitationRequest" },
486 { 6, "unknownInvokeIDResult" },
487 { 7, "mistypedResultRequest" },
488 { 8, "unknownInvokeIDError" },
489 { 9, "unknownError" },
490 { 10, "mistypedParameterError" },
496 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_) {
497 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
504 static const ber_sequence_t IdmReject_sequence[] = {
505 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
506 { &hf_idmp_reason , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_idmp_T_reason },
507 { NULL, 0, 0, 0, NULL }
511 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_) {
512 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
513 IdmReject_sequence, hf_index, ett_idmp_IdmReject);
521 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_) {
522 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
528 static const value_string idmp_Abort_vals[] = {
529 { 0, "mistypedPDU" },
530 { 1, "unboundRequest" },
532 { 3, "resourceLimitation" },
533 { 4, "connectionFailed" },
534 { 5, "invalidProtocol" },
535 { 6, "reasonNotSpecified" },
541 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_) {
542 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
551 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_) {
552 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
558 static const value_string idmp_TLSResponse_vals[] = {
560 { 1, "operationsError" },
561 { 2, "protocolError" },
562 { 3, "unavailable" },
568 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_) {
569 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
576 static const value_string idmp_IDM_PDU_vals[] = {
587 { 10, "tLSResponse" },
591 static const ber_choice_t IDM_PDU_choice[] = {
592 { 0, &hf_idmp_bind , BER_CLASS_CON, 0, 0, dissect_idmp_IdmBind },
593 { 1, &hf_idmp_bindResult , BER_CLASS_CON, 1, 0, dissect_idmp_IdmBindResult },
594 { 2, &hf_idmp_bindError , BER_CLASS_CON, 2, 0, dissect_idmp_IdmBindError },
595 { 3, &hf_idmp_request , BER_CLASS_CON, 3, 0, dissect_idmp_Request },
596 { 4, &hf_idmp_idm_result , BER_CLASS_CON, 4, 0, dissect_idmp_IdmResult },
597 { 5, &hf_idmp_idm_error , BER_CLASS_CON, 5, 0, dissect_idmp_Error },
598 { 6, &hf_idmp_reject , BER_CLASS_CON, 6, 0, dissect_idmp_IdmReject },
599 { 7, &hf_idmp_unbind , BER_CLASS_CON, 7, 0, dissect_idmp_Unbind },
600 { 8, &hf_idmp_abort , BER_CLASS_CON, 8, 0, dissect_idmp_Abort },
601 { 9, &hf_idmp_startTLS , BER_CLASS_CON, 9, 0, dissect_idmp_StartTLS },
602 { 10, &hf_idmp_tLSResponse , BER_CLASS_CON, 10, 0, dissect_idmp_TLSResponse },
603 { 0, NULL, 0, 0, 0, NULL }
607 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_) {
608 offset = dissect_ber_choice(actx, tree, tvb, offset,
609 IDM_PDU_choice, hf_index, ett_idmp_IDM_PDU,
616 /*--- End of included file: packet-idmp-fn.c ---*/
617 #line 136 "packet-idmp-template.c"
620 register_idmp_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name)
622 /* just register with ROS for now */
623 register_ros_protocol_info(oid, rinfo, proto, name, FALSE);
627 static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
631 proto_item *item=NULL;
632 proto_tree *tree=NULL;
634 void *save_private_data;
635 struct SESSION_DATA_STRUCTURE session;
638 fragment_data *fd_head;
639 conversation_t *conv;
642 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
644 conv = find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
645 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
647 /* Found a conversation, also use index for the generated dst_ref */
648 dst_ref = conv->index;
651 /* save parent_tree so subdissectors can create new top nodes */
652 top_tree=parent_tree;
655 item = proto_tree_add_item(parent_tree, proto_idmp, tvb, 0, -1, FALSE);
656 tree = proto_item_add_subtree(item, ett_idmp);
659 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IDMP");
661 /* now check the segment fields */
663 proto_tree_add_item(tree, hf_idmp_version, tvb, offset, 1, FALSE); offset++;
664 proto_tree_add_item(tree, hf_idmp_final, tvb, offset, 1, FALSE);
665 idmp_final = tvb_get_guint8(tvb, offset); offset++;
666 proto_tree_add_item(tree, hf_idmp_length, tvb, offset, 4, FALSE);
667 idmp_length = tvb_get_ntohl(tvb, offset); offset += 4;
669 if(idmp_reassemble) {
671 pinfo->fragmented = !idmp_final;
673 if (check_col(pinfo->cinfo, COL_INFO))
674 col_append_fstr(pinfo->cinfo, COL_INFO, " [%sIDMP fragment, %u byte%s]",
675 idmp_final ? "Final " : "" ,
676 idmp_length, plurality(idmp_length, "", "s"));
678 fd_head = fragment_add_seq_next(tvb, offset, pinfo, dst_ref,
679 idmp_segment_table, idmp_reassembled_table,
680 idmp_length, !idmp_final);
682 if(fd_head && fd_head->next) {
683 proto_tree_add_text(tree, tvb, offset, (idmp_length) ? -1 : 0,
684 "IDMP segment data (%u byte%s)", idmp_length,
685 plurality(idmp_length, "", "s"));
688 /* This is the last segment */
689 tvb = process_reassembled_data (tvb, offset, pinfo,
690 "Reassembled IDMP", fd_head, &idmp_frag_items, NULL, tree);
692 } else if (pinfo->fd->num != fd_head->reassembled_in) {
693 /* Add a "Reassembled in" link if not reassembled in this frame */
694 proto_tree_add_uint (tree, hf_idmp_reassembled_in,
695 tvb, 0, 0, fd_head->reassembled_in);
702 if (check_col(pinfo->cinfo, COL_INFO))
703 col_append_fstr(pinfo->cinfo, COL_INFO, " [IDMP fragment, %u byte%s, IDMP reassembly not enabled]",
704 idmp_length, plurality(idmp_length, "", "s"));
706 proto_tree_add_text(tree, tvb, offset, (idmp_length) ? -1 : 0,
707 "IDMP segment data (%u byte%s) (IDMP reassembly not enabled)", idmp_length,
708 plurality(idmp_length, "", "s"));
711 /* not reassembling - just dissect */
713 save_private_data = pinfo->private_data;
714 pinfo->private_data = &session;
716 offset = dissect_idmp_IDM_PDU(FALSE, tvb, offset, &asn1_ctx, tree, hf_idmp_PDU);
718 pinfo->private_data = save_private_data;
723 static guint get_idmp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
727 len = tvb_get_ntohl(tvb, offset + 2);
732 static void dissect_idmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
735 tcp_dissect_pdus(tvb, pinfo, parent_tree, idmp_desegment, 0, get_idmp_pdu_len, dissect_idmp);
739 static void idmp_reassemble_init (void)
741 fragment_table_init (&idmp_segment_table);
742 reassembled_table_init (&idmp_reassembled_table);
744 saved_protocolID = NULL;
747 /*--- proto_register_idmp -------------------------------------------*/
748 void proto_register_idmp(void) {
751 static hf_register_info hf[] =
754 { "version", "idmp.version",
755 FT_INT8, BASE_DEC, NULL, 0,
756 "idmp.INTEGER", HFILL }},
758 { "final", "idmp.final",
759 FT_BOOLEAN, 8, NULL, 0,
760 "idmp.BOOLEAN", HFILL }},
762 { "length", "idmp.length",
763 FT_INT32, BASE_DEC, NULL, 0,
764 "idmp.INTEGER", HFILL }},
766 { "IDM-PDU", "idmp.pdu",
767 FT_UINT32, BASE_DEC, VALS(idmp_IDM_PDU_vals), 0,
768 "idmp.PDU", HFILL }},
769 /* Fragment entries */
770 { &hf_idmp_fragments,
771 { "IDMP fragments", "idmp.fragments", FT_NONE, BASE_NONE,
772 NULL, 0x00, NULL, HFILL } },
774 { "IDMP fragment", "idmp.fragment", FT_FRAMENUM, BASE_NONE,
775 NULL, 0x00, NULL, HFILL } },
776 { &hf_idmp_fragment_overlap,
777 { "IDMP fragment overlap", "idmp.fragment.overlap", FT_BOOLEAN,
778 BASE_NONE, NULL, 0x00, NULL, HFILL } },
779 { &hf_idmp_fragment_overlap_conflicts,
780 { "IDMP fragment overlapping with conflicting data",
781 "idmp.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE,
782 NULL, 0x00, NULL, HFILL } },
783 { &hf_idmp_fragment_multiple_tails,
784 { "IDMP has multiple tail fragments",
785 "idmp.fragment.multiple_tails", FT_BOOLEAN, BASE_NONE,
786 NULL, 0x00, NULL, HFILL } },
787 { &hf_idmp_fragment_too_long_fragment,
788 { "IDMP fragment too long", "idmp.fragment.too_long_fragment",
789 FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } },
790 { &hf_idmp_fragment_error,
791 { "IDMP defragmentation error", "idmp.fragment.error", FT_FRAMENUM,
792 BASE_NONE, NULL, 0x00, NULL, HFILL } },
793 { &hf_idmp_reassembled_in,
794 { "Reassembled IDMP in frame", "idmp.reassembled.in", FT_FRAMENUM, BASE_NONE,
795 NULL, 0x00, "This IDMP packet is reassembled in this frame", HFILL } },
796 { &hf_idmp_reassembled_length,
797 { "Reassembled IDMP length", "idmp.reassembled.length", FT_UINT32, BASE_DEC,
798 NULL, 0x00, "The total length of the reassembled payload", HFILL } },
801 /*--- Included file: packet-idmp-hfarr.c ---*/
802 #line 1 "packet-idmp-hfarr.c"
804 { "bind", "idmp.bind",
805 FT_NONE, BASE_NONE, NULL, 0,
807 { &hf_idmp_bindResult,
808 { "bindResult", "idmp.bindResult",
809 FT_NONE, BASE_NONE, NULL, 0,
810 "IdmBindResult", HFILL }},
811 { &hf_idmp_bindError,
812 { "bindError", "idmp.bindError",
813 FT_NONE, BASE_NONE, NULL, 0,
814 "IdmBindError", HFILL }},
816 { "request", "idmp.request",
817 FT_NONE, BASE_NONE, NULL, 0,
819 { &hf_idmp_idm_result,
820 { "result", "idmp.result",
821 FT_NONE, BASE_NONE, NULL, 0,
822 "IdmResult", HFILL }},
823 { &hf_idmp_idm_error,
824 { "error", "idmp.error",
825 FT_NONE, BASE_NONE, NULL, 0,
828 { "reject", "idmp.reject",
829 FT_NONE, BASE_NONE, NULL, 0,
830 "IdmReject", HFILL }},
832 { "unbind", "idmp.unbind",
833 FT_NONE, BASE_NONE, NULL, 0,
836 { "abort", "idmp.abort",
837 FT_UINT32, BASE_DEC, VALS(idmp_Abort_vals), 0,
840 { "startTLS", "idmp.startTLS",
841 FT_NONE, BASE_NONE, NULL, 0,
843 { &hf_idmp_tLSResponse,
844 { "tLSResponse", "idmp.tLSResponse",
845 FT_UINT32, BASE_DEC, VALS(idmp_TLSResponse_vals), 0,
847 { &hf_idmp_protocolID,
848 { "protocolID", "idmp.protocolID",
849 FT_OID, BASE_NONE, NULL, 0,
850 "OBJECT_IDENTIFIER", HFILL }},
851 { &hf_idmp_callingAETitle,
852 { "callingAETitle", "idmp.callingAETitle",
853 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
854 "GeneralName", HFILL }},
855 { &hf_idmp_calledAETitle,
856 { "calledAETitle", "idmp.calledAETitle",
857 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
858 "GeneralName", HFILL }},
859 { &hf_idmp_bind_argument,
860 { "argument", "idmp.argument",
861 FT_NONE, BASE_NONE, NULL, 0,
862 "Bind_argument", HFILL }},
863 { &hf_idmp_respondingAETitle,
864 { "respondingAETitle", "idmp.respondingAETitle",
865 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
866 "GeneralName", HFILL }},
867 { &hf_idmp_bind_result,
868 { "result", "idmp.result",
869 FT_NONE, BASE_NONE, NULL, 0,
870 "Bind_result", HFILL }},
871 { &hf_idmp_bind_errcode,
872 { "errcode", "idmp.errcode",
873 FT_NONE, BASE_NONE, NULL, 0,
874 "Bind_errcode", HFILL }},
875 { &hf_idmp_aETitleError,
876 { "aETitleError", "idmp.aETitleError",
877 FT_UINT32, BASE_DEC, VALS(idmp_T_aETitleError_vals), 0,
879 { &hf_idmp_bind_error,
880 { "error", "idmp.error",
881 FT_NONE, BASE_NONE, NULL, 0,
882 "Bind_error", HFILL }},
884 { "invokeID", "idmp.invokeID",
885 FT_INT32, BASE_DEC, NULL, 0,
888 { "opcode", "idmp.opcode",
889 FT_UINT32, BASE_DEC, VALS(idmp_Code_vals), 0,
892 { "argument", "idmp.argument",
893 FT_NONE, BASE_NONE, NULL, 0,
895 { &hf_idmp_idm_invokeID,
896 { "invokeID", "idmp.invokeID",
897 FT_UINT32, BASE_DEC, VALS(idmp_InvokeId_vals), 0,
900 { "result", "idmp.result",
901 FT_NONE, BASE_NONE, NULL, 0,
904 { "errcode", "idmp.errcode",
905 FT_NONE, BASE_NONE, NULL, 0,
908 { "error", "idmp.error",
909 FT_NONE, BASE_NONE, NULL, 0,
912 { "reason", "idmp.reason",
913 FT_UINT32, BASE_DEC, VALS(idmp_T_reason_vals), 0,
916 { "local", "idmp.local",
917 FT_INT32, BASE_DEC, NULL, 0,
920 { "global", "idmp.global",
921 FT_OID, BASE_NONE, NULL, 0,
922 "OBJECT_IDENTIFIER", HFILL }},
924 { "present", "idmp.present",
925 FT_INT32, BASE_DEC, NULL, 0,
928 { "absent", "idmp.absent",
929 FT_NONE, BASE_NONE, NULL, 0,
932 /*--- End of included file: packet-idmp-hfarr.c ---*/
933 #line 319 "packet-idmp-template.c"
936 /* List of subtrees */
937 static gint *ett[] = {
942 /*--- Included file: packet-idmp-ettarr.c ---*/
943 #line 1 "packet-idmp-ettarr.c"
946 &ett_idmp_IdmBindResult,
947 &ett_idmp_IdmBindError,
955 /*--- End of included file: packet-idmp-ettarr.c ---*/
956 #line 327 "packet-idmp-template.c"
958 module_t *idmp_module;
960 /* Register protocol */
961 proto_idmp = proto_register_protocol(PNAME, PSNAME, PFNAME);
963 /* Register fields and subtrees */
964 proto_register_field_array(proto_idmp, hf, array_length(hf));
965 proto_register_subtree_array(ett, array_length(ett));
967 register_dissector("idmp", dissect_idmp_tcp, proto_idmp);
969 register_init_routine (&idmp_reassemble_init);
971 /* Register our configuration options for IDMP, particularly our port */
973 idmp_module = prefs_register_protocol_subtree("OSI/X.500", proto_idmp, prefs_register_idmp);
975 prefs_register_bool_preference(idmp_module, "desegment_idmp_messages",
976 "Reassemble IDMP messages spanning multiple TCP segments",
977 "Whether the IDMP dissector should reassemble messages spanning multiple TCP segments."
978 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
981 prefs_register_bool_preference(idmp_module, "reassemble",
982 "Reassemble segmented IDMP datagrams",
983 "Whether segmented IDMP datagrams should be reassembled."
984 " To use this option, you must also enable"
985 " \"Allow subdissectors to reassemble TCP streams\""
986 " in the TCP protocol settings.", &idmp_reassemble);
988 prefs_register_uint_preference(idmp_module, "tcp.port", "IDMP TCP Port",
989 "Set the port for Internet Directly Mapped Protocol requests/responses",
990 10, &global_idmp_tcp_port);
995 /*--- proto_reg_handoff_idm --- */
996 void proto_reg_handoff_idm(void) {
998 /* remember the idm handler for change in preferences */
999 idmp_handle = find_dissector(PFNAME);
1005 prefs_register_idmp(void)
1008 /* de-register the old port */
1009 /* port 102 is registered by TPKT - don't undo this! */
1011 dissector_delete_uint("tcp.port", tcp_port, idmp_handle);
1013 /* Set our port number for future use */
1014 tcp_port = global_idmp_tcp_port;
1016 if((tcp_port > 0) && idmp_handle)
1017 dissector_add_uint("tcp.port", global_idmp_tcp_port, idmp_handle);