summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-h450-ros.c
blob: 3a2c1e1909c81e4b0fa3e0ced53b8c55d2a8af13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
/* Do not modify this file. Changes will be overwritten.                      */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler       */
/* packet-h450-ros.c                                                          */
/* asn2wrs.py -q -L -p h450.ros -c ./h450-ros.cnf -s ./packet-h450-ros-template -D . -O ../.. ../ros/Remote-Operations-Information-Objects.asn Remote-Operations-Apdus.asn */

/* packet-h450-ros.c
 * Routines for H.450 packet dissection
 * 2007  Tomas Kukosa
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"

#include <epan/packet.h>
#include <epan/strutil.h>
#include <epan/asn1.h>
#include <epan/expert.h>
#include <wsutil/array.h>

#include "packet-per.h"
#include "packet-h450-ros.h"

#define PNAME  "H.450 Remote Operations Apdus"
#define PSNAME "H450.ROS"
#define PFNAME "h450.ros"

void proto_register_h450_ros(void);
void proto_reg_handoff_h450_ros(void);

/* Initialize the protocol and registered fields */
static int proto_h450_ros;
static int hf_h450_ros_local;                     /* T_local */
static int hf_h450_ros_global;                    /* T_global */
static int hf_h450_ros_invoke;                    /* Invoke */
static int hf_h450_ros_returnResult;              /* ReturnResult */
static int hf_h450_ros_returnError;               /* ReturnError */
static int hf_h450_ros_reject;                    /* Reject */
static int hf_h450_ros_invokeIdConstrained;       /* T_invokeIdConstrained */
static int hf_h450_ros_linkedId;                  /* InvokeId */
static int hf_h450_ros_opcode;                    /* Code */
static int hf_h450_ros_argument;                  /* InvokeArgument */
static int hf_h450_ros_invokeId;                  /* InvokeId */
static int hf_h450_ros_result;                    /* T_result */
static int hf_h450_ros_resultArgument;            /* ResultArgument */
static int hf_h450_ros_errcode;                   /* Code */
static int hf_h450_ros_parameter;                 /* T_parameter */
static int hf_h450_ros_problem;                   /* T_problem */
static int hf_h450_ros_general;                   /* GeneralProblem */
static int hf_h450_ros_invokeProblem;             /* InvokeProblem */
static int hf_h450_ros_returnResultProblem;       /* ReturnResultProblem */
static int hf_h450_ros_returnErrorProblem;        /* ReturnErrorProblem */

/* Initialize the subtree pointers */
static int ett_h450_ros_Code;
static int ett_h450_ros_ROS;
static int ett_h450_ros_Invoke;
static int ett_h450_ros_ReturnResult;
static int ett_h450_ros_T_result;
static int ett_h450_ros_ReturnError;
static int ett_h450_ros_Reject;
static int ett_h450_ros_T_problem;

static expert_field ei_ros_undecoded;

/* Preferences */

/* Subdissectors */
static dissector_handle_t data_handle;

/* Global variables */
static int32_t problem_val;
static char problem_str[64];
static tvbuff_t *arg_next_tvb, *res_next_tvb, *err_next_tvb;

static int
argument_cb(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) {
  arg_next_tvb = tvb;
  return tvb_captured_length(tvb);
}

static int
result_cb(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) {
  res_next_tvb = tvb;
  return tvb_captured_length(tvb);
}

static int
error_cb(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) {
  err_next_tvb = tvb;
  return tvb_captured_length(tvb);
}



static int
dissect_h450_ros_T_local(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &actx->rose_ctx->d.code_local);

  return offset;
}



static int
dissect_h450_ros_T_global(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_object_identifier_str(tvb, offset, actx, tree, hf_index, &actx->rose_ctx->d.code_global);

  return offset;
}


static const value_string h450_ros_Code_vals[] = {
  {   0, "local" },
  {   1, "global" },
  { 0, NULL }
};

