ASN_EmbeddedPDV.cc 158 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
/******************************************************************************
Adam Knapp's avatar
Adam Knapp committed
2
 * Copyright (c) 2000-2021 Ericsson Telecom AB
Elemer Lelik's avatar
Elemer Lelik committed
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v2.0
Elemer Lelik's avatar
Elemer Lelik committed
5
 * which accompanies this distribution, and is available at
6
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
Elemer Lelik's avatar
Elemer Lelik committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 *
 * Contributors:
 *   Balasko, Jeno
 *   Baranyi, Botond
 *   Beres, Szabolcs
 *   Delic, Adam
 *   Forstner, Matyas
 *   Kovacs, Ferenc
 *   Raduly, Csaba
 *   Szabados, Kristof
 *   Szabo, Bence Janos
 *   Szabo, Janos Zoltan – initial implementation
 *   Szalai, Gabor
 *
 ******************************************************************************/
Elemer Lelik's avatar
Elemer Lelik committed
22
23
24
25
26
27
28
29
30
31
32
#include <string.h>

#include "Error.hh"
#include "Logger.hh"
#include "Encdec.hh"
#include "BER.hh"
#include "Param_Types.hh"

#include "ASN_EmbeddedPDV.hh"

#include "../common/dbgnew.hh"
33
#include "OER.hh"
Elemer Lelik's avatar
Elemer Lelik committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

/*

to do when regenerating:

in .hh file:

add __SUNPRO_CC ifdefs for single_value_struct

in .cc file:

replace '@EMBEDDED PDV' with 'EMBEDDED PDV'

remove RAW and TEXT enc/dec functions

make the type descriptors of embedded types static

*/

