// This C++ source file was generated by the TTCN-3 compiler
// of the TTCN-3 Test Executor version 9.0.0
// The generation of user and time information were disabled by the -D flag.

// Copyright (c) 2000-2023 Ericsson Telecom AB

// Do not edit this file unless you know what you are doing.

/* Including header files */

#include "Osmocom_CTRL_Types.hh"

namespace Osmocom__CTRL__Types {

/* Literal string constants */

extern const CHARSTRING cs_3(0, NULL),
cs_0(' '),
cs_1(6, "ERROR "),
cs_4(3, "GET"),
cs_6(9, "GET_REPLY"),
cs_5(3, "SET"),
cs_7(9, "SET_REPLY"),
cs_2(7, "TRAP 0 ");
const Token_Match mp_2(" ", TRUE, TRUE),
mp_5("", TRUE),
mp_0("^(((GET)|(SET)))", FALSE),
mp_1("^(((GET_REPLY)|(SET_REPLY)))", FALSE),
mp_3("^(ERROR )", FALSE),
mp_4("^(TRAP 0 )", FALSE);
const unsigned char module_checksum[] = { 0xfc, 0xd4, 0xeb, 0xac, 0x3c, 0x73, 0x7a, 0x16, 0xfc, 0x62, 0x5b, 0x38, 0x4f, 0xb0, 0x5c, 0x2d };

/* Global variable definitions */

const TTCN_TEXTdescriptor_param_values CtrlVerb_par_ = {{FALSE,FALSE,-1,-1,0,1},{FALSE,FALSE,-1,-1,1,1}};
const TTCN_TEXTdescriptor_t CtrlVerb_text_ = {NULL,NULL,NULL,NULL,NULL,NULL,&mp_0,{&CtrlVerb_par_}};
const XERdescriptor_t       CtrlVerb_xer_ = { {"CtrlVerb>\n", "CtrlVerb>\n"}, {10, 10}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlVerb_descr_ = { "@Osmocom_CTRL_Types.CtrlVerb", NULL, &CHARSTRING_raw_, &CtrlVerb_text_, &CtrlVerb_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlVerb_default_coding("TEXT");
const TTCN_TEXTdescriptor_param_values CtrlReplyVerb_par_ = {{FALSE,FALSE,-1,-1,0,1},{FALSE,FALSE,-1,-1,1,1}};
const TTCN_TEXTdescriptor_t CtrlReplyVerb_text_ = {NULL,NULL,NULL,NULL,NULL,NULL,&mp_1,{&CtrlReplyVerb_par_}};
const XERdescriptor_t       CtrlReplyVerb_xer_ = { {"CtrlReplyVerb>\n", "CtrlReplyVerb>\n"}, {15, 15}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlReplyVerb_descr_ = { "@Osmocom_CTRL_Types.CtrlReplyVerb", NULL, &CHARSTRING_raw_, &CtrlReplyVerb_text_, &CtrlReplyVerb_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlReplyVerb_default_coding("TEXT");
const XERdescriptor_t       CtrlId_xer_ = { {"CtrlId>\n", "CtrlId>\n"}, {8, 8}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlId_descr_ = { "@Osmocom_CTRL_Types.CtrlId", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlId_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlId_default_coding("TEXT");
const XERdescriptor_t       CtrlVariable_xer_ = { {"CtrlVariable>\n", "CtrlVariable>\n"}, {14, 14}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlVariable_descr_ = { "@Osmocom_CTRL_Types.CtrlVariable", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlVariable_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlVariable_default_coding("TEXT");
const XERdescriptor_t       CtrlValue_xer_ = { {"CtrlValue>\n", "CtrlValue>\n"}, {11, 11}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlValue_descr_ = { "@Osmocom_CTRL_Types.CtrlValue", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlValue_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlValue_default_coding("TEXT");
const XERdescriptor_t       CtrlReason_xer_ = { {"CtrlReason>\n", "CtrlReason>\n"}, {12, 12}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlReason_descr_ = { "@Osmocom_CTRL_Types.CtrlReason", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlReason_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlReason_default_coding("TEXT");
const XERdescriptor_t       CtrlCommand_verb_xer_ = { {"verb>\n", "verb>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlCommand_verb_descr_ = { "@Osmocom_CTRL_Types.CtrlCommand.verb", NULL, &CHARSTRING_raw_, &CtrlVerb_text_, &CtrlCommand_verb_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlCommand_verb_default_coding("TEXT");
const XERdescriptor_t       CtrlCommand_id_xer_ = { {"id>\n", "id>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlCommand_id_descr_ = { "@Osmocom_CTRL_Types.CtrlCommand.id", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlCommand_id_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlCommand_id_default_coding("TEXT");
const XERdescriptor_t       CtrlCommand_variable_xer_ = { {"variable>\n", "variable>\n"}, {10, 10}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlCommand_variable_descr_ = { "@Osmocom_CTRL_Types.CtrlCommand.variable", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlCommand_variable_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlCommand_variable_default_coding("TEXT");
const TTCN_TEXTdescriptor_t CtrlCommand_text_ = {NULL,NULL,NULL,NULL,&cs_0,&mp_2,NULL,{NULL}};
// No XER for CtrlCommand
const TTCN_Typedescriptor_t CtrlCommand_descr_ = { "@Osmocom_CTRL_Types.CtrlCommand", NULL, NULL, &CtrlCommand_text_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t       CtrlCommand_val_xer_ = { {"val>\n", "val>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED |XER_OPTIONAL, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlCommand_val_descr_ = { "@Osmocom_CTRL_Types.CtrlCommand.val", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlCommand_val_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlCommand_val_default_coding("TEXT");
UNIVERSAL_CHARSTRING CtrlCommand_default_coding("TEXT");
const XERdescriptor_t       CtrlResponse_verb_xer_ = { {"verb>\n", "verb>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlResponse_verb_descr_ = { "@Osmocom_CTRL_Types.CtrlResponse.verb", NULL, &CHARSTRING_raw_, &CtrlReplyVerb_text_, &CtrlResponse_verb_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlResponse_verb_default_coding("TEXT");
const XERdescriptor_t       CtrlResponse_id_xer_ = { {"id>\n", "id>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlResponse_id_descr_ = { "@Osmocom_CTRL_Types.CtrlResponse.id", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlResponse_id_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlResponse_id_default_coding("TEXT");
const XERdescriptor_t       CtrlResponse_variable_xer_ = { {"variable>\n", "variable>\n"}, {10, 10}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlResponse_variable_descr_ = { "@Osmocom_CTRL_Types.CtrlResponse.variable", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlResponse_variable_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlResponse_variable_default_coding("TEXT");
const XERdescriptor_t       CtrlResponse_val_xer_ = { {"val>\n", "val>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlResponse_val_descr_ = { "@Osmocom_CTRL_Types.CtrlResponse.val", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlResponse_val_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlResponse_val_default_coding("TEXT");
const TTCN_TEXTdescriptor_t CtrlResponse_text_ = {NULL,NULL,NULL,NULL,&cs_0,&mp_2,NULL,{NULL}};
// No XER for CtrlResponse
const TTCN_Typedescriptor_t CtrlResponse_descr_ = { "@Osmocom_CTRL_Types.CtrlResponse", NULL, NULL, &CtrlResponse_text_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlResponse_default_coding("TEXT");
const XERdescriptor_t       CtrlError_id_xer_ = { {"id>\n", "id>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlError_id_descr_ = { "@Osmocom_CTRL_Types.CtrlError.id", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlError_id_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlError_id_default_coding("TEXT");
const XERdescriptor_t       CtrlError_reason_xer_ = { {"reason>\n", "reason>\n"}, {8, 8}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlError_reason_descr_ = { "@Osmocom_CTRL_Types.CtrlError.reason", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlError_reason_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlError_reason_default_coding("TEXT");
const TTCN_TEXTdescriptor_t CtrlError_text_ = {&cs_1,&mp_3,NULL,NULL,&cs_0,&mp_2,NULL,{NULL}};
// No XER for CtrlError
const TTCN_Typedescriptor_t CtrlError_descr_ = { "@Osmocom_CTRL_Types.CtrlError", NULL, NULL, &CtrlError_text_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlError_default_coding("TEXT");
const XERdescriptor_t       CtrlTrap_variable_xer_ = { {"variable>\n", "variable>\n"}, {10, 10}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlTrap_variable_descr_ = { "@Osmocom_CTRL_Types.CtrlTrap.variable", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlTrap_variable_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlTrap_variable_default_coding("TEXT");
const XERdescriptor_t       CtrlTrap_val_xer_ = { {"val>\n", "val>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t CtrlTrap_val_descr_ = { "@Osmocom_CTRL_Types.CtrlTrap.val", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &CtrlTrap_val_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlTrap_val_default_coding("TEXT");
const TTCN_TEXTdescriptor_t CtrlTrap_text_ = {&cs_2,&mp_4,NULL,NULL,&cs_0,&mp_2,NULL,{NULL}};
// No XER for CtrlTrap
const TTCN_Typedescriptor_t CtrlTrap_descr_ = { "@Osmocom_CTRL_Types.CtrlTrap", NULL, NULL, &CtrlTrap_text_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlTrap_default_coding("TEXT");
const TTCN_TEXTdescriptor_t CtrlMessage_text_ = {&cs_3,&mp_5,NULL,NULL,NULL,NULL,NULL,{NULL}};
// No XER for CtrlMessage
const TTCN_Typedescriptor_t CtrlMessage_descr_ = { "@Osmocom_CTRL_Types.CtrlMessage", NULL, NULL, &CtrlMessage_text_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING CtrlMessage_cmd_default_coding("TEXT");
UNIVERSAL_CHARSTRING CtrlMessage_resp_default_coding("TEXT");
UNIVERSAL_CHARSTRING CtrlMessage_err_default_coding("TEXT");
UNIVERSAL_CHARSTRING CtrlMessage_trap_default_coding("TEXT");
UNIVERSAL_CHARSTRING CtrlMessage_default_coding("TEXT");
CHARSTRING_template template_ts__CtrlMsgTrap_val_defval;
const CHARSTRING_template& ts__CtrlMsgTrap_val_defval = template_ts__CtrlMsgTrap_val_defval;
CHARSTRING_template template_tr__CtrlMsgGet_variable_defval;
const CHARSTRING_template& tr__CtrlMsgGet_variable_defval = template_tr__CtrlMsgGet_variable_defval;
CHARSTRING_template template_tr__CtrlMsgSet_variable_defval;
const CHARSTRING_template& tr__CtrlMsgSet_variable_defval = template_tr__CtrlMsgSet_variable_defval;
CHARSTRING_template template_tr__CtrlMsgSet_val_defval;
const CHARSTRING_template& tr__CtrlMsgSet_val_defval = template_tr__CtrlMsgSet_val_defval;
CHARSTRING_template template_tr__CtrlMsgGetRepl_variable_defval;
const CHARSTRING_template& tr__CtrlMsgGetRepl_variable_defval = template_tr__CtrlMsgGetRepl_variable_defval;
CHARSTRING_template template_tr__CtrlMsgSetRepl_variable_defval;
const CHARSTRING_template& tr__CtrlMsgSetRepl_variable_defval = template_tr__CtrlMsgSetRepl_variable_defval;
CHARSTRING_template template_tr__CtrlMsgSetRepl_val_defval;
const CHARSTRING_template& tr__CtrlMsgSetRepl_val_defval = template_tr__CtrlMsgSetRepl_val_defval;
CHARSTRING_template template_tr__CtrlMsgTrap_variable_defval;
const CHARSTRING_template& tr__CtrlMsgTrap_variable_defval = template_tr__CtrlMsgTrap_variable_defval;
CHARSTRING_template template_tr__CtrlMsgTrap_val_defval;
const CHARSTRING_template& tr__CtrlMsgTrap_val_defval = template_tr__CtrlMsgTrap_val_defval;
CHARSTRING_template template_tr__CtrlMsgError_id_defval;
const CHARSTRING_template& tr__CtrlMsgError_id_defval = template_tr__CtrlMsgError_id_defval;
CHARSTRING_template template_tr__CtrlMsgError_reason_defval;
const CHARSTRING_template& tr__CtrlMsgError_reason_defval = template_tr__CtrlMsgError_reason_defval;
TTCN_Module module_object("Osmocom_CTRL_Types", __DATE__, __TIME__, module_checksum, pre_init_module, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, post_init_module, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

const RuntimeVersionChecker ver_checker(  current_runtime_version.requires_major_version_9,
  current_runtime_version.requires_minor_version_0,
  current_runtime_version.requires_patch_level_0,  current_runtime_version.requires_runtime_1);

/* Member functions of C++ classes */

CtrlCommand::CtrlCommand()
{
}

CtrlCommand::CtrlCommand(const CHARSTRING& par_verb,
    const CHARSTRING& par_id,
    const CHARSTRING& par_variable,
    const OPTIONAL< CHARSTRING >& par_val)
  :   field_verb(par_verb),
  field_id(par_id),
  field_variable(par_variable),
  field_val(par_val)
{
}

CtrlCommand::CtrlCommand(const CtrlCommand& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Osmocom_CTRL_Types.CtrlCommand.");
if (other_value.verb().is_bound()) field_verb = other_value.verb();
else field_verb.clean_up();
if (other_value.id().is_bound()) field_id = other_value.id();
else field_id.clean_up();
if (other_value.variable().is_bound()) field_variable = other_value.variable();
else field_variable.clean_up();
if (other_value.val().is_bound()) field_val = other_value.val();
else field_val.clean_up();
}

void CtrlCommand::clean_up()
{
field_verb.clean_up();
field_id.clean_up();
field_variable.clean_up();
field_val.clean_up();
}

const TTCN_Typedescriptor_t* CtrlCommand::get_descriptor() const { return &CtrlCommand_descr_; }
CtrlCommand& CtrlCommand::operator=(const CtrlCommand& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Osmocom_CTRL_Types.CtrlCommand.");
  if (other_value.verb().is_bound()) field_verb = other_value.verb();
  else field_verb.clean_up();
  if (other_value.id().is_bound()) field_id = other_value.id();
  else field_id.clean_up();
  if (other_value.variable().is_bound()) field_variable = other_value.variable();
  else field_variable.clean_up();
  if (other_value.val().is_bound()) field_val = other_value.val();
  else field_val.clean_up();
}
return *this;
}

boolean CtrlCommand::operator==(const CtrlCommand& other_value) const
{
return field_verb==other_value.field_verb
  && field_id==other_value.field_id
  && field_variable==other_value.field_variable
  && field_val==other_value.field_val;
}

boolean CtrlCommand::is_bound() const
{
return (field_verb.is_bound())
  || (field_id.is_bound())
  || (field_variable.is_bound())
  || (OPTIONAL_OMIT == field_val.get_selection() || field_val.is_bound());
}
boolean CtrlCommand::is_value() const
{
return field_verb.is_value()
  && field_id.is_value()
  && field_variable.is_value()
  && (OPTIONAL_OMIT == field_val.get_selection() || field_val.is_value());
}
int CtrlCommand::size_of() const
{
  int ret_val = 3;
  if (field_val.ispresent()) ret_val++;
  return ret_val;
}

void CtrlCommand::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ verb := ");
field_verb.log();
TTCN_Logger::log_event_str(", id := ");
field_id.log();
TTCN_Logger::log_event_str(", variable := ");
field_variable.log();
TTCN_Logger::log_event_str(", val := ");
field_val.log();
TTCN_Logger::log_event_str(" }");
}

void CtrlCommand::set_implicit_omit()
{
if (verb().is_bound()) verb().set_implicit_omit();
if (id().is_bound()) id().set_implicit_omit();
if (variable().is_bound()) variable().set_implicit_omit();
if (!val().is_bound()) val() = OMIT_VALUE;
else val().set_implicit_omit();
}

void CtrlCommand::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (4<param.get_size()) {
      param.error("record value of type @Osmocom_CTRL_Types.CtrlCommand has 4 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) verb().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) id().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) variable().set_param(*param.get_elem(2));
    if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) val().set_param(*param.get_elem(3));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "verb")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          verb().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "id")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          id().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "variable")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          variable().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "val")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          val().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Osmocom_CTRL_Types.CtrlCommand: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@Osmocom_CTRL_Types.CtrlCommand");
  }
}

void CtrlCommand::encode_text(Text_Buf& text_buf) const
{
field_verb.encode_text(text_buf);
field_id.encode_text(text_buf);
field_variable.encode_text(text_buf);
field_val.encode_text(text_buf);
}

void CtrlCommand::decode_text(Text_Buf& text_buf)
{
field_verb.decode_text(text_buf);
field_id.decode_text(text_buf);
field_variable.decode_text(text_buf);
field_val.decode_text(text_buf);
}

void CtrlCommand::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
    unsigned BER_coding=va_arg(pvar, unsigned);
    BER_encode_chk_coding(BER_coding);
    ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
    tlv->put_in_buffer(p_buf);
    ASN_BER_TLV_t::destruct(tlv);
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    RAW_enc_tr_pos rp;
    rp.level=0;
    rp.pos=NULL;
    RAW_enc_tree root(FALSE, NULL, &rp, 1, p_td.raw);
    RAW_encode(p_td, root);
    root.put_to_buf(p_buf);
    break;}
  case TTCN_EncDec::CT_TEXT: {
    TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
      ("No TEXT descriptor available for type '%s'.", p_td.name);
    TEXT_encode(p_td,p_buf);
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
    p_buf.put_c('\n');
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok(va_arg(pvar, int) != 0);
    JSON_encode(p_td, tok, FALSE);
    p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
    OER_encode(p_td, p_buf);
    break;}
  default:
    TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
  }
  va_end(pvar);
}

void CtrlCommand::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
    unsigned L_form=va_arg(pvar, unsigned);
    ASN_BER_TLV_t tlv;
    BER_decode_str2TLV(p_buf, tlv, L_form);
    BER_decode_TLV(p_td, tlv, L_form);
    if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    raw_order_t r_order;
    switch(p_td.raw->top_bit_order) {
    case TOP_BIT_LEFT:
      r_order=ORDER_LSB;
      break;
    case TOP_BIT_RIGHT:
    default:
      r_order=ORDER_MSB;
    }
    int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
    if(rawr<0) switch (-rawr) {
    case TTCN_EncDec::ET_INCOMPL_MSG:
    case TTCN_EncDec::ET_LEN_ERR:
      ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
      break;
    case 1:
    default:
      ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
      break;
    }
    break;}
  case TTCN_EncDec::CT_TEXT: {
    Limit_Token_List limit;
    TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
        ("No TEXT descriptor available for type '%s'.", p_td.name);
    const unsigned char *b_data=p_buf.get_data();
    int null_added=0;
    if(b_data[p_buf.get_len()-1]!='\0'){
      null_added=1;
      p_buf.set_pos(p_buf.get_len());
      p_buf.put_zero(8,ORDER_LSB);
      p_buf.rewind();
    }
    if(TEXT_decode(p_td,p_buf,limit)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    if(null_added){
      size_t actpos=p_buf.get_pos();
      p_buf.set_pos(p_buf.get_len()-1);
      p_buf.cut_end();
      p_buf.set_pos(actpos);
    }
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XmlReaderWrap reader(p_buf);
    for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
      if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
    }
    XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
    size_t bytes = reader.ByteConsumed();
    p_buf.set_pos(bytes);
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
    if(JSON_decode(p_td, tok, FALSE, FALSE)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    p_buf.set_pos(tok.get_buf_pos());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
     OER_struct p_oer;
    OER_decode(p_td, p_buf, p_oer);
    break;}
  default:
    TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
  }
  va_end(pvar);
}

int CtrlCommand::TEXT_encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf) const{
  if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
  boolean need_separator=FALSE;
  int encoded_length=0;
  if(p_td.text->begin_encode){
    p_buf.put_cs(*p_td.text->begin_encode);
    encoded_length+=p_td.text->begin_encode->lengthof();
  }
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_verb.TEXT_encode(CtrlVerb_descr_,p_buf);
 need_separator=TRUE;
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_id.TEXT_encode(CtrlId_descr_,p_buf);
 need_separator=TRUE;
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_variable.TEXT_encode(CtrlVariable_descr_,p_buf);
 need_separator=TRUE;
  if(field_val.ispresent()){
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_val().TEXT_encode(CtrlValue_descr_,p_buf);
 need_separator=TRUE;
  }
  if(p_td.text->end_encode){
    p_buf.put_cs(*p_td.text->end_encode);
    encoded_length+=p_td.text->end_encode->lengthof();
  }
  return encoded_length;
}
int CtrlCommand::TEXT_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, Limit_Token_List& limit, boolean no_err, boolean){
  int decoded_length=0;
  int decoded_field_length=0;
  size_t pos=p_buf.get_pos();
  boolean sep_found=FALSE;
  int sep_length=0;
  int ml=0;
  if(p_td.text->begin_decode){
    int tl;
    if((tl=p_td.text->begin_decode->match_begin(p_buf))<0){
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error
              (TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->begin_decode), p_td.name);
          return 0;
        }
    decoded_length+=tl;
    p_buf.increase_pos(tl);
  }
  if(p_td.text->end_decode){
    limit.add_token(p_td.text->end_decode);
    ml++;
  }
  if(p_td.text->separator_decode){
    limit.add_token(p_td.text->separator_decode);
    ml++;
  }
    field_val=OMIT_VALUE;
    while(TRUE){
    decoded_field_length=field_verb.TEXT_decode(CtrlVerb_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'verb' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    if(p_td.text->separator_decode){
      int tl;
      if((tl=p_td.text->separator_decode->match_begin(p_buf))<0){
          limit.remove_tokens(ml);
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->separator_decode),p_td.name);
          return decoded_length;
      } else {
      decoded_length+=tl;
      p_buf.increase_pos(tl);
      sep_length=tl;
      sep_found=TRUE;}
    } else sep_found=FALSE;
  }
    decoded_field_length=field_id.TEXT_decode(CtrlId_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'id' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    if(p_td.text->separator_decode){
      int tl;
      if((tl=p_td.text->separator_decode->match_begin(p_buf))<0){
          limit.remove_tokens(ml);
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->separator_decode),p_td.name);
          return decoded_length;
      } else {
      decoded_length+=tl;
      p_buf.increase_pos(tl);
      sep_length=tl;
      sep_found=TRUE;}
    } else sep_found=FALSE;
  }
    decoded_field_length=field_variable.TEXT_decode(CtrlVariable_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'variable' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    if(p_td.text->separator_decode){
      int tl;
      if((tl=p_td.text->separator_decode->match_begin(p_buf))<0){
      sep_found=FALSE;
      break;
      } else {
      decoded_length+=tl;
      p_buf.increase_pos(tl);
      sep_length=tl;
      sep_found=TRUE;}
    } else {
      sep_found=FALSE;
      if(p_td.text->end_decode){
      int tl;
      if((tl=p_td.text->end_decode->match_begin(p_buf))!=-1){
        decoded_length+=tl;
        p_buf.increase_pos(tl);
        limit.remove_tokens(ml);
        return decoded_length;
      }
    } else if(limit.has_token(ml)){
      if(limit.match(p_buf,ml)==0){
        sep_found=FALSE;
        break;
      }
    }
    }
  }
    pos=p_buf.get_pos();
    decoded_field_length=field_val().TEXT_decode(CtrlValue_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
    field_val=OMIT_VALUE;
    p_buf.set_pos(pos);
    } else {
  decoded_length+=decoded_field_length;
    sep_found=FALSE;
  }
   break;
  }
  limit.remove_tokens(ml);
  if(sep_found){
      p_buf.set_pos(p_buf.get_pos()-sep_length);
      decoded_length-=sep_length;
  }
  if(p_td.text->end_decode){
    int tl;
    if((tl=p_td.text->end_decode->match_begin(p_buf))<0){
      if(no_err)return -1;
      TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->end_decode),p_td.name);
      return decoded_length;
    }
    decoded_length+=tl;
    p_buf.increase_pos(tl);
  }
  return decoded_length;
}
struct CtrlCommand_template::single_value_struct {
CHARSTRING_template field_verb;
CHARSTRING_template field_id;
CHARSTRING_template field_variable;
CHARSTRING_template field_val;
};

void CtrlCommand_template::set_specific()
{
if (template_selection != SPECIFIC_VALUE) {
template_sel old_selection = template_selection;
clean_up();
single_value = new single_value_struct;
set_selection(SPECIFIC_VALUE);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
single_value->field_verb = ANY_VALUE;
single_value->field_id = ANY_VALUE;
single_value->field_variable = ANY_VALUE;
single_value->field_val = ANY_OR_OMIT;
}
}
}

void CtrlCommand_template::copy_value(const CtrlCommand& other_value)
{
single_value = new single_value_struct;
if (other_value.verb().is_bound()) {
  single_value->field_verb = other_value.verb();
} else {
  single_value->field_verb.clean_up();
}
if (other_value.id().is_bound()) {
  single_value->field_id = other_value.id();
} else {
  single_value->field_id.clean_up();
}
if (other_value.variable().is_bound()) {
  single_value->field_variable = other_value.variable();
} else {
  single_value->field_variable.clean_up();
}
if (other_value.val().is_bound()) {
  if (other_value.val().ispresent()) single_value->field_val = other_value.val()();
  else single_value->field_val = OMIT_VALUE;
} else {
  single_value->field_val.clean_up();
}
set_selection(SPECIFIC_VALUE);
}

void CtrlCommand_template::copy_template(const CtrlCommand_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.verb().get_selection()) {
single_value->field_verb = other_value.verb();
} else {
single_value->field_verb.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.id().get_selection()) {
single_value->field_id = other_value.id();
} else {
single_value->field_id.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.variable().get_selection()) {
single_value->field_variable = other_value.variable();
} else {
single_value->field_variable.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.val().get_selection()) {
single_value->field_val = other_value.val();
} else {
single_value->field_val.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new CtrlCommand_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;
case IMPLICATION_MATCH:
implication_.precondition = new CtrlCommand_template(*other_value.implication_.precondition);
implication_.implied_template = new CtrlCommand_template(*other_value.implication_.implied_template);
break;
case DYNAMIC_MATCH:
dyn_match = other_value.dyn_match;
dyn_match->ref_count++;
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlCommand.");
break;
}
set_selection(other_value);
}

CtrlCommand_template::CtrlCommand_template()
{
}

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

CtrlCommand_template::CtrlCommand_template(const CtrlCommand& other_value)
{
copy_value(other_value);
}

CtrlCommand_template::CtrlCommand_template(const OPTIONAL<CtrlCommand>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlCommand&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Osmocom_CTRL_Types.CtrlCommand from an unbound optional field.");
}
}

CtrlCommand_template::CtrlCommand_template(CtrlCommand_template* p_precondition, CtrlCommand_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

CtrlCommand_template::CtrlCommand_template(Dynamic_Match_Interface<CtrlCommand>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<CtrlCommand>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

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

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

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

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

CtrlCommand_template& CtrlCommand_template::operator=(const OPTIONAL<CtrlCommand>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlCommand&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of type @Osmocom_CTRL_Types.CtrlCommand.");
}
return *this;
}

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

boolean CtrlCommand_template::match(const CtrlCommand& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
if(!other_value.verb().is_bound()) return FALSE;
if(!single_value->field_verb.match(other_value.verb(), legacy))return FALSE;
if(!other_value.id().is_bound()) return FALSE;
if(!single_value->field_id.match(other_value.id(), legacy))return FALSE;
if(!other_value.variable().is_bound()) return FALSE;
if(!single_value->field_variable.match(other_value.variable(), legacy))return FALSE;
if(!other_value.val().is_bound()) return FALSE;
if((other_value.val().ispresent() ? !single_value->field_val.match((const CHARSTRING&)other_value.val(), legacy) : !single_value->field_val.match_omit(legacy)))return FALSE;
return TRUE;
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, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
case CONJUNCTION_MATCH:
for (unsigned int i = 0; i < value_list.n_values; i++) {
if (!value_list.list_value[i].match(other_value)) {
return FALSE;
}
}
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value);
case DYNAMIC_MATCH:
return dyn_match->ptr->match(other_value);
default:
TTCN_error("Matching an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlCommand.");
}
return FALSE;
}

boolean CtrlCommand_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_verb.is_bound()
 || single_value->field_id.is_bound()
 || single_value->field_variable.is_bound()
 || (single_value->field_val.is_omit() || single_value->field_val.is_bound());
}

boolean CtrlCommand_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_verb.is_value()
 && single_value->field_id.is_value()
 && single_value->field_variable.is_value()
 && (single_value->field_val.is_omit() || single_value->field_val.is_value());
}

void CtrlCommand_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
delete [] value_list.list_value;
break;
case IMPLICATION_MATCH:
delete implication_.precondition;
delete implication_.implied_template;
break;
case DYNAMIC_MATCH:
dyn_match->ref_count--;
if (dyn_match->ref_count == 0) {
delete dyn_match->ptr;
delete dyn_match;
}
break;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}

CtrlCommand CtrlCommand_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of type @Osmocom_CTRL_Types.CtrlCommand.");
CtrlCommand ret_val;
if (single_value->field_verb.is_bound()) {
ret_val.verb() = single_value->field_verb.valueof();
}
if (single_value->field_id.is_bound()) {
ret_val.id() = single_value->field_id.valueof();
}
if (single_value->field_variable.is_bound()) {
ret_val.variable() = single_value->field_variable.valueof();
}
if (single_value->field_val.is_omit()) ret_val.val() = OMIT_VALUE;
else if (single_value->field_val.is_bound()) {
ret_val.val() = single_value->field_val.valueof();
}
return ret_val;
}

void CtrlCommand_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH)
TTCN_error("Setting an invalid list for a template of type @Osmocom_CTRL_Types.CtrlCommand.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new CtrlCommand_template[list_length];
}

CtrlCommand_template& CtrlCommand_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH)
TTCN_error("Accessing a list element of a non-list template of type @Osmocom_CTRL_Types.CtrlCommand.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Osmocom_CTRL_Types.CtrlCommand.");
return value_list.list_value[list_index];
}

CHARSTRING_template& CtrlCommand_template::verb()
{
set_specific();
return single_value->field_verb;
}

const CHARSTRING_template& CtrlCommand_template::verb() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field verb of a non-specific template of type @Osmocom_CTRL_Types.CtrlCommand.");
return single_value->field_verb;
}

CHARSTRING_template& CtrlCommand_template::id()
{
set_specific();
return single_value->field_id;
}

const CHARSTRING_template& CtrlCommand_template::id() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field id of a non-specific template of type @Osmocom_CTRL_Types.CtrlCommand.");
return single_value->field_id;
}

CHARSTRING_template& CtrlCommand_template::variable()
{
set_specific();
return single_value->field_variable;
}

const CHARSTRING_template& CtrlCommand_template::variable() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field variable of a non-specific template of type @Osmocom_CTRL_Types.CtrlCommand.");
return single_value->field_variable;
}

CHARSTRING_template& CtrlCommand_template::val()
{
set_specific();
return single_value->field_val;
}

const CHARSTRING_template& CtrlCommand_template::val() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field val of a non-specific template of type @Osmocom_CTRL_Types.CtrlCommand.");
return single_value->field_val;
}

int CtrlCommand_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand which has an ifpresent attribute.");
  switch (template_selection)
  {
  case SPECIFIC_VALUE:
  {    int ret_val = 3;
      if (single_value->field_val.is_present()) ret_val++;
      return ret_val;
    }
  case VALUE_LIST:
   {
     if (value_list.n_values<1)
       TTCN_error("Internal error: Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand containing an empty list.");
      int item_size = value_list.list_value[0].size_of();
      for (unsigned int l_idx = 1; l_idx < value_list.n_values; l_idx++)
      {
        if (value_list.list_value[l_idx].size_of()!=item_size)
          TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlCommand containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlCommand.");
  }
  return 0;
}

void CtrlCommand_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ verb := ");
single_value->field_verb.log();
TTCN_Logger::log_event_str(", id := ");
single_value->field_id.log();
TTCN_Logger::log_event_str(", variable := ");
single_value->field_variable.log();
TTCN_Logger::log_event_str(", val := ");
single_value->field_val.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case CONJUNCTION_MATCH:
if (template_selection == CONJUNCTION_MATCH) {
TTCN_Logger::log_event_str("conjunct");
}
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;
case IMPLICATION_MATCH:
implication_.precondition->log();
TTCN_Logger::log_event_str(" implies ");
implication_.implied_template->log();
break;
case DYNAMIC_MATCH:
TTCN_Logger::log_event_str("@dynamic template");
break;
default:
log_generic();
}
log_ifpresent();
}

void CtrlCommand_template::log_match(const CtrlCommand& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
if(match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
} else{
if (template_selection == SPECIFIC_VALUE) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
if(!single_value->field_verb.match(match_value.verb(), legacy)){
TTCN_Logger::log_logmatch_info(".verb");
single_value->field_verb.log_match(match_value.verb(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_id.match(match_value.id(), legacy)){
TTCN_Logger::log_logmatch_info(".id");
single_value->field_id.log_match(match_value.id(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_variable.match(match_value.variable(), legacy)){
TTCN_Logger::log_logmatch_info(".variable");
single_value->field_variable.log_match(match_value.variable(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if (match_value.val().ispresent()){
if(!single_value->field_val.match(match_value.val(), legacy)){
TTCN_Logger::log_logmatch_info(".val");
single_value->field_val.log_match(match_value.val(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
} else {
if (!single_value->field_val.match_omit(legacy)){
 TTCN_Logger::log_logmatch_info(".val := omit with ");
TTCN_Logger::print_logmatch_buffer();
single_value->field_val.log();
TTCN_Logger::log_event_str(" unmatched");
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}
}else {
TTCN_Logger::print_logmatch_buffer();
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
TTCN_Logger::log_event_str(" unmatched");
}
}
return;
}
if (template_selection == SPECIFIC_VALUE) {
TTCN_Logger::log_event_str("{ verb := ");
single_value->field_verb.log_match(match_value.verb(), legacy);
TTCN_Logger::log_event_str(", id := ");
single_value->field_id.log_match(match_value.id(), legacy);
TTCN_Logger::log_event_str(", variable := ");
single_value->field_variable.log_match(match_value.variable(), legacy);
TTCN_Logger::log_event_str(", val := ");
if (match_value.val().ispresent()) {
single_value->field_val.log_match(match_value.val(), legacy);
} else {
TTCN_Logger::log_event_str("omit with ");
single_value->field_val.log();
if (single_value->field_val.match_omit(legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
TTCN_Logger::log_event_str(" }");
} else {
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}

void CtrlCommand_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_verb.encode_text(text_buf);
single_value->field_id.encode_text(text_buf);
single_value->field_variable.encode_text(text_buf);
single_value->field_val.encode_text(text_buf);
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/unsupported template of type @Osmocom_CTRL_Types.CtrlCommand.");
}
}

void CtrlCommand_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
single_value->field_verb.decode_text(text_buf);
single_value->field_id.decode_text(text_buf);
single_value->field_variable.decode_text(text_buf);
single_value->field_val.decode_text(text_buf);
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 CtrlCommand_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: An unknown/unsupported selection was received in a template of type @Osmocom_CTRL_Types.CtrlCommand.");
}
}

void CtrlCommand_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
  switch (param.get_type()) {
  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:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    CtrlCommand_template new_temp;
    new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size());
    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (4<param.get_size()) {
      param.error("record template of type @Osmocom_CTRL_Types.CtrlCommand has 4 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) verb().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) id().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) variable().set_param(*param.get_elem(2));
    if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) val().set_param(*param.get_elem(3));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "verb")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          verb().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "id")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          id().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "variable")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          variable().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "val")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          val().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Osmocom_CTRL_Types.CtrlCommand: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    CtrlCommand_template* precondition = new CtrlCommand_template;
    precondition->set_param(*param.get_elem(0));
    CtrlCommand_template* implied_template = new CtrlCommand_template;
    implied_template->set_param(*param.get_elem(1));
    *this = CtrlCommand_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@Osmocom_CTRL_Types.CtrlCommand");
  }
  is_ifpresent = param.get_ifpresent();
}

void CtrlCommand_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_OMIT:
if (template_selection==OMIT_VALUE) return;
case TR_VALUE:
if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break;
single_value->field_verb.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlCommand");
single_value->field_id.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlCommand");
single_value->field_variable.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlCommand");
single_value->field_val.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlCommand");
return;
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@Osmocom_CTRL_Types.CtrlCommand");
}

boolean CtrlCommand_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean CtrlCommand_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match_omit() || implication_.implied_template->match_omit();
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

CtrlResponse::CtrlResponse()
{
}

CtrlResponse::CtrlResponse(const CHARSTRING& par_verb,
    const CHARSTRING& par_id,
    const CHARSTRING& par_variable,
    const CHARSTRING& par_val)
  :   field_verb(par_verb),
  field_id(par_id),
  field_variable(par_variable),
  field_val(par_val)
{
}

CtrlResponse::CtrlResponse(const CtrlResponse& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Osmocom_CTRL_Types.CtrlResponse.");
if (other_value.verb().is_bound()) field_verb = other_value.verb();
else field_verb.clean_up();
if (other_value.id().is_bound()) field_id = other_value.id();
else field_id.clean_up();
if (other_value.variable().is_bound()) field_variable = other_value.variable();
else field_variable.clean_up();
if (other_value.val().is_bound()) field_val = other_value.val();
else field_val.clean_up();
}

void CtrlResponse::clean_up()
{
field_verb.clean_up();
field_id.clean_up();
field_variable.clean_up();
field_val.clean_up();
}

const TTCN_Typedescriptor_t* CtrlResponse::get_descriptor() const { return &CtrlResponse_descr_; }
CtrlResponse& CtrlResponse::operator=(const CtrlResponse& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Osmocom_CTRL_Types.CtrlResponse.");
  if (other_value.verb().is_bound()) field_verb = other_value.verb();
  else field_verb.clean_up();
  if (other_value.id().is_bound()) field_id = other_value.id();
  else field_id.clean_up();
  if (other_value.variable().is_bound()) field_variable = other_value.variable();
  else field_variable.clean_up();
  if (other_value.val().is_bound()) field_val = other_value.val();
  else field_val.clean_up();
}
return *this;
}

boolean CtrlResponse::operator==(const CtrlResponse& other_value) const
{
return field_verb==other_value.field_verb
  && field_id==other_value.field_id
  && field_variable==other_value.field_variable
  && field_val==other_value.field_val;
}

boolean CtrlResponse::is_bound() const
{
return (field_verb.is_bound())
  || (field_id.is_bound())
  || (field_variable.is_bound())
  || (field_val.is_bound());
}
boolean CtrlResponse::is_value() const
{
return field_verb.is_value()
  && field_id.is_value()
  && field_variable.is_value()
  && field_val.is_value();
}
void CtrlResponse::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ verb := ");
field_verb.log();
TTCN_Logger::log_event_str(", id := ");
field_id.log();
TTCN_Logger::log_event_str(", variable := ");
field_variable.log();
TTCN_Logger::log_event_str(", val := ");
field_val.log();
TTCN_Logger::log_event_str(" }");
}

void CtrlResponse::set_implicit_omit()
{
if (verb().is_bound()) verb().set_implicit_omit();
if (id().is_bound()) id().set_implicit_omit();
if (variable().is_bound()) variable().set_implicit_omit();
if (val().is_bound()) val().set_implicit_omit();
}

void CtrlResponse::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (4<param.get_size()) {
      param.error("record value of type @Osmocom_CTRL_Types.CtrlResponse has 4 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) verb().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) id().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) variable().set_param(*param.get_elem(2));
    if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) val().set_param(*param.get_elem(3));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "verb")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          verb().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "id")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          id().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "variable")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          variable().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "val")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          val().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Osmocom_CTRL_Types.CtrlResponse: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@Osmocom_CTRL_Types.CtrlResponse");
  }
}

void CtrlResponse::encode_text(Text_Buf& text_buf) const
{
field_verb.encode_text(text_buf);
field_id.encode_text(text_buf);
field_variable.encode_text(text_buf);
field_val.encode_text(text_buf);
}

void CtrlResponse::decode_text(Text_Buf& text_buf)
{
field_verb.decode_text(text_buf);
field_id.decode_text(text_buf);
field_variable.decode_text(text_buf);
field_val.decode_text(text_buf);
}

void CtrlResponse::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
    unsigned BER_coding=va_arg(pvar, unsigned);
    BER_encode_chk_coding(BER_coding);
    ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
    tlv->put_in_buffer(p_buf);
    ASN_BER_TLV_t::destruct(tlv);
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    RAW_enc_tr_pos rp;
    rp.level=0;
    rp.pos=NULL;
    RAW_enc_tree root(FALSE, NULL, &rp, 1, p_td.raw);
    RAW_encode(p_td, root);
    root.put_to_buf(p_buf);
    break;}
  case TTCN_EncDec::CT_TEXT: {
    TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
      ("No TEXT descriptor available for type '%s'.", p_td.name);
    TEXT_encode(p_td,p_buf);
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
    p_buf.put_c('\n');
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok(va_arg(pvar, int) != 0);
    JSON_encode(p_td, tok, FALSE);
    p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
    OER_encode(p_td, p_buf);
    break;}
  default:
    TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
  }
  va_end(pvar);
}