static const per_choice_t Code_choice[] = {
  {   0, &hf_h450_ros_local      , ASN1_NO_EXTENSIONS     , dissect_h450_ros_T_local },
  {   1, &hf_h450_ros_global     , ASN1_NO_EXTENSIONS     , dissect_h450_ros_T_global },
  { 0, NULL, 0, NULL }
};

static int
dissect_h450_ros_Code(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
                                 ett_h450_ros_Code, Code_choice,
                                 &actx->rose_ctx->d.code);

  actx->rose_ctx->d.code_item = actx->created_item;
  return offset;
}



static int
dissect_h450_ros_InvokeId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, NULL);

  return offset;
}



static int
dissect_h450_ros_T_invokeIdConstrained(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
                                           0U, 65535U, NULL, true);

  return offset;
}



static int
dissect_h450_ros_InvokeArgument(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_open_type_pdu_new(tvb, offset, actx, tree, hf_index, argument_cb);

  return offset;
}


static const per_sequence_t Invoke_sequence[] = {
  { &hf_h450_ros_invokeIdConstrained, ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_T_invokeIdConstrained },
  { &hf_h450_ros_linkedId   , ASN1_NO_EXTENSIONS     , ASN1_OPTIONAL    , dissect_h450_ros_InvokeId },
  { &hf_h450_ros_opcode     , ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_Code },
  { &hf_h450_ros_argument   , ASN1_NO_EXTENSIONS     , ASN1_OPTIONAL    , dissect_h450_ros_InvokeArgument },
  { NULL, 0, 0, NULL }
};

static int
dissect_h450_ros_Invoke(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  dissector_handle_t arg_handle = NULL;
  const char *descr = "";

  arg_next_tvb = NULL;
  offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
                                   ett_h450_ros_Invoke, Invoke_sequence);

  actx->rose_ctx->d.pdu = 1;

  if ((actx->rose_ctx->d.code == 0) && actx->rose_ctx->arg_local_dissector_table) {
    arg_handle = dissector_get_uint_handle(actx->rose_ctx->arg_local_dissector_table, actx->rose_ctx->d.code_local);
  } else if ((actx->rose_ctx->d.code == 1) && actx->rose_ctx->arg_global_dissector_table) {
    arg_handle = dissector_get_string_handle(actx->rose_ctx->arg_global_dissector_table, actx->rose_ctx->d.code_global);
  } else {
    arg_handle = NULL;
  }

  if (!arg_handle ||
      !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(arg_handle)))) {
    if (actx->rose_ctx->d.code == 0)
      descr = wmem_strdup_printf(actx->pinfo->pool, "INV: %d", actx->rose_ctx->d.code_local);
    else if (actx->rose_ctx->d.code == 1)
      descr = wmem_strdup_printf(actx->pinfo->pool, "INV: %s", actx->rose_ctx->d.code_global);
  } else {
    descr = wmem_strdup(actx->pinfo->pool, "INV:");
  }

  if (actx->rose_ctx->apdu_depth >= 0)
    proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), "  %s", descr);
  if (actx->rose_ctx->fillin_info)
    col_append_str(actx->pinfo->cinfo, COL_INFO, descr);
  if (actx->rose_ctx->fillin_ptr)
    (void) g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size);

  if (!arg_next_tvb) {  /* empty argument */
    arg_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0);
  }

  call_dissector_with_data((arg_handle)?arg_handle:data_handle, arg_next_tvb, actx->pinfo, tree, actx->rose_ctx);
  if (!arg_handle) {
    expert_add_info_format(actx->pinfo, tree, &ei_ros_undecoded, "Undecoded %s", descr);
  }
  return offset;
}



static int
dissect_h450_ros_ResultArgument(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_open_type_pdu_new(tvb, offset, actx, tree, hf_index, result_cb);

  return offset;
}