static const ASN_Tag_t EMBEDDED_PDV_identification_tag_[] = { { ASN_TAG_CONT, 0u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_ber_ = { 1u, EMBEDDED_PDV_identification_tag_ };
55
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_descr_ = { "EMBEDDED PDV.identification", &EMBEDDED_PDV_identification_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
Elemer Lelik's avatar
Elemer Lelik committed
56
57
58

static const ASN_Tag_t EMBEDDED_PDV_identification_syntaxes_abstract_tag_[] = { { ASN_TAG_CONT, 0u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_syntaxes_abstract_ber_ = { 1u, EMBEDDED_PDV_identification_syntaxes_abstract_tag_ };
59
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_syntaxes_abstract_descr_ = { "EMBEDDED PDV.identification.syntaxes.abstract", &EMBEDDED_PDV_identification_syntaxes_abstract_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID };
Elemer Lelik's avatar
Elemer Lelik committed
60
61
62

static const ASN_Tag_t EMBEDDED_PDV_identification_syntaxes_transfer_tag_[] = { { ASN_TAG_CONT, 1u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_syntaxes_transfer_ber_ = { 1u, EMBEDDED_PDV_identification_syntaxes_transfer_tag_ };
63
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_syntaxes_transfer_descr_ = { "EMBEDDED PDV.identification.syntaxes.transfer", &EMBEDDED_PDV_identification_syntaxes_transfer_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID };
Elemer Lelik's avatar
Elemer Lelik committed
64
65
66

static const ASN_Tag_t EMBEDDED_PDV_identification_syntaxes_tag_[] = { { ASN_TAG_CONT, 0u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_syntaxes_ber_ = { 1u, EMBEDDED_PDV_identification_syntaxes_tag_ };
67
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_syntaxes_descr_ = { "EMBEDDED PDV.identification.syntaxes", &EMBEDDED_PDV_identification_syntaxes_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
Elemer Lelik's avatar
Elemer Lelik committed
68
69
70

static const ASN_Tag_t EMBEDDED_PDV_identification_syntax_tag_[] = { { ASN_TAG_CONT, 1u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_syntax_ber_ = { 1u, EMBEDDED_PDV_identification_syntax_tag_ };
71
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_syntax_descr_ = { "EMBEDDED PDV.identification.syntax", &EMBEDDED_PDV_identification_syntax_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID };
Elemer Lelik's avatar
Elemer Lelik committed
72
73
74

static const ASN_Tag_t EMBEDDED_PDV_identification_presentation__context__id_tag_[] = { { ASN_TAG_CONT, 2u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_presentation__context__id_ber_ = { 1u, EMBEDDED_PDV_identification_presentation__context__id_tag_ };
75
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_presentation__context__id_descr_ = { "EMBEDDED PDV.identification.presentation-context-id", &EMBEDDED_PDV_identification_presentation__context__id_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
Elemer Lelik's avatar
Elemer Lelik committed
76
77
78

static const ASN_Tag_t EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_tag_[] = { { ASN_TAG_CONT, 0u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_ber_ = { 1u, EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_tag_ };
79
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_descr_ = { "EMBEDDED PDV.identification.context-negotiation.presentation-context-id", &EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
Elemer Lelik's avatar
Elemer Lelik committed
80
81
82

static const ASN_Tag_t EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_tag_[] = { { ASN_TAG_CONT, 1u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_ber_ = { 1u, EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_tag_ };
83
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_descr_ = { "EMBEDDED PDV.identification.context-negotiation.transfer-syntax", &EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID };
Elemer Lelik's avatar
Elemer Lelik committed
84
85
86

static const ASN_Tag_t EMBEDDED_PDV_identification_context__negotiation_tag_[] = { { ASN_TAG_CONT, 3u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_context__negotiation_ber_ = { 1u, EMBEDDED_PDV_identification_context__negotiation_tag_ };
87
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_context__negotiation_descr_ = { "EMBEDDED PDV.identification.context-negotiation", &EMBEDDED_PDV_identification_context__negotiation_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
Elemer Lelik's avatar
Elemer Lelik committed
88
89
90

static const ASN_Tag_t EMBEDDED_PDV_identification_transfer__syntax_tag_[] = { { ASN_TAG_CONT, 4u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_transfer__syntax_ber_ = { 1u, EMBEDDED_PDV_identification_transfer__syntax_tag_ };
91
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_transfer__syntax_descr_ = { "EMBEDDED PDV.identification.transfer-syntax", &EMBEDDED_PDV_identification_transfer__syntax_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID };
Elemer Lelik's avatar
Elemer Lelik committed
92
93
94

static const ASN_Tag_t EMBEDDED_PDV_identification_fixed_tag_[] = { { ASN_TAG_CONT, 5u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_fixed_ber_ = { 1u, EMBEDDED_PDV_identification_fixed_tag_ };
95
static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_fixed_descr_ = { "EMBEDDED PDV.identification.fixed", &EMBEDDED_PDV_identification_fixed_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
Elemer Lelik's avatar
Elemer Lelik committed
96
97
98

static const ASN_Tag_t EMBEDDED_PDV_data__value_tag_[] = { { ASN_TAG_CONT, 2u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_data__value_ber_ = { 1u, EMBEDDED_PDV_data__value_tag_ };
99
static const TTCN_Typedescriptor_t EMBEDDED_PDV_data__value_descr_ = { "EMBEDDED PDV.data-value", &EMBEDDED_PDV_data__value_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
Elemer Lelik's avatar
Elemer Lelik committed
100
101
102

static const ASN_Tag_t EMBEDDED_PDV_data__value__descriptor_tag_[] = { { ASN_TAG_CONT, 1u }};
static const ASN_BERdescriptor_t EMBEDDED_PDV_data__value__descriptor_ber_ = { 1u, EMBEDDED_PDV_data__value__descriptor_tag_ };
103
static const TTCN_Typedescriptor_t EMBEDDED_PDV_data__value__descriptor_descr_ = { "EMBEDDED PDV.data-value-descriptor", &EMBEDDED_PDV_data__value__descriptor_ber_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::GRAPHICSTRING };
Elemer Lelik's avatar
Elemer Lelik committed
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

/******************** EMBEDDED_PDV_identification ********************/

void EMBEDDED_PDV_identification::clean_up()
{
  switch (union_selection) {
  case ALT_syntaxes:
    delete field_syntaxes;
    break;
  case ALT_syntax:
    delete field_syntax;
    break;
  case ALT_presentation__context__id:
    delete field_presentation__context__id;
    break;
  case ALT_context__negotiation:
    delete field_context__negotiation;
    break;
  case ALT_transfer__syntax:
    delete field_transfer__syntax;
    break;
  case ALT_fixed:
    delete field_fixed;
    break;
  default:
    break;
  }
  union_selection = UNBOUND_VALUE;
}

void EMBEDDED_PDV_identification::copy_value(const EMBEDDED_PDV_identification& other_value)
{
  switch (other_value.union_selection) {
  case ALT_syntaxes:
    field_syntaxes = new EMBEDDED_PDV_identification_syntaxes(*other_value.field_syntaxes);
    break;
  case ALT_syntax:
    field_syntax = new OBJID(*other_value.field_syntax);
    break;
  case ALT_presentation__context__id:
    field_presentation__context__id = new INTEGER(*other_value.field_presentation__context__id);
    break;
  case ALT_context__negotiation:
    field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation(*other_value.field_context__negotiation);
    break;
  case ALT_transfer__syntax:
    field_transfer__syntax = new OBJID(*other_value.field_transfer__syntax);
    break;
  case ALT_fixed:
    field_fixed = new ASN_NULL(*other_value.field_fixed);
    break;
  default:
    TTCN_error("Assignment of an unbound union value of type EMBEDDED PDV.identification.");
  }
  union_selection = other_value.union_selection;
}

EMBEDDED_PDV_identification::EMBEDDED_PDV_identification()
{
  union_selection = UNBOUND_VALUE;
}

EMBEDDED_PDV_identification::EMBEDDED_PDV_identification(const EMBEDDED_PDV_identification& other_value)
: Base_Type(other_value)
{
  copy_value(other_value);
}

EMBEDDED_PDV_identification::~EMBEDDED_PDV_identification()
{
  clean_up();
}

EMBEDDED_PDV_identification& EMBEDDED_PDV_identification::operator=(const EMBEDDED_PDV_identification& other_value)
{
  if (this != &other_value) {
    clean_up();
    copy_value(other_value);
  }
  return *this;
}

boolean EMBEDDED_PDV_identification::operator==(const EMBEDDED_PDV_identification& other_value) const
{
  if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type EMBEDDED PDV.identification.");
  if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type EMBEDDED PDV.identification.");
  if (union_selection != other_value.union_selection) return FALSE;
  switch (union_selection) {
  case ALT_syntaxes:
    return *field_syntaxes == *other_value.field_syntaxes;
  case ALT_syntax:
    return *field_syntax == *other_value.field_syntax;
  case ALT_presentation__context__id:
    return *field_presentation__context__id == *other_value.field_presentation__context__id;
  case ALT_context__negotiation:
    return *field_context__negotiation == *other_value.field_context__negotiation;
  case ALT_transfer__syntax:
    return *field_transfer__syntax == *other_value.field_transfer__syntax;
  case ALT_fixed:
    return *field_fixed == *other_value.field_fixed;
  default:
    return FALSE;
  }
}

EMBEDDED_PDV_identification_syntaxes& EMBEDDED_PDV_identification::syntaxes()
{
  if (union_selection != ALT_syntaxes) {
    clean_up();
    field_syntaxes = new EMBEDDED_PDV_identification_syntaxes;
    union_selection = ALT_syntaxes;
  }
  return *field_syntaxes;
}

const EMBEDDED_PDV_identification_syntaxes& EMBEDDED_PDV_identification::syntaxes() const
{
  if (union_selection != ALT_syntaxes) TTCN_error("Using non-selected field syntaxes in a value of union type EMBEDDED PDV.identification.");
  return *field_syntaxes;
}

OBJID& EMBEDDED_PDV_identification::syntax()
{
  if (union_selection != ALT_syntax) {
    clean_up();
    field_syntax = new OBJID;
    union_selection = ALT_syntax;
  }
  return *field_syntax;
}

const OBJID& EMBEDDED_PDV_identification::syntax() const
{
  if (union_selection != ALT_syntax) TTCN_error("Using non-selected field syntax in a value of union type EMBEDDED PDV.identification.");
  return *field_syntax;
}

INTEGER& EMBEDDED_PDV_identification::presentation__context__id()
{
  if (union_selection != ALT_presentation__context__id) {
    clean_up();
    field_presentation__context__id = new INTEGER;
    union_selection = ALT_presentation__context__id;
  }
  return *field_presentation__context__id;
}

const INTEGER& EMBEDDED_PDV_identification::presentation__context__id() const
{
  if (union_selection != ALT_presentation__context__id) TTCN_error("Using non-selected field presentation_context_id in a value of union type EMBEDDED PDV.identification.");
  return *field_presentation__context__id;
}

EMBEDDED_PDV_identification_context__negotiation& EMBEDDED_PDV_identification::context__negotiation()
{
  if (union_selection != ALT_context__negotiation) {
    clean_up();
    field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation;
    union_selection = ALT_context__negotiation;
  }
  return *field_context__negotiation;
}

const EMBEDDED_PDV_identification_context__negotiation& EMBEDDED_PDV_identification::context__negotiation() const
{
  if (union_selection != ALT_context__negotiation) TTCN_error("Using non-selected field context_negotiation in a value of union type EMBEDDED PDV.identification.");
  return *field_context__negotiation;
}

OBJID& EMBEDDED_PDV_identification::transfer__syntax()
{
  if (union_selection != ALT_transfer__syntax) {
    clean_up();
    field_transfer__syntax = new OBJID;
    union_selection = ALT_transfer__syntax;
  }
  return *field_transfer__syntax;
}

const OBJID& EMBEDDED_PDV_identification::transfer__syntax() const
{
  if (union_selection != ALT_transfer__syntax) TTCN_error("Using non-selected field transfer_syntax in a value of union type EMBEDDED PDV.identification.");
  return *field_transfer__syntax;
}

ASN_NULL& EMBEDDED_PDV_identification::fixed()
{
  if (union_selection != ALT_fixed) {
    clean_up();
    field_fixed = new ASN_NULL;
    union_selection = ALT_fixed;
  }
  return *field_fixed;
}

const ASN_NULL& EMBEDDED_PDV_identification::fixed() const
{
  if (union_selection != ALT_fixed) TTCN_error("Using non-selected field fixed in a value of union type EMBEDDED PDV.identification.");
  return *field_fixed;
}

boolean EMBEDDED_PDV_identification::ischosen(union_selection_type checked_selection) const
{
  if (checked_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EMBEDDED PDV.identification.");
  if (union_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type EMBEDDED PDV.identification.");
  return union_selection == checked_selection;
}

boolean EMBEDDED_PDV_identification::is_bound() const
{
  return UNBOUND_VALUE != union_selection;
}

boolean EMBEDDED_PDV_identification::is_value() const
{
  switch (union_selection) {
  case ALT_syntaxes:
    return field_syntaxes->is_value();
  case ALT_syntax:
    return field_syntax->is_value();
  case ALT_presentation__context__id:
    return field_presentation__context__id->is_value();
  case ALT_context__negotiation:
    return field_context__negotiation->is_value();
  case ALT_transfer__syntax:
    return field_transfer__syntax->is_value();
  case ALT_fixed:
    return field_fixed->is_value();
  default:
    return FALSE;
  }
}

void EMBEDDED_PDV_identification::log() const
{
  switch (union_selection) {
  case ALT_syntaxes:
    TTCN_Logger::log_event_str("{ syntaxes := ");
    field_syntaxes->log();
    TTCN_Logger::log_event_str(" }");
    break;
  case ALT_syntax:
    TTCN_Logger::log_event_str("{ syntax := ");
    field_syntax->log();
    TTCN_Logger::log_event_str(" }");
    break;
  case ALT_presentation__context__id:
    TTCN_Logger::log_event_str("{ presentation_context_id := ");
    field_presentation__context__id->log();
    TTCN_Logger::log_event_str(" }");
    break;
  case ALT_context__negotiation:
    TTCN_Logger::log_event_str("{ context_negotiation := ");
    field_context__negotiation->log();
    TTCN_Logger::log_event_str(" }");
    break;
  case ALT_transfer__syntax:
    TTCN_Logger::log_event_str("{ transfer_syntax := ");
    field_transfer__syntax->log();
    TTCN_Logger::log_event_str(" }");
    break;
  case ALT_fixed:
    TTCN_Logger::log_event_str("{ fixed := ");
    field_fixed->log();
    TTCN_Logger::log_event_str(" }");
    break;
  default:
    TTCN_Logger::log_event_str("<unbound>");
    break;
  }
}

void EMBEDDED_PDV_identification::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "union value");
Elemer Lelik's avatar
Elemer Lelik committed
379
  Module_Param_Ptr mp = &param;
380
#ifdef TITAN_RUNTIME_2
Elemer Lelik's avatar
Elemer Lelik committed
381
382
383
  if (param.get_type() == Module_Param::MP_Reference) {
    mp = param.get_referenced_param();
  }
384
#endif
Elemer Lelik's avatar
Elemer Lelik committed
385
386
  if (mp->get_type()==Module_Param::MP_Value_List && mp->get_size()==0) return;
  if (mp->get_type()!=Module_Param::MP_Assignment_List) {
Elemer Lelik's avatar
Elemer Lelik committed
387
388
    param.error("union value with field name was expected");
  }
Elemer Lelik's avatar
Elemer Lelik committed
389
  Module_Param* mp_last = mp->get_elem(mp->get_size()-1);
Elemer Lelik's avatar
Elemer Lelik committed
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
  if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) {
    syntaxes().set_param(*mp_last);
    return;
  }
  if (!strcmp(mp_last->get_id()->get_name(), "syntax")) {
    syntax().set_param(*mp_last);
    return;
  }
  if (!strcmp(mp_last->get_id()->get_name(), "presentation_context_id")) {
    presentation__context__id().set_param(*mp_last);
    return;
  }
  if (!strcmp(mp_last->get_id()->get_name(), "context_negotiation")) {
    context__negotiation().set_param(*mp_last);
    return;
  }
  if (!strcmp(mp_last->get_id()->get_name(), "transfer_syntax")) {
    transfer__syntax().set_param(*mp_last);
    return;
  }
  if (!strcmp(mp_last->get_id()->get_name(), "fixed")) {
    fixed().set_param(*mp_last);
    return;
  }
  mp_last->error("Field %s does not exist in type EMBEDDED PDV.identification.", mp_last->get_id()->get_name());
}

417
#ifdef TITAN_RUNTIME_2
Elemer Lelik's avatar
Elemer Lelik committed
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
Module_Param* EMBEDDED_PDV_identification::get_param(Module_Param_Name& param_name) const
{
  if (!is_bound()) {
    return new Module_Param_Unbound();
  }
  Module_Param* mp_field = NULL;
  switch(get_selection()) {
  case ALT_syntaxes:
    mp_field = field_syntaxes->get_param(param_name);
    mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
    break;
  case ALT_syntax:
    mp_field = field_syntax->get_param(param_name);
    mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax")));
    break;
  case ALT_presentation__context__id:
    mp_field = field_presentation__context__id->get_param(param_name);
    mp_field->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
    break;
  case ALT_context__negotiation:
    mp_field = field_context__negotiation->get_param(param_name);
    mp_field->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
    break;
  case ALT_transfer__syntax:
    mp_field = field_transfer__syntax->get_param(param_name);
    mp_field->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
    break;
  case ALT_fixed:
    mp_field = field_fixed->get_param(param_name);
    mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed")));
    break;
  default:
    break;
  }
  Module_Param_Assignment_List* mp = new Module_Param_Assignment_List();
  mp->add_elem(mp_field);
  return mp;
}
456
#endif
Elemer Lelik's avatar
Elemer Lelik committed
457

Elemer Lelik's avatar
Elemer Lelik committed
458
459
460
void EMBEDDED_PDV_identification_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "union template");
Elemer Lelik's avatar
Elemer Lelik committed
461
  Module_Param_Ptr mp = &param;
462
#ifdef TITAN_RUNTIME_2
Elemer Lelik's avatar
Elemer Lelik committed
463
464
465
  if (param.get_type() == Module_Param::MP_Reference) {
    mp = param.get_referenced_param();
  }
466
#endif
Elemer Lelik's avatar
Elemer Lelik committed
467
  switch (mp->get_type()) {
Elemer Lelik's avatar
Elemer Lelik committed
468
469
470
471
472
473
474
475
476
477
  case Module_Param::MP_Omit:
    *this = OMIT_VALUE;
    break;
  case Module_Param::MP_Any:
    *this = ANY_VALUE;
    break;
  case Module_Param::MP_AnyOrNone:
    *this = ANY_OR_OMIT;
    break;
  case Module_Param::MP_List_Template:
Elemer Lelik's avatar
Elemer Lelik committed
478
479
480
481
482
483
  case Module_Param::MP_ComplementList_Template: {
    EMBEDDED_PDV_identification_template temp;
    temp.set_type(mp->get_type() == Module_Param::MP_List_Template ?
      VALUE_LIST : COMPLEMENTED_LIST, mp->get_size());
    for (size_t i=0; i<mp->get_size(); i++) {
      temp.list_item(i).set_param(*mp->get_elem(i));
Elemer Lelik's avatar
Elemer Lelik committed
484
    }
Elemer Lelik's avatar
Elemer Lelik committed
485
486
    *this = temp;
    break; }
Elemer Lelik's avatar
Elemer Lelik committed
487
  case Module_Param::MP_Value_List:
Elemer Lelik's avatar
Elemer Lelik committed
488
    if (mp->get_size()==0) break;
Elemer Lelik's avatar
Elemer Lelik committed
489
490
491
    param.type_error("union template", "EMBEDDED PDV.identification");
    break;
  case Module_Param::MP_Assignment_List: {
Elemer Lelik's avatar
Elemer Lelik committed
492
    Module_Param* mp_last = mp->get_elem(mp->get_size()-1);
Elemer Lelik's avatar
Elemer Lelik committed
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
    if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) {
      syntaxes().set_param(*mp_last);
      break;
    }
    if (!strcmp(mp_last->get_id()->get_name(), "syntax")) {
      syntax().set_param(*mp_last);
      break;
    }
    if (!strcmp(mp_last->get_id()->get_name(), "presentation_context_id")) {
      presentation__context__id().set_param(*mp_last);
      break;
    }
    if (!strcmp(mp_last->get_id()->get_name(), "context_negotiation")) {
      context__negotiation().set_param(*mp_last);
      break;
    }
    if (!strcmp(mp_last->get_id()->get_name(), "transfer_syntax")) {
      transfer__syntax().set_param(*mp_last);
      break;
    }
    if (!strcmp(mp_last->get_id()->get_name(), "fixed")) {
      fixed().set_param(*mp_last);
      break;
    }
    mp_last->error("Field %s does not exist in type EMBEDDED PDV.identification.", mp_last->get_id()->get_name());
  } break;
  default:
    param.type_error("union template", "EMBEDDED PDV.identification");
  }
Elemer Lelik's avatar
Elemer Lelik committed
522
523
524
  is_ifpresent = param.get_ifpresent() || mp->get_ifpresent();
}

525
#ifdef TITAN_RUNTIME_2
Elemer Lelik's avatar
Elemer Lelik committed
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
Module_Param* EMBEDDED_PDV_identification_template::get_param(Module_Param_Name& param_name) const
{
  Module_Param* mp = NULL;
  switch (template_selection) {
  case UNINITIALIZED_TEMPLATE:
    mp = new Module_Param_Unbound();
    break;
  case OMIT_VALUE:
    mp = new Module_Param_Omit();
    break;
  case ANY_VALUE:
    mp = new Module_Param_Any();
    break;
  case ANY_OR_OMIT:
    mp = new Module_Param_AnyOrNone();
    break;
  case SPECIFIC_VALUE: {
    Module_Param* mp_field = NULL;
    switch(single_value.union_selection) {
    case EMBEDDED_PDV_identification::ALT_syntaxes:
      mp_field = single_value.field_syntaxes->get_param(param_name);
      mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
      break;
    case EMBEDDED_PDV_identification::ALT_syntax:
      mp_field = single_value.field_syntax->get_param(param_name);
      mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax")));
      break;
    case EMBEDDED_PDV_identification::ALT_presentation__context__id:
      mp_field = single_value.field_presentation__context__id->get_param(param_name);
      mp_field->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
      break;
    case EMBEDDED_PDV_identification::ALT_context__negotiation:
      mp_field = single_value.field_context__negotiation->get_param(param_name);
      mp_field->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
      break;
    case EMBEDDED_PDV_identification::ALT_transfer__syntax:
      mp_field = single_value.field_transfer__syntax->get_param(param_name);
      mp_field->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
      break;
    case EMBEDDED_PDV_identification::ALT_fixed:
      mp_field = single_value.field_fixed->get_param(param_name);
      mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed")));
      break;
    default:
      break;
    }
    mp = new Module_Param_Assignment_List();
    mp->add_elem(mp_field);
    break; }
  case VALUE_LIST:
  case COMPLEMENTED_LIST: {
    if (template_selection == VALUE_LIST) {
      mp = new Module_Param_List_Template();
    }
    else {
      mp = new Module_Param_ComplementList_Template();
    }
    for (size_t i = 0; i < value_list.n_values; ++i) {
      mp->add_elem(value_list.list_value[i].get_param(param_name));
    }
    break; }
  default:
588
    TTCN_error("Referencing an uninitialized/unsupported value of type EMBEDDED PDV.identification.");
Elemer Lelik's avatar
Elemer Lelik committed
589
590
591
592
593
594
    break;
  }
  if (is_ifpresent) {
    mp->set_ifpresent();
  }
  return mp;
Elemer Lelik's avatar
Elemer Lelik committed
595
}
596
#endif
Elemer Lelik's avatar
Elemer Lelik committed
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
650
651

void EMBEDDED_PDV_identification::encode_text(Text_Buf& text_buf) const
{
  text_buf.push_int(union_selection);
  switch (union_selection) {
  case ALT_syntaxes:
    field_syntaxes->encode_text(text_buf);
    break;
  case ALT_syntax:
    field_syntax->encode_text(text_buf);
    break;
  case ALT_presentation__context__id:
    field_presentation__context__id->encode_text(text_buf);
    break;
  case ALT_context__negotiation:
    field_context__negotiation->encode_text(text_buf);
    break;
  case ALT_transfer__syntax:
    field_transfer__syntax->encode_text(text_buf);
    break;
  case ALT_fixed:
    field_fixed->encode_text(text_buf);
    break;
  default:
    TTCN_error("Text encoder: Encoding an unbound value of union type EMBEDDED PDV.identification.");
  }
}

void EMBEDDED_PDV_identification::decode_text(Text_Buf& text_buf)
{
  switch ((union_selection_type)text_buf.pull_int().get_val()) {
  case ALT_syntaxes:
    syntaxes().decode_text(text_buf);
    break;
  case ALT_syntax:
    syntax().decode_text(text_buf);
    break;
  case ALT_presentation__context__id:
    presentation__context__id().decode_text(text_buf);
    break;
  case ALT_context__negotiation:
    context__negotiation().decode_text(text_buf);
    break;
  case ALT_transfer__syntax:
    transfer__syntax().decode_text(text_buf);
    break;
  case ALT_fixed:
    fixed().decode_text(text_buf);
    break;
  default:
    TTCN_error("Text decoder: Unrecognized union selector was received for type EMBEDDED PDV.identification.");
  }
}

// No encode/decode for this implementation class
652
653
//void EMBEDDED_PDV_identification::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
//void EMBEDDED_PDV_identification::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
Elemer Lelik's avatar
Elemer Lelik committed
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779

ASN_BER_TLV_t *EMBEDDED_PDV_identification::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const
{
  BER_chk_descr(p_td);
  ASN_BER_TLV_t *new_tlv;
  TTCN_EncDec_ErrorContext ec_0("Alternative '");
  TTCN_EncDec_ErrorContext ec_1;
  switch (union_selection) {
  case ALT_syntaxes:
    ec_1.set_msg("syntaxes': ");
    new_tlv = field_syntaxes->BER_encode_TLV(EMBEDDED_PDV_identification_syntaxes_descr_, p_coding);
    break;
  case ALT_syntax:
    ec_1.set_msg("syntax': ");
    new_tlv = field_syntax->BER_encode_TLV(EMBEDDED_PDV_identification_syntax_descr_, p_coding);
    break;
  case ALT_presentation__context__id:
    ec_1.set_msg("presentation_context_id': ");
    new_tlv = field_presentation__context__id->BER_encode_TLV(EMBEDDED_PDV_identification_presentation__context__id_descr_, p_coding);
    break;
  case ALT_context__negotiation:
    ec_1.set_msg("context_negotiation': ");
    new_tlv = field_context__negotiation->BER_encode_TLV(EMBEDDED_PDV_identification_context__negotiation_descr_, p_coding);
    break;
  case ALT_transfer__syntax:
    ec_1.set_msg("transfer_syntax': ");
    new_tlv = field_transfer__syntax->BER_encode_TLV(EMBEDDED_PDV_identification_transfer__syntax_descr_, p_coding);
    break;
  case ALT_fixed:
    ec_1.set_msg("fixed': ");
    new_tlv = field_fixed->BER_encode_TLV(EMBEDDED_PDV_identification_fixed_descr_, p_coding);
    break;
  case UNBOUND_VALUE:
    new_tlv = BER_encode_chk_bound(FALSE);
    break;
  default:
    TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
    new_tlv = NULL;
    break;
  }
  return ASN_BER_V2TLV(new_tlv, p_td, p_coding);
}

boolean EMBEDDED_PDV_identification::BER_decode_set_selection(const ASN_BER_TLV_t& p_tlv)
{
  clean_up();
  field_syntaxes = new EMBEDDED_PDV_identification_syntaxes;
  union_selection = ALT_syntaxes;
  if (field_syntaxes->BER_decode_isMyMsg(EMBEDDED_PDV_identification_syntaxes_descr_, p_tlv)) return TRUE;
  delete field_syntaxes;
  field_syntax = new OBJID;
  union_selection = ALT_syntax;
  if (field_syntax->BER_decode_isMyMsg(EMBEDDED_PDV_identification_syntax_descr_, p_tlv)) return TRUE;
  delete field_syntax;
  field_presentation__context__id = new INTEGER;
  union_selection = ALT_presentation__context__id;
  if (field_presentation__context__id->BER_decode_isMyMsg(EMBEDDED_PDV_identification_presentation__context__id_descr_, p_tlv)) return TRUE;
  delete field_presentation__context__id;
  field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation;
  union_selection = ALT_context__negotiation;
  if (field_context__negotiation->BER_decode_isMyMsg(EMBEDDED_PDV_identification_context__negotiation_descr_, p_tlv)) return TRUE;
  delete field_context__negotiation;
  field_transfer__syntax = new OBJID;
  union_selection = ALT_transfer__syntax;
  if (field_transfer__syntax->BER_decode_isMyMsg(EMBEDDED_PDV_identification_transfer__syntax_descr_, p_tlv)) return TRUE;
  delete field_transfer__syntax;
  field_fixed = new ASN_NULL;
  union_selection = ALT_fixed;
  if (field_fixed->BER_decode_isMyMsg(EMBEDDED_PDV_identification_fixed_descr_, p_tlv)) return TRUE;
  delete field_fixed;
  union_selection = UNBOUND_VALUE;
  return FALSE;
}

boolean EMBEDDED_PDV_identification::BER_decode_isMyMsg(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv)
{
  if (p_td.ber->n_tags == 0) {
    EMBEDDED_PDV_identification tmp_type;
    return tmp_type.BER_decode_set_selection(p_tlv);
  } else return Base_Type::BER_decode_isMyMsg(p_td, p_tlv);
}

boolean EMBEDDED_PDV_identification::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form)
{
  BER_chk_descr(p_td);
  ASN_BER_TLV_t stripped_tlv;
  BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv);
  TTCN_EncDec_ErrorContext ec_0("While decoding 'EMBEDDED PDV.identification' type: ");
  ASN_BER_TLV_t tmp_tlv;
  if (!BER_decode_TLV_CHOICE(*p_td.ber, stripped_tlv, L_form, tmp_tlv) || !BER_decode_CHOICE_selection(BER_decode_set_selection(tmp_tlv), tmp_tlv)) return FALSE;
  TTCN_EncDec_ErrorContext ec_1("Alternative '");
  TTCN_EncDec_ErrorContext ec_2;
  switch (union_selection) {
  case ALT_syntaxes:
    ec_2.set_msg("syntaxes': ");
    field_syntaxes->BER_decode_TLV(EMBEDDED_PDV_identification_syntaxes_descr_, tmp_tlv, L_form);
    break;
  case ALT_syntax:
    ec_2.set_msg("syntax': ");
    field_syntax->BER_decode_TLV(EMBEDDED_PDV_identification_syntax_descr_, tmp_tlv, L_form);
    break;
  case ALT_presentation__context__id:
    ec_2.set_msg("presentation_context_id': ");
    field_presentation__context__id->BER_decode_TLV(EMBEDDED_PDV_identification_presentation__context__id_descr_, tmp_tlv, L_form);
    break;
  case ALT_context__negotiation:
    ec_2.set_msg("context_negotiation': ");
    field_context__negotiation->BER_decode_TLV(EMBEDDED_PDV_identification_context__negotiation_descr_, tmp_tlv, L_form);
    break;
  case ALT_transfer__syntax:
    ec_2.set_msg("transfer_syntax': ");
    field_transfer__syntax->BER_decode_TLV(EMBEDDED_PDV_identification_transfer__syntax_descr_, tmp_tlv, L_form);
    break;
  case ALT_fixed:
    ec_2.set_msg("fixed': ");
    field_fixed->BER_decode_TLV(EMBEDDED_PDV_identification_fixed_descr_, tmp_tlv, L_form);
    break;
  default:
    return FALSE;
  }
  return TRUE;
}

// FIXME maybe: XER_encode and decode is virtually identical to CHARACTER_STRING

int EMBEDDED_PDV_identification::XER_encode(const XERdescriptor_t& p_td,
780
  TTCN_Buffer& p_buf, unsigned int flavor, unsigned int flavor2, int indent, embed_values_enc_struct_t*) const
Elemer Lelik's avatar
Elemer Lelik committed
781
782
{
  int indenting = !is_canonical(flavor);
783
  boolean exer  = is_exer(flavor);
Elemer Lelik's avatar
Elemer Lelik committed
784
785
786
787
788
789
790
791
792
  int encoded_length=(int)p_buf.get_len();
  if (indenting) do_indent(p_buf, indent);
  p_buf.put_c('<');
  if (exer) write_ns_prefix(p_td, p_buf);
  p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]);
  flavor &= XER_MASK;
  ++indent;
  switch (union_selection) {
  case ALT_syntaxes:
793
    field_syntaxes->XER_encode(EMBEDDED_PDV_identification_sxs_xer_, p_buf, flavor, flavor2, indent, 0);;
Elemer Lelik's avatar
Elemer Lelik committed
794
795
    break;
  case ALT_syntax:
796
    field_syntax->XER_encode(EMBEDDED_PDV_identification_sx_xer_, p_buf, flavor, flavor2, indent, 0);;
Elemer Lelik's avatar
Elemer Lelik committed
797
798
    break;
  case ALT_presentation__context__id:
799
    field_presentation__context__id->XER_encode(EMBEDDED_PDV_identification_pci_xer_, p_buf, flavor, flavor2, indent, 0);;
Elemer Lelik's avatar
Elemer Lelik committed
800
801
    break;
  case ALT_context__negotiation:
802
    field_context__negotiation->XER_encode(EMBEDDED_PDV_identification_cn_xer_, p_buf, flavor, flavor2, indent, 0);;
Elemer Lelik's avatar
Elemer Lelik committed
803
804
    break;
  case ALT_transfer__syntax:
805
    field_transfer__syntax->XER_encode(EMBEDDED_PDV_identification_ts_xer_, p_buf, flavor, flavor2, indent, 0);;
Elemer Lelik's avatar
Elemer Lelik committed
806
807
    break;
  case ALT_fixed:
808
    field_fixed->XER_encode(EMBEDDED_PDV_identification_fix_xer_, p_buf, flavor, flavor2, indent, 0);;
Elemer Lelik's avatar
Elemer Lelik committed
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
    break;
  default:
    TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
    break;
  }

  if (indenting) do_indent(p_buf, --indent);
  p_buf.put_c('<');
  p_buf.put_c('/');
  if (exer) write_ns_prefix(p_td, p_buf);
  p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]);
  return (int)p_buf.get_len() - encoded_length;
}

int EMBEDDED_PDV_identification::XER_decode(const XERdescriptor_t& p_td,
Elemer Lelik's avatar
Elemer Lelik committed
824
  XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
Elemer Lelik's avatar
Elemer Lelik committed
825
{
826
  boolean exer  = is_exer(flavor);
Elemer Lelik's avatar
Elemer Lelik committed
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
  // we are supposed to be parked on our element
  for (int success = 1; success == 1; success = reader.Read()) {
    int type = reader.NodeType();
    switch (type) {
    case XML_READER_TYPE_ELEMENT: {
      if (verify_name(reader, p_td, exer)) {
	// it's us
	for (success = reader.Read(); success == 1; success = reader.Read()) {
	  type = reader.NodeType();
	  if (XML_READER_TYPE_ELEMENT == type) break;
	  else if (XML_READER_TYPE_END_ELEMENT == type) goto bail;
	}
	const char *name = (const char*)reader.Name();
	// Avoid chained if-else on strcmp. Use the length as a hash.
	size_t namelen = strlen(name);
	switch (namelen) {
	case 8: // syntaxes
Elemer Lelik's avatar
Elemer Lelik committed
844
	  syntaxes().XER_decode(EMBEDDED_PDV_identification_sxs_xer_, reader, flavor, flavor2, 0);
Elemer Lelik's avatar
Elemer Lelik committed
845
846
847
	  break;

	case 6: // syntax
Elemer Lelik's avatar
Elemer Lelik committed
848
	  syntax().XER_decode(EMBEDDED_PDV_identification_sx_xer_, reader, flavor, flavor2, 0);
Elemer Lelik's avatar
Elemer Lelik committed
849
850
851
	  break;

	case 23: // presentation-context-id
Elemer Lelik's avatar
Elemer Lelik committed
852
	  presentation__context__id().XER_decode(EMBEDDED_PDV_identification_pci_xer_, reader, flavor, flavor2, 0);
Elemer Lelik's avatar
Elemer Lelik committed
853
854
855
	  break;

	case 19: // context-negotiation
Elemer Lelik's avatar
Elemer Lelik committed
856
	  context__negotiation().XER_decode(EMBEDDED_PDV_identification_cn_xer_, reader, flavor, flavor2, 0);
Elemer Lelik's avatar
Elemer Lelik committed
857
858
859
	  break;

	case 15: // transfer-syntax
Elemer Lelik's avatar
Elemer Lelik committed
860
	  transfer__syntax().XER_decode(EMBEDDED_PDV_identification_ts_xer_, reader, flavor, flavor2, 0);
Elemer Lelik's avatar
Elemer Lelik committed
861
862
863
	  break;

	case 5: // fixed
Elemer Lelik's avatar
Elemer Lelik committed
864
	  fixed().XER_decode(EMBEDDED_PDV_identification_fix_xer_, reader, flavor, flavor2, 0);
Elemer Lelik's avatar
Elemer Lelik committed
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
	  break;

	default:
	  goto bail;
	} // switch
      }
      else { // it belongs to somebody else
	goto bail;
      }
      break; }
    case XML_READER_TYPE_END_ELEMENT: {
      // advance to the next thing and bail
      reader.Read();
      goto bail; }
    }
  }
  bail:
  return 1;
}

885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
int EMBEDDED_PDV_identification::OER_encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf) const {
  switch (union_selection) {
  case ALT_syntaxes:
    p_buf.put_c(128); // tag
    field_syntaxes->OER_encode(p_td, p_buf);
    break;
  case ALT_syntax:
    p_buf.put_c(129);
    field_syntax->OER_encode(OBJID_descr_, p_buf);
    break;
  case ALT_presentation__context__id:
    p_buf.put_c(130);
    field_presentation__context__id->OER_encode(INTEGER_descr_, p_buf);
    break;
  case ALT_context__negotiation:
    p_buf.put_c(131);
    field_context__negotiation->OER_encode(p_td, p_buf);
    break;
  case ALT_transfer__syntax:
    p_buf.put_c(132);
    field_transfer__syntax->OER_encode(OBJID_descr_, p_buf);
    break;
  case ALT_fixed:
    p_buf.put_c(133);
    field_fixed->OER_encode(p_td, p_buf);
    break;
  default:
    TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
    break;
  }
  return 0;
}

int EMBEDDED_PDV_identification::OER_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, OER_struct& p_oer) {
  const unsigned char* uc = p_buf.get_read_data();
  p_buf.increase_pos(1);
  switch (uc[0]) {
  case 128:
    syntaxes().OER_decode(p_td, p_buf, p_oer);
    break;
  case 129:
    syntax().OER_decode(OBJID_descr_, p_buf, p_oer);
    break;
  case 130:
    presentation__context__id().OER_decode(INTEGER_descr_, p_buf, p_oer);
    break;
  case 131:
    context__negotiation().OER_decode(p_td, p_buf, p_oer);
    break;
  case 132:
    transfer__syntax().OER_decode(OBJID_descr_, p_buf, p_oer);
    break;
  case 133:
    fixed().OER_decode(p_td, p_buf, p_oer);
    break;
  default:
    TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
    break;
  }
  return 0;
}

Elemer Lelik's avatar
Elemer Lelik committed
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
/******************** EMBEDDED_PDV_identification_template ********************/

void EMBEDDED_PDV_identification_template::clean_up()
{
  switch (template_selection) {
  case SPECIFIC_VALUE:
    switch (single_value.union_selection) {
    case EMBEDDED_PDV_identification::ALT_syntaxes:
      delete single_value.field_syntaxes;
      break;
    case EMBEDDED_PDV_identification::ALT_syntax:
      delete single_value.field_syntax;
      break;
    case EMBEDDED_PDV_identification::ALT_presentation__context__id:
      delete single_value.field_presentation__context__id;
      break;
    case EMBEDDED_PDV_identification::ALT_context__negotiation:
      delete single_value.field_context__negotiation;
      break;
    case EMBEDDED_PDV_identification::ALT_transfer__syntax:
      delete single_value.field_transfer__syntax;
      break;
    case EMBEDDED_PDV_identification::ALT_fixed:
      delete single_value.field_fixed;
      break;
    default:
      break;
    }
    break;
  case VALUE_LIST:
  case COMPLEMENTED_LIST:
    delete [] value_list.list_value;
    break;
  default:
    break;
  }
  template_selection = UNINITIALIZED_TEMPLATE;
}

void EMBEDDED_PDV_identification_template::copy_value(const EMBEDDED_PDV_identification& other_value)
{
  single_value.union_selection = other_value.get_selection();
  switch (single_value.union_selection) {
  case EMBEDDED_PDV_identification::ALT_syntaxes:
    single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template(other_value.syntaxes());
    break;
  case EMBEDDED_PDV_identification::ALT_syntax:
    single_value.field_syntax = new OBJID_template(other_value.syntax());
    break;
  case EMBEDDED_PDV_identification::ALT_presentation__context__id:
    single_value.field_presentation__context__id = new INTEGER_template(other_value.presentation__context__id());
    break;
  case EMBEDDED_PDV_identification::ALT_context__negotiation:
    single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template(other_value.context__negotiation());
    break;
  case EMBEDDED_PDV_identification::ALT_transfer__syntax:
    single_value.field_transfer__syntax = new OBJID_template(other_value.transfer__syntax());
    break;
  case EMBEDDED_PDV_identification::ALT_fixed:
    single_value.field_fixed = new ASN_NULL_template(other_value.fixed());
    break;
  default:
    TTCN_error("Initializing a template with an unbound value of type EMBEDDED PDV.identification.");
  }
  set_selection(SPECIFIC_VALUE);
}

void EMBEDDED_PDV_identification_template::copy_template(const EMBEDDED_PDV_identification_template& other_value)
{
  switch (other_value.template_selection) {
  case SPECIFIC_VALUE:
    single_value.union_selection = other_value.single_value.union_selection;
    switch (single_value.union_selection) {
    case EMBEDDED_PDV_identification::ALT_syntaxes:
      single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template(*other_value.single_value.field_syntaxes);
      break;
    case EMBEDDED_PDV_identification::ALT_syntax:
      single_value.field_syntax = new OBJID_template(*other_value.single_value.field_syntax);
      break;
    case EMBEDDED_PDV_identification::ALT_presentation__context__id:
      single_value.field_presentation__context__id = new INTEGER_template(*other_value.single_value.field_presentation__context__id);
      break;
    case EMBEDDED_PDV_identification::ALT_context__negotiation:
      single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template(*other_value.single_value.field_context__negotiation);
      break;
    case EMBEDDED_PDV_identification::ALT_transfer__syntax:
      single_value.field_transfer__syntax = new OBJID_template(*other_value.single_value.field_transfer__syntax);
      break;
    case EMBEDDED_PDV_identification::ALT_fixed:
      single_value.field_fixed = new ASN_NULL_template(*other_value.single_value.field_fixed);
      break;
    default:
      TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type EMBEDDED PDV.identification.");
    }
    break;
  case OMIT_VALUE:
  case ANY_VALUE:
  case ANY_OR_OMIT:
    break;
  case VALUE_LIST:
  case COMPLEMENTED_LIST:
    value_list.n_values = other_value.value_list.n_values;
    value_list.list_value = new EMBEDDED_PDV_identification_template[value_list.n_values];
    for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
      value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
    break;
  default:
    TTCN_error("Copying an uninitialized template of union type EMBEDDED PDV.identification.");
  }
  set_selection(other_value);
}

EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template()
{
}

EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(template_sel other_value)
  : Base_Template(other_value)
{
  check_single_selection(other_value);
}

EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const EMBEDDED_PDV_identification& other_value)
{
  copy_value(other_value);
}

EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const OPTIONAL<EMBEDDED_PDV_identification>& other_value)
{
  switch (other_value.get_selection()) {
  case OPTIONAL_PRESENT:
    copy_value((const EMBEDDED_PDV_identification&)other_value);
    break;
  case OPTIONAL_OMIT:
    set_selection(OMIT_VALUE);
    break;
1083
  case OPTIONAL_UNBOUND:
Elemer Lelik's avatar
Elemer Lelik committed
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
    TTCN_error("Creating a template of union type EMBEDDED PDV.identification from an unbound optional field.");
  }
}

EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const EMBEDDED_PDV_identification_template& other_value)
: Base_Template()
{
  copy_template(other_value);
}

EMBEDDED_PDV_identification_template::~EMBEDDED_PDV_identification_template()
{
  clean_up();
}

EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::operator=(template_sel other_value)
{
  check_single_selection(other_value);
  clean_up();
  set_selection(other_value);
  return *this;
}

EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::operator=(const EMBEDDED_PDV_identification& other_value)
{
  clean_up();
  copy_value(other_value);
  return *this;
}

EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::operator=(const OPTIONAL<EMBEDDED_PDV_identification>& other_value)
{
  clean_up();
  switch (other_value.get_selection()) {
  case OPTIONAL_PRESENT:
    copy_value((const EMBEDDED_PDV_identification&)other_value);
    break;
  case OPTIONAL_OMIT:
    set_selection(OMIT_VALUE);
    break;
1124
  case OPTIONAL_UNBOUND:
Elemer Lelik's avatar
Elemer Lelik committed
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
    TTCN_error("Assignment of an unbound optional field to a template of union type EMBEDDED PDV.identification.");
  }
  return *this;
}

EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::operator=(const EMBEDDED_PDV_identification_template& other_value)
{
  if (&other_value != this) {
    clean_up();
    copy_template(other_value);
  }
  return *this;
}

Elemer Lelik's avatar
Elemer Lelik committed
1139
1140
boolean EMBEDDED_PDV_identification_template::match(const EMBEDDED_PDV_identification& other_value,
                                                    boolean /* legacy */) const
Elemer Lelik's avatar
Elemer Lelik committed
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
{
  switch (template_selection) {
  case ANY_VALUE:
  case ANY_OR_OMIT:
    return TRUE;
  case OMIT_VALUE:
    return FALSE;
  case SPECIFIC_VALUE:
    {
      EMBEDDED_PDV_identification::union_selection_type value_selection = other_value.get_selection();
      if (value_selection == EMBEDDED_PDV_identification::UNBOUND_VALUE) return FALSE;
      if (value_selection != single_value.union_selection) return FALSE;
      switch (value_selection) {
      case EMBEDDED_PDV_identification::ALT_syntaxes:
	return single_value.field_syntaxes->match(other_value.syntaxes());
      case EMBEDDED_PDV_identification::ALT_syntax:
	return single_value.field_syntax->match(other_value.syntax());
      case EMBEDDED_PDV_identification::ALT_presentation__context__id:
	return single_value.field_presentation__context__id->match(other_value.presentation__context__id());
      case EMBEDDED_PDV_identification::ALT_context__negotiation:
	return single_value.field_context__negotiation->match(other_value.context__negotiation());
      case EMBEDDED_PDV_identification::ALT_transfer__syntax:
	return single_value.field_transfer__syntax->match(other_value.transfer__syntax());
      case EMBEDDED_PDV_identification::ALT_fixed:
	return single_value.field_fixed->match(other_value.fixed());
      default:
	TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type EMBEDDED PDV.identification.");
      }
    }
    break; // should never get here
  case VALUE_LIST:
  case COMPLEMENTED_LIST:
    for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
      if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST;
    return template_selection == COMPLEMENTED_LIST;
  default:
    TTCN_error ("Matching an uninitialized template of union type EMBEDDED PDV.identification.");
  }
  return FALSE;
}

EMBEDDED_PDV_identification EMBEDDED_PDV_identification_template::valueof() const
{
  if (template_selection != SPECIFIC_VALUE || is_ifpresent)
Botond Baranyi's avatar
Botond Baranyi committed
1185
    TTCN_error("Performing a valueof or send operation on a non-specific template of union type EMBEDDED PDV.identification.");
Elemer Lelik's avatar
Elemer Lelik committed
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
  EMBEDDED_PDV_identification ret_val;
  switch (single_value.union_selection) {
  case EMBEDDED_PDV_identification::ALT_syntaxes:
    ret_val.syntaxes() = single_value.field_syntaxes->valueof();
    break;
  case EMBEDDED_PDV_identification::ALT_syntax:
    ret_val.syntax() = single_value.field_syntax->valueof();
    break;
  case EMBEDDED_PDV_identification::ALT_presentation__context__id:
    ret_val.presentation__context__id() = single_value.field_presentation__context__id->valueof();
    break;
  case EMBEDDED_PDV_identification::ALT_context__negotiation:
    ret_val.context__negotiation() = single_value.field_context__negotiation->valueof();
    break;
  case EMBEDDED_PDV_identification::ALT_transfer__syntax:
    ret_val.transfer__syntax() = single_value.field_transfer__syntax->valueof();
    break;
  case EMBEDDED_PDV_identification::ALT_fixed:
    ret_val.fixed() = single_value.field_fixed->valueof();
    break;
  default:
    TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type EMBEDDED PDV.identification.");
  }
  return ret_val;
}

EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::list_item(unsigned int list_index) const
{
  if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Internal error: Accessing a list element of a non-list template of union type EMBEDDED PDV.identification.");
  if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of union type EMBEDDED PDV.identification.");
  return value_list.list_value[list_index];
}
void EMBEDDED_PDV_identification_template::set_type(template_sel template_type, unsigned int list_length)
{
  if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error ("Internal error: Setting an invalid list for a template of union type EMBEDDED PDV.identification.");
  clean_up();
  set_selection(template_type);
  value_list.n_values = list_length;
  value_list.list_value = new EMBEDDED_PDV_identification_template[list_length];
}

EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_template::syntaxes()
{
  if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_syntaxes) {
    template_sel old_selection = template_selection;
    clean_up();
    if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template(ANY_VALUE);
    else single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template;
    single_value.union_selection = EMBEDDED_PDV_identification::ALT_syntaxes;
    set_selection(SPECIFIC_VALUE);
  }
  return *single_value.field_syntaxes;
}

const EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_template::syntaxes() const
{
  if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field syntaxes in a non-specific template of union type EMBEDDED PDV.identification.");
  if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_syntaxes) TTCN_error("Accessing non-selected field syntaxes in a template of union type EMBEDDED PDV.identification.");
  return *single_value.field_syntaxes;
}

OBJID_template& EMBEDDED_PDV_identification_template::syntax()
{
  if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_syntax) {
    template_sel old_selection = template_selection;
    clean_up();
    if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_syntax = new OBJID_template(ANY_VALUE);
    else single_value.field_syntax = new OBJID_template;
    single_value.union_selection = EMBEDDED_PDV_identification::ALT_syntax;
    set_selection(SPECIFIC_VALUE);
  }
  return *single_value.field_syntax;
}

const OBJID_template& EMBEDDED_PDV_identification_template::syntax() const
{
  if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field syntax in a non-specific template of union type EMBEDDED PDV.identification.");
  if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_syntax) TTCN_error("Accessing non-selected field syntax in a template of union type EMBEDDED PDV.identification.");
  return *single_value.field_syntax;
}

INTEGER_template& EMBEDDED_PDV_identification_template::presentation__context__id()
{
  if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_presentation__context__id) {
    template_sel old_selection = template_selection;
    clean_up();
    if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_presentation__context__id = new INTEGER_template(ANY_VALUE);
    else single_value.field_presentation__context__id = new INTEGER_template;
    single_value.union_selection = EMBEDDED_PDV_identification::ALT_presentation__context__id;
    set_selection(SPECIFIC_VALUE);
  }
  return *single_value.field_presentation__context__id;
}

const INTEGER_template& EMBEDDED_PDV_identification_template::presentation__context__id() const
{
  if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type EMBEDDED PDV.identification.");
  if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_presentation__context__id) TTCN_error("Accessing non-selected field presentation_context_id in a template of union type EMBEDDED PDV.identification.");
  return *single_value.field_presentation__context__id;
}

EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_template::context__negotiation()
{
  if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_context__negotiation) {
    template_sel old_selection = template_selection;
    clean_up();
    if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template(ANY_VALUE);
    else single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template;
    single_value.union_selection = EMBEDDED_PDV_identification::ALT_context__negotiation;
    set_selection(SPECIFIC_VALUE);
  }
  return *single_value.field_context__negotiation;
}

const EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_template::context__negotiation() const
{
  if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field context_negotiation in a non-specific template of union type EMBEDDED PDV.identification.");
  if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_context__negotiation) TTCN_error("Accessing non-selected field context_negotiation in a template of union type EMBEDDED PDV.identification.");
  return *single_value.field_context__negotiation;
}

OBJID_template& EMBEDDED_PDV_identification_template::transfer__syntax()
{
  if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_transfer__syntax) {
    template_sel old_selection = template_selection;
    clean_up();
    if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_transfer__syntax = new OBJID_template(ANY_VALUE);
    else single_value.field_transfer__syntax = new OBJID_template;
    single_value.union_selection = EMBEDDED_PDV_identification::ALT_transfer__syntax;
    set_selection(SPECIFIC_VALUE);
  }
  return *single_value.field_transfer__syntax;
}

const OBJID_template& EMBEDDED_PDV_identification_template::transfer__syntax() const
{
  if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type EMBEDDED PDV.identification.");
  if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_transfer__syntax) TTCN_error("Accessing non-selected field transfer_syntax in a template of union type EMBEDDED PDV.identification.");
  return *single_value.field_transfer__syntax;
}

ASN_NULL_template& EMBEDDED_PDV_identification_template::fixed()
{
  if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_fixed) {
    template_sel old_selection = template_selection;
    clean_up();
    if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_fixed = new ASN_NULL_template(ANY_VALUE);
    else single_value.field_fixed = new ASN_NULL_template;
    single_value.union_selection = EMBEDDED_PDV_identification::ALT_fixed;
    set_selection(SPECIFIC_VALUE);
  }
  return *single_value.field_fixed;
}

const ASN_NULL_template& EMBEDDED_PDV_identification_template::fixed() const
{
  if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field fixed in a non-specific template of union type EMBEDDED PDV.identification.");
  if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_fixed) TTCN_error("Accessing non-selected field fixed in a template of union type EMBEDDED PDV.identification.");
  return *single_value.field_fixed;
}

boolean EMBEDDED_PDV_identification_template::ischosen(EMBEDDED_PDV_identification::union_selection_type checked_selection) const
{
  if (checked_selection == EMBEDDED_PDV_identification::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EMBEDDED PDV.identification.");
  switch (template_selection) {
  case SPECIFIC_VALUE:
    if (single_value.union_selection == EMBEDDED_PDV_identification::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type EMBEDDED PDV.identification.");
    return single_value.union_selection == checked_selection;
  case VALUE_LIST:
    {
      if (value_list.n_values < 1)
	TTCN_error("Internal error: Performing ischosen() operation on a template of union type EMBEDDED PDV.identification containing an empty list.");
      boolean ret_val = value_list.list_value[0].ischosen(checked_selection);
      boolean all_same = TRUE;
      for (unsigned int list_count = 1; list_count < value_list.n_values; list_count++) {
	if (value_list.list_value[list_count].ischosen(checked_selection) != ret_val) {
	  all_same = FALSE;
	  break;
	}
      }
      if (all_same) return ret_val;
    }
    // FIXME really no break?
  case ANY_VALUE:
  case ANY_OR_OMIT:
  case OMIT_VALUE:
  case COMPLEMENTED_LIST:
    TTCN_error("Performing ischosen() operation on a template of union type EMBEDDED PDV.identification, which does not determine unambiguously the chosen field of the matching values.");
  default:
    TTCN_error("Performing ischosen() operation on an uninitialized template of union type EMBEDDED PDV.identification");
  }
  return FALSE;
}

void EMBEDDED_PDV_identification_template::log() const
{
  switch (template_selection) {
  case SPECIFIC_VALUE:
    switch (single_value.union_selection) {
    case EMBEDDED_PDV_identification::ALT_syntaxes:
      TTCN_Logger::log_event_str("{ syntaxes := ");
      single_value.field_syntaxes->log();
      TTCN_Logger::log_event_str(" }");
      break;
    case EMBEDDED_PDV_identification::ALT_syntax:
      TTCN_Logger::log_event_str("{ syntax := ");
      single_value.field_syntax->log();
      TTCN_Logger::log_event_str(" }");
      break;
    case EMBEDDED_PDV_identification::ALT_presentation__context__id:
      TTCN_Logger::log_event_str("{ presentation_context_id := ");
      single_value.field_presentation__context__id->log();
      TTCN_Logger::log_event_str(" }");
      break;
    case EMBEDDED_PDV_identification::ALT_context__negotiation:
      TTCN_Logger::log_event_str("{ context_negotiation := ");
      single_value.field_context__negotiation->log();
      TTCN_Logger::log_event_str(" }");
      break;
    case EMBEDDED_PDV_identification::ALT_transfer__syntax:
      TTCN_Logger::log_event_str("{ transfer_syntax := ");
      single_value.field_transfer__syntax->log();
      TTCN_Logger::log_event_str(" }");
      break;
    case EMBEDDED_PDV_identification::ALT_fixed:
      TTCN_Logger::log_event_str("{ fixed := ");
      single_value.field_fixed->log();
      TTCN_Logger::log_event_str(" }");
      break;
    default:
      TTCN_Logger::log_event_str("<invalid selector>");
      break;
    }
    break;
  case COMPLEMENTED_LIST:
1421
    TTCN_Logger::log_event_str("complement");
Elemer Lelik's avatar
Elemer Lelik committed
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
    // no break
  case VALUE_LIST:
    TTCN_Logger::log_char('(');
    for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) {
      if (list_count > 0) TTCN_Logger::log_event_str(", ");
      value_list.list_value[list_count].log();
    }
    TTCN_Logger::log_char(')');
    break;
  default:
    log_generic();
    break;
  }
  log_ifpresent();
}

Elemer Lelik's avatar
Elemer Lelik committed
1438
1439
void EMBEDDED_PDV_identification_template::log_match(const EMBEDDED_PDV_identification& match_value,
                                                     boolean /* legacy */) const
Elemer Lelik's avatar
Elemer Lelik committed
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
{
  if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
    if(match(match_value)){
      TTCN_Logger::print_logmatch_buffer();
      TTCN_Logger::log_event_str(" matched ");
    }
    return;
  }
  if (template_selection == SPECIFIC_VALUE && single_value.union_selection == match_value.get_selection()) {
    switch (single_value.union_selection) {
    case EMBEDDED_PDV_identification::ALT_syntaxes:
      if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
        TTCN_Logger::log_logmatch_info(".syntaxes");
        single_value.field_syntaxes->log_match(match_value.syntaxes());
      }else{
      TTCN_Logger::log_event_str("{ syntaxes := ");
      single_value.field_syntaxes->log_match(match_value.syntaxes());
      TTCN_Logger::log_event_str(" }");
      }
      break;
    case EMBEDDED_PDV_identification::ALT_syntax:
      if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
        TTCN_Logger::log_logmatch_info(".syntax");
        single_value.field_syntax->log_match(match_value.syntax());
      }else{
      TTCN_Logger::log_event_str("{ syntax := ");
      single_value.field_syntax->log_match(match_value.syntax());
      TTCN_Logger::log_event_str(" }");
      }
      break;
    case EMBEDDED_PDV_identification::ALT_presentation__context__id:
      if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
        TTCN_Logger::log_logmatch_info(".presentation_context_id");
        single_value.field_presentation__context__id->log_match(match_value.presentation__context__id());
      }else{
      TTCN_Logger::log_event_str("{ presentation_context_id := ");
      single_value.field_presentation__context__id->log_match(match_value.presentation__context__id());
      TTCN_Logger::log_event_str(" }");
      }
      break;
    case EMBEDDED_PDV_identification::ALT_context__negotiation:
      if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
        TTCN_Logger::log_logmatch_info(".context_negotiation");
        single_value.field_context__negotiation->log_match(match_value.context__negotiation());
      }else{
      TTCN_Logger::log_event_str("{ context_negotiation := ");
      single_value.field_context__negotiation->log_match(match_value.context__negotiation());
      TTCN_Logger::log_event_str(" }");
      }
      break;
    case EMBEDDED_PDV_identification::ALT_transfer__syntax:
      if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
        TTCN_Logger::log_logmatch_info(".transfer_syntax");
        single_value.field_transfer__syntax->log_match(match_value.transfer__syntax());
      }else{
      TTCN_Logger::log_event_str("{ transfer_syntax := ");
      single_value.field_transfer__syntax->log_match(match_value.transfer__syntax());
      TTCN_Logger::log_event_str(" }");
      }
      break;
    case EMBEDDED_PDV_identification::ALT_fixed:
      if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
        TTCN_Logger::log_logmatch_info(".fixed");
        single_value.field_fixed->log_match(match_value.fixed());
      }else{
      TTCN_Logger::log_event_str("{ fixed := ");
      single_value.field_fixed->log_match(match_value.fixed());
      TTCN_Logger::log_event_str(" }");
      }
      break;
    default:
      TTCN_Logger::print_logmatch_buffer();
      TTCN_Logger::log_event_str("<invalid selector>");
    }
  } else {
    TTCN_Logger::print_logmatch_buffer();
    match_value.log();
    TTCN_Logger::log_event_str(" with ");
    log();
    if (match(match_value)) TTCN_Logger::log_event_str(" matched");
    else TTCN_Logger::log_event_str(" unmatched");
  }
}