void CtrlResponse::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
    unsigned L_form=va_arg(pvar, unsigned);
    ASN_BER_TLV_t tlv;
    BER_decode_str2TLV(p_buf, tlv, L_form);
    BER_decode_TLV(p_td, tlv, L_form);
    if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    raw_order_t r_order;
    switch(p_td.raw->top_bit_order) {
    case TOP_BIT_LEFT:
      r_order=ORDER_LSB;
      break;
    case TOP_BIT_RIGHT:
    default:
      r_order=ORDER_MSB;
    }
    int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
    if(rawr<0) switch (-rawr) {
    case TTCN_EncDec::ET_INCOMPL_MSG:
    case TTCN_EncDec::ET_LEN_ERR:
      ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
      break;
    case 1:
    default:
      ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
      break;
    }
    break;}
  case TTCN_EncDec::CT_TEXT: {
    Limit_Token_List limit;
    TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
        ("No TEXT descriptor available for type '%s'.", p_td.name);
    const unsigned char *b_data=p_buf.get_data();
    int null_added=0;
    if(b_data[p_buf.get_len()-1]!='\0'){
      null_added=1;
      p_buf.set_pos(p_buf.get_len());
      p_buf.put_zero(8,ORDER_LSB);
      p_buf.rewind();
    }
    if(TEXT_decode(p_td,p_buf,limit)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    if(null_added){
      size_t actpos=p_buf.get_pos();
      p_buf.set_pos(p_buf.get_len()-1);
      p_buf.cut_end();
      p_buf.set_pos(actpos);
    }
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XmlReaderWrap reader(p_buf);
    for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
      if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
    }
    XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
    size_t bytes = reader.ByteConsumed();
    p_buf.set_pos(bytes);
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
    if(JSON_decode(p_td, tok, FALSE, FALSE)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    p_buf.set_pos(tok.get_buf_pos());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
     OER_struct p_oer;
    OER_decode(p_td, p_buf, p_oer);
    break;}
  default:
    TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
  }
  va_end(pvar);
}

