HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-idmp.c
blobbfc95a309fc92ef1bcb022c41063dee923920f95
1 /* Do not modify this file. Changes will be overwritten. */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler */
3 /* packet-idmp.c */
4 /* ../../tools/asn2wrs.py -b -L -p idmp -c ./idmp.cnf -s ./packet-idmp-template -D . -O ../../epan/dissectors IDMProtocolSpecification.asn CommonProtocolSpecification.asn */
6 /* Input file: packet-idmp-template.c */
8 #line 1 "../../asn1/idmp/packet-idmp-template.c"
9 /* packet-idmp.c
10 * Routines for X.519 Internet Directly Mapped Procotol (IDMP) packet dissection
11 * Graeme Lunt 2010
13 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 #include "config.h"
36 #include <glib.h>
37 #include <epan/packet.h>
38 #include <epan/prefs.h>
39 #include <epan/wmem/wmem.h>
40 #include <epan/reassemble.h>
41 #include <epan/conversation.h>
42 #include <epan/oids.h>
43 #include <epan/asn1.h>
44 #include <epan/ipproto.h>
46 #include <epan/dissectors/packet-tcp.h>
48 #include "packet-ber.h"
49 #include "packet-ros.h"
50 #include "packet-x509ce.h"
52 #include <epan/strutil.h>
54 #define PNAME "X.519 Internet Directly Mapped Protocol"
55 #define PSNAME "IDMP"
56 #define PFNAME "idmp"
58 static gboolean idmp_desegment = TRUE;
59 static guint global_idmp_tcp_port = 1102; /* made up for now */
60 static gboolean idmp_reassemble = TRUE;
61 static guint tcp_port = 0;
62 static dissector_handle_t idmp_handle = NULL;
64 static proto_tree *top_tree = NULL;
65 static const char *protocolID = NULL;
66 static const char *saved_protocolID = NULL;
67 static guint32 opcode = -1;
69 static void prefs_register_idmp(void); /* forward declaration for use in preferences registration */
71 /* Initialize the protocol and registered fields */
72 int proto_idmp = -1;
74 static int hf_idmp_version = -1;
75 static int hf_idmp_final = -1;
76 static int hf_idmp_length = -1;
77 static int hf_idmp_PDU = -1;
79 static reassembly_table idmp_reassembly_table;
81 static int hf_idmp_fragments = -1;
82 static int hf_idmp_fragment = -1;
83 static int hf_idmp_fragment_overlap = -1;
84 static int hf_idmp_fragment_overlap_conflicts = -1;
85 static int hf_idmp_fragment_multiple_tails = -1;
86 static int hf_idmp_fragment_too_long_fragment = -1;
87 static int hf_idmp_fragment_error = -1;
88 static int hf_idmp_fragment_count = -1;
89 static int hf_idmp_reassembled_in = -1;
90 static int hf_idmp_reassembled_length = -1;
92 static gint ett_idmp_fragment = -1;
93 static gint ett_idmp_fragments = -1;
95 static const fragment_items idmp_frag_items = {
96 /* Fragment subtrees */
97 &ett_idmp_fragment,
98 &ett_idmp_fragments,
99 /* Fragment fields */
100 &hf_idmp_fragments,
101 &hf_idmp_fragment,
102 &hf_idmp_fragment_overlap,
103 &hf_idmp_fragment_overlap_conflicts,
104 &hf_idmp_fragment_multiple_tails,
105 &hf_idmp_fragment_too_long_fragment,
106 &hf_idmp_fragment_error,
107 &hf_idmp_fragment_count,
108 /* Reassembled in field */
109 &hf_idmp_reassembled_in,
110 /* Reassembled length field */
111 &hf_idmp_reassembled_length,
112 /* Reassembled data field */
113 NULL,
114 /* Tag */
115 "IDMP fragments"
119 static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo, int op, proto_tree *tree, struct SESSION_DATA_STRUCTURE *session)
121 if(session != 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 = wmem_strdup(wmem_file_scope(), protocolID);
128 /* mimic ROS! */
129 session->ros_op = op;
130 offset = call_ros_oid_callback(saved_protocolID ? saved_protocolID : protocolID, tvb, offset, pinfo, tree, session);
133 return offset;
138 /*--- Included file: packet-idmp-hf.c ---*/
139 #line 1 "../../asn1/idmp/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 "../../asn1/idmp/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 "../../asn1/idmp/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 "../../asn1/idmp/packet-idmp-template.c"
196 /*--- Included file: packet-idmp-fn.c ---*/
197 #line 1 "../../asn1/idmp/packet-idmp-fn.c"
200 static int
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);
204 return offset;
209 static int
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_) {
211 struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
213 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_ARGUMENT), top_tree, session);
216 return offset;
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 }
228 static int
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);
233 return offset;
238 static int
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_) {
240 struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
242 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_RESULT), top_tree, session);
245 return offset;
249 static const ber_sequence_t IdmBindResult_sequence[] = {
250 { &hf_idmp_protocolID , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
251 { &hf_idmp_respondingAETitle, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
252 { &hf_idmp_bind_result , BER_CLASS_CON, 1, 0, dissect_idmp_Bind_result },
253 { NULL, 0, 0, 0, NULL }
256 static int
257 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_) {
258 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
259 IdmBindResult_sequence, hf_index, ett_idmp_IdmBindResult);
261 return offset;
266 static int
267 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_) {
270 return offset;
274 static const value_string idmp_T_aETitleError_vals[] = {
275 { 0, "callingAETitleNotAccepted" },
276 { 1, "calledAETitleNotRecognized" },
277 { 0, NULL }
281 static int
282 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_) {
283 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
284 NULL);
286 return offset;
291 static int
292 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 struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
295 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND| ROS_OP_ERROR), top_tree, session);
298 return offset;
302 static const ber_sequence_t IdmBindError_sequence[] = {
303 { &hf_idmp_protocolID , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
304 { &hf_idmp_bind_errcode , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_Bind_errcode },
305 { &hf_idmp_respondingAETitle, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_x509ce_GeneralName },
306 { &hf_idmp_aETitleError , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_idmp_T_aETitleError },
307 { &hf_idmp_bind_error , BER_CLASS_CON, 1, 0, dissect_idmp_Bind_error },
308 { NULL, 0, 0, 0, NULL }
311 static int
312 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_) {
313 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
314 IdmBindError_sequence, hf_index, ett_idmp_IdmBindError);
316 return offset;
321 static int
322 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_) {
323 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
324 NULL);
326 return offset;
331 static int
332 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_) {
333 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
334 &opcode);
336 return offset;
340 static const value_string idmp_Code_vals[] = {
341 { 0, "local" },
342 { 1, "global" },
343 { 0, NULL }
346 static const ber_choice_t Code_choice[] = {
347 { 0, &hf_idmp_local , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_T_local },
348 { 1, &hf_idmp_global , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_idmp_OBJECT_IDENTIFIER },
349 { 0, NULL, 0, 0, 0, NULL }
352 static int
353 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_) {
354 offset = dissect_ber_choice(actx, tree, tvb, offset,
355 Code_choice, hf_index, ett_idmp_Code,
356 NULL);
358 return offset;
363 static int
364 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_) {
365 struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
367 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_ARGUMENT | opcode), top_tree, session);
370 return offset;
374 static const ber_sequence_t Request_sequence[] = {
375 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
376 { &hf_idmp_opcode , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_Code },
377 { &hf_idmp_argument , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_argument },
378 { NULL, 0, 0, 0, NULL }
381 static int
382 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_) {
383 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
384 Request_sequence, hf_index, ett_idmp_Request);
386 return offset;
391 static int
392 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_) {
393 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
395 return offset;
399 static const value_string idmp_InvokeId_vals[] = {
400 { 0, "present" },
401 { 1, "absent" },
402 { 0, NULL }
405 static const ber_choice_t InvokeId_choice[] = {
406 { 0, &hf_idmp_present , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
407 { 1, &hf_idmp_absent , BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_idmp_NULL },
408 { 0, NULL, 0, 0, 0, NULL }
411 static int
412 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_) {
413 offset = dissect_ber_choice(actx, tree, tvb, offset,
414 InvokeId_choice, hf_index, ett_idmp_InvokeId,
415 NULL);
417 return offset;
422 static int
423 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_) {
424 struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
426 return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_RESULT | opcode), top_tree, session);
429 return offset;
433 static const ber_sequence_t IdmResult_sequence[] = {
434 { &hf_idmp_idm_invokeID , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_InvokeId },
435 { &hf_idmp_opcode , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_idmp_Code },
436 { &hf_idmp_result , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_result },
437 { NULL, 0, 0, 0, NULL }
440 static int
441 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_) {
442 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
443 IdmResult_sequence, hf_index, ett_idmp_IdmResult);
445 return offset;
450 static int
451 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_) {
454 return offset;
459 static int
460 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 return offset;
467 static const ber_sequence_t Error_sequence[] = {
468 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
469 { &hf_idmp_errcode , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_errcode },
470 { &hf_idmp_error , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_idmp_T_error },
471 { NULL, 0, 0, 0, NULL }
474 static int
475 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_) {
476 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
477 Error_sequence, hf_index, ett_idmp_Error);
479 return offset;
483 static const value_string idmp_T_reason_vals[] = {
484 { 0, "mistypedPDU" },
485 { 1, "duplicateInvokeIDRequest" },
486 { 2, "unsupportedOperationRequest" },
487 { 3, "unknownOperationRequest" },
488 { 4, "mistypedArgumentRequest" },
489 { 5, "resourceLimitationRequest" },
490 { 6, "unknownInvokeIDResult" },
491 { 7, "mistypedResultRequest" },
492 { 8, "unknownInvokeIDError" },
493 { 9, "unknownError" },
494 { 10, "mistypedParameterError" },
495 { 0, NULL }
499 static int
500 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_) {
501 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
502 NULL);
504 return offset;
508 static const ber_sequence_t IdmReject_sequence[] = {
509 { &hf_idmp_invokeID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_idmp_INTEGER },
510 { &hf_idmp_reason , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_idmp_T_reason },
511 { NULL, 0, 0, 0, NULL }
514 static int
515 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_) {
516 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
517 IdmReject_sequence, hf_index, ett_idmp_IdmReject);
519 return offset;
524 static int
525 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_) {
526 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
528 return offset;
532 static const value_string idmp_Abort_vals[] = {
533 { 0, "mistypedPDU" },
534 { 1, "unboundRequest" },
535 { 2, "invalidPDU" },
536 { 3, "resourceLimitation" },
537 { 4, "connectionFailed" },
538 { 5, "invalidProtocol" },
539 { 6, "reasonNotSpecified" },
540 { 0, NULL }
544 static int
545 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_) {
546 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
547 NULL);
549 return offset;
554 static int
555 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_) {
556 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
558 return offset;
562 static const value_string idmp_TLSResponse_vals[] = {
563 { 0, "success" },
564 { 1, "operationsError" },
565 { 2, "protocolError" },
566 { 3, "unavailable" },
567 { 0, NULL }
571 static int
572 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_) {
573 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
574 NULL);
576 return offset;
580 static const value_string idmp_IDM_PDU_vals[] = {
581 { 0, "bind" },
582 { 1, "bindResult" },
583 { 2, "bindError" },
584 { 3, "request" },
585 { 4, "result" },
586 { 5, "error" },
587 { 6, "reject" },
588 { 7, "unbind" },
589 { 8, "abort" },
590 { 9, "startTLS" },
591 { 10, "tLSResponse" },
592 { 0, NULL }
595 static const ber_choice_t IDM_PDU_choice[] = {
596 { 0, &hf_idmp_bind , BER_CLASS_CON, 0, 0, dissect_idmp_IdmBind },
597 { 1, &hf_idmp_bindResult , BER_CLASS_CON, 1, 0, dissect_idmp_IdmBindResult },
598 { 2, &hf_idmp_bindError , BER_CLASS_CON, 2, 0, dissect_idmp_IdmBindError },
599 { 3, &hf_idmp_request , BER_CLASS_CON, 3, 0, dissect_idmp_Request },
600 { 4, &hf_idmp_idm_result , BER_CLASS_CON, 4, 0, dissect_idmp_IdmResult },
601 { 5, &hf_idmp_idm_error , BER_CLASS_CON, 5, 0, dissect_idmp_Error },
602 { 6, &hf_idmp_reject , BER_CLASS_CON, 6, 0, dissect_idmp_IdmReject },
603 { 7, &hf_idmp_unbind , BER_CLASS_CON, 7, 0, dissect_idmp_Unbind },
604 { 8, &hf_idmp_abort , BER_CLASS_CON, 8, 0, dissect_idmp_Abort },
605 { 9, &hf_idmp_startTLS , BER_CLASS_CON, 9, 0, dissect_idmp_StartTLS },
606 { 10, &hf_idmp_tLSResponse , BER_CLASS_CON, 10, 0, dissect_idmp_TLSResponse },
607 { 0, NULL, 0, 0, 0, NULL }
610 static int
611 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_) {
612 offset = dissect_ber_choice(actx, tree, tvb, offset,
613 IDM_PDU_choice, hf_index, ett_idmp_IDM_PDU,
614 NULL);
616 return offset;
620 /*--- End of included file: packet-idmp-fn.c ---*/
621 #line 136 "../../asn1/idmp/packet-idmp-template.c"
623 void
624 register_idmp_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name)
626 /* just register with ROS for now */
627 register_ros_protocol_info(oid, rinfo, proto, name, FALSE);
631 static int dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
633 int offset = 0;
635 proto_item *item;
636 proto_tree *tree;
637 asn1_ctx_t asn1_ctx;
638 struct SESSION_DATA_STRUCTURE session;
639 gboolean idmp_final;
640 guint32 idmp_length;
641 fragment_head *fd_head;
642 conversation_t *conv;
643 guint32 dst_ref = 0;
645 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
647 conv = find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
648 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
649 if (conv) {
650 /* Found a conversation, also use index for the generated dst_ref */
651 dst_ref = conv->index;
654 /* save parent_tree so subdissectors can create new top nodes */
655 top_tree=parent_tree;
657 item = proto_tree_add_item(parent_tree, proto_idmp, tvb, 0, -1, ENC_NA);
658 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, ENC_BIG_ENDIAN); offset++;
665 proto_tree_add_item(tree, hf_idmp_final, tvb, offset, 1, ENC_BIG_ENDIAN);
666 idmp_final = tvb_get_guint8(tvb, offset); offset++;
667 proto_tree_add_item(tree, hf_idmp_length, tvb, offset, 4, ENC_BIG_ENDIAN);
668 idmp_length = tvb_get_ntohl(tvb, offset); offset += 4;
670 asn1_ctx.private_data = &session;
672 if(idmp_reassemble) {
674 pinfo->fragmented = !idmp_final;
676 col_append_fstr(pinfo->cinfo, COL_INFO, " [%sIDMP fragment, %u byte%s]",
677 idmp_final ? "Final " : "" ,
678 idmp_length, plurality(idmp_length, "", "s"));
680 fd_head = fragment_add_seq_next(&idmp_reassembly_table, tvb, offset,
681 pinfo, dst_ref, NULL,
682 idmp_length, !idmp_final);
684 if(fd_head && fd_head->next) {
685 proto_tree_add_text(tree, tvb, offset, (idmp_length) ? -1 : 0,
686 "IDMP segment data (%u byte%s)", idmp_length,
687 plurality(idmp_length, "", "s"));
689 if (idmp_final) {
690 /* This is the last segment */
691 tvb = process_reassembled_data (tvb, offset, pinfo,
692 "Reassembled IDMP", fd_head, &idmp_frag_items, NULL, tree);
693 offset = 0;
694 } else if (pinfo->fd->num != fd_head->reassembled_in) {
695 /* Add a "Reassembled in" link if not reassembled in this frame */
696 proto_tree_add_uint (tree, hf_idmp_reassembled_in,
697 tvb, 0, 0, fd_head->reassembled_in);
701 } else {
702 if(!idmp_final) {
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 */
713 if(idmp_final) {
714 asn1_ctx.private_data = &session;
715 dissect_idmp_IDM_PDU(FALSE, tvb, offset, &asn1_ctx, tree, hf_idmp_PDU);
718 return tvb_length(tvb);
721 static guint get_idmp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
723 guint32 len;
725 len = tvb_get_ntohl(tvb, offset + 2);
727 return len + 6;
730 static int dissect_idmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data)
732 tcp_dissect_pdus(tvb, pinfo, parent_tree, idmp_desegment, 0, get_idmp_pdu_len, dissect_idmp, data);
733 return tvb_length(tvb);
736 static void idmp_reassemble_init (void)
738 reassembly_table_init (&idmp_reassembly_table,
739 &addresses_reassembly_table_functions);
741 saved_protocolID = NULL;
744 /*--- proto_register_idmp -------------------------------------------*/
745 void proto_register_idmp(void)
747 /* List of fields */
748 static hf_register_info hf[] = {
749 { &hf_idmp_version,
750 { "version", "idmp.version",
751 FT_INT8, BASE_DEC, NULL, 0,
752 "idmp.INTEGER", HFILL }},
753 { &hf_idmp_final,
754 { "final", "idmp.final",
755 FT_BOOLEAN, BASE_NONE, NULL, 0,
756 "idmp.BOOLEAN", HFILL }},
757 { &hf_idmp_length,
758 { "length", "idmp.length",
759 FT_INT32, BASE_DEC, NULL, 0,
760 "idmp.INTEGER", HFILL }},
761 { &hf_idmp_PDU,
762 { "IDM-PDU", "idmp.pdu",
763 FT_UINT32, BASE_DEC, VALS(idmp_IDM_PDU_vals), 0,
764 "idmp.PDU", HFILL }},
765 /* Fragment entries */
766 { &hf_idmp_fragments,
767 { "IDMP fragments", "idmp.fragments", FT_NONE, BASE_NONE,
768 NULL, 0x00, NULL, HFILL } },
769 { &hf_idmp_fragment,
770 { "IDMP fragment", "idmp.fragment", FT_FRAMENUM, BASE_NONE,
771 NULL, 0x00, NULL, HFILL } },
772 { &hf_idmp_fragment_overlap,
773 { "IDMP fragment overlap", "idmp.fragment.overlap", FT_BOOLEAN,
774 BASE_NONE, NULL, 0x00, NULL, HFILL } },
775 { &hf_idmp_fragment_overlap_conflicts,
776 { "IDMP fragment overlapping with conflicting data",
777 "idmp.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE,
778 NULL, 0x00, NULL, HFILL } },
779 { &hf_idmp_fragment_multiple_tails,
780 { "IDMP has multiple tail fragments",
781 "idmp.fragment.multiple_tails", FT_BOOLEAN, BASE_NONE,
782 NULL, 0x00, NULL, HFILL } },
783 { &hf_idmp_fragment_too_long_fragment,
784 { "IDMP fragment too long", "idmp.fragment.too_long_fragment",
785 FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } },
786 { &hf_idmp_fragment_error,
787 { "IDMP defragmentation error", "idmp.fragment.error", FT_FRAMENUM,
788 BASE_NONE, NULL, 0x00, NULL, HFILL } },
789 { &hf_idmp_fragment_count,
790 { "IDMP fragment count", "idmp.fragment.count", FT_UINT32, BASE_DEC,
791 NULL, 0x00, NULL, HFILL } },
792 { &hf_idmp_reassembled_in,
793 { "Reassembled IDMP in frame", "idmp.reassembled.in", FT_FRAMENUM, BASE_NONE,
794 NULL, 0x00, "This IDMP packet is reassembled in this frame", HFILL } },
795 { &hf_idmp_reassembled_length,
796 { "Reassembled IDMP length", "idmp.reassembled.length", FT_UINT32, BASE_DEC,
797 NULL, 0x00, "The total length of the reassembled payload", HFILL } },
800 /*--- Included file: packet-idmp-hfarr.c ---*/
801 #line 1 "../../asn1/idmp/packet-idmp-hfarr.c"
802 { &hf_idmp_bind,
803 { "bind", "idmp.bind_element",
804 FT_NONE, BASE_NONE, NULL, 0,
805 "IdmBind", HFILL }},
806 { &hf_idmp_bindResult,
807 { "bindResult", "idmp.bindResult_element",
808 FT_NONE, BASE_NONE, NULL, 0,
809 "IdmBindResult", HFILL }},
810 { &hf_idmp_bindError,
811 { "bindError", "idmp.bindError_element",
812 FT_NONE, BASE_NONE, NULL, 0,
813 "IdmBindError", HFILL }},
814 { &hf_idmp_request,
815 { "request", "idmp.request_element",
816 FT_NONE, BASE_NONE, NULL, 0,
817 NULL, HFILL }},
818 { &hf_idmp_idm_result,
819 { "result", "idmp.result_element",
820 FT_NONE, BASE_NONE, NULL, 0,
821 "IdmResult", HFILL }},
822 { &hf_idmp_idm_error,
823 { "error", "idmp.error_element",
824 FT_NONE, BASE_NONE, NULL, 0,
825 NULL, HFILL }},
826 { &hf_idmp_reject,
827 { "reject", "idmp.reject_element",
828 FT_NONE, BASE_NONE, NULL, 0,
829 "IdmReject", HFILL }},
830 { &hf_idmp_unbind,
831 { "unbind", "idmp.unbind_element",
832 FT_NONE, BASE_NONE, NULL, 0,
833 NULL, HFILL }},
834 { &hf_idmp_abort,
835 { "abort", "idmp.abort",
836 FT_UINT32, BASE_DEC, VALS(idmp_Abort_vals), 0,
837 NULL, HFILL }},
838 { &hf_idmp_startTLS,
839 { "startTLS", "idmp.startTLS_element",
840 FT_NONE, BASE_NONE, NULL, 0,
841 NULL, HFILL }},
842 { &hf_idmp_tLSResponse,
843 { "tLSResponse", "idmp.tLSResponse",
844 FT_UINT32, BASE_DEC, VALS(idmp_TLSResponse_vals), 0,
845 NULL, HFILL }},
846 { &hf_idmp_protocolID,
847 { "protocolID", "idmp.protocolID",
848 FT_OID, BASE_NONE, NULL, 0,
849 "OBJECT_IDENTIFIER", HFILL }},
850 { &hf_idmp_callingAETitle,
851 { "callingAETitle", "idmp.callingAETitle",
852 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
853 "GeneralName", HFILL }},
854 { &hf_idmp_calledAETitle,
855 { "calledAETitle", "idmp.calledAETitle",
856 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
857 "GeneralName", HFILL }},
858 { &hf_idmp_bind_argument,
859 { "argument", "idmp.argument_element",
860 FT_NONE, BASE_NONE, NULL, 0,
861 "Bind_argument", HFILL }},
862 { &hf_idmp_respondingAETitle,
863 { "respondingAETitle", "idmp.respondingAETitle",
864 FT_UINT32, BASE_DEC, VALS(x509ce_GeneralName_vals), 0,
865 "GeneralName", HFILL }},
866 { &hf_idmp_bind_result,
867 { "result", "idmp.result_element",
868 FT_NONE, BASE_NONE, NULL, 0,
869 "Bind_result", HFILL }},
870 { &hf_idmp_bind_errcode,
871 { "errcode", "idmp.errcode_element",
872 FT_NONE, BASE_NONE, NULL, 0,
873 "Bind_errcode", HFILL }},
874 { &hf_idmp_aETitleError,
875 { "aETitleError", "idmp.aETitleError",
876 FT_UINT32, BASE_DEC, VALS(idmp_T_aETitleError_vals), 0,
877 NULL, HFILL }},
878 { &hf_idmp_bind_error,
879 { "error", "idmp.error_element",
880 FT_NONE, BASE_NONE, NULL, 0,
881 "Bind_error", HFILL }},
882 { &hf_idmp_invokeID,
883 { "invokeID", "idmp.invokeID",
884 FT_INT32, BASE_DEC, NULL, 0,
885 "INTEGER", HFILL }},
886 { &hf_idmp_opcode,
887 { "opcode", "idmp.opcode",
888 FT_UINT32, BASE_DEC, VALS(idmp_Code_vals), 0,
889 "Code", HFILL }},
890 { &hf_idmp_argument,
891 { "argument", "idmp.argument_element",
892 FT_NONE, BASE_NONE, NULL, 0,
893 NULL, HFILL }},
894 { &hf_idmp_idm_invokeID,
895 { "invokeID", "idmp.invokeID",
896 FT_UINT32, BASE_DEC, VALS(idmp_InvokeId_vals), 0,
897 NULL, HFILL }},
898 { &hf_idmp_result,
899 { "result", "idmp.result_element",
900 FT_NONE, BASE_NONE, NULL, 0,
901 NULL, HFILL }},
902 { &hf_idmp_errcode,
903 { "errcode", "idmp.errcode_element",
904 FT_NONE, BASE_NONE, NULL, 0,
905 NULL, HFILL }},
906 { &hf_idmp_error,
907 { "error", "idmp.error_element",
908 FT_NONE, BASE_NONE, NULL, 0,
909 NULL, HFILL }},
910 { &hf_idmp_reason,
911 { "reason", "idmp.reason",
912 FT_UINT32, BASE_DEC, VALS(idmp_T_reason_vals), 0,
913 NULL, HFILL }},
914 { &hf_idmp_local,
915 { "local", "idmp.local",
916 FT_INT32, BASE_DEC, NULL, 0,
917 NULL, HFILL }},
918 { &hf_idmp_global,
919 { "global", "idmp.global",
920 FT_OID, BASE_NONE, NULL, 0,
921 "OBJECT_IDENTIFIER", HFILL }},
922 { &hf_idmp_present,
923 { "present", "idmp.present",
924 FT_INT32, BASE_DEC, NULL, 0,
925 "INTEGER", HFILL }},
926 { &hf_idmp_absent,
927 { "absent", "idmp.absent_element",
928 FT_NONE, BASE_NONE, NULL, 0,
929 NULL, HFILL }},
931 /*--- End of included file: packet-idmp-hfarr.c ---*/
932 #line 314 "../../asn1/idmp/packet-idmp-template.c"
935 /* List of subtrees */
936 static gint *ett[] = {
937 &ett_idmp,
938 &ett_idmp_fragment,
939 &ett_idmp_fragments,
941 /*--- Included file: packet-idmp-ettarr.c ---*/
942 #line 1 "../../asn1/idmp/packet-idmp-ettarr.c"
943 &ett_idmp_IDM_PDU,
944 &ett_idmp_IdmBind,
945 &ett_idmp_IdmBindResult,
946 &ett_idmp_IdmBindError,
947 &ett_idmp_Request,
948 &ett_idmp_IdmResult,
949 &ett_idmp_Error,
950 &ett_idmp_IdmReject,
951 &ett_idmp_Code,
952 &ett_idmp_InvokeId,
954 /*--- End of included file: packet-idmp-ettarr.c ---*/
955 #line 322 "../../asn1/idmp/packet-idmp-template.c"
957 module_t *idmp_module;
959 /* Register protocol */
960 proto_idmp = proto_register_protocol(PNAME, PSNAME, PFNAME);
962 /* Register fields and subtrees */
963 proto_register_field_array(proto_idmp, hf, array_length(hf));
964 proto_register_subtree_array(ett, array_length(ett));
966 new_register_dissector("idmp", dissect_idmp_tcp, proto_idmp);
968 register_init_routine (&idmp_reassemble_init);
970 /* Register our configuration options for IDMP, particularly our port */
972 idmp_module = prefs_register_protocol_subtree("OSI/X.500", proto_idmp, prefs_register_idmp);
974 prefs_register_bool_preference(idmp_module, "desegment_idmp_messages",
975 "Reassemble IDMP messages spanning multiple TCP segments",
976 "Whether the IDMP dissector should reassemble messages spanning multiple TCP segments."
977 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
978 &idmp_desegment);
980 prefs_register_bool_preference(idmp_module, "reassemble",
981 "Reassemble segmented IDMP datagrams",
982 "Whether segmented IDMP datagrams should be reassembled."
983 " To use this option, you must also enable"
984 " \"Allow subdissectors to reassemble TCP streams\""
985 " in the TCP protocol settings.", &idmp_reassemble);
987 prefs_register_uint_preference(idmp_module, "tcp.port", "IDMP TCP Port",
988 "Set the port for Internet Directly Mapped Protocol requests/responses",
989 10, &global_idmp_tcp_port);
994 /*--- proto_reg_handoff_idm --- */
995 void proto_reg_handoff_idm(void) {
997 /* remember the idm handler for change in preferences */
998 idmp_handle = find_dissector(PFNAME);
1003 static void
1004 prefs_register_idmp(void)
1007 /* de-register the old port */
1008 /* port 102 is registered by TPKT - don't undo this! */
1009 if(idmp_handle)
1010 dissector_delete_uint("tcp.port", tcp_port, idmp_handle);
1012 /* Set our port number for future use */
1013 tcp_port = global_idmp_tcp_port;
1015 if((tcp_port > 0) && idmp_handle)
1016 dissector_add_uint("tcp.port", global_idmp_tcp_port, idmp_handle);