void EMBEDDED_PDV_identification_template::encode_text(Text_Buf& text_buf) const
{
  encode_text_base(text_buf);
  switch (template_selection) {
  case SPECIFIC_VALUE:
    text_buf.push_int(single_value.union_selection);
    switch (single_value.union_selection) {
    case EMBEDDED_PDV_identification::ALT_syntaxes:
      single_value.field_syntaxes->encode_text(text_buf);
      break;
    case EMBEDDED_PDV_identification::ALT_syntax:
      single_value.field_syntax->encode_text(text_buf);
      break;
    case EMBEDDED_PDV_identification::ALT_presentation__context__id:
      single_value.field_presentation__context__id->encode_text(text_buf);
      break;
    case EMBEDDED_PDV_identification::ALT_context__negotiation:
      single_value.field_context__negotiation->encode_text(text_buf);
      break;
    case EMBEDDED_PDV_identification::ALT_transfer__syntax:
      single_value.field_transfer__syntax->encode_text(text_buf);
      break;
    case EMBEDDED_PDV_identification::ALT_fixed:
      single_value.field_fixed->encode_text(text_buf);
      break;
    default:
      TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type EMBEDDED PDV.identification.");
    }
    break;
  case OMIT_VALUE:
  case ANY_VALUE:
  case ANY_OR_OMIT:
    break;
  case VALUE_LIST:
  case COMPLEMENTED_LIST:
    text_buf.push_int(value_list.n_values);
    for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
      value_list.list_value[list_count].encode_text(text_buf);
    break;
  default:
    TTCN_error("Text encoder: Encoding an uninitialized template of type EMBEDDED PDV.identification.");
  }
}