static const per_sequence_t T_result_sequence[] = {
  { &hf_h450_ros_opcode     , ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_Code },
  { &hf_h450_ros_resultArgument, ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_ResultArgument },
  { NULL, 0, 0, NULL }
};

static int
dissect_h450_ros_T_result(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
                                   ett_h450_ros_T_result, T_result_sequence);

  return offset;
}


static const per_sequence_t ReturnResult_sequence[] = {
  { &hf_h450_ros_invokeId   , ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_InvokeId },
  { &hf_h450_ros_result     , ASN1_NO_EXTENSIONS     , ASN1_OPTIONAL    , dissect_h450_ros_T_result },
  { NULL, 0, 0, NULL }
};

static int
dissect_h450_ros_ReturnResult(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  dissector_handle_t res_handle = NULL;
  const char *descr = "";

  actx->rose_ctx->d.code = -1;
  res_next_tvb = NULL;
  offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
                                   ett_h450_ros_ReturnResult, ReturnResult_sequence);

  actx->rose_ctx->d.pdu = 2;

  if ((actx->rose_ctx->d.code == 0) && actx->rose_ctx->res_local_dissector_table) {
    res_handle = dissector_get_uint_handle(actx->rose_ctx->res_local_dissector_table, actx->rose_ctx->d.code_local);
  } else if ((actx->rose_ctx->d.code == 1) && actx->rose_ctx->res_global_dissector_table) {
    res_handle = dissector_get_string_handle(actx->rose_ctx->res_global_dissector_table, actx->rose_ctx->d.code_global);
  } else {
    res_handle = NULL;
  }

  if (!res_handle ||
      !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(res_handle)))) {
    if (actx->rose_ctx->d.code == 0)
      descr = wmem_strdup_printf(actx->pinfo->pool, "RES: %d", actx->rose_ctx->d.code_local);
    else if (actx->rose_ctx->d.code == 1)
      descr = wmem_strdup_printf(actx->pinfo->pool, "RES: %s", actx->rose_ctx->d.code_global);
  } else {
    descr = wmem_strdup(actx->pinfo->pool, "RES:");
  }

  if (actx->rose_ctx->apdu_depth >= 0)
    proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), "  %s", descr);
  if (actx->rose_ctx->fillin_info)
    col_append_str(actx->pinfo->cinfo, COL_INFO, descr);
  if (actx->rose_ctx->fillin_ptr)
    (void) g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size);

  if (actx->rose_ctx->d.code != -1) {
    if (!res_next_tvb) {  /* empty result */
      res_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0);
    }

    call_dissector_with_data((res_handle)?res_handle:data_handle, res_next_tvb, actx->pinfo, tree, actx->rose_ctx);
    if (!res_handle) {
      expert_add_info_format(actx->pinfo, tree, &ei_ros_undecoded, "Undecoded %s", descr);
    }
  }
  return offset;
}



static int
dissect_h450_ros_T_parameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_open_type_pdu_new(tvb, offset, actx, tree, hf_index, error_cb);

  return offset;
}


static const per_sequence_t ReturnError_sequence[] = {
  { &hf_h450_ros_invokeId   , ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_InvokeId },
  { &hf_h450_ros_errcode    , ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_Code },
  { &hf_h450_ros_parameter  , ASN1_NO_EXTENSIONS     , ASN1_OPTIONAL    , dissect_h450_ros_T_parameter },
  { NULL, 0, 0, NULL }
};