int CtrlResponse::TEXT_encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf) const{
  if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
  boolean need_separator=FALSE;
  int encoded_length=0;
  if(p_td.text->begin_encode){
    p_buf.put_cs(*p_td.text->begin_encode);
    encoded_length+=p_td.text->begin_encode->lengthof();
  }
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_verb.TEXT_encode(CtrlReplyVerb_descr_,p_buf);
 need_separator=TRUE;
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_id.TEXT_encode(CtrlId_descr_,p_buf);
 need_separator=TRUE;
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_variable.TEXT_encode(CtrlVariable_descr_,p_buf);
 need_separator=TRUE;
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_val.TEXT_encode(CtrlValue_descr_,p_buf);
 need_separator=TRUE;
  if(p_td.text->end_encode){
    p_buf.put_cs(*p_td.text->end_encode);
    encoded_length+=p_td.text->end_encode->lengthof();
  }
  return encoded_length;
}
int CtrlResponse::TEXT_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, Limit_Token_List& limit, boolean no_err, boolean){
  int decoded_length=0;
  int decoded_field_length=0;
  boolean sep_found=FALSE;
  int sep_length=0;
  int ml=0;
  if(p_td.text->begin_decode){
    int tl;
    if((tl=p_td.text->begin_decode->match_begin(p_buf))<0){
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error
              (TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->begin_decode), p_td.name);
          return 0;
        }
    decoded_length+=tl;
    p_buf.increase_pos(tl);
  }
  if(p_td.text->end_decode){
    limit.add_token(p_td.text->end_decode);
    ml++;
  }
  if(p_td.text->separator_decode){
    limit.add_token(p_td.text->separator_decode);
    ml++;
  }
    while(TRUE){
    decoded_field_length=field_verb.TEXT_decode(CtrlReplyVerb_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'verb' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    if(p_td.text->separator_decode){
      int tl;
      if((tl=p_td.text->separator_decode->match_begin(p_buf))<0){
          limit.remove_tokens(ml);
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->separator_decode),p_td.name);
          return decoded_length;
      } else {
      decoded_length+=tl;
      p_buf.increase_pos(tl);
      sep_length=tl;
      sep_found=TRUE;}
    } else sep_found=FALSE;
  }
    decoded_field_length=field_id.TEXT_decode(CtrlId_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'id' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    if(p_td.text->separator_decode){
      int tl;
      if((tl=p_td.text->separator_decode->match_begin(p_buf))<0){
          limit.remove_tokens(ml);
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->separator_decode),p_td.name);
          return decoded_length;
      } else {
      decoded_length+=tl;
      p_buf.increase_pos(tl);
      sep_length=tl;
      sep_found=TRUE;}
    } else sep_found=FALSE;
  }
    decoded_field_length=field_variable.TEXT_decode(CtrlVariable_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'variable' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    if(p_td.text->separator_decode){
      int tl;
      if((tl=p_td.text->separator_decode->match_begin(p_buf))<0){
          limit.remove_tokens(ml);
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->separator_decode),p_td.name);
          return decoded_length;
      } else {
      decoded_length+=tl;
      p_buf.increase_pos(tl);
      sep_length=tl;
      sep_found=TRUE;}
    } else sep_found=FALSE;
  }
    decoded_field_length=field_val.TEXT_decode(CtrlValue_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'val' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    sep_found=FALSE;
  }
   break;
  }
  limit.remove_tokens(ml);
  if(sep_found){
      p_buf.set_pos(p_buf.get_pos()-sep_length);
      decoded_length-=sep_length;
  }
  if(p_td.text->end_decode){
    int tl;
    if((tl=p_td.text->end_decode->match_begin(p_buf))<0){
      if(no_err)return -1;
      TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->end_decode),p_td.name);
      return decoded_length;
    }
    decoded_length+=tl;
    p_buf.increase_pos(tl);
  }
  return decoded_length;
}
struct CtrlResponse_template::single_value_struct {
CHARSTRING_template field_verb;
CHARSTRING_template field_id;
CHARSTRING_template field_variable;
CHARSTRING_template field_val;
};

void CtrlResponse_template::set_specific()
{
if (template_selection != SPECIFIC_VALUE) {
template_sel old_selection = template_selection;
clean_up();
single_value = new single_value_struct;
set_selection(SPECIFIC_VALUE);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
single_value->field_verb = ANY_VALUE;
single_value->field_id = ANY_VALUE;
single_value->field_variable = ANY_VALUE;
single_value->field_val = ANY_VALUE;
}
}
}

void CtrlResponse_template::copy_value(const CtrlResponse& other_value)
{
single_value = new single_value_struct;
if (other_value.verb().is_bound()) {
  single_value->field_verb = other_value.verb();
} else {
  single_value->field_verb.clean_up();
}
if (other_value.id().is_bound()) {
  single_value->field_id = other_value.id();
} else {
  single_value->field_id.clean_up();
}
if (other_value.variable().is_bound()) {
  single_value->field_variable = other_value.variable();
} else {
  single_value->field_variable.clean_up();
}
if (other_value.val().is_bound()) {
  single_value->field_val = other_value.val();
} else {
  single_value->field_val.clean_up();
}
set_selection(SPECIFIC_VALUE);
}

void CtrlResponse_template::copy_template(const CtrlResponse_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.verb().get_selection()) {
single_value->field_verb = other_value.verb();
} else {
single_value->field_verb.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.id().get_selection()) {
single_value->field_id = other_value.id();
} else {
single_value->field_id.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.variable().get_selection()) {
single_value->field_variable = other_value.variable();
} else {
single_value->field_variable.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.val().get_selection()) {
single_value->field_val = other_value.val();
} else {
single_value->field_val.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new CtrlResponse_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;
case IMPLICATION_MATCH:
implication_.precondition = new CtrlResponse_template(*other_value.implication_.precondition);
implication_.implied_template = new CtrlResponse_template(*other_value.implication_.implied_template);
break;
case DYNAMIC_MATCH:
dyn_match = other_value.dyn_match;
dyn_match->ref_count++;
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlResponse.");
break;
}
set_selection(other_value);
}

CtrlResponse_template::CtrlResponse_template()
{
}

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

CtrlResponse_template::CtrlResponse_template(const CtrlResponse& other_value)
{
copy_value(other_value);
}

CtrlResponse_template::CtrlResponse_template(const OPTIONAL<CtrlResponse>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlResponse&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Osmocom_CTRL_Types.CtrlResponse from an unbound optional field.");
}
}