void EMBEDDED_PDV_identification_template::decode_text(Text_Buf& text_buf)
{
  clean_up();
  decode_text_base(text_buf);
  switch (template_selection) {
  case SPECIFIC_VALUE:
    {
      single_value.union_selection = EMBEDDED_PDV_identification::UNBOUND_VALUE;
      EMBEDDED_PDV_identification::union_selection_type new_selection = (EMBEDDED_PDV_identification::union_selection_type)text_buf.pull_int().get_val();
      switch (new_selection) {
      case EMBEDDED_PDV_identification::ALT_syntaxes:
	single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template;
	single_value.field_syntaxes->decode_text(text_buf);
	break;
      case EMBEDDED_PDV_identification::ALT_syntax:
	single_value.field_syntax = new OBJID_template;
	single_value.field_syntax->decode_text(text_buf);
	break;
      case EMBEDDED_PDV_identification::ALT_presentation__context__id:
	single_value.field_presentation__context__id = new INTEGER_template;
	single_value.field_presentation__context__id->decode_text(text_buf);
	break;
      case EMBEDDED_PDV_identification::ALT_context__negotiation:
	single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template;
	single_value.field_context__negotiation->decode_text(text_buf);
	break;
      case EMBEDDED_PDV_identification::ALT_transfer__syntax:
	single_value.field_transfer__syntax = new OBJID_template;
	single_value.field_transfer__syntax->decode_text(text_buf);
	break;
      case EMBEDDED_PDV_identification::ALT_fixed:
	single_value.field_fixed = new ASN_NULL_template;
	single_value.field_fixed->decode_text(text_buf);
	break;
      default:
	TTCN_error("Text decoder: Unrecognized union selector was received for a template of type EMBEDDED PDV.identification.");
      }
      single_value.union_selection = new_selection;
    }
    break;
  case OMIT_VALUE:
  case ANY_VALUE:
  case ANY_OR_OMIT:
    break;
  case VALUE_LIST:
  case COMPLEMENTED_LIST:
    value_list.n_values = text_buf.pull_int().get_val();
    value_list.list_value = new EMBEDDED_PDV_identification_template[value_list.n_values];
    for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
      value_list.list_value[list_count].decode_text(text_buf);
    break;
  default:
    TTCN_error("Text decoder: Unrecognized selector was received in a template of type EMBEDDED PDV.identification.");
  }
}