static int
dissect_h450_ros_ReturnError(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  dissector_handle_t err_handle = NULL;
  const char *descr = "";

  err_next_tvb = NULL;
  offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
                                   ett_h450_ros_ReturnError, ReturnError_sequence);

  actx->rose_ctx->d.pdu = 3;

  if ((actx->rose_ctx->d.code == 0) && actx->rose_ctx->err_local_dissector_table) {
    err_handle = dissector_get_uint_handle(actx->rose_ctx->err_local_dissector_table, actx->rose_ctx->d.code_local);
  } else if ((actx->rose_ctx->d.code == 1) && actx->rose_ctx->err_global_dissector_table) {
    err_handle = dissector_get_string_handle(actx->rose_ctx->err_global_dissector_table, actx->rose_ctx->d.code_global);
  } else {
    err_handle = NULL;
  }

  if (!err_handle ||
      !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(err_handle)))) {
    if (actx->rose_ctx->d.code == 0)
      descr = wmem_strdup_printf(actx->pinfo->pool, "ERR: %d", actx->rose_ctx->d.code_local);
    else if (actx->rose_ctx->d.code == 1)
      descr = wmem_strdup_printf(actx->pinfo->pool, "ERR: %s", actx->rose_ctx->d.code_global);
  } else {
    descr = wmem_strdup(actx->pinfo->pool, "ERR:");
  }

  if (actx->rose_ctx->apdu_depth >= 0)
    proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), "  %s", descr);
  if (actx->rose_ctx->fillin_info)
    col_append_str(actx->pinfo->cinfo, COL_INFO, descr);
  if (actx->rose_ctx->fillin_ptr)
    (void) g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size);

  if (!err_next_tvb) {  /* empty error */
    err_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0);
  }

  call_dissector_with_data((err_handle)?err_handle:data_handle, err_next_tvb, actx->pinfo, tree, actx->rose_ctx);
  if (!err_handle) {
    expert_add_info_format(actx->pinfo, tree, &ei_ros_undecoded, "Undecoded %s", descr);
  }
  return offset;
}


static const value_string h450_ros_GeneralProblem_vals[] = {
  {   0, "unrecognizedComponent" },
  {   1, "mistypedComponent" },
  {   2, "badlyStructuredComponent" },
  { 0, NULL }
};


static int
dissect_h450_ros_GeneralProblem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &problem_val);

  (void) g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(h450_ros_GeneralProblem_vals), ""), 64);
  problem_str[64-1] = '\0';
  return offset;
}


static const value_string h450_ros_InvokeProblem_vals[] = {
  {   0, "duplicateInvocation" },
  {   1, "unrecognizedOperation" },
  {   2, "mistypedArgument" },
  {   3, "resourceLimitation" },
  {   4, "releaseInProgress" },
  {   5, "unrecognizedLinkedId" },
  {   6, "linkedResponseUnexpected" },
  {   7, "unexpectedLinkedOperation" },
  { 0, NULL }
};


static int
dissect_h450_ros_InvokeProblem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &problem_val);

  (void) g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(h450_ros_InvokeProblem_vals), ""), 64);
  problem_str[64-1] = '\0';
  return offset;
}


static const value_string h450_ros_ReturnResultProblem_vals[] = {
  {   0, "unrecognizedInvocation" },
  {   1, "resultResponseUnexpected" },
  {   2, "mistypedResult" },
  { 0, NULL }
};


static int
dissect_h450_ros_ReturnResultProblem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &problem_val);

  (void) g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(h450_ros_ReturnResultProblem_vals), ""), 64);
  problem_str[64-1] = '\0';
  return offset;
}


static const value_string h450_ros_ReturnErrorProblem_vals[] = {
  {   0, "unrecognizedInvocation" },
  {   1, "errorResponseUnexpected" },
  {   2, "unrecognizedError" },
  {   3, "unexpectedError" },
  {   4, "mistypedParameter" },
  { 0, NULL }
};


static int
dissect_h450_ros_ReturnErrorProblem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &problem_val);

  (void) g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(h450_ros_ReturnErrorProblem_vals), ""), 64);
  problem_str[64-1] = '\0';
  return offset;
}


static const value_string h450_ros_T_problem_vals[] = {
  {   0, "general" },
  {   1, "invoke" },
  {   2, "returnResult" },
  {   3, "returnError" },
  { 0, NULL }
};