CtrlResponse_template::CtrlResponse_template(CtrlResponse_template* p_precondition, CtrlResponse_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

CtrlResponse_template::CtrlResponse_template(Dynamic_Match_Interface<CtrlResponse>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<CtrlResponse>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

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

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

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

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

CtrlResponse_template& CtrlResponse_template::operator=(const OPTIONAL<CtrlResponse>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlResponse&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of type @Osmocom_CTRL_Types.CtrlResponse.");
}
return *this;
}

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

boolean CtrlResponse_template::match(const CtrlResponse& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
if(!other_value.verb().is_bound()) return FALSE;
if(!single_value->field_verb.match(other_value.verb(), legacy))return FALSE;
if(!other_value.id().is_bound()) return FALSE;
if(!single_value->field_id.match(other_value.id(), legacy))return FALSE;
if(!other_value.variable().is_bound()) return FALSE;
if(!single_value->field_variable.match(other_value.variable(), legacy))return FALSE;
if(!other_value.val().is_bound()) return FALSE;
if(!single_value->field_val.match(other_value.val(), legacy))return FALSE;
return TRUE;
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, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
case CONJUNCTION_MATCH:
for (unsigned int i = 0; i < value_list.n_values; i++) {
if (!value_list.list_value[i].match(other_value)) {
return FALSE;
}
}
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value);
case DYNAMIC_MATCH:
return dyn_match->ptr->match(other_value);
default:
TTCN_error("Matching an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlResponse.");
}
return FALSE;
}

boolean CtrlResponse_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_verb.is_bound()
 || single_value->field_id.is_bound()
 || single_value->field_variable.is_bound()
 || single_value->field_val.is_bound();
}

boolean CtrlResponse_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_verb.is_value()
 && single_value->field_id.is_value()
 && single_value->field_variable.is_value()
 && single_value->field_val.is_value();
}

void CtrlResponse_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
delete [] value_list.list_value;
break;
case IMPLICATION_MATCH:
delete implication_.precondition;
delete implication_.implied_template;
break;
case DYNAMIC_MATCH:
dyn_match->ref_count--;
if (dyn_match->ref_count == 0) {
delete dyn_match->ptr;
delete dyn_match;
}
break;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}

CtrlResponse CtrlResponse_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of type @Osmocom_CTRL_Types.CtrlResponse.");
CtrlResponse ret_val;
if (single_value->field_verb.is_bound()) {
ret_val.verb() = single_value->field_verb.valueof();
}
if (single_value->field_id.is_bound()) {
ret_val.id() = single_value->field_id.valueof();
}
if (single_value->field_variable.is_bound()) {
ret_val.variable() = single_value->field_variable.valueof();
}
if (single_value->field_val.is_bound()) {
ret_val.val() = single_value->field_val.valueof();
}
return ret_val;
}

void CtrlResponse_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH)
TTCN_error("Setting an invalid list for a template of type @Osmocom_CTRL_Types.CtrlResponse.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new CtrlResponse_template[list_length];
}

CtrlResponse_template& CtrlResponse_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH)
TTCN_error("Accessing a list element of a non-list template of type @Osmocom_CTRL_Types.CtrlResponse.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Osmocom_CTRL_Types.CtrlResponse.");
return value_list.list_value[list_index];
}

CHARSTRING_template& CtrlResponse_template::verb()
{
set_specific();
return single_value->field_verb;
}

const CHARSTRING_template& CtrlResponse_template::verb() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field verb of a non-specific template of type @Osmocom_CTRL_Types.CtrlResponse.");
return single_value->field_verb;
}

CHARSTRING_template& CtrlResponse_template::id()
{
set_specific();
return single_value->field_id;
}

const CHARSTRING_template& CtrlResponse_template::id() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field id of a non-specific template of type @Osmocom_CTRL_Types.CtrlResponse.");
return single_value->field_id;
}

CHARSTRING_template& CtrlResponse_template::variable()
{
set_specific();
return single_value->field_variable;
}

const CHARSTRING_template& CtrlResponse_template::variable() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field variable of a non-specific template of type @Osmocom_CTRL_Types.CtrlResponse.");
return single_value->field_variable;
}

CHARSTRING_template& CtrlResponse_template::val()
{
set_specific();
return single_value->field_val;
}

const CHARSTRING_template& CtrlResponse_template::val() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field val of a non-specific template of type @Osmocom_CTRL_Types.CtrlResponse.");
return single_value->field_val;
}

int CtrlResponse_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse which has an ifpresent attribute.");
  switch (template_selection)
  {
  case SPECIFIC_VALUE:
    return 4;
  case VALUE_LIST:
   {
     if (value_list.n_values<1)
       TTCN_error("Internal error: Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse containing an empty list.");
      int item_size = value_list.list_value[0].size_of();
      for (unsigned int l_idx = 1; l_idx < value_list.n_values; l_idx++)
      {
        if (value_list.list_value[l_idx].size_of()!=item_size)
          TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlResponse containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlResponse.");
  }
  return 0;
}

void CtrlResponse_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ verb := ");
single_value->field_verb.log();
TTCN_Logger::log_event_str(", id := ");
single_value->field_id.log();
TTCN_Logger::log_event_str(", variable := ");
single_value->field_variable.log();
TTCN_Logger::log_event_str(", val := ");
single_value->field_val.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case CONJUNCTION_MATCH:
if (template_selection == CONJUNCTION_MATCH) {
TTCN_Logger::log_event_str("conjunct");
}
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;
case IMPLICATION_MATCH:
implication_.precondition->log();
TTCN_Logger::log_event_str(" implies ");
implication_.implied_template->log();
break;
case DYNAMIC_MATCH:
TTCN_Logger::log_event_str("@dynamic template");
break;
default:
log_generic();
}
log_ifpresent();
}

void CtrlResponse_template::log_match(const CtrlResponse& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
if(match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
} else{
if (template_selection == SPECIFIC_VALUE) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
if(!single_value->field_verb.match(match_value.verb(), legacy)){
TTCN_Logger::log_logmatch_info(".verb");
single_value->field_verb.log_match(match_value.verb(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_id.match(match_value.id(), legacy)){
TTCN_Logger::log_logmatch_info(".id");
single_value->field_id.log_match(match_value.id(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_variable.match(match_value.variable(), legacy)){
TTCN_Logger::log_logmatch_info(".variable");
single_value->field_variable.log_match(match_value.variable(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_val.match(match_value.val(), legacy)){
TTCN_Logger::log_logmatch_info(".val");
single_value->field_val.log_match(match_value.val(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}else {
TTCN_Logger::print_logmatch_buffer();
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
TTCN_Logger::log_event_str(" unmatched");
}
}
return;
}
if (template_selection == SPECIFIC_VALUE) {
TTCN_Logger::log_event_str("{ verb := ");
single_value->field_verb.log_match(match_value.verb(), legacy);
TTCN_Logger::log_event_str(", id := ");
single_value->field_id.log_match(match_value.id(), legacy);
TTCN_Logger::log_event_str(", variable := ");
single_value->field_variable.log_match(match_value.variable(), legacy);
TTCN_Logger::log_event_str(", val := ");
single_value->field_val.log_match(match_value.val(), legacy);
TTCN_Logger::log_event_str(" }");
} else {
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}

void CtrlResponse_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_verb.encode_text(text_buf);
single_value->field_id.encode_text(text_buf);
single_value->field_variable.encode_text(text_buf);
single_value->field_val.encode_text(text_buf);
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/unsupported template of type @Osmocom_CTRL_Types.CtrlResponse.");
}
}

void CtrlResponse_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
single_value->field_verb.decode_text(text_buf);
single_value->field_id.decode_text(text_buf);
single_value->field_variable.decode_text(text_buf);
single_value->field_val.decode_text(text_buf);
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 CtrlResponse_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: An unknown/unsupported selection was received in a template of type @Osmocom_CTRL_Types.CtrlResponse.");
}
}

void CtrlResponse_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
  switch (param.get_type()) {
  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:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    CtrlResponse_template new_temp;
    new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size());
    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (4<param.get_size()) {
      param.error("record template of type @Osmocom_CTRL_Types.CtrlResponse has 4 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) verb().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) id().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) variable().set_param(*param.get_elem(2));
    if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) val().set_param(*param.get_elem(3));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "verb")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          verb().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "id")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          id().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "variable")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          variable().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "val")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          val().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Osmocom_CTRL_Types.CtrlResponse: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    CtrlResponse_template* precondition = new CtrlResponse_template;
    precondition->set_param(*param.get_elem(0));
    CtrlResponse_template* implied_template = new CtrlResponse_template;
    implied_template->set_param(*param.get_elem(1));
    *this = CtrlResponse_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@Osmocom_CTRL_Types.CtrlResponse");
  }
  is_ifpresent = param.get_ifpresent();
}

void CtrlResponse_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_OMIT:
if (template_selection==OMIT_VALUE) return;
case TR_VALUE:
if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break;
single_value->field_verb.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlResponse");
single_value->field_id.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlResponse");
single_value->field_variable.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlResponse");
single_value->field_val.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlResponse");
return;
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@Osmocom_CTRL_Types.CtrlResponse");
}

boolean CtrlResponse_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean CtrlResponse_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match_omit() || implication_.implied_template->match_omit();
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

CtrlError::CtrlError()
{
}

CtrlError::CtrlError(const CHARSTRING& par_id,
    const CHARSTRING& par_reason)
  :   field_id(par_id),
  field_reason(par_reason)
{
}

CtrlError::CtrlError(const CtrlError& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Osmocom_CTRL_Types.CtrlError.");
if (other_value.id().is_bound()) field_id = other_value.id();
else field_id.clean_up();
if (other_value.reason().is_bound()) field_reason = other_value.reason();
else field_reason.clean_up();
}

void CtrlError::clean_up()
{
field_id.clean_up();
field_reason.clean_up();
}

const TTCN_Typedescriptor_t* CtrlError::get_descriptor() const { return &CtrlError_descr_; }
CtrlError& CtrlError::operator=(const CtrlError& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Osmocom_CTRL_Types.CtrlError.");
  if (other_value.id().is_bound()) field_id = other_value.id();
  else field_id.clean_up();
  if (other_value.reason().is_bound()) field_reason = other_value.reason();
  else field_reason.clean_up();
}
return *this;
}

boolean CtrlError::operator==(const CtrlError& other_value) const
{
return field_id==other_value.field_id
  && field_reason==other_value.field_reason;
}

boolean CtrlError::is_bound() const
{
return (field_id.is_bound())
  || (field_reason.is_bound());
}
boolean CtrlError::is_value() const
{
return field_id.is_value()
  && field_reason.is_value();
}
void CtrlError::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ id := ");
field_id.log();
TTCN_Logger::log_event_str(", reason := ");
field_reason.log();
TTCN_Logger::log_event_str(" }");
}

void CtrlError::set_implicit_omit()
{
if (id().is_bound()) id().set_implicit_omit();
if (reason().is_bound()) reason().set_implicit_omit();
}

void CtrlError::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record value of type @Osmocom_CTRL_Types.CtrlError has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) id().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) reason().set_param(*param.get_elem(1));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "id")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          id().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "reason")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          reason().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Osmocom_CTRL_Types.CtrlError: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@Osmocom_CTRL_Types.CtrlError");
  }
}

void CtrlError::encode_text(Text_Buf& text_buf) const
{
field_id.encode_text(text_buf);
field_reason.encode_text(text_buf);
}

void CtrlError::decode_text(Text_Buf& text_buf)
{
field_id.decode_text(text_buf);
field_reason.decode_text(text_buf);
}

void CtrlError::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
    unsigned BER_coding=va_arg(pvar, unsigned);
    BER_encode_chk_coding(BER_coding);
    ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
    tlv->put_in_buffer(p_buf);
    ASN_BER_TLV_t::destruct(tlv);
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    RAW_enc_tr_pos rp;
    rp.level=0;
    rp.pos=NULL;
    RAW_enc_tree root(FALSE, NULL, &rp, 1, p_td.raw);
    RAW_encode(p_td, root);
    root.put_to_buf(p_buf);
    break;}
  case TTCN_EncDec::CT_TEXT: {
    TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
      ("No TEXT descriptor available for type '%s'.", p_td.name);
    TEXT_encode(p_td,p_buf);
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
    p_buf.put_c('\n');
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok(va_arg(pvar, int) != 0);
    JSON_encode(p_td, tok, FALSE);
    p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
    OER_encode(p_td, p_buf);
    break;}
  default:
    TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
  }
  va_end(pvar);
}

void CtrlError::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
    unsigned L_form=va_arg(pvar, unsigned);
    ASN_BER_TLV_t tlv;
    BER_decode_str2TLV(p_buf, tlv, L_form);
    BER_decode_TLV(p_td, tlv, L_form);
    if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    raw_order_t r_order;
    switch(p_td.raw->top_bit_order) {
    case TOP_BIT_LEFT:
      r_order=ORDER_LSB;
      break;
    case TOP_BIT_RIGHT:
    default:
      r_order=ORDER_MSB;
    }
    int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
    if(rawr<0) switch (-rawr) {
    case TTCN_EncDec::ET_INCOMPL_MSG:
    case TTCN_EncDec::ET_LEN_ERR:
      ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
      break;
    case 1:
    default:
      ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
      break;
    }
    break;}
  case TTCN_EncDec::CT_TEXT: {
    Limit_Token_List limit;
    TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
        ("No TEXT descriptor available for type '%s'.", p_td.name);
    const unsigned char *b_data=p_buf.get_data();
    int null_added=0;
    if(b_data[p_buf.get_len()-1]!='\0'){
      null_added=1;
      p_buf.set_pos(p_buf.get_len());
      p_buf.put_zero(8,ORDER_LSB);
      p_buf.rewind();
    }
    if(TEXT_decode(p_td,p_buf,limit)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    if(null_added){
      size_t actpos=p_buf.get_pos();
      p_buf.set_pos(p_buf.get_len()-1);
      p_buf.cut_end();
      p_buf.set_pos(actpos);
    }
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XmlReaderWrap reader(p_buf);
    for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
      if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
    }
    XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
    size_t bytes = reader.ByteConsumed();
    p_buf.set_pos(bytes);
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
    if(JSON_decode(p_td, tok, FALSE, FALSE)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    p_buf.set_pos(tok.get_buf_pos());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
     OER_struct p_oer;
    OER_decode(p_td, p_buf, p_oer);
    break;}
  default:
    TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
  }
  va_end(pvar);
}

int CtrlError::TEXT_encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf) const{
  if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
  boolean need_separator=FALSE;
  int encoded_length=0;
  if(p_td.text->begin_encode){
    p_buf.put_cs(*p_td.text->begin_encode);
    encoded_length+=p_td.text->begin_encode->lengthof();
  }
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_id.TEXT_encode(CtrlId_descr_,p_buf);
 need_separator=TRUE;
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_reason.TEXT_encode(CtrlReason_descr_,p_buf);
 need_separator=TRUE;
  if(p_td.text->end_encode){
    p_buf.put_cs(*p_td.text->end_encode);
    encoded_length+=p_td.text->end_encode->lengthof();
  }
  return encoded_length;
}
int CtrlError::TEXT_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, Limit_Token_List& limit, boolean no_err, boolean){
  int decoded_length=0;
  int decoded_field_length=0;
  boolean sep_found=FALSE;
  int sep_length=0;
  int ml=0;
  if(p_td.text->begin_decode){
    int tl;
    if((tl=p_td.text->begin_decode->match_begin(p_buf))<0){
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error
              (TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->begin_decode), p_td.name);
          return 0;
        }
    decoded_length+=tl;
    p_buf.increase_pos(tl);
  }
  if(p_td.text->end_decode){
    limit.add_token(p_td.text->end_decode);
    ml++;
  }
  if(p_td.text->separator_decode){
    limit.add_token(p_td.text->separator_decode);
    ml++;
  }
    while(TRUE){
    decoded_field_length=field_id.TEXT_decode(CtrlId_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'id' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    if(p_td.text->separator_decode){
      int tl;
      if((tl=p_td.text->separator_decode->match_begin(p_buf))<0){
          limit.remove_tokens(ml);
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->separator_decode),p_td.name);
          return decoded_length;
      } else {
      decoded_length+=tl;
      p_buf.increase_pos(tl);
      sep_length=tl;
      sep_found=TRUE;}
    } else sep_found=FALSE;
  }
    decoded_field_length=field_reason.TEXT_decode(CtrlReason_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'reason' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    sep_found=FALSE;
  }
   break;
  }
  limit.remove_tokens(ml);
  if(sep_found){
      p_buf.set_pos(p_buf.get_pos()-sep_length);
      decoded_length-=sep_length;
  }
  if(p_td.text->end_decode){
    int tl;
    if((tl=p_td.text->end_decode->match_begin(p_buf))<0){
      if(no_err)return -1;
      TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->end_decode),p_td.name);
      return decoded_length;
    }
    decoded_length+=tl;
    p_buf.increase_pos(tl);
  }
  return decoded_length;
}
struct CtrlError_template::single_value_struct {
CHARSTRING_template field_id;
CHARSTRING_template field_reason;
};