Elemer Lelik's avatar
Elemer Lelik committed
1624
boolean EMBEDDED_PDV_identification_template::is_present(boolean legacy /* = FALSE */) const
Elemer Lelik's avatar
Elemer Lelik committed
1625
1626
{
  if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
Elemer Lelik's avatar
Elemer Lelik committed
1627
  return !match_omit(legacy);
Elemer Lelik's avatar
Elemer Lelik committed
1628
1629
}

Elemer Lelik's avatar
Elemer Lelik committed
1630
boolean EMBEDDED_PDV_identification_template::match_omit(boolean legacy /* = FALSE */) const
Elemer Lelik's avatar
Elemer Lelik committed
1631
1632
1633
1634
1635
1636
1637
1638
{
  if (is_ifpresent) return TRUE;
  switch (template_selection) {
  case OMIT_VALUE:
  case ANY_OR_OMIT:
    return TRUE;
  case VALUE_LIST:
  case COMPLEMENTED_LIST:
Elemer Lelik's avatar
Elemer Lelik committed
1639
1640
1641
1642
1643
1644
    if (legacy) {
      for (unsigned int i=0; i<value_list.n_values; i++)
        if (value_list.list_value[i].match_omit())
          return template_selection==VALUE_LIST;
      return template_selection==COMPLEMENTED_LIST;
    } // else fall through
Elemer Lelik's avatar
Elemer Lelik committed
1645
1646
1647
1648
1649
1650
1651
  default:
    return FALSE;
  }
  return FALSE;
}