static const per_choice_t T_problem_choice[] = {
  {   0, &hf_h450_ros_general    , ASN1_NO_EXTENSIONS     , dissect_h450_ros_GeneralProblem },
  {   1, &hf_h450_ros_invokeProblem, ASN1_NO_EXTENSIONS     , dissect_h450_ros_InvokeProblem },
  {   2, &hf_h450_ros_returnResultProblem, ASN1_NO_EXTENSIONS     , dissect_h450_ros_ReturnResultProblem },
  {   3, &hf_h450_ros_returnErrorProblem, ASN1_NO_EXTENSIONS     , dissect_h450_ros_ReturnErrorProblem },
  { 0, NULL, 0, NULL }
};

static int
dissect_h450_ros_T_problem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
                                 ett_h450_ros_T_problem, T_problem_choice,
                                 NULL);

  return offset;
}


static const per_sequence_t Reject_sequence[] = {
  { &hf_h450_ros_invokeId   , ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_InvokeId },
  { &hf_h450_ros_problem    , ASN1_NO_EXTENSIONS     , ASN1_NOT_OPTIONAL, dissect_h450_ros_T_problem },
  { NULL, 0, 0, NULL }
};

static int
dissect_h450_ros_Reject(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  const char *descr;

  problem_str[0] = '\0';
  offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
                                   ett_h450_ros_Reject, Reject_sequence);

  descr = wmem_strdup_printf(actx->pinfo->pool, "REJ: %s", problem_str);

  if (actx->rose_ctx->apdu_depth >= 0)
    proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), "  %s", descr);
  if (actx->rose_ctx->fillin_info)
    col_append_str(actx->pinfo->cinfo, COL_INFO, descr);
  if (actx->rose_ctx->fillin_ptr)
    (void) g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size);
  return offset;
}


const value_string h450_ros_ROS_vals[] = {
  {   1, "invoke" },
  {   2, "returnResult" },
  {   3, "returnError" },
  {   4, "reject" },
  { 0, NULL }
};

static const per_choice_t ROS_choice[] = {
  {   1, &hf_h450_ros_invoke     , ASN1_NO_EXTENSIONS     , dissect_h450_ros_Invoke },
  {   2, &hf_h450_ros_returnResult, ASN1_NO_EXTENSIONS     , dissect_h450_ros_ReturnResult },
  {   3, &hf_h450_ros_returnError, ASN1_NO_EXTENSIONS     , dissect_h450_ros_ReturnError },
  {   4, &hf_h450_ros_reject     , ASN1_NO_EXTENSIONS     , dissect_h450_ros_Reject },
  { 0, NULL, 0, NULL }
};

int
dissect_h450_ros_ROS(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
  DISSECTOR_ASSERT(actx->rose_ctx);
  rose_ctx_clean_data(actx->rose_ctx);
  offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
                                 ett_h450_ros_ROS, ROS_choice,
                                 NULL);

  return offset;
}