void CtrlError_template::set_specific()
{
if (template_selection != SPECIFIC_VALUE) {
template_sel old_selection = template_selection;
clean_up();
single_value = new single_value_struct;
set_selection(SPECIFIC_VALUE);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
single_value->field_id = ANY_VALUE;
single_value->field_reason = ANY_VALUE;
}
}
}

void CtrlError_template::copy_value(const CtrlError& other_value)
{
single_value = new single_value_struct;
if (other_value.id().is_bound()) {
  single_value->field_id = other_value.id();
} else {
  single_value->field_id.clean_up();
}
if (other_value.reason().is_bound()) {
  single_value->field_reason = other_value.reason();
} else {
  single_value->field_reason.clean_up();
}
set_selection(SPECIFIC_VALUE);
}

void CtrlError_template::copy_template(const CtrlError_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.id().get_selection()) {
single_value->field_id = other_value.id();
} else {
single_value->field_id.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.reason().get_selection()) {
single_value->field_reason = other_value.reason();
} else {
single_value->field_reason.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new CtrlError_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;
case IMPLICATION_MATCH:
implication_.precondition = new CtrlError_template(*other_value.implication_.precondition);
implication_.implied_template = new CtrlError_template(*other_value.implication_.implied_template);
break;
case DYNAMIC_MATCH:
dyn_match = other_value.dyn_match;
dyn_match->ref_count++;
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlError.");
break;
}
set_selection(other_value);
}

CtrlError_template::CtrlError_template()
{
}

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

CtrlError_template::CtrlError_template(const CtrlError& other_value)
{
copy_value(other_value);
}

CtrlError_template::CtrlError_template(const OPTIONAL<CtrlError>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlError&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Osmocom_CTRL_Types.CtrlError from an unbound optional field.");
}
}

CtrlError_template::CtrlError_template(CtrlError_template* p_precondition, CtrlError_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

CtrlError_template::CtrlError_template(Dynamic_Match_Interface<CtrlError>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<CtrlError>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

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

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

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

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

CtrlError_template& CtrlError_template::operator=(const OPTIONAL<CtrlError>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlError&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of type @Osmocom_CTRL_Types.CtrlError.");
}
return *this;
}

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

boolean CtrlError_template::match(const CtrlError& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
if(!other_value.id().is_bound()) return FALSE;
if(!single_value->field_id.match(other_value.id(), legacy))return FALSE;
if(!other_value.reason().is_bound()) return FALSE;
if(!single_value->field_reason.match(other_value.reason(), legacy))return FALSE;
return TRUE;
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, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
case CONJUNCTION_MATCH:
for (unsigned int i = 0; i < value_list.n_values; i++) {
if (!value_list.list_value[i].match(other_value)) {
return FALSE;
}
}
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value);
case DYNAMIC_MATCH:
return dyn_match->ptr->match(other_value);
default:
TTCN_error("Matching an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlError.");
}
return FALSE;
}

boolean CtrlError_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_id.is_bound()
 || single_value->field_reason.is_bound();
}

boolean CtrlError_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_id.is_value()
 && single_value->field_reason.is_value();
}

void CtrlError_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
delete [] value_list.list_value;
break;
case IMPLICATION_MATCH:
delete implication_.precondition;
delete implication_.implied_template;
break;
case DYNAMIC_MATCH:
dyn_match->ref_count--;
if (dyn_match->ref_count == 0) {
delete dyn_match->ptr;
delete dyn_match;
}
break;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}

CtrlError CtrlError_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of type @Osmocom_CTRL_Types.CtrlError.");
CtrlError ret_val;
if (single_value->field_id.is_bound()) {
ret_val.id() = single_value->field_id.valueof();
}
if (single_value->field_reason.is_bound()) {
ret_val.reason() = single_value->field_reason.valueof();
}
return ret_val;
}

void CtrlError_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH)
TTCN_error("Setting an invalid list for a template of type @Osmocom_CTRL_Types.CtrlError.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new CtrlError_template[list_length];
}

CtrlError_template& CtrlError_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH)
TTCN_error("Accessing a list element of a non-list template of type @Osmocom_CTRL_Types.CtrlError.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Osmocom_CTRL_Types.CtrlError.");
return value_list.list_value[list_index];
}

CHARSTRING_template& CtrlError_template::id()
{
set_specific();
return single_value->field_id;
}

const CHARSTRING_template& CtrlError_template::id() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field id of a non-specific template of type @Osmocom_CTRL_Types.CtrlError.");
return single_value->field_id;
}

CHARSTRING_template& CtrlError_template::reason()
{
set_specific();
return single_value->field_reason;
}

const CHARSTRING_template& CtrlError_template::reason() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field reason of a non-specific template of type @Osmocom_CTRL_Types.CtrlError.");
return single_value->field_reason;
}

int CtrlError_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError which has an ifpresent attribute.");
  switch (template_selection)
  {
  case SPECIFIC_VALUE:
    return 2;
  case VALUE_LIST:
   {
     if (value_list.n_values<1)
       TTCN_error("Internal error: Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError containing an empty list.");
      int item_size = value_list.list_value[0].size_of();
      for (unsigned int l_idx = 1; l_idx < value_list.n_values; l_idx++)
      {
        if (value_list.list_value[l_idx].size_of()!=item_size)
          TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlError containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlError.");
  }
  return 0;
}

void CtrlError_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ id := ");
single_value->field_id.log();
TTCN_Logger::log_event_str(", reason := ");
single_value->field_reason.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case CONJUNCTION_MATCH:
if (template_selection == CONJUNCTION_MATCH) {
TTCN_Logger::log_event_str("conjunct");
}
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;
case IMPLICATION_MATCH:
implication_.precondition->log();
TTCN_Logger::log_event_str(" implies ");
implication_.implied_template->log();
break;
case DYNAMIC_MATCH:
TTCN_Logger::log_event_str("@dynamic template");
break;
default:
log_generic();
}
log_ifpresent();
}

void CtrlError_template::log_match(const CtrlError& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
if(match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
} else{
if (template_selection == SPECIFIC_VALUE) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
if(!single_value->field_id.match(match_value.id(), legacy)){
TTCN_Logger::log_logmatch_info(".id");
single_value->field_id.log_match(match_value.id(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_reason.match(match_value.reason(), legacy)){
TTCN_Logger::log_logmatch_info(".reason");
single_value->field_reason.log_match(match_value.reason(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}else {
TTCN_Logger::print_logmatch_buffer();
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
TTCN_Logger::log_event_str(" unmatched");
}
}
return;
}
if (template_selection == SPECIFIC_VALUE) {
TTCN_Logger::log_event_str("{ id := ");
single_value->field_id.log_match(match_value.id(), legacy);
TTCN_Logger::log_event_str(", reason := ");
single_value->field_reason.log_match(match_value.reason(), legacy);
TTCN_Logger::log_event_str(" }");
} else {
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}

void CtrlError_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_id.encode_text(text_buf);
single_value->field_reason.encode_text(text_buf);
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/unsupported template of type @Osmocom_CTRL_Types.CtrlError.");
}
}

void CtrlError_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
single_value->field_id.decode_text(text_buf);
single_value->field_reason.decode_text(text_buf);
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 CtrlError_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: An unknown/unsupported selection was received in a template of type @Osmocom_CTRL_Types.CtrlError.");
}
}

void CtrlError_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
  switch (param.get_type()) {
  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:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    CtrlError_template new_temp;
    new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size());
    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record template of type @Osmocom_CTRL_Types.CtrlError has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) id().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) reason().set_param(*param.get_elem(1));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "id")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          id().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "reason")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          reason().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Osmocom_CTRL_Types.CtrlError: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    CtrlError_template* precondition = new CtrlError_template;
    precondition->set_param(*param.get_elem(0));
    CtrlError_template* implied_template = new CtrlError_template;
    implied_template->set_param(*param.get_elem(1));
    *this = CtrlError_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@Osmocom_CTRL_Types.CtrlError");
  }
  is_ifpresent = param.get_ifpresent();
}

void CtrlError_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_OMIT:
if (template_selection==OMIT_VALUE) return;
case TR_VALUE:
if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break;
single_value->field_id.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlError");
single_value->field_reason.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlError");
return;
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@Osmocom_CTRL_Types.CtrlError");
}

boolean CtrlError_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean CtrlError_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match_omit() || implication_.implied_template->match_omit();
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

CtrlTrap::CtrlTrap()
{
}

CtrlTrap::CtrlTrap(const CHARSTRING& par_variable,
    const CHARSTRING& par_val)
  :   field_variable(par_variable),
  field_val(par_val)
{
}

CtrlTrap::CtrlTrap(const CtrlTrap& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Osmocom_CTRL_Types.CtrlTrap.");
if (other_value.variable().is_bound()) field_variable = other_value.variable();
else field_variable.clean_up();
if (other_value.val().is_bound()) field_val = other_value.val();
else field_val.clean_up();
}

void CtrlTrap::clean_up()
{
field_variable.clean_up();
field_val.clean_up();
}

const TTCN_Typedescriptor_t* CtrlTrap::get_descriptor() const { return &CtrlTrap_descr_; }
CtrlTrap& CtrlTrap::operator=(const CtrlTrap& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Osmocom_CTRL_Types.CtrlTrap.");
  if (other_value.variable().is_bound()) field_variable = other_value.variable();
  else field_variable.clean_up();
  if (other_value.val().is_bound()) field_val = other_value.val();
  else field_val.clean_up();
}
return *this;
}

boolean CtrlTrap::operator==(const CtrlTrap& other_value) const
{
return field_variable==other_value.field_variable
  && field_val==other_value.field_val;
}

boolean CtrlTrap::is_bound() const
{
return (field_variable.is_bound())
  || (field_val.is_bound());
}
boolean CtrlTrap::is_value() const
{
return field_variable.is_value()
  && field_val.is_value();
}
void CtrlTrap::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ variable := ");
field_variable.log();
TTCN_Logger::log_event_str(", val := ");
field_val.log();
TTCN_Logger::log_event_str(" }");
}

void CtrlTrap::set_implicit_omit()
{
if (variable().is_bound()) variable().set_implicit_omit();
if (val().is_bound()) val().set_implicit_omit();
}

void CtrlTrap::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record value of type @Osmocom_CTRL_Types.CtrlTrap has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) variable().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) val().set_param(*param.get_elem(1));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "variable")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          variable().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "val")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          val().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Osmocom_CTRL_Types.CtrlTrap: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@Osmocom_CTRL_Types.CtrlTrap");
  }
}

void CtrlTrap::encode_text(Text_Buf& text_buf) const
{
field_variable.encode_text(text_buf);
field_val.encode_text(text_buf);
}

void CtrlTrap::decode_text(Text_Buf& text_buf)
{
field_variable.decode_text(text_buf);
field_val.decode_text(text_buf);
}

void CtrlTrap::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
    unsigned BER_coding=va_arg(pvar, unsigned);
    BER_encode_chk_coding(BER_coding);
    ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
    tlv->put_in_buffer(p_buf);
    ASN_BER_TLV_t::destruct(tlv);
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    RAW_enc_tr_pos rp;
    rp.level=0;
    rp.pos=NULL;
    RAW_enc_tree root(FALSE, NULL, &rp, 1, p_td.raw);
    RAW_encode(p_td, root);
    root.put_to_buf(p_buf);
    break;}
  case TTCN_EncDec::CT_TEXT: {
    TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
      ("No TEXT descriptor available for type '%s'.", p_td.name);
    TEXT_encode(p_td,p_buf);
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
    p_buf.put_c('\n');
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok(va_arg(pvar, int) != 0);
    JSON_encode(p_td, tok, FALSE);
    p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
    OER_encode(p_td, p_buf);
    break;}
  default:
    TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
  }
  va_end(pvar);
}

void CtrlTrap::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
    unsigned L_form=va_arg(pvar, unsigned);
    ASN_BER_TLV_t tlv;
    BER_decode_str2TLV(p_buf, tlv, L_form);
    BER_decode_TLV(p_td, tlv, L_form);
    if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    raw_order_t r_order;
    switch(p_td.raw->top_bit_order) {
    case TOP_BIT_LEFT:
      r_order=ORDER_LSB;
      break;
    case TOP_BIT_RIGHT:
    default:
      r_order=ORDER_MSB;
    }
    int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
    if(rawr<0) switch (-rawr) {
    case TTCN_EncDec::ET_INCOMPL_MSG:
    case TTCN_EncDec::ET_LEN_ERR:
      ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
      break;
    case 1:
    default:
      ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
      break;
    }
    break;}
  case TTCN_EncDec::CT_TEXT: {
    Limit_Token_List limit;
    TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
        ("No TEXT descriptor available for type '%s'.", p_td.name);
    const unsigned char *b_data=p_buf.get_data();
    int null_added=0;
    if(b_data[p_buf.get_len()-1]!='\0'){
      null_added=1;
      p_buf.set_pos(p_buf.get_len());
      p_buf.put_zero(8,ORDER_LSB);
      p_buf.rewind();
    }
    if(TEXT_decode(p_td,p_buf,limit)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    if(null_added){
      size_t actpos=p_buf.get_pos();
      p_buf.set_pos(p_buf.get_len()-1);
      p_buf.cut_end();
      p_buf.set_pos(actpos);
    }
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XmlReaderWrap reader(p_buf);
    for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
      if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
    }
    XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
    size_t bytes = reader.ByteConsumed();
    p_buf.set_pos(bytes);
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
    if(JSON_decode(p_td, tok, FALSE, FALSE)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    p_buf.set_pos(tok.get_buf_pos());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
     OER_struct p_oer;
    OER_decode(p_td, p_buf, p_oer);
    break;}
  default:
    TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
  }
  va_end(pvar);
}

int CtrlTrap::TEXT_encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf) const{
  if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
  boolean need_separator=FALSE;
  int encoded_length=0;
  if(p_td.text->begin_encode){
    p_buf.put_cs(*p_td.text->begin_encode);
    encoded_length+=p_td.text->begin_encode->lengthof();
  }
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_variable.TEXT_encode(CtrlVariable_descr_,p_buf);
 need_separator=TRUE;
 if(need_separator && p_td.text->separator_encode){
    p_buf.put_cs(*p_td.text->separator_encode);
    encoded_length+=p_td.text->separator_encode->lengthof();
 }
 encoded_length+=field_val.TEXT_encode(CtrlValue_descr_,p_buf);
 need_separator=TRUE;
  if(p_td.text->end_encode){
    p_buf.put_cs(*p_td.text->end_encode);
    encoded_length+=p_td.text->end_encode->lengthof();
  }
  return encoded_length;
}
int CtrlTrap::TEXT_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, Limit_Token_List& limit, boolean no_err, boolean){
  int decoded_length=0;
  int decoded_field_length=0;
  boolean sep_found=FALSE;
  int sep_length=0;
  int ml=0;
  if(p_td.text->begin_decode){
    int tl;
    if((tl=p_td.text->begin_decode->match_begin(p_buf))<0){
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error
              (TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->begin_decode), p_td.name);
          return 0;
        }
    decoded_length+=tl;
    p_buf.increase_pos(tl);
  }
  if(p_td.text->end_decode){
    limit.add_token(p_td.text->end_decode);
    ml++;
  }
  if(p_td.text->separator_decode){
    limit.add_token(p_td.text->separator_decode);
    ml++;
  }
    while(TRUE){
    decoded_field_length=field_variable.TEXT_decode(CtrlVariable_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'variable' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    if(p_td.text->separator_decode){
      int tl;
      if((tl=p_td.text->separator_decode->match_begin(p_buf))<0){
          limit.remove_tokens(ml);
          if(no_err)return -1;
          TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->separator_decode),p_td.name);
          return decoded_length;
      } else {
      decoded_length+=tl;
      p_buf.increase_pos(tl);
      sep_length=tl;
      sep_found=TRUE;}
    } else sep_found=FALSE;
  }
    decoded_field_length=field_val.TEXT_decode(CtrlValue_descr_,p_buf,limit,TRUE);
    if(decoded_field_length<0){
     limit.remove_tokens(ml);
     if(no_err)return -1;
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "Error during decoding field 'val' for '%s': ", p_td.name);
     return decoded_length;
   } else {
  decoded_length+=decoded_field_length;
    sep_found=FALSE;
  }
   break;
  }
  limit.remove_tokens(ml);
  if(sep_found){
      p_buf.set_pos(p_buf.get_pos()-sep_length);
      decoded_length-=sep_length;
  }
  if(p_td.text->end_decode){
    int tl;
    if((tl=p_td.text->end_decode->match_begin(p_buf))<0){
      if(no_err)return -1;
      TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ",(const char*)*(p_td.text->end_decode),p_td.name);
      return decoded_length;
    }
    decoded_length+=tl;
    p_buf.increase_pos(tl);
  }
  return decoded_length;
}
struct CtrlTrap_template::single_value_struct {
CHARSTRING_template field_variable;
CHARSTRING_template field_val;
};