#ifndef TITAN_RUNTIME_2
Elemer Lelik's avatar
Elemer Lelik committed
1652
1653
void EMBEDDED_PDV_identification_template::check_restriction(template_res t_res, const char* t_name,
                                                             boolean legacy /* = FALSE */) const
Elemer Lelik's avatar
Elemer Lelik committed
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
{
  if (template_selection==UNINITIALIZED_TEMPLATE) return;
  switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
  case TR_VALUE:
    if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return;
    break;
  case TR_OMIT:
    if (!is_ifpresent && (template_selection==OMIT_VALUE ||
        template_selection==SPECIFIC_VALUE)) return;
    break;
  case TR_PRESENT:
Elemer Lelik's avatar
Elemer Lelik committed
1665
    if (!match_omit(legacy)) return;
Elemer Lelik's avatar
Elemer Lelik committed
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
    break;
  default:
    return;
  }
  TTCN_error("Restriction `%s' on template of type %s violated.",
             get_res_name(t_res), t_name ? t_name : "EMBEDDED PDV.identification");
}
#endif

EMBEDDED_PDV_identification_syntaxes::EMBEDDED_PDV_identification_syntaxes()
{
}

EMBEDDED_PDV_identification_syntaxes::EMBEDDED_PDV_identification_syntaxes(const OBJID& par_abstract,
									   const OBJID& par_transfer)
  : field_abstract(par_abstract),
    field_transfer(par_transfer)
{
}