/*--- proto_register_h450_ros -----------------------------------------------*/
void proto_register_h450_ros(void) {

  /* List of fields */
  static hf_register_info hf[] = {
    { &hf_h450_ros_local,
      { "local", "h450.ros.local",
        FT_INT32, BASE_DEC, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_global,
      { "global", "h450.ros.global",
        FT_OID, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_invoke,
      { "invoke", "h450.ros.invoke_element",
        FT_NONE, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_returnResult,
      { "returnResult", "h450.ros.returnResult_element",
        FT_NONE, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_returnError,
      { "returnError", "h450.ros.returnError_element",
        FT_NONE, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_reject,
      { "reject", "h450.ros.reject_element",
        FT_NONE, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_invokeIdConstrained,
      { "invokeId", "h450.ros.invokeId",
        FT_INT32, BASE_DEC, NULL, 0,
        "T_invokeIdConstrained", HFILL }},
    { &hf_h450_ros_linkedId,
      { "linkedId", "h450.ros.linkedId",
        FT_INT32, BASE_DEC, NULL, 0,
        "InvokeId", HFILL }},
    { &hf_h450_ros_opcode,
      { "opcode", "h450.ros.opcode",
        FT_UINT32, BASE_DEC, VALS(h450_ros_Code_vals), 0,
        "Code", HFILL }},
    { &hf_h450_ros_argument,
      { "argument", "h450.ros.argument",
        FT_BYTES, BASE_NONE, NULL, 0,
        "InvokeArgument", HFILL }},
    { &hf_h450_ros_invokeId,
      { "invokeId", "h450.ros.invokeId",
        FT_INT32, BASE_DEC, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_result,
      { "result", "h450.ros.result_element",
        FT_NONE, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_resultArgument,
      { "result", "h450.ros.result",
        FT_BYTES, BASE_NONE, NULL, 0,
        "ResultArgument", HFILL }},
    { &hf_h450_ros_errcode,
      { "errcode", "h450.ros.errcode",
        FT_UINT32, BASE_DEC, VALS(h450_ros_Code_vals), 0,
        "Code", HFILL }},
    { &hf_h450_ros_parameter,
      { "parameter", "h450.ros.parameter",
        FT_BYTES, BASE_NONE, NULL, 0,
        NULL, HFILL }},
    { &hf_h450_ros_problem,
      { "problem", "h450.ros.problem",
        FT_UINT32, BASE_DEC, VALS(h450_ros_T_problem_vals), 0,
        NULL, HFILL }},
    { &hf_h450_ros_general,
      { "general", "h450.ros.general",
        FT_INT32, BASE_DEC, VALS(h450_ros_GeneralProblem_vals), 0,
        "GeneralProblem", HFILL }},
    { &hf_h450_ros_invokeProblem,
      { "invoke", "h450.ros.invoke",
        FT_INT32, BASE_DEC, VALS(h450_ros_InvokeProblem_vals), 0,
        "InvokeProblem", HFILL }},
    { &hf_h450_ros_returnResultProblem,
      { "returnResult", "h450.ros.returnResult",
        FT_INT32, BASE_DEC, VALS(h450_ros_ReturnResultProblem_vals), 0,
        "ReturnResultProblem", HFILL }},
    { &hf_h450_ros_returnErrorProblem,
      { "returnError", "h450.ros.returnError",
        FT_INT32, BASE_DEC, VALS(h450_ros_ReturnErrorProblem_vals), 0,
        "ReturnErrorProblem", HFILL }},
  };

  /* List of subtrees */
  static int *ett[] = {
    &ett_h450_ros_Code,
    &ett_h450_ros_ROS,
    &ett_h450_ros_Invoke,
    &ett_h450_ros_ReturnResult,
    &ett_h450_ros_T_result,
    &ett_h450_ros_ReturnError,
    &ett_h450_ros_Reject,
    &ett_h450_ros_T_problem,
  };

  static ei_register_info ei[] = {
     { &ei_ros_undecoded, { "h450.ros.undecoded", PI_UNDECODED, PI_WARN, "Undecoded", EXPFILL }},
  };

  expert_module_t* expert_h450_ros;

  /* Register protocol and dissector */
  proto_h450_ros = proto_register_protocol(PNAME, PSNAME, PFNAME);
  proto_set_cant_toggle(proto_h450_ros);

  /* Register fields and subtrees */
  proto_register_field_array(proto_h450_ros, hf, array_length(hf));
  proto_register_subtree_array(ett, array_length(ett));
  expert_h450_ros = expert_register_protocol(proto_h450_ros);
  expert_register_field_array(expert_h450_ros, ei, array_length(ei));
}

/*--- proto_reg_handoff_h450_ros --------------------------------------------*/
void proto_reg_handoff_h450_ros(void) {
  data_handle = find_dissector("data");
}

/*---------------------------------------------------------------------------*/