void CtrlTrap_template::set_specific()
{
if (template_selection != SPECIFIC_VALUE) {
template_sel old_selection = template_selection;
clean_up();
single_value = new single_value_struct;
set_selection(SPECIFIC_VALUE);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
single_value->field_variable = ANY_VALUE;
single_value->field_val = ANY_VALUE;
}
}
}

void CtrlTrap_template::copy_value(const CtrlTrap& other_value)
{
single_value = new single_value_struct;
if (other_value.variable().is_bound()) {
  single_value->field_variable = other_value.variable();
} else {
  single_value->field_variable.clean_up();
}
if (other_value.val().is_bound()) {
  single_value->field_val = other_value.val();
} else {
  single_value->field_val.clean_up();
}
set_selection(SPECIFIC_VALUE);
}

void CtrlTrap_template::copy_template(const CtrlTrap_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.variable().get_selection()) {
single_value->field_variable = other_value.variable();
} else {
single_value->field_variable.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.val().get_selection()) {
single_value->field_val = other_value.val();
} else {
single_value->field_val.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new CtrlTrap_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;
case IMPLICATION_MATCH:
implication_.precondition = new CtrlTrap_template(*other_value.implication_.precondition);
implication_.implied_template = new CtrlTrap_template(*other_value.implication_.implied_template);
break;
case DYNAMIC_MATCH:
dyn_match = other_value.dyn_match;
dyn_match->ref_count++;
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlTrap.");
break;
}
set_selection(other_value);
}

CtrlTrap_template::CtrlTrap_template()
{
}

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

CtrlTrap_template::CtrlTrap_template(const CtrlTrap& other_value)
{
copy_value(other_value);
}

CtrlTrap_template::CtrlTrap_template(const OPTIONAL<CtrlTrap>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlTrap&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Osmocom_CTRL_Types.CtrlTrap from an unbound optional field.");
}
}

CtrlTrap_template::CtrlTrap_template(CtrlTrap_template* p_precondition, CtrlTrap_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

CtrlTrap_template::CtrlTrap_template(Dynamic_Match_Interface<CtrlTrap>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<CtrlTrap>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

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

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

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

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

CtrlTrap_template& CtrlTrap_template::operator=(const OPTIONAL<CtrlTrap>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlTrap&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of type @Osmocom_CTRL_Types.CtrlTrap.");
}
return *this;
}

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

boolean CtrlTrap_template::match(const CtrlTrap& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
if(!other_value.variable().is_bound()) return FALSE;
if(!single_value->field_variable.match(other_value.variable(), legacy))return FALSE;
if(!other_value.val().is_bound()) return FALSE;
if(!single_value->field_val.match(other_value.val(), legacy))return FALSE;
return TRUE;
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, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
case CONJUNCTION_MATCH:
for (unsigned int i = 0; i < value_list.n_values; i++) {
if (!value_list.list_value[i].match(other_value)) {
return FALSE;
}
}
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value);
case DYNAMIC_MATCH:
return dyn_match->ptr->match(other_value);
default:
TTCN_error("Matching an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlTrap.");
}
return FALSE;
}

boolean CtrlTrap_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_variable.is_bound()
 || single_value->field_val.is_bound();
}

boolean CtrlTrap_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_variable.is_value()
 && single_value->field_val.is_value();
}

void CtrlTrap_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
delete [] value_list.list_value;
break;
case IMPLICATION_MATCH:
delete implication_.precondition;
delete implication_.implied_template;
break;
case DYNAMIC_MATCH:
dyn_match->ref_count--;
if (dyn_match->ref_count == 0) {
delete dyn_match->ptr;
delete dyn_match;
}
break;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}

CtrlTrap CtrlTrap_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of type @Osmocom_CTRL_Types.CtrlTrap.");
CtrlTrap ret_val;
if (single_value->field_variable.is_bound()) {
ret_val.variable() = single_value->field_variable.valueof();
}
if (single_value->field_val.is_bound()) {
ret_val.val() = single_value->field_val.valueof();
}
return ret_val;
}

void CtrlTrap_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH)
TTCN_error("Setting an invalid list for a template of type @Osmocom_CTRL_Types.CtrlTrap.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new CtrlTrap_template[list_length];
}

CtrlTrap_template& CtrlTrap_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH)
TTCN_error("Accessing a list element of a non-list template of type @Osmocom_CTRL_Types.CtrlTrap.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Osmocom_CTRL_Types.CtrlTrap.");
return value_list.list_value[list_index];
}

CHARSTRING_template& CtrlTrap_template::variable()
{
set_specific();
return single_value->field_variable;
}

const CHARSTRING_template& CtrlTrap_template::variable() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field variable of a non-specific template of type @Osmocom_CTRL_Types.CtrlTrap.");
return single_value->field_variable;
}

CHARSTRING_template& CtrlTrap_template::val()
{
set_specific();
return single_value->field_val;
}

const CHARSTRING_template& CtrlTrap_template::val() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field val of a non-specific template of type @Osmocom_CTRL_Types.CtrlTrap.");
return single_value->field_val;
}

int CtrlTrap_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap which has an ifpresent attribute.");
  switch (template_selection)
  {
  case SPECIFIC_VALUE:
    return 2;
  case VALUE_LIST:
   {
     if (value_list.n_values<1)
       TTCN_error("Internal error: Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap containing an empty list.");
      int item_size = value_list.list_value[0].size_of();
      for (unsigned int l_idx = 1; l_idx < value_list.n_values; l_idx++)
      {
        if (value_list.list_value[l_idx].size_of()!=item_size)
          TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Osmocom_CTRL_Types.CtrlTrap containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Osmocom_CTRL_Types.CtrlTrap.");
  }
  return 0;
}

void CtrlTrap_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ variable := ");
single_value->field_variable.log();
TTCN_Logger::log_event_str(", val := ");
single_value->field_val.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case CONJUNCTION_MATCH:
if (template_selection == CONJUNCTION_MATCH) {
TTCN_Logger::log_event_str("conjunct");
}
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;
case IMPLICATION_MATCH:
implication_.precondition->log();
TTCN_Logger::log_event_str(" implies ");
implication_.implied_template->log();
break;
case DYNAMIC_MATCH:
TTCN_Logger::log_event_str("@dynamic template");
break;
default:
log_generic();
}
log_ifpresent();
}

void CtrlTrap_template::log_match(const CtrlTrap& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
if(match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
} else{
if (template_selection == SPECIFIC_VALUE) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
if(!single_value->field_variable.match(match_value.variable(), legacy)){
TTCN_Logger::log_logmatch_info(".variable");
single_value->field_variable.log_match(match_value.variable(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_val.match(match_value.val(), legacy)){
TTCN_Logger::log_logmatch_info(".val");
single_value->field_val.log_match(match_value.val(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}else {
TTCN_Logger::print_logmatch_buffer();
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
TTCN_Logger::log_event_str(" unmatched");
}
}
return;
}
if (template_selection == SPECIFIC_VALUE) {
TTCN_Logger::log_event_str("{ variable := ");
single_value->field_variable.log_match(match_value.variable(), legacy);
TTCN_Logger::log_event_str(", val := ");
single_value->field_val.log_match(match_value.val(), legacy);
TTCN_Logger::log_event_str(" }");
} else {
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}

void CtrlTrap_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_variable.encode_text(text_buf);
single_value->field_val.encode_text(text_buf);
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/unsupported template of type @Osmocom_CTRL_Types.CtrlTrap.");
}
}

void CtrlTrap_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
single_value->field_variable.decode_text(text_buf);
single_value->field_val.decode_text(text_buf);
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 CtrlTrap_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: An unknown/unsupported selection was received in a template of type @Osmocom_CTRL_Types.CtrlTrap.");
}
}

void CtrlTrap_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
  switch (param.get_type()) {
  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:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    CtrlTrap_template new_temp;
    new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size());
    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record template of type @Osmocom_CTRL_Types.CtrlTrap has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) variable().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) val().set_param(*param.get_elem(1));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "variable")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          variable().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "val")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          val().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Osmocom_CTRL_Types.CtrlTrap: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    CtrlTrap_template* precondition = new CtrlTrap_template;
    precondition->set_param(*param.get_elem(0));
    CtrlTrap_template* implied_template = new CtrlTrap_template;
    implied_template->set_param(*param.get_elem(1));
    *this = CtrlTrap_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@Osmocom_CTRL_Types.CtrlTrap");
  }
  is_ifpresent = param.get_ifpresent();
}

void CtrlTrap_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_OMIT:
if (template_selection==OMIT_VALUE) return;
case TR_VALUE:
if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break;
single_value->field_variable.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlTrap");
single_value->field_val.check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlTrap");
return;
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@Osmocom_CTRL_Types.CtrlTrap");
}

boolean CtrlTrap_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean CtrlTrap_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match_omit() || implication_.implied_template->match_omit();
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

void CtrlMessage::copy_value(const CtrlMessage& other_value)
{
switch (other_value.union_selection) {
case ALT_cmd:
field_cmd = new CtrlCommand(*other_value.field_cmd);
break;
case ALT_resp:
field_resp = new CtrlResponse(*other_value.field_resp);
break;
case ALT_err:
field_err = new CtrlError(*other_value.field_err);
break;
case ALT_trap:
field_trap = new CtrlTrap(*other_value.field_trap);
break;
default:
TTCN_error("Assignment of an unbound union value of type @Osmocom_CTRL_Types.CtrlMessage.");
}
union_selection = other_value.union_selection;
}

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

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

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

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

boolean CtrlMessage::operator==(const CtrlMessage& other_value) const
{
if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type @Osmocom_CTRL_Types.CtrlMessage.");
if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type @Osmocom_CTRL_Types.CtrlMessage.");
if (union_selection != other_value.union_selection) return FALSE;
switch (union_selection) {
case ALT_cmd:
return *field_cmd == *other_value.field_cmd;
case ALT_resp:
return *field_resp == *other_value.field_resp;
case ALT_err:
return *field_err == *other_value.field_err;
case ALT_trap:
return *field_trap == *other_value.field_trap;
default:
return FALSE;
}
}

CtrlCommand& CtrlMessage::cmd()
{
if (union_selection != ALT_cmd) {
clean_up();
field_cmd = new CtrlCommand;
union_selection = ALT_cmd;
}
return *field_cmd;
}

const CtrlCommand& CtrlMessage::cmd() const
{
if (union_selection != ALT_cmd) TTCN_error("Using non-selected field cmd in a value of union type @Osmocom_CTRL_Types.CtrlMessage.");
return *field_cmd;
}

CtrlResponse& CtrlMessage::resp()
{
if (union_selection != ALT_resp) {
clean_up();
field_resp = new CtrlResponse;
union_selection = ALT_resp;
}
return *field_resp;
}

const CtrlResponse& CtrlMessage::resp() const
{
if (union_selection != ALT_resp) TTCN_error("Using non-selected field resp in a value of union type @Osmocom_CTRL_Types.CtrlMessage.");
return *field_resp;
}

CtrlError& CtrlMessage::err()
{
if (union_selection != ALT_err) {
clean_up();
field_err = new CtrlError;
union_selection = ALT_err;
}
return *field_err;
}

const CtrlError& CtrlMessage::err() const
{
if (union_selection != ALT_err) TTCN_error("Using non-selected field err in a value of union type @Osmocom_CTRL_Types.CtrlMessage.");
return *field_err;
}

CtrlTrap& CtrlMessage::trap()
{
if (union_selection != ALT_trap) {
clean_up();
field_trap = new CtrlTrap;
union_selection = ALT_trap;
}
return *field_trap;
}

const CtrlTrap& CtrlMessage::trap() const
{
if (union_selection != ALT_trap) TTCN_error("Using non-selected field trap in a value of union type @Osmocom_CTRL_Types.CtrlMessage.");
return *field_trap;
}

boolean CtrlMessage::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 @Osmocom_CTRL_Types.CtrlMessage.");
return union_selection == checked_selection;
}

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

boolean CtrlMessage::is_value() const
{
switch (union_selection) {
case UNBOUND_VALUE: return FALSE;
case ALT_cmd: return field_cmd->is_value();
case ALT_resp: return field_resp->is_value();
case ALT_err: return field_err->is_value();
case ALT_trap: return field_trap->is_value();
default: TTCN_error("Invalid selection in union is_bound");}
}

void CtrlMessage::clean_up()
{
switch (union_selection) {
case ALT_cmd:
  delete field_cmd;
  break;
case ALT_resp:
  delete field_resp;
  break;
case ALT_err:
  delete field_err;
  break;
case ALT_trap:
  delete field_trap;
  break;
default:
  break;
}
union_selection = UNBOUND_VALUE;
}

void CtrlMessage::log() const
{
switch (union_selection) {
case ALT_cmd:
TTCN_Logger::log_event_str("{ cmd := ");
field_cmd->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_resp:
TTCN_Logger::log_event_str("{ resp := ");
field_resp->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_err:
TTCN_Logger::log_event_str("{ err := ");
field_err->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_trap:
TTCN_Logger::log_event_str("{ trap := ");
field_trap->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_unbound();
}
}

void CtrlMessage::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "union value");
  Module_Param_Ptr m_p = &param;
  if (m_p->get_type()==Module_Param::MP_Value_List && m_p->get_size()==0) return;
  if (m_p->get_type()!=Module_Param::MP_Assignment_List) {
    param.error("union value with field name was expected");
  }
  Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
  char* last_name = mp_last->get_id()->get_name();
  if (!strcmp(last_name, "cmd")) {
    cmd().set_param(*mp_last);
    if (!cmd().is_bound()) clean_up();
    return;
  }
  if (!strcmp(last_name, "resp")) {
    resp().set_param(*mp_last);
    if (!resp().is_bound()) clean_up();
    return;
  }
  if (!strcmp(last_name, "err")) {
    err().set_param(*mp_last);
    if (!err().is_bound()) clean_up();
    return;
  }
  if (!strcmp(last_name, "trap")) {
    trap().set_param(*mp_last);
    if (!trap().is_bound()) clean_up();
    return;
  }
  mp_last->error("Field %s does not exist in type @Osmocom_CTRL_Types.CtrlMessage.", last_name);
}

void CtrlMessage::set_implicit_omit()
{
switch (union_selection) {
case ALT_cmd:
field_cmd->set_implicit_omit(); break;
case ALT_resp:
field_resp->set_implicit_omit(); break;
case ALT_err:
field_err->set_implicit_omit(); break;
case ALT_trap:
field_trap->set_implicit_omit(); break;
default: break;
}
}

void CtrlMessage::encode_text(Text_Buf& text_buf) const
{
text_buf.push_int(union_selection);
switch (union_selection) {
case ALT_cmd:
field_cmd->encode_text(text_buf);
break;
case ALT_resp:
field_resp->encode_text(text_buf);
break;
case ALT_err:
field_err->encode_text(text_buf);
break;
case ALT_trap:
field_trap->encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an unbound value of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
}

void CtrlMessage::decode_text(Text_Buf& text_buf)
{
switch ((union_selection_type)text_buf.pull_int().get_val()) {
case ALT_cmd:
cmd().decode_text(text_buf);
break;
case ALT_resp:
resp().decode_text(text_buf);
break;
case ALT_err:
err().decode_text(text_buf);
break;
case ALT_trap:
trap().decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for type @Osmocom_CTRL_Types.CtrlMessage.");
}
}

void CtrlMessage::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
    unsigned BER_coding=va_arg(pvar, unsigned);
    BER_encode_chk_coding(BER_coding);
    ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
    tlv->put_in_buffer(p_buf);
    ASN_BER_TLV_t::destruct(tlv);
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    RAW_enc_tr_pos rp;
    rp.level=0;
    rp.pos=NULL;
    RAW_enc_tree root(TRUE, NULL, &rp, 1, p_td.raw);
    RAW_encode(p_td, root);
    root.put_to_buf(p_buf);
    break;}
  case TTCN_EncDec::CT_TEXT: {
    TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
      ("No TEXT descriptor available for type '%s'.", p_td.name);
    TEXT_encode(p_td,p_buf);
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
    p_buf.put_c('\n');
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok(va_arg(pvar, int) != 0);
    JSON_encode(p_td, tok, FALSE);
    p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
    OER_encode(p_td, p_buf);
    break;}
  default:
    TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
  }
  va_end(pvar);
}