boolean EMBEDDED_PDV_identification_syntaxes::operator==(const EMBEDDED_PDV_identification_syntaxes& other_value) const
{
  return field_abstract==other_value.field_abstract
    && field_transfer==other_value.field_transfer;
}

int EMBEDDED_PDV_identification_syntaxes::size_of() const
{
  int ret_val = 2;
  return ret_val;
}

void EMBEDDED_PDV_identification_syntaxes::log() const
{
  TTCN_Logger::log_event_str("{ abstract := ");
  field_abstract.log();
  TTCN_Logger::log_event_str(", transfer := ");
  field_transfer.log();
  TTCN_Logger::log_event_str(" }");
}

boolean EMBEDDED_PDV_identification_syntaxes::is_bound() const
{
  if(field_abstract.is_bound()) return TRUE;
  if(field_transfer.is_bound()) return TRUE;
  return FALSE;
}

boolean EMBEDDED_PDV_identification_syntaxes::is_value() const
{
  if(!field_abstract.is_value()) return FALSE;
  if(!field_transfer.is_value()) return FALSE;
  return TRUE;
}

void EMBEDDED_PDV_identification_syntaxes::clean_up()
{
  field_abstract.clean_up();
  field_transfer.clean_up();
}

void EMBEDDED_PDV_identification_syntaxes::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
Elemer Lelik's avatar
Elemer Lelik committed
1730
  Module_Param_Ptr mp = &param;
1731
#ifdef TITAN_RUNTIME_2
Elemer Lelik's avatar
Elemer Lelik committed
1732
1733
1734
  if (param.get_type() == Module_Param::MP_Reference) {
    mp = param.get_referenced_param();
  }
1735
#endif
Elemer Lelik's avatar
Elemer Lelik committed
1736
  switch (mp->get_type()) {
Elemer Lelik's avatar
Elemer Lelik committed
1737
  case Module_Param::MP_Value_List:
Elemer Lelik's avatar
Elemer Lelik committed
1738
1739
1740
    if (mp->get_size()==0) return;
    if (2!=mp->get_size()) {
      param.error("record value of type EMBEDDED PDV.identification.syntaxes has 2 fields but list value has %d fields", (int)mp->get_size());
Elemer Lelik's avatar
Elemer Lelik committed
1741
    }
Elemer Lelik's avatar
Elemer Lelik committed
1742
1743
    if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*mp->get_elem(0));
    if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*mp->get_elem(1));
Elemer Lelik's avatar
Elemer Lelik committed
1744
1745
    break;
  case Module_Param::MP_Assignment_List: {
Elemer Lelik's avatar
Elemer Lelik committed
1746
    Vector<bool> value_used(mp->get_size());
1747
    value_used.resize(mp->get_size(), FALSE);
Elemer Lelik's avatar
Elemer Lelik committed
1748
1749
    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
      Module_Param* const curr_param = mp->get_elem(val_idx);
Elemer Lelik's avatar
Elemer Lelik committed
1750
1751
      if (!strcmp(curr_param->get_id()->get_name(), "abstract")) {
        abstract().set_param(*curr_param);
1752
        value_used[val_idx]=TRUE;
Elemer Lelik's avatar
Elemer Lelik committed
1753
1754
      }
    }
Elemer Lelik's avatar
Elemer Lelik committed
1755
1756
    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
      Module_Param* const curr_param = mp->get_elem(val_idx);
Elemer Lelik's avatar
Elemer Lelik committed
1757
1758
      if (!strcmp(curr_param->get_id()->get_name(), "transfer")) {
        transfer().set_param(*curr_param);
1759
        value_used[val_idx]=TRUE;
Elemer Lelik's avatar
Elemer Lelik committed
1760
1761
      }
    }
Elemer Lelik's avatar
Elemer Lelik committed
1762
1763
    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) {
      mp->get_elem(val_idx)->error("Non existent field name in type EMBEDDED PDV.identification.syntaxes: %s", mp->get_elem(val_idx)->get_id()->get_name());
Elemer Lelik's avatar
Elemer Lelik committed
1764
1765
1766
1767
1768
1769
1770
1771
      break;
    }
  } break;
  default:
    param.type_error("record value", "EMBEDDED PDV.identification.syntaxes");
  }
}

1772
#ifdef TITAN_RUNTIME_2
Elemer Lelik's avatar
Elemer Lelik committed
1773
Module_Param* EMBEDDED_PDV_identification_syntaxes::get_param(Module_Param_Name& param_name) const
Elemer Lelik's avatar
Elemer Lelik committed
1774
{
Elemer Lelik's avatar
Elemer Lelik committed
1775
1776
  if (!is_bound()) {
    return new Module_Param_Unbound();
Elemer Lelik's avatar
Elemer Lelik committed
1777
  }
Elemer Lelik's avatar
Elemer Lelik committed
1778
1779
1780
1781
1782
1783
1784
1785
  Module_Param* mp_field_abstract = field_abstract.get_param(param_name);
  mp_field_abstract->set_id(new Module_Param_FieldName(mcopystr("abstract")));
  Module_Param* mp_field_transfer = field_transfer.get_param(param_name);
  mp_field_transfer->set_id(new Module_Param_FieldName(mcopystr("transfer")));
  Module_Param_Assignment_List* mp = new Module_Param_Assignment_List();
  mp->add_elem(mp_field_abstract);
  mp->add_elem(mp_field_transfer);
  return mp;
Elemer Lelik's avatar
Elemer Lelik committed
1786
}
1787
#endif
Elemer Lelik's avatar
Elemer Lelik committed
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801

void EMBEDDED_PDV_identification_syntaxes::encode_text(Text_Buf& text_buf) const
{
  field_abstract.encode_text(text_buf);
  field_transfer.encode_text(text_buf);
}

void EMBEDDED_PDV_identification_syntaxes::decode_text(Text_Buf& text_buf)
{
  field_abstract.decode_text(text_buf);
  field_transfer.decode_text(text_buf);
}

// No encode/decode for this implementation class
1802
1803
//void EMBEDDED_PDV_identification_syntaxes::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
//void EMBEDDED_PDV_identification_syntaxes::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
Elemer Lelik's avatar
Elemer Lelik committed
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847

ASN_BER_TLV_t* EMBEDDED_PDV_identification_syntaxes::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const
{
  BER_chk_descr(p_td);
  ASN_BER_TLV_t *new_tlv=ASN_BER_TLV_t::construct(NULL);
  TTCN_EncDec_ErrorContext ec_0("Component '");
  TTCN_EncDec_ErrorContext ec_1;
  ec_1.set_msg("abstract': ");
  new_tlv->add_TLV(field_abstract.BER_encode_TLV(EMBEDDED_PDV_identification_syntaxes_abstract_descr_, p_coding));
  ec_1.set_msg("transfer': ");
  new_tlv->add_TLV(field_transfer.BER_encode_TLV(EMBEDDED_PDV_identification_syntaxes_transfer_descr_, p_coding));
  new_tlv=ASN_BER_V2TLV(new_tlv, p_td, p_coding);
  return new_tlv;
}

boolean EMBEDDED_PDV_identification_syntaxes::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form)
{
  BER_chk_descr(p_td);
  ASN_BER_TLV_t stripped_tlv;
  BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv);
  TTCN_EncDec_ErrorContext ec_0("While decoding 'EMBEDDED PDV.identification.syntaxes' type: ");
  stripped_tlv.chk_constructed_flag(TRUE);
  size_t V_pos=0;
  ASN_BER_TLV_t tmp_tlv;
  boolean tlv_present=FALSE;
  {
    TTCN_EncDec_ErrorContext ec_1("Component '");
    TTCN_EncDec_ErrorContext ec_2;
    ec_2.set_msg("abstract': ");
    if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv);
    if(!tlv_present) return FALSE;
    field_abstract.BER_decode_TLV(EMBEDDED_PDV_identification_syntaxes_abstract_descr_, tmp_tlv, L_form);
    tlv_present=FALSE;
    ec_2.set_msg("transfer': ");
    if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv);
    if(!tlv_present) return FALSE;
    field_transfer.BER_decode_TLV(EMBEDDED_PDV_identification_syntaxes_transfer_descr_, tmp_tlv, L_form);
    tlv_present=FALSE;
  }
  BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present);
  return TRUE;
}

int EMBEDDED_PDV_identification_syntaxes::XER_encode(const XERdescriptor_t& p_td,
1848
    TTCN_Buffer& p_buf, unsigned int flavor, unsigned int flavor2, int indent, embed_values_enc_struct_t*) const
Elemer Lelik's avatar
Elemer Lelik committed
1849
1850
{
  int indenting = !is_canonical(flavor);
1851
  boolean exer  = is_exer(flavor);
Elemer Lelik's avatar
Elemer Lelik committed
1852
1853
1854
1855
1856
1857
1858
  int encoded_length=(int)p_buf.get_len();
  if (indenting) do_indent(p_buf, indent);
  p_buf.put_c('<');
  if (exer) write_ns_prefix(p_td, p_buf);
  p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]);

  ++indent;
1859
1860
  field_abstract.XER_encode(EMBEDDED_PDV_identification_sxs_abs_xer_, p_buf, flavor, flavor2, indent, 0);
  field_transfer.XER_encode(EMBEDDED_PDV_identification_sxs_xfr_xer_, p_buf, flavor, flavor2, indent, 0);
Elemer Lelik's avatar
Elemer Lelik committed
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870

  if (indenting) do_indent(p_buf, --indent);
  p_buf.put_c('<');
  p_buf.put_c('/');
  if (exer) write_ns_prefix(p_td, p_buf);
  p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]);
  return (int)p_buf.get_len() - encoded_length;
}

int EMBEDDED_PDV_identification_syntaxes::XER_decode(const XERdescriptor_t& /*p_td*/,
Elemer Lelik's avatar
Elemer Lelik committed
1871
  XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
Elemer Lelik's avatar
Elemer Lelik committed
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
{ // we stand on <syntaxes>, move ahead first
  int type;
  for (int success = reader.Read(); success == 1; success = reader.Read())
  {
    type = reader.NodeType();
    if (XML_READER_TYPE_ELEMENT == type)
      // no verify_name for a CHOICE
      break;
  }
  // FIXME this assumes the right element
Elemer Lelik's avatar
Elemer Lelik committed
1882
1883
  field_abstract.XER_decode(EMBEDDED_PDV_identification_sxs_abs_xer_, reader, flavor, flavor2, 0);
  field_transfer.XER_decode(EMBEDDED_PDV_identification_sxs_xfr_xer_, reader, flavor, flavor2, 0);
Elemer Lelik's avatar
Elemer Lelik committed
1884
1885
1886
1887
1888
1889
1890
1891
1892
  for (int success = 1; success == 1; success = reader.Read())
  {
    type = reader.NodeType();
    if (XML_READER_TYPE_END_ELEMENT == type)
      break;
  }
  return 0; // TODO maybe return proper value
}

1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
int EMBEDDED_PDV_identification_syntaxes::OER_encode(const TTCN_Typedescriptor_t&, TTCN_Buffer& p_buf) const {
  field_abstract.OER_encode(OBJID_descr_, p_buf);
  field_transfer.OER_encode(OBJID_descr_, p_buf);
  return 0;
}

int EMBEDDED_PDV_identification_syntaxes::OER_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer& p_buf, OER_struct& p_oer) {
  field_abstract.OER_decode(OBJID_descr_, p_buf, p_oer);
  field_transfer.OER_decode(OBJID_descr_, p_buf, p_oer);
  return 0;
}

Elemer Lelik's avatar
Elemer Lelik committed
1905
1906
1907
1908
1909
1910
1911
/******************** EMBEDDED_PDV_identification_syntaxes_template ********************/

struct EMBEDDED_PDV_identification_syntaxes_template::single_value_struct {
  OBJID_template field_abstract;
  OBJID_template field_transfer;
};

Elemer Lelik's avatar
Elemer Lelik committed
1912
1913
1914
1915
void EMBEDDED_PDV_identification_syntaxes_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
  Module_Param_Ptr mp = &param;
1916
#ifdef TITAN_RUNTIME_2
Elemer Lelik's avatar
Elemer Lelik committed
1917
1918
1919
  if (param.get_type() == Module_Param::MP_Reference) {
    mp = param.get_referenced_param();
  }
1920
#endif
Elemer Lelik's avatar
Elemer Lelik committed
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930