void CtrlMessage::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
    unsigned L_form=va_arg(pvar, unsigned);
    ASN_BER_TLV_t tlv;
    BER_decode_str2TLV(p_buf, tlv, L_form);
    BER_decode_TLV(p_td, tlv, L_form);
    if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    raw_order_t r_order;
    switch(p_td.raw->top_bit_order) {
    case TOP_BIT_LEFT:
      r_order=ORDER_LSB;
      break;
    case TOP_BIT_RIGHT:
    default:
      r_order=ORDER_MSB;
    }
    int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
    if(rawr<0) switch (-rawr) {
    case TTCN_EncDec::ET_INCOMPL_MSG:
    case TTCN_EncDec::ET_LEN_ERR:
      ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
      break;
    case 1:
    default:
      ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
      break;
    }
    break;}
  case TTCN_EncDec::CT_TEXT: {
    Limit_Token_List limit;
    TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
        ("No TEXT descriptor available for type '%s'.", p_td.name);
    const unsigned char *b_data=p_buf.get_data();
    int null_added=0;
    if(b_data[p_buf.get_len()-1]!='\0'){
      null_added=1;
      p_buf.set_pos(p_buf.get_len());
      p_buf.put_zero(8,ORDER_LSB);
      p_buf.rewind();
    }
    if(TEXT_decode(p_td,p_buf,limit)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    if(null_added){
      size_t actpos=p_buf.get_pos();
      p_buf.set_pos(p_buf.get_len()-1);
      p_buf.cut_end();
      p_buf.set_pos(actpos);
    }
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XmlReaderWrap reader(p_buf);
    for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
      if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
    }
    XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
    size_t bytes = reader.ByteConsumed();
    p_buf.set_pos(bytes);
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
    if(JSON_decode(p_td, tok, FALSE, FALSE)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    p_buf.set_pos(tok.get_buf_pos());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
     OER_struct p_oer;
    OER_decode(p_td, p_buf, p_oer);
    break;}
  default:
    TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
  }
  va_end(pvar);
}

int CtrlMessage::TEXT_encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf) const
{
  int encoded_length=0;
  if (p_td.text->begin_encode) {
    p_buf.put_cs(*p_td.text->begin_encode);
    encoded_length += p_td.text->begin_encode->lengthof();
  }
  switch(union_selection){
  case ALT_cmd:
   encoded_length += field_cmd->TEXT_encode(CtrlCommand_descr_,p_buf);
   break;
  case ALT_resp:
   encoded_length += field_resp->TEXT_encode(CtrlResponse_descr_,p_buf);
   break;
  case ALT_err:
   encoded_length += field_err->TEXT_encode(CtrlError_descr_,p_buf);
   break;
  case ALT_trap:
   encoded_length += field_trap->TEXT_encode(CtrlTrap_descr_,p_buf);
   break;
  default:
    TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
    break;
  }
  if (p_td.text->end_encode) {
    p_buf.put_cs(*p_td.text->end_encode);
    encoded_length += p_td.text->end_encode->lengthof();
  }
  return encoded_length;
}

int CtrlMessage::TEXT_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, Limit_Token_List& limit, boolean no_err, boolean)
{
  int decoded_length = 0;
  if(p_td.text->begin_decode){
    int tl = p_td.text->begin_decode->match_begin(p_buf);
    if (tl >= 0) {
      decoded_length += tl;
      p_buf.increase_pos(tl);
    } else {
      if (no_err) return -1;
      TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ", (const char*)(*p_td.text->begin_decode), p_td.name);
      return 0;
    }
  }
  if (p_buf.get_read_len() < 1 && no_err) return -1;
  size_t pos = p_buf.get_pos();
  int ml = 0;
  boolean found = FALSE;
  if (p_td.text->end_decode) {
    limit.add_token(p_td.text->end_decode);
    ml++;
  }
  int str_len = cmd().TEXT_decode(CtrlCommand_descr_, p_buf, limit, TRUE);
  if (str_len >= 0) found = TRUE;
  if (!found) {
    p_buf.set_pos(pos);
    str_len = resp().TEXT_decode(CtrlResponse_descr_, p_buf, limit, TRUE);
    if (str_len >= 0) found = TRUE;
  }
  if (!found) {
    p_buf.set_pos(pos);
    str_len = err().TEXT_decode(CtrlError_descr_, p_buf, limit, TRUE);
    if (str_len >= 0) found = TRUE;
  }
  if (!found) {
    p_buf.set_pos(pos);
    str_len = trap().TEXT_decode(CtrlTrap_descr_, p_buf, limit, TRUE);
    if (str_len >= 0) found = TRUE;
  }
  limit.remove_tokens(ml);
  if (found) {
    decoded_length += str_len;
    if (p_td.text->end_decode) {
      int tl = p_td.text->end_decode->match_begin(p_buf);
      if (tl >= 0){
        decoded_length += tl;
        p_buf.increase_pos(tl);
      } else {
        if (no_err) return -1;
        TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "The specified token '%s' not found for '%s': ", (const char*)(*p_td.text->end_decode), p_td.name);
      }
    }
  } else {
    if (no_err) return -1;
    TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TOKEN_ERR, "No union member found for '%s': ", p_td.name);
    clean_up();
  }
  return decoded_length;
}
void CtrlMessage_template::copy_value(const CtrlMessage& other_value)
{
single_value.union_selection = other_value.get_selection();
switch (single_value.union_selection) {
case CtrlMessage::ALT_cmd:
single_value.field_cmd = new CtrlCommand_template(other_value.cmd());
break;
case CtrlMessage::ALT_resp:
single_value.field_resp = new CtrlResponse_template(other_value.resp());
break;
case CtrlMessage::ALT_err:
single_value.field_err = new CtrlError_template(other_value.err());
break;
case CtrlMessage::ALT_trap:
single_value.field_trap = new CtrlTrap_template(other_value.trap());
break;
default:
TTCN_error("Initializing a template with an unbound value of type @Osmocom_CTRL_Types.CtrlMessage.");
}
set_selection(SPECIFIC_VALUE);
}

void CtrlMessage_template::copy_template(const CtrlMessage_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 CtrlMessage::ALT_cmd:
single_value.field_cmd = new CtrlCommand_template(*other_value.single_value.field_cmd);
break;
case CtrlMessage::ALT_resp:
single_value.field_resp = new CtrlResponse_template(*other_value.single_value.field_resp);
break;
case CtrlMessage::ALT_err:
single_value.field_err = new CtrlError_template(*other_value.single_value.field_err);
break;
case CtrlMessage::ALT_trap:
single_value.field_trap = new CtrlTrap_template(*other_value.single_value.field_trap);
break;
default:
TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type @Osmocom_CTRL_Types.CtrlMessage.");
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new CtrlMessage_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;
case IMPLICATION_MATCH:
implication_.precondition = new CtrlMessage_template(*other_value.implication_.precondition);
implication_.implied_template = new CtrlMessage_template(*other_value.implication_.implied_template);
break;
case DYNAMIC_MATCH:
dyn_match = other_value.dyn_match;
dyn_match->ref_count++;
break;
default:
TTCN_error("Copying an uninitialized template of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
set_selection(other_value);
}

CtrlMessage_template::CtrlMessage_template()
{
}

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

CtrlMessage_template::CtrlMessage_template(const CtrlMessage& other_value)
{
copy_value(other_value);
}

CtrlMessage_template::CtrlMessage_template(const OPTIONAL<CtrlMessage>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlMessage&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of union type @Osmocom_CTRL_Types.CtrlMessage from an unbound optional field.");
}
}

CtrlMessage_template::CtrlMessage_template(CtrlMessage_template* p_precondition, CtrlMessage_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

CtrlMessage_template::CtrlMessage_template(Dynamic_Match_Interface<CtrlMessage>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<CtrlMessage>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

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

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

void CtrlMessage_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
switch (single_value.union_selection) {
case CtrlMessage::ALT_cmd:
delete single_value.field_cmd;
break;
case CtrlMessage::ALT_resp:
delete single_value.field_resp;
break;
case CtrlMessage::ALT_err:
delete single_value.field_err;
break;
case CtrlMessage::ALT_trap:
delete single_value.field_trap;
default:
break;
}
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
delete [] value_list.list_value;
break;
case IMPLICATION_MATCH:
delete implication_.precondition;
delete implication_.implied_template;
break;
case DYNAMIC_MATCH:
dyn_match->ref_count--;
if (dyn_match->ref_count == 0) {
delete dyn_match->ptr;
delete dyn_match;
}
break;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}

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

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

CtrlMessage_template& CtrlMessage_template::operator=(const OPTIONAL<CtrlMessage>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CtrlMessage&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
return *this;
}

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

boolean CtrlMessage_template::match(const CtrlMessage& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
{
CtrlMessage::union_selection_type value_selection = other_value.get_selection();
if (value_selection == CtrlMessage::UNBOUND_VALUE) return FALSE;
if (value_selection != single_value.union_selection) return FALSE;
switch (value_selection) {
case CtrlMessage::ALT_cmd:
return single_value.field_cmd->match(other_value.cmd(), legacy);
case CtrlMessage::ALT_resp:
return single_value.field_resp->match(other_value.resp(), legacy);
case CtrlMessage::ALT_err:
return single_value.field_err->match(other_value.err(), legacy);
case CtrlMessage::ALT_trap:
return single_value.field_trap->match(other_value.trap(), legacy);
default:
TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
}
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, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
case CONJUNCTION_MATCH:
for (unsigned int i = 0; i < value_list.n_values; i++) {
if (!value_list.list_value[i].match(other_value)) {
return FALSE;
}
}
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value);
case DYNAMIC_MATCH:
return dyn_match->ptr->match(other_value);
default:
TTCN_error ("Matching an uninitialized template of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
return FALSE;
}

boolean CtrlMessage_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
switch (single_value.union_selection) {
case CtrlMessage::ALT_cmd:
return single_value.field_cmd->is_value();
case CtrlMessage::ALT_resp:
return single_value.field_resp->is_value();
case CtrlMessage::ALT_err:
return single_value.field_err->is_value();
case CtrlMessage::ALT_trap:
return single_value.field_trap->is_value();
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing is_value operation on a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
}

CtrlMessage CtrlMessage_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of union type @Osmocom_CTRL_Types.CtrlMessage.");
CtrlMessage ret_val;
switch (single_value.union_selection) {
case CtrlMessage::ALT_cmd:
ret_val.cmd() = single_value.field_cmd->valueof();
break;
case CtrlMessage::ALT_resp:
ret_val.resp() = single_value.field_resp->valueof();
break;
case CtrlMessage::ALT_err:
ret_val.err() = single_value.field_err->valueof();
break;
case CtrlMessage::ALT_trap:
ret_val.trap() = single_value.field_trap->valueof();
break;
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
return ret_val;
}

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

CtrlCommand_template& CtrlMessage_template::cmd()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CtrlMessage::ALT_cmd) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_cmd = new CtrlCommand_template(ANY_VALUE);
else single_value.field_cmd = new CtrlCommand_template;
single_value.union_selection = CtrlMessage::ALT_cmd;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_cmd;
}

const CtrlCommand_template& CtrlMessage_template::cmd() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field cmd in a non-specific template of union type @Osmocom_CTRL_Types.CtrlMessage.");
if (single_value.union_selection != CtrlMessage::ALT_cmd) TTCN_error("Accessing non-selected field cmd in a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
return *single_value.field_cmd;
}

CtrlResponse_template& CtrlMessage_template::resp()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CtrlMessage::ALT_resp) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_resp = new CtrlResponse_template(ANY_VALUE);
else single_value.field_resp = new CtrlResponse_template;
single_value.union_selection = CtrlMessage::ALT_resp;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_resp;
}

const CtrlResponse_template& CtrlMessage_template::resp() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field resp in a non-specific template of union type @Osmocom_CTRL_Types.CtrlMessage.");
if (single_value.union_selection != CtrlMessage::ALT_resp) TTCN_error("Accessing non-selected field resp in a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
return *single_value.field_resp;
}

CtrlError_template& CtrlMessage_template::err()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CtrlMessage::ALT_err) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_err = new CtrlError_template(ANY_VALUE);
else single_value.field_err = new CtrlError_template;
single_value.union_selection = CtrlMessage::ALT_err;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_err;
}

const CtrlError_template& CtrlMessage_template::err() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field err in a non-specific template of union type @Osmocom_CTRL_Types.CtrlMessage.");
if (single_value.union_selection != CtrlMessage::ALT_err) TTCN_error("Accessing non-selected field err in a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
return *single_value.field_err;
}

CtrlTrap_template& CtrlMessage_template::trap()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CtrlMessage::ALT_trap) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_trap = new CtrlTrap_template(ANY_VALUE);
else single_value.field_trap = new CtrlTrap_template;
single_value.union_selection = CtrlMessage::ALT_trap;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_trap;
}

const CtrlTrap_template& CtrlMessage_template::trap() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field trap in a non-specific template of union type @Osmocom_CTRL_Types.CtrlMessage.");
if (single_value.union_selection != CtrlMessage::ALT_trap) TTCN_error("Accessing non-selected field trap in a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
return *single_value.field_trap;
}

boolean CtrlMessage_template::ischosen(CtrlMessage::union_selection_type checked_selection) const
{
if (checked_selection == CtrlMessage::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @Osmocom_CTRL_Types.CtrlMessage.");
switch (template_selection) {
case SPECIFIC_VALUE:
if (single_value.union_selection == CtrlMessage::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
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 @Osmocom_CTRL_Types.CtrlMessage containing an empty list.");
boolean ret_val = value_list.list_value[0].ischosen(checked_selection);
for (unsigned int list_count = 1; ret_val == TRUE && list_count < value_list.n_values; list_count++) {
ret_val = value_list.list_value[list_count].ischosen(checked_selection);
}
return ret_val;
}
default:
return FALSE;
}
return FALSE;
}

void CtrlMessage_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
switch (single_value.union_selection) {
case CtrlMessage::ALT_cmd:
TTCN_Logger::log_event_str("{ cmd := ");
single_value.field_cmd->log();
TTCN_Logger::log_event_str(" }");
break;
case CtrlMessage::ALT_resp:
TTCN_Logger::log_event_str("{ resp := ");
single_value.field_resp->log();
TTCN_Logger::log_event_str(" }");
break;
case CtrlMessage::ALT_err:
TTCN_Logger::log_event_str("{ err := ");
single_value.field_err->log();
TTCN_Logger::log_event_str(" }");
break;
case CtrlMessage::ALT_trap:
TTCN_Logger::log_event_str("{ trap := ");
single_value.field_trap->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_str("<invalid selector>");
}
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case CONJUNCTION_MATCH:
if (template_selection == CONJUNCTION_MATCH) {
TTCN_Logger::log_event_str("conjunct");
}
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;
case IMPLICATION_MATCH:
implication_.precondition->log();
TTCN_Logger::log_event_str(" implies ");
implication_.implied_template->log();
break;
case DYNAMIC_MATCH:
TTCN_Logger::log_event_str("@dynamic template");
break;
default:
log_generic();
}
log_ifpresent();
}

void CtrlMessage_template::log_match(const CtrlMessage& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity() && match(match_value, legacy)){
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()) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
switch (single_value.union_selection) {
case CtrlMessage::ALT_cmd:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".cmd");
single_value.field_cmd->log_match(match_value.cmd(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
} else {
TTCN_Logger::log_event_str("{ cmd := ");
single_value.field_cmd->log_match(match_value.cmd(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CtrlMessage::ALT_resp:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".resp");
single_value.field_resp->log_match(match_value.resp(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
} else {
TTCN_Logger::log_event_str("{ resp := ");
single_value.field_resp->log_match(match_value.resp(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CtrlMessage::ALT_err:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".err");
single_value.field_err->log_match(match_value.err(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
} else {
TTCN_Logger::log_event_str("{ err := ");
single_value.field_err->log_match(match_value.err(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CtrlMessage::ALT_trap:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".trap");
single_value.field_trap->log_match(match_value.trap(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
} else {
TTCN_Logger::log_event_str("{ trap := ");
single_value.field_trap->log_match(match_value.trap(), legacy);
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, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}

void CtrlMessage_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 CtrlMessage::ALT_cmd:
single_value.field_cmd->encode_text(text_buf);
break;
case CtrlMessage::ALT_resp:
single_value.field_resp->encode_text(text_buf);
break;
case CtrlMessage::ALT_err:
single_value.field_err->encode_text(text_buf);
break;
case CtrlMessage::ALT_trap:
single_value.field_trap->encode_text(text_buf);
break;
default:
TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
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 @Osmocom_CTRL_Types.CtrlMessage.");
}
}

void CtrlMessage_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
{
single_value.union_selection = CtrlMessage::UNBOUND_VALUE;
CtrlMessage::union_selection_type new_selection = (CtrlMessage::union_selection_type)text_buf.pull_int().get_val();
switch (new_selection) {
case CtrlMessage::ALT_cmd:
single_value.field_cmd = new CtrlCommand_template;
single_value.field_cmd->decode_text(text_buf);
break;
case CtrlMessage::ALT_resp:
single_value.field_resp = new CtrlResponse_template;
single_value.field_resp->decode_text(text_buf);
break;
case CtrlMessage::ALT_err:
single_value.field_err = new CtrlError_template;
single_value.field_err->decode_text(text_buf);
break;
case CtrlMessage::ALT_trap:
single_value.field_trap = new CtrlTrap_template;
single_value.field_trap->decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for a template of type @Osmocom_CTRL_Types.CtrlMessage.");
}
single_value.union_selection = new_selection;
}
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 CtrlMessage_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 @Osmocom_CTRL_Types.CtrlMessage.");
}
}

boolean CtrlMessage_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean CtrlMessage_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match_omit() || implication_.implied_template->match_omit();
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int v_idx=0; v_idx<value_list.n_values; v_idx++)
if (value_list.list_value[v_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

void CtrlMessage_template::set_param(Module_Param& param)
{
  if (dynamic_cast<Module_Param_Name*>(param.get_id()) != NULL &&
      param.get_id()->next_name()) {
    char* param_field = param.get_id()->get_current_name();
    if (param_field[0] >= '0' && param_field[0] <= '9') {
      param.error("Unexpected array index in module parameter, expected a valid field"
        " name for union template type `@Osmocom_CTRL_Types.CtrlMessage'");
    }
    if (strcmp("cmd", param_field) == 0) {
      cmd().set_param(param);
      return;
    } else if (strcmp("resp", param_field) == 0) {
      resp().set_param(param);
      return;
    } else if (strcmp("err", param_field) == 0) {
      err().set_param(param);
      return;
    } else if (strcmp("trap", param_field) == 0) {
      trap().set_param(param);
      return;
    } else param.error("Field `%s' not found in union template type `@Osmocom_CTRL_Types.CtrlMessage'", param_field);
  }
  param.basic_check(Module_Param::BC_TEMPLATE, "union template");
  Module_Param_Ptr m_p = &param;
  switch (m_p->get_type()) {
  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:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    CtrlMessage_template new_temp;
    new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (m_p->get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), m_p->get_size());
    for (size_t p_i=0; p_i<m_p->get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (m_p->get_size()==0) break;
    param.type_error("union template", "@Osmocom_CTRL_Types.CtrlMessage");
    break;
  case Module_Param::MP_Assignment_List: {
    Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
    char* last_name = mp_last->get_id()->get_name();
    if (!strcmp(last_name, "cmd")) {
      cmd().set_param(*mp_last);
      break;
    }
    if (!strcmp(last_name, "resp")) {
      resp().set_param(*mp_last);
      break;
    }
    if (!strcmp(last_name, "err")) {
      err().set_param(*mp_last);
      break;
    }
    if (!strcmp(last_name, "trap")) {
      trap().set_param(*mp_last);
      break;
    }
    mp_last->error("Field %s does not exist in type @Osmocom_CTRL_Types.CtrlMessage.", last_name);
  } break;
  case Module_Param::MP_Implication_Template: {
    CtrlMessage_template* precondition = new CtrlMessage_template;
    precondition->set_param(*m_p->get_elem(0));
    CtrlMessage_template* implied_template = new CtrlMessage_template;
    implied_template->set_param(*m_p->get_elem(1));
    *this = CtrlMessage_template(precondition, implied_template);
  } break;
  default:
    param.type_error("union template", "@Osmocom_CTRL_Types.CtrlMessage");
  }
  is_ifpresent = param.get_ifpresent();
}

void CtrlMessage_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_OMIT:
if (template_selection==OMIT_VALUE) return;
case TR_VALUE:
if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break;
switch (single_value.union_selection) {
case CtrlMessage::ALT_cmd:
single_value.field_cmd->check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlMessage");
return;
case CtrlMessage::ALT_resp:
single_value.field_resp->check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlMessage");
return;
case CtrlMessage::ALT_err:
single_value.field_err->check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlMessage");
return;
case CtrlMessage::ALT_trap:
single_value.field_trap->check_restriction(t_res, t_name ? t_name : "@Osmocom_CTRL_Types.CtrlMessage");
return;
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing check_restriction operation on a template of union type @Osmocom_CTRL_Types.CtrlMessage.");
}
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@Osmocom_CTRL_Types.CtrlMessage");
}


/* Bodies of functions, altsteps and testcases */

void CtrlVerb_encoder(const CHARSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CtrlVerb_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlVerb_decoder(OCTETSTRING& input_stream, CHARSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CtrlVerb_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlReplyVerb_encoder(const CHARSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CtrlReplyVerb_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlReplyVerb_decoder(OCTETSTRING& input_stream, CHARSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CtrlReplyVerb_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlId_encoder(const CHARSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CHARSTRING_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlId_decoder(OCTETSTRING& input_stream, CHARSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CHARSTRING_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlVariable_encoder(const CHARSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CHARSTRING_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlVariable_decoder(OCTETSTRING& input_stream, CHARSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CHARSTRING_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlValue_encoder(const CHARSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CHARSTRING_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlValue_decoder(OCTETSTRING& input_stream, CHARSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CHARSTRING_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlReason_encoder(const CHARSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CHARSTRING_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlReason_decoder(OCTETSTRING& input_stream, CHARSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `charstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CHARSTRING_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlCommand_encoder(const CtrlCommand& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlCommand' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CtrlCommand_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlCommand_decoder(OCTETSTRING& input_stream, CtrlCommand& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlCommand' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CtrlCommand_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlResponse_encoder(const CtrlResponse& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlResponse' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CtrlResponse_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlResponse_decoder(OCTETSTRING& input_stream, CtrlResponse& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlResponse' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CtrlResponse_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlError_encoder(const CtrlError& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlError' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CtrlError_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlError_decoder(OCTETSTRING& input_stream, CtrlError& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlError' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CtrlError_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlTrap_encoder(const CtrlTrap& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlTrap' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CtrlTrap_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlTrap_decoder(OCTETSTRING& input_stream, CtrlTrap& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlTrap' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CtrlTrap_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void CtrlMessage_encoder(const CtrlMessage& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlMessage' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(CtrlMessage_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER CtrlMessage_decoder(OCTETSTRING& input_stream, CtrlMessage& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_TEXT) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@Osmocom_CTRL_Types.CtrlMessage' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(CtrlMessage_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

CHARSTRING enc__CtrlMessage(const CtrlMessage& id)
{
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("enc_CtrlMessage(): Encoding @Osmocom_CTRL_Types.CtrlMessage: ");
id.log();
TTCN_Logger::end_event();
}
TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
TTCN_Buffer ttcn_buffer;
id.encode(CtrlMessage_descr_, ttcn_buffer, TTCN_EncDec::CT_TEXT, 0);
CHARSTRING ret_val;
ttcn_buffer.get_string(ret_val);
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("enc_CtrlMessage(): Stream after encoding: ");
ret_val.log();
TTCN_Logger::end_event();
}
return ret_val;
}

CtrlMessage dec__CtrlMessage(const CHARSTRING& id)
{
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("dec_CtrlMessage(): Stream before decoding: ");
id.log();
TTCN_Logger::end_event();
}
TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
TTCN_EncDec::clear_error();
TTCN_Buffer ttcn_buffer(id);
CtrlMessage ret_val;
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
  TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_LOG_MATCHING, TTCN_EncDec::EB_WARNING);
}
ret_val.decode(CtrlMessage_descr_, ttcn_buffer, TTCN_EncDec::CT_TEXT);
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("dec_CtrlMessage(): Decoded @Osmocom_CTRL_Types.CtrlMessage: ");
ret_val.log();
TTCN_Logger::end_event();
}
if (TTCN_EncDec::get_last_error_type() == TTCN_EncDec::ET_NONE) {
if (ttcn_buffer.get_pos() < ttcn_buffer.get_len()) {
ttcn_buffer.cut();
OCTETSTRING tmp_os;
ttcn_buffer.get_string(tmp_os);
TTCN_Logger::begin_event_log2str();
tmp_os.log();
CHARSTRING remaining_stream = TTCN_Logger::end_event_log2str();
TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_EXTRA_DATA, "dec_CtrlMessage(): Data remained at the end of the stream after successful decoding: %s", (const char*) remaining_stream);
}
}
return ret_val;
}

CtrlMessage_template ts__CtrlMsgGet(const CHARSTRING& id, const CHARSTRING& variable)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 79, TTCN_Location::LOCATION_TEMPLATE, "ts_CtrlMsgGet");
CtrlMessage_template ret_val;
{
CtrlCommand_template& tmp_0 = ret_val.cmd();
tmp_0.verb() = cs_4;
tmp_0.id() = id;
tmp_0.variable() = variable;
tmp_0.val() = OMIT_VALUE;
}
return ret_val;
}

CtrlMessage_template ts__CtrlMsgSet(const CHARSTRING& id, const CHARSTRING& variable, const CHARSTRING& val)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 88, TTCN_Location::LOCATION_TEMPLATE, "ts_CtrlMsgSet");
CtrlMessage_template ret_val;
{
CtrlCommand_template& tmp_1 = ret_val.cmd();
tmp_1.verb() = cs_5;
tmp_1.id() = id;
tmp_1.variable() = variable;
tmp_1.val() = val;
}
return ret_val;
}

CtrlMessage_template ts__CtrlMsgTrap(const CHARSTRING& variable, const CHARSTRING_template& val)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 97, TTCN_Location::LOCATION_TEMPLATE, "ts_CtrlMsgTrap");
CtrlMessage_template ret_val;
{
CtrlTrap_template& tmp_2 = ret_val.trap();
tmp_2.variable() = variable;
tmp_2.val() = val;
}
return ret_val;
}

CtrlMessage_template ts__CtrlMsgGetRepl(const CHARSTRING& id, const CHARSTRING& variable, const CHARSTRING& val)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 104, TTCN_Location::LOCATION_TEMPLATE, "ts_CtrlMsgGetRepl");
CtrlMessage_template ret_val;
{
CtrlResponse_template& tmp_3 = ret_val.resp();
tmp_3.verb() = cs_6;
tmp_3.id() = id;
tmp_3.variable() = variable;
tmp_3.val() = val;
}
return ret_val;
}

CtrlMessage_template ts__CtrlMsgSetRepl(const CHARSTRING& id, const CHARSTRING& variable, const CHARSTRING& val)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 113, TTCN_Location::LOCATION_TEMPLATE, "ts_CtrlMsgSetRepl");
CtrlMessage_template ret_val;
{
CtrlResponse_template& tmp_4 = ret_val.resp();
tmp_4.verb() = cs_7;
tmp_4.id() = id;
tmp_4.variable() = variable;
tmp_4.val() = val;
}
return ret_val;
}

CtrlMessage_template tr__CtrlMsgGet(const CHARSTRING_template& id, const CHARSTRING_template& variable)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 122, TTCN_Location::LOCATION_TEMPLATE, "tr_CtrlMsgGet");
CtrlMessage_template ret_val;
{
CtrlCommand_template& tmp_5 = ret_val.cmd();
tmp_5.verb() = cs_4;
tmp_5.id() = id;
tmp_5.variable() = variable;
tmp_5.val() = OMIT_VALUE;
}
return ret_val;
}

CtrlMessage_template tr__CtrlMsgSet(const CHARSTRING_template& id, const CHARSTRING_template& variable, const CHARSTRING_template& val)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 131, TTCN_Location::LOCATION_TEMPLATE, "tr_CtrlMsgSet");
CtrlMessage_template ret_val;
{
CtrlCommand_template& tmp_6 = ret_val.cmd();
tmp_6.verb() = cs_5;
tmp_6.id() = id;
tmp_6.variable() = variable;
tmp_6.val() = val;
}
return ret_val;
}

CtrlMessage_template tr__CtrlMsgGetRepl(const CHARSTRING_template& id, const CHARSTRING_template& variable)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 141, TTCN_Location::LOCATION_TEMPLATE, "tr_CtrlMsgGetRepl");
CtrlMessage_template ret_val;
{
CtrlResponse_template& tmp_7 = ret_val.resp();
tmp_7.verb() = cs_6;
tmp_7.id() = id;
tmp_7.variable() = variable;
tmp_7.val() = ANY_VALUE;
}
return ret_val;
}

CtrlMessage_template tr__CtrlMsgSetRepl(const CHARSTRING_template& id, const CHARSTRING_template& variable, const CHARSTRING_template& val)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 150, TTCN_Location::LOCATION_TEMPLATE, "tr_CtrlMsgSetRepl");
CtrlMessage_template ret_val;
{
CtrlResponse_template& tmp_8 = ret_val.resp();
tmp_8.verb() = cs_7;
tmp_8.id() = id;
tmp_8.variable() = variable;
tmp_8.val() = val;
}
return ret_val;
}

CtrlMessage_template tr__CtrlMsgTrap(const CHARSTRING_template& variable, const CHARSTRING_template& val)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 160, TTCN_Location::LOCATION_TEMPLATE, "tr_CtrlMsgTrap");
CtrlMessage_template ret_val;
{
CtrlTrap_template& tmp_9 = ret_val.trap();
tmp_9.variable() = variable;
tmp_9.val() = val;
}
return ret_val;
}

CtrlMessage_template tr__CtrlMsgError(const CHARSTRING_template& id, const CHARSTRING_template& reason)
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 168, TTCN_Location::LOCATION_TEMPLATE, "tr_CtrlMsgError");
CtrlMessage_template ret_val;
{
CtrlError_template& tmp_10 = ret_val.err();
tmp_10.id() = id;
tmp_10.reason() = reason;
}
return ret_val;
}


/* Bodies of static functions */

void pre_init_module()
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Osmocom_CTRL_Types");
module_object.add_function("enc_CtrlMessage", (genericfunc_t)&enc__CtrlMessage, NULL);
module_object.add_function("dec_CtrlMessage", (genericfunc_t)&dec__CtrlMessage, NULL);
}

void post_init_module()
{
TTCN_Location current_location("Osmocom_CTRL_Types.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Osmocom_CTRL_Types");
current_location.update_lineno(97);
/* Osmocom_CTRL_Types.ttcn, line 97 */
template_ts__CtrlMsgTrap_val_defval = OMIT_VALUE;
current_location.update_lineno(122);
/* Osmocom_CTRL_Types.ttcn, line 122 */
template_tr__CtrlMsgGet_variable_defval = ANY_VALUE;
current_location.update_lineno(131);
/* Osmocom_CTRL_Types.ttcn, line 131 */
template_tr__CtrlMsgSet_variable_defval = ANY_VALUE;
current_location.update_lineno(132);
/* Osmocom_CTRL_Types.ttcn, line 132 */
template_tr__CtrlMsgSet_val_defval = ANY_VALUE;
current_location.update_lineno(141);
/* Osmocom_CTRL_Types.ttcn, line 141 */
template_tr__CtrlMsgGetRepl_variable_defval = ANY_VALUE;
current_location.update_lineno(150);
/* Osmocom_CTRL_Types.ttcn, line 150 */
template_tr__CtrlMsgSetRepl_variable_defval = ANY_VALUE;
current_location.update_lineno(151);
/* Osmocom_CTRL_Types.ttcn, line 151 */
template_tr__CtrlMsgSetRepl_val_defval = ANY_VALUE;
current_location.update_lineno(160);
/* Osmocom_CTRL_Types.ttcn, line 160 */
template_tr__CtrlMsgTrap_variable_defval = ANY_VALUE;
current_location.update_lineno(161);
/* Osmocom_CTRL_Types.ttcn, line 161 */
template_tr__CtrlMsgTrap_val_defval = ANY_VALUE;
current_location.update_lineno(168);
/* Osmocom_CTRL_Types.ttcn, line 168 */
template_tr__CtrlMsgError_id_defval = ANY_VALUE;
current_location.update_lineno(168);
/* Osmocom_CTRL_Types.ttcn, line 168 */
template_tr__CtrlMsgError_reason_defval = ANY_VALUE;
}


} /* end of namespace */
