// This C++ source file was generated by the TTCN-3 compiler // of the TTCN-3 Test Executor version 9.0.0 // for (build@3978f7fbee0c) on Mon Jun 24 02:37:33 2024 // Copyright (c) 2000-2023 Ericsson Telecom AB // Do not edit this file unless you know what you are doing. /* Including header files */ #include "PAP_Types.hh" namespace PAP__Types { /* Literal string constants */ const unsigned char module_checksum[] = { 0x76, 0x83, 0xcd, 0x0e, 0x0e, 0x13, 0xe1, 0x91, 0x4c, 0x3d, 0xe0, 0xf0, 0x94, 0x9d, 0x58, 0xb0 }; /* Global variable definitions */ const TTCN_RAWdescriptor_t PapCode_raw_ = {8,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapCode const TTCN_Typedescriptor_t PapCode_descr_ = { "@PAP_Types.PapCode", NULL, &PapCode_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapCode_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPacket_code_raw_ = {8,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapPacket_code const TTCN_Typedescriptor_t PapPacket_code_descr_ = { "@PAP_Types.PapPacket.code", NULL, &PapPacket_code_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapPacket_code_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPacket_identifier_raw_ = {8,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t PapPacket_identifier_xer_ = { {"identifier>\n", "identifier>\n"}, {12, 12}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t PapPacket_identifier_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t PapPacket_identifier_descr_ = { "@PAP_Types.PapPacket.identifier", &INTEGER_ber_, &PapPacket_identifier_raw_, &INTEGER_text_, &PapPacket_identifier_xer_, &INTEGER_json_, &PapPacket_identifier_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapPacket_identifier_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPacket_len_raw_ = {16,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t PapPacket_len_xer_ = { {"len>\n", "len>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t PapPacket_len_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t PapPacket_len_descr_ = { "@PAP_Types.PapPacket.len", &INTEGER_ber_, &PapPacket_len_raw_, &INTEGER_text_, &PapPacket_len_xer_, &INTEGER_json_, &PapPacket_len_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapPacket_len_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPayloadUnion_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapPayloadUnion const TTCN_Typedescriptor_t PapPayloadUnion_descr_ = { "@PAP_Types.PapPayloadUnion", NULL, &PapPayloadUnion_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; const TTCN_RAWdescriptor_t PapAuthReq_peer__id__len_raw_ = {8,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t PapAuthReq_peer__id__len_xer_ = { {"peer_id_len>\n", "peer_id_len>\n"}, {13, 13}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t PapAuthReq_peer__id__len_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t PapAuthReq_peer__id__len_descr_ = { "@PAP_Types.PapAuthReq.peer_id_len", &INTEGER_ber_, &PapAuthReq_peer__id__len_raw_, &INTEGER_text_, &PapAuthReq_peer__id__len_xer_, &INTEGER_json_, &PapAuthReq_peer__id__len_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapAuthReq_peer__id__len_default_coding("RAW"); const TTCN_RAWdescriptor_t PapAuthReq_peer__id_raw_ = {0,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t PapAuthReq_peer__id_xer_ = { {"peer_id>\n", "peer_id>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const int PapAuthReq_peer__id_oer_ext_arr_[0] = {}; const int PapAuthReq_peer__id_oer_p_[0] = {}; const TTCN_OERdescriptor_t PapAuthReq_peer__id_oer_ = { -1, TRUE, -1, FALSE, 0, 0, PapAuthReq_peer__id_oer_ext_arr_, 0, PapAuthReq_peer__id_oer_p_}; const TTCN_Typedescriptor_t PapAuthReq_peer__id_descr_ = { "@PAP_Types.PapAuthReq.peer_id", &OCTETSTRING_ber_, &PapAuthReq_peer__id_raw_, &OCTETSTRING_text_, &PapAuthReq_peer__id_xer_, &OCTETSTRING_json_, &PapAuthReq_peer__id_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapAuthReq_peer__id_default_coding("RAW"); const TTCN_RAWdescriptor_t PapAuthReq_passwd__len_raw_ = {8,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t PapAuthReq_passwd__len_xer_ = { {"passwd_len>\n", "passwd_len>\n"}, {12, 12}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t PapAuthReq_passwd__len_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t PapAuthReq_passwd__len_descr_ = { "@PAP_Types.PapAuthReq.passwd_len", &INTEGER_ber_, &PapAuthReq_passwd__len_raw_, &INTEGER_text_, &PapAuthReq_passwd__len_xer_, &INTEGER_json_, &PapAuthReq_passwd__len_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapAuthReq_passwd__len_default_coding("RAW"); const TTCN_RAWdescriptor_t PapAuthReq_passwd_raw_ = {0,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t PapAuthReq_passwd_xer_ = { {"passwd>\n", "passwd>\n"}, {8, 8}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const int PapAuthReq_passwd_oer_ext_arr_[0] = {}; const int PapAuthReq_passwd_oer_p_[0] = {}; const TTCN_OERdescriptor_t PapAuthReq_passwd_oer_ = { -1, TRUE, -1, FALSE, 0, 0, PapAuthReq_passwd_oer_ext_arr_, 0, PapAuthReq_passwd_oer_p_}; const TTCN_Typedescriptor_t PapAuthReq_passwd_descr_ = { "@PAP_Types.PapAuthReq.passwd", &OCTETSTRING_ber_, &PapAuthReq_passwd_raw_, &OCTETSTRING_text_, &PapAuthReq_passwd_xer_, &OCTETSTRING_json_, &PapAuthReq_passwd_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapAuthReq_passwd_default_coding("RAW"); const TTCN_RAWdescriptor_t PapAuthReq_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapAuthReq const TTCN_Typedescriptor_t PapAuthReq_descr_ = { "@PAP_Types.PapAuthReq", NULL, &PapAuthReq_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapAuthReq_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPayloadUnion_req_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapPayloadUnion_req const TTCN_Typedescriptor_t PapPayloadUnion_req_descr_ = { "@PAP_Types.PapPayloadUnion.req", NULL, &PapPayloadUnion_req_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapPayloadUnion_req_default_coding("RAW"); const TTCN_RAWdescriptor_t PapAuthResp_msg__len_raw_ = {8,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t PapAuthResp_msg__len_xer_ = { {"msg_len>\n", "msg_len>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t PapAuthResp_msg__len_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t PapAuthResp_msg__len_descr_ = { "@PAP_Types.PapAuthResp.msg_len", &INTEGER_ber_, &PapAuthResp_msg__len_raw_, &INTEGER_text_, &PapAuthResp_msg__len_xer_, &INTEGER_json_, &PapAuthResp_msg__len_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapAuthResp_msg__len_default_coding("RAW"); const TTCN_RAWdescriptor_t PapAuthResp_msg_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t PapAuthResp_msg_xer_ = { {"msg>\n", "msg>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_Typedescriptor_t PapAuthResp_msg_descr_ = { "@PAP_Types.PapAuthResp.msg", NULL, &PapAuthResp_msg_raw_, &CHARSTRING_text_, &PapAuthResp_msg_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapAuthResp_msg_default_coding("RAW"); const TTCN_RAWdescriptor_t PapAuthResp_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapAuthResp const TTCN_Typedescriptor_t PapAuthResp_descr_ = { "@PAP_Types.PapAuthResp", NULL, &PapAuthResp_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapAuthResp_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPayloadUnion_ack_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapPayloadUnion_ack const TTCN_Typedescriptor_t PapPayloadUnion_ack_descr_ = { "@PAP_Types.PapPayloadUnion.ack", NULL, &PapPayloadUnion_ack_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapPayloadUnion_ack_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPayloadUnion_nak_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapPayloadUnion_nak const TTCN_Typedescriptor_t PapPayloadUnion_nak_descr_ = { "@PAP_Types.PapPayloadUnion.nak", NULL, &PapPayloadUnion_nak_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapPayloadUnion_nak_default_coding("RAW"); UNIVERSAL_CHARSTRING PapPayloadUnion_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPacket_payload_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapPacket_payload const TTCN_Typedescriptor_t PapPacket_payload_descr_ = { "@PAP_Types.PapPacket.payload", NULL, &PapPacket_payload_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapPacket_payload_default_coding("RAW"); const TTCN_RAWdescriptor_t PapPacket_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for PapPacket const TTCN_Typedescriptor_t PapPacket_descr_ = { "@PAP_Types.PapPacket", NULL, &PapPacket_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING PapPacket_default_coding("RAW"); INTEGER const_ts__PAP__AuthReq_identifier_defval; const INTEGER& ts__PAP__AuthReq_identifier_defval = const_ts__PAP__AuthReq_identifier_defval; INTEGER_template template_tr__PAP__AuthReq_identifier_defval; const INTEGER_template& tr__PAP__AuthReq_identifier_defval = template_tr__PAP__AuthReq_identifier_defval; INTEGER const_ts__PAP__AuthAck_identifier_defval; const INTEGER& ts__PAP__AuthAck_identifier_defval = const_ts__PAP__AuthAck_identifier_defval; INTEGER_template template_tr__PAP__AuthAck_identifier_defval; const INTEGER_template& tr__PAP__AuthAck_identifier_defval = template_tr__PAP__AuthAck_identifier_defval; INTEGER const_ts__PAP__AuthNak_identifier_defval; const INTEGER& ts__PAP__AuthNak_identifier_defval = const_ts__PAP__AuthNak_identifier_defval; INTEGER_template template_tr__PAP__AuthNak_identifier_defval; const INTEGER_template& tr__PAP__AuthNak_identifier_defval = template_tr__PAP__AuthNak_identifier_defval; TTCN_Module module_object("PAP_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 */ PapCode::PapCode() { enum_value = UNBOUND_VALUE; } PapCode::PapCode(int other_value) { if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @PAP_Types.PapCode with invalid numeric value %d.", other_value); enum_value = (enum_type)other_value; } PapCode::PapCode(enum_type other_value) { enum_value = other_value; } PapCode::PapCode(const PapCode& other_value) : Base_Type() { if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @PAP_Types.PapCode."); enum_value = other_value.enum_value; } PapCode& PapCode::operator=(int other_value) { if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @PAP_Types.PapCode.", other_value); enum_value = (enum_type)other_value; return *this; } PapCode& PapCode::operator=(enum_type other_value) { enum_value = other_value; return *this; } PapCode& PapCode::operator=(const PapCode& other_value) { if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @PAP_Types.PapCode."); enum_value = other_value.enum_value; return *this; } boolean PapCode::operator==(enum_type other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); return enum_value == other_value; } boolean PapCode::operator==(const PapCode& other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); return enum_value == other_value.enum_value; } boolean PapCode::operator<(enum_type other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); return enum_value < other_value; } boolean PapCode::operator<(const PapCode& other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); return enum_value < other_value.enum_value; } boolean PapCode::operator>(enum_type other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); return enum_value > other_value; } boolean PapCode::operator>(const PapCode& other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @PAP_Types.PapCode."); return enum_value > other_value.enum_value; } const char *PapCode::enum_to_str(enum_type enum_par) { switch (enum_par) { case PAP__AuthenticateReq: return "PAP_AuthenticateReq"; case PAP__AuthenticateAck: return "PAP_AuthenticateAck"; case PAP__AuthenticateNak: return "PAP_AuthenticateNak"; default: return ""; } } PapCode::enum_type PapCode::str_to_enum(const char *str_par) { if (!strcmp(str_par, "PAP_AuthenticateReq")) return PAP__AuthenticateReq; else if (!strcmp(str_par, "PAP_AuthenticateAck")) return PAP__AuthenticateAck; else if (!strcmp(str_par, "PAP_AuthenticateNak")) return PAP__AuthenticateNak; else return UNKNOWN_VALUE; } boolean PapCode::is_valid_enum(int int_par) { switch (int_par) { case 1: case 2: case 3: return TRUE; default: return FALSE; } } int PapCode::enum2int(enum_type enum_par) { if (enum_par==UNBOUND_VALUE || enum_par==UNKNOWN_VALUE) TTCN_error("The argument of function enum2int() is an %s value of enumerated type @PAP_Types.PapCode.", enum_par==UNBOUND_VALUE?"unbound":"invalid"); return enum_par; } int PapCode::enum2int(const PapCode& enum_par) { if (enum_par.enum_value==UNBOUND_VALUE || enum_par.enum_value==UNKNOWN_VALUE) TTCN_error("The argument of function enum2int() is an %s value of enumerated type @PAP_Types.PapCode.", enum_par==UNBOUND_VALUE?"unbound":"invalid"); return enum_par.enum_value; } void PapCode::int2enum(int int_val) { if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @PAP_Types.PapCode.", int_val); enum_value = (enum_type)int_val; } PapCode::operator PapCode::enum_type() const { if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @PAP_Types.PapCode."); return enum_value; } void PapCode::log() const { if (enum_value != UNBOUND_VALUE) TTCN_Logger::log_event_enum(enum_to_str(enum_value), enum_value); else TTCN_Logger::log_event_unbound(); } void PapCode::set_param(Module_Param& param) { param.basic_check(Module_Param::BC_VALUE, "enumerated value"); if (param.get_type()!=Module_Param::MP_Enumerated) param.type_error("enumerated value", "@PAP_Types.PapCode"); enum_value = str_to_enum(param.get_enumerated()); if (!is_valid_enum(enum_value)) { param.error("Invalid enumerated value for type @PAP_Types.PapCode."); } } void PapCode::encode_text(Text_Buf& text_buf) const { if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @PAP_Types.PapCode."); text_buf.push_int(enum_value); } void PapCode::decode_text(Text_Buf& text_buf) { enum_value = (enum_type)text_buf.pull_int().get_val(); if (!is_valid_enum(enum_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for enumerated type @PAP_Types.PapCode.", enum_value); } void PapCode::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 PapCode::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 PapCode::RAW_decode(const TTCN_Typedescriptor_t& p_td,TTCN_Buffer& p_buf,int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit*) { int decoded_value = 0; int decoded_length = RAW_decode_enum_type(p_td, p_buf, limit, top_bit_ord, decoded_value, 2, no_err); if (decoded_length < 0) return decoded_length; if (is_valid_enum(decoded_value)) enum_value = (enum_type)decoded_value; else { if(no_err){ return -1; } else { TTCN_EncDec_ErrorContext::error (TTCN_EncDec::ET_ENC_ENUM, "Invalid enum value '%d' for '%s': ",decoded_value, p_td.name); enum_value = UNKNOWN_VALUE; } } return decoded_length; } int PapCode::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) const { return RAW_encode_enum_type(p_td, myleaf, (int)enum_value, 2); } void PapCode_template::copy_template(const PapCode_template& other_value) { set_selection(other_value); switch (template_selection) { case SPECIFIC_VALUE: single_value = other_value.single_value; break; 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 PapCode_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 PapCode_template(*other_value.implication_.precondition); implication_.implied_template = new PapCode_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 enumerated type @PAP_Types.PapCode."); } } PapCode_template::PapCode_template() { } PapCode_template::PapCode_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } PapCode_template::PapCode_template(int other_value) : Base_Template(SPECIFIC_VALUE) { if (!PapCode::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @PAP_Types.PapCode with unknown numeric value %d.", other_value); single_value = (PapCode::enum_type)other_value; } PapCode_template::PapCode_template(PapCode::enum_type other_value) : Base_Template(SPECIFIC_VALUE) { single_value = other_value; } PapCode_template::PapCode_template(const PapCode& other_value) : Base_Template(SPECIFIC_VALUE) { if (other_value.enum_value == PapCode::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @PAP_Types.PapCode."); single_value = other_value.enum_value; } PapCode_template::PapCode_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: set_selection(SPECIFIC_VALUE); single_value = (PapCode::enum_type)(const PapCode&)other_value; break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of enumerated type @PAP_Types.PapCode from an unbound optional field."); } } PapCode_template::PapCode_template(PapCode_template* p_precondition, PapCode_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } PapCode_template::PapCode_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } PapCode_template::PapCode_template(const PapCode_template& other_value) : Base_Template() { copy_template(other_value); } PapCode_template::~PapCode_template() { clean_up(); } boolean PapCode_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; return TRUE; } boolean PapCode_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value != PapCode::UNBOUND_VALUE; } void PapCode_template::clean_up() { switch (template_selection) { 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; } PapCode_template& PapCode_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } PapCode_template& PapCode_template::operator=(int other_value) { if (!PapCode::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @PAP_Types.PapCode.", other_value); clean_up(); set_selection(SPECIFIC_VALUE); single_value = (PapCode::enum_type)other_value; return *this; } PapCode_template& PapCode_template::operator=(PapCode::enum_type other_value) { clean_up(); set_selection(SPECIFIC_VALUE); single_value = other_value; return *this; } PapCode_template& PapCode_template::operator=(const PapCode& other_value) { if (other_value.enum_value == PapCode::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @PAP_Types.PapCode to a template."); clean_up(); set_selection(SPECIFIC_VALUE); single_value = other_value.enum_value; return *this; } PapCode_template& PapCode_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: set_selection(SPECIFIC_VALUE); single_value = (PapCode::enum_type)(const PapCode&)other_value; break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Assignment of an unbound optional field to a template of enumerated type @PAP_Types.PapCode."); } return *this; } PapCode_template& PapCode_template::operator=(const PapCode_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean PapCode_template::match(PapCode::enum_type other_value, boolean) const { switch (template_selection) { case SPECIFIC_VALUE: return single_value == other_value; case OMIT_VALUE: return FALSE; case ANY_VALUE: case ANY_OR_OMIT: 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)) 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 enumerated type @PAP_Types.PapCode."); } return FALSE; } boolean PapCode_template::match(const PapCode& other_value, boolean) const { if (other_value.enum_value == PapCode::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @PAP_Types.PapCode with an unbound value."); return match(other_value.enum_value); } PapCode::enum_type PapCode_template::valueof() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) TTCN_error("Performing a valueof or send operation on a non-specific template of enumerated type @PAP_Types.PapCode."); return single_value; } void PapCode_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 type for a template of enumerated type @PAP_Types.PapCode."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new PapCode_template[list_length]; } PapCode_template& PapCode_template::list_item(unsigned int list_index) { if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST && template_selection != CONJUNCTION_MATCH) TTCN_error("Accessing a list element in a non-list template of enumerated type @PAP_Types.PapCode."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @PAP_Types.PapCode."); return value_list.list_value[list_index]; } void PapCode_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_enum(PapCode::enum_to_str(single_value), single_value); 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 elem_count = 0; elem_count < value_list.n_values; elem_count++) { if (elem_count > 0) TTCN_Logger::log_event_str(", "); value_list.list_value[elem_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 PapCode_template::log_match(const PapCode& match_value, boolean) const { match_value.log(); TTCN_Logger::log_event_str(" with "); log(); if (match(match_value)) TTCN_Logger::log_event_str(" matched"); else TTCN_Logger::log_event_str(" unmatched"); } void PapCode_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); 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 elem_count = 0; elem_count < value_list.n_values; elem_count++) value_list.list_value[elem_count].encode_text(text_buf); break; default: TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of enumerated type @PAP_Types.PapCode."); } } void PapCode_template::decode_text(Text_Buf& text_buf) { clean_up(); decode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value = (PapCode::enum_type)text_buf.pull_int().get_val(); if (!PapCode::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @PAP_Types.PapCode.", single_value); 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 PapCode_template[value_list.n_values]; for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++) value_list.list_value[elem_count].decode_text(text_buf); break; default: TTCN_error("Text decoder: An unknown/unsupported selection was received for a template of enumerated type @PAP_Types.PapCode."); } } boolean PapCode_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean PapCode_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 i=0; iget_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: { PapCode_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_iget_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_Enumerated: { PapCode::enum_type enum_val = PapCode::str_to_enum(m_p->get_enumerated()); if (!PapCode::is_valid_enum(enum_val)) { param.error("Invalid enumerated value for type @PAP_Types.PapCode."); } *this = enum_val; } break; case Module_Param::MP_Implication_Template: { PapCode_template* precondition = new PapCode_template; precondition->set_param(*m_p->get_elem(0)); PapCode_template* implied_template = new PapCode_template; implied_template->set_param(*m_p->get_elem(1)); *this = PapCode_template(precondition, implied_template); } break; default: param.type_error("enumerated template", "@PAP_Types.PapCode"); } is_ifpresent = param.get_ifpresent(); } void PapCode_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_VALUE: if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; break; case TR_OMIT: if (!is_ifpresent && (template_selection==OMIT_VALUE || template_selection==SPECIFIC_VALUE)) return; break; case TR_PRESENT: 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 : "@PAP_Types.PapCode"); } void PapPayloadUnion::copy_value(const PapPayloadUnion& other_value) { switch (other_value.union_selection) { case ALT_req: field_req = new PapAuthReq(*other_value.field_req); break; case ALT_ack: field_ack = new PapAuthResp(*other_value.field_ack); break; case ALT_nak: field_nak = new PapAuthResp(*other_value.field_nak); break; default: TTCN_error("Assignment of an unbound union value of type @PAP_Types.PapPayloadUnion."); } union_selection = other_value.union_selection; } PapPayloadUnion::PapPayloadUnion() { union_selection = UNBOUND_VALUE; } PapPayloadUnion::PapPayloadUnion(const PapPayloadUnion& other_value) : Base_Type(){ copy_value(other_value); } PapPayloadUnion::~PapPayloadUnion() { clean_up(); } PapPayloadUnion& PapPayloadUnion::operator=(const PapPayloadUnion& other_value) { if (this != &other_value) { clean_up(); copy_value(other_value); } return *this; } boolean PapPayloadUnion::operator==(const PapPayloadUnion& other_value) const { if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type @PAP_Types.PapPayloadUnion."); if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type @PAP_Types.PapPayloadUnion."); if (union_selection != other_value.union_selection) return FALSE; switch (union_selection) { case ALT_req: return *field_req == *other_value.field_req; case ALT_ack: return *field_ack == *other_value.field_ack; case ALT_nak: return *field_nak == *other_value.field_nak; default: return FALSE; } } PapAuthReq& PapPayloadUnion::req() { if (union_selection != ALT_req) { clean_up(); field_req = new PapAuthReq; union_selection = ALT_req; } return *field_req; } const PapAuthReq& PapPayloadUnion::req() const { if (union_selection != ALT_req) TTCN_error("Using non-selected field req in a value of union type @PAP_Types.PapPayloadUnion."); return *field_req; } PapAuthResp& PapPayloadUnion::ack() { if (union_selection != ALT_ack) { clean_up(); field_ack = new PapAuthResp; union_selection = ALT_ack; } return *field_ack; } const PapAuthResp& PapPayloadUnion::ack() const { if (union_selection != ALT_ack) TTCN_error("Using non-selected field ack in a value of union type @PAP_Types.PapPayloadUnion."); return *field_ack; } PapAuthResp& PapPayloadUnion::nak() { if (union_selection != ALT_nak) { clean_up(); field_nak = new PapAuthResp; union_selection = ALT_nak; } return *field_nak; } const PapAuthResp& PapPayloadUnion::nak() const { if (union_selection != ALT_nak) TTCN_error("Using non-selected field nak in a value of union type @PAP_Types.PapPayloadUnion."); return *field_nak; } boolean PapPayloadUnion::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 @PAP_Types.PapPayloadUnion."); return union_selection == checked_selection; } boolean PapPayloadUnion::is_bound() const { return union_selection != UNBOUND_VALUE; } boolean PapPayloadUnion::is_value() const { switch (union_selection) { case UNBOUND_VALUE: return FALSE; case ALT_req: return field_req->is_value(); case ALT_ack: return field_ack->is_value(); case ALT_nak: return field_nak->is_value(); default: TTCN_error("Invalid selection in union is_bound");} } void PapPayloadUnion::clean_up() { switch (union_selection) { case ALT_req: delete field_req; break; case ALT_ack: delete field_ack; break; case ALT_nak: delete field_nak; break; default: break; } union_selection = UNBOUND_VALUE; } void PapPayloadUnion::log() const { switch (union_selection) { case ALT_req: TTCN_Logger::log_event_str("{ req := "); field_req->log(); TTCN_Logger::log_event_str(" }"); break; case ALT_ack: TTCN_Logger::log_event_str("{ ack := "); field_ack->log(); TTCN_Logger::log_event_str(" }"); break; case ALT_nak: TTCN_Logger::log_event_str("{ nak := "); field_nak->log(); TTCN_Logger::log_event_str(" }"); break; default: TTCN_Logger::log_event_unbound(); } } void PapPayloadUnion::set_param(Module_Param& param) { param.basic_check(Module_Param::BC_VALUE, "union value"); Module_Param_Ptr m_p = ¶m; 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, "req")) { req().set_param(*mp_last); if (!req().is_bound()) clean_up(); return; } if (!strcmp(last_name, "ack")) { ack().set_param(*mp_last); if (!ack().is_bound()) clean_up(); return; } if (!strcmp(last_name, "nak")) { nak().set_param(*mp_last); if (!nak().is_bound()) clean_up(); return; } mp_last->error("Field %s does not exist in type @PAP_Types.PapPayloadUnion.", last_name); } void PapPayloadUnion::set_implicit_omit() { switch (union_selection) { case ALT_req: field_req->set_implicit_omit(); break; case ALT_ack: field_ack->set_implicit_omit(); break; case ALT_nak: field_nak->set_implicit_omit(); break; default: break; } } void PapPayloadUnion::encode_text(Text_Buf& text_buf) const { text_buf.push_int(union_selection); switch (union_selection) { case ALT_req: field_req->encode_text(text_buf); break; case ALT_ack: field_ack->encode_text(text_buf); break; case ALT_nak: field_nak->encode_text(text_buf); break; default: TTCN_error("Text encoder: Encoding an unbound value of union type @PAP_Types.PapPayloadUnion."); } } void PapPayloadUnion::decode_text(Text_Buf& text_buf) { switch ((union_selection_type)text_buf.pull_int().get_val()) { case ALT_req: req().decode_text(text_buf); break; case ALT_ack: ack().decode_text(text_buf); break; case ALT_nak: nak().decode_text(text_buf); break; default: TTCN_error("Text decoder: Unrecognized union selector was received for type @PAP_Types.PapPayloadUnion."); } } void PapPayloadUnion::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 PapPayloadUnion::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 PapPayloadUnion::RAW_decode( const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, int sel_field, boolean, const RAW_Force_Omit* force_omit) { int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding); limit-=prepaddlength; int decoded_length=0; int starting_pos=p_buf.get_pos_bit(); if(sel_field!=-1){ switch(sel_field){ case 0: { RAW_Force_Omit field_force_omit(0, force_omit, PapPayloadUnion_req_descr_.raw->forceomit); decoded_length = req().RAW_decode(PapPayloadUnion_req_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit); break; } case 1: { RAW_Force_Omit field_force_omit(1, force_omit, PapPayloadUnion_ack_descr_.raw->forceomit); decoded_length = ack().RAW_decode(PapPayloadUnion_ack_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit); break; } case 2: { RAW_Force_Omit field_force_omit(2, force_omit, PapPayloadUnion_nak_descr_.raw->forceomit); decoded_length = nak().RAW_decode(PapPayloadUnion_nak_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit); break; } default: break; } return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength; } else { p_buf.set_pos_bit(starting_pos); RAW_Force_Omit field_0_force_omit(0, force_omit, PapPayloadUnion_req_descr_.raw->forceomit); decoded_length = req().RAW_decode(PapPayloadUnion_req_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_0_force_omit); if (decoded_length >= 0) { return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength; } p_buf.set_pos_bit(starting_pos); RAW_Force_Omit field_1_force_omit(1, force_omit, PapPayloadUnion_ack_descr_.raw->forceomit); decoded_length = ack().RAW_decode(PapPayloadUnion_ack_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_1_force_omit); if (decoded_length >= 0) { return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength; } p_buf.set_pos_bit(starting_pos); RAW_Force_Omit field_2_force_omit(2, force_omit, PapPayloadUnion_nak_descr_.raw->forceomit); decoded_length = nak().RAW_decode(PapPayloadUnion_nak_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_2_force_omit); if (decoded_length >= 0) { return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength; } } clean_up(); return -1; } int PapPayloadUnion::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const { int encoded_length = 0; myleaf.isleaf = FALSE; myleaf.body.node.num_of_nodes = 3; myleaf.body.node.nodes = init_nodes_of_enc_tree(3); memset(myleaf.body.node.nodes, 0, 3 * sizeof(RAW_enc_tree *)); switch (union_selection) { case ALT_req: myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 0, PapPayloadUnion_req_descr_.raw); encoded_length = field_req->RAW_encode(PapPayloadUnion_req_descr_, *myleaf.body.node.nodes[0]); myleaf.body.node.nodes[0]->coding_descr = &PapPayloadUnion_req_descr_; break; case ALT_ack: myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 1, PapPayloadUnion_ack_descr_.raw); encoded_length = field_ack->RAW_encode(PapPayloadUnion_ack_descr_, *myleaf.body.node.nodes[1]); myleaf.body.node.nodes[1]->coding_descr = &PapPayloadUnion_ack_descr_; break; case ALT_nak: myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 2, PapPayloadUnion_nak_descr_.raw); encoded_length = field_nak->RAW_encode(PapPayloadUnion_nak_descr_, *myleaf.body.node.nodes[2]); myleaf.body.node.nodes[2]->coding_descr = &PapPayloadUnion_nak_descr_; break; default: TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value."); } return encoded_length; } void PapPayloadUnion_template::copy_value(const PapPayloadUnion& other_value) { single_value.union_selection = other_value.get_selection(); switch (single_value.union_selection) { case PapPayloadUnion::ALT_req: single_value.field_req = new PapAuthReq_template(other_value.req()); break; case PapPayloadUnion::ALT_ack: single_value.field_ack = new PapAuthResp_template(other_value.ack()); break; case PapPayloadUnion::ALT_nak: single_value.field_nak = new PapAuthResp_template(other_value.nak()); break; default: TTCN_error("Initializing a template with an unbound value of type @PAP_Types.PapPayloadUnion."); } set_selection(SPECIFIC_VALUE); } void PapPayloadUnion_template::copy_template(const PapPayloadUnion_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 PapPayloadUnion::ALT_req: single_value.field_req = new PapAuthReq_template(*other_value.single_value.field_req); break; case PapPayloadUnion::ALT_ack: single_value.field_ack = new PapAuthResp_template(*other_value.single_value.field_ack); break; case PapPayloadUnion::ALT_nak: single_value.field_nak = new PapAuthResp_template(*other_value.single_value.field_nak); break; default: TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type @PAP_Types.PapPayloadUnion."); } 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 PapPayloadUnion_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 PapPayloadUnion_template(*other_value.implication_.precondition); implication_.implied_template = new PapPayloadUnion_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 @PAP_Types.PapPayloadUnion."); } set_selection(other_value); } PapPayloadUnion_template::PapPayloadUnion_template() { } PapPayloadUnion_template::PapPayloadUnion_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } PapPayloadUnion_template::PapPayloadUnion_template(const PapPayloadUnion& other_value) { copy_value(other_value); } PapPayloadUnion_template::PapPayloadUnion_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const PapPayloadUnion&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of union type @PAP_Types.PapPayloadUnion from an unbound optional field."); } } PapPayloadUnion_template::PapPayloadUnion_template(PapPayloadUnion_template* p_precondition, PapPayloadUnion_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } PapPayloadUnion_template::PapPayloadUnion_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } PapPayloadUnion_template::PapPayloadUnion_template(const PapPayloadUnion_template& other_value) : Base_Template(){ copy_template(other_value); } PapPayloadUnion_template::~PapPayloadUnion_template() { clean_up(); } void PapPayloadUnion_template::clean_up() { switch (template_selection) { case SPECIFIC_VALUE: switch (single_value.union_selection) { case PapPayloadUnion::ALT_req: delete single_value.field_req; break; case PapPayloadUnion::ALT_ack: delete single_value.field_ack; break; case PapPayloadUnion::ALT_nak: delete single_value.field_nak; 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; } PapPayloadUnion_template& PapPayloadUnion_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } PapPayloadUnion_template& PapPayloadUnion_template::operator=(const PapPayloadUnion& other_value) { clean_up(); copy_value(other_value); return *this; } PapPayloadUnion_template& PapPayloadUnion_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const PapPayloadUnion&)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 @PAP_Types.PapPayloadUnion."); } return *this; } PapPayloadUnion_template& PapPayloadUnion_template::operator=(const PapPayloadUnion_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean PapPayloadUnion_template::match(const PapPayloadUnion& 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: { PapPayloadUnion::union_selection_type value_selection = other_value.get_selection(); if (value_selection == PapPayloadUnion::UNBOUND_VALUE) return FALSE; if (value_selection != single_value.union_selection) return FALSE; switch (value_selection) { case PapPayloadUnion::ALT_req: return single_value.field_req->match(other_value.req(), legacy); case PapPayloadUnion::ALT_ack: return single_value.field_ack->match(other_value.ack(), legacy); case PapPayloadUnion::ALT_nak: return single_value.field_nak->match(other_value.nak(), legacy); default: TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type @PAP_Types.PapPayloadUnion."); } } 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 @PAP_Types.PapPayloadUnion."); } return FALSE; } boolean PapPayloadUnion_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; switch (single_value.union_selection) { case PapPayloadUnion::ALT_req: return single_value.field_req->is_value(); case PapPayloadUnion::ALT_ack: return single_value.field_ack->is_value(); case PapPayloadUnion::ALT_nak: return single_value.field_nak->is_value(); default: TTCN_error("Internal error: Invalid selector in a specific value when performing is_value operation on a template of union type @PAP_Types.PapPayloadUnion."); } } PapPayloadUnion PapPayloadUnion_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 @PAP_Types.PapPayloadUnion."); PapPayloadUnion ret_val; switch (single_value.union_selection) { case PapPayloadUnion::ALT_req: ret_val.req() = single_value.field_req->valueof(); break; case PapPayloadUnion::ALT_ack: ret_val.ack() = single_value.field_ack->valueof(); break; case PapPayloadUnion::ALT_nak: ret_val.nak() = single_value.field_nak->valueof(); break; default: TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type @PAP_Types.PapPayloadUnion."); } return ret_val; } PapPayloadUnion_template& PapPayloadUnion_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 @PAP_Types.PapPayloadUnion."); if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of union type @PAP_Types.PapPayloadUnion."); return value_list.list_value[list_index]; } void PapPayloadUnion_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 @PAP_Types.PapPayloadUnion."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new PapPayloadUnion_template[list_length]; } PapAuthReq_template& PapPayloadUnion_template::req() { if (template_selection != SPECIFIC_VALUE || single_value.union_selection != PapPayloadUnion::ALT_req) { template_sel old_selection = template_selection; clean_up(); if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_req = new PapAuthReq_template(ANY_VALUE); else single_value.field_req = new PapAuthReq_template; single_value.union_selection = PapPayloadUnion::ALT_req; set_selection(SPECIFIC_VALUE); } return *single_value.field_req; } const PapAuthReq_template& PapPayloadUnion_template::req() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field req in a non-specific template of union type @PAP_Types.PapPayloadUnion."); if (single_value.union_selection != PapPayloadUnion::ALT_req) TTCN_error("Accessing non-selected field req in a template of union type @PAP_Types.PapPayloadUnion."); return *single_value.field_req; } PapAuthResp_template& PapPayloadUnion_template::ack() { if (template_selection != SPECIFIC_VALUE || single_value.union_selection != PapPayloadUnion::ALT_ack) { template_sel old_selection = template_selection; clean_up(); if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_ack = new PapAuthResp_template(ANY_VALUE); else single_value.field_ack = new PapAuthResp_template; single_value.union_selection = PapPayloadUnion::ALT_ack; set_selection(SPECIFIC_VALUE); } return *single_value.field_ack; } const PapAuthResp_template& PapPayloadUnion_template::ack() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field ack in a non-specific template of union type @PAP_Types.PapPayloadUnion."); if (single_value.union_selection != PapPayloadUnion::ALT_ack) TTCN_error("Accessing non-selected field ack in a template of union type @PAP_Types.PapPayloadUnion."); return *single_value.field_ack; } PapAuthResp_template& PapPayloadUnion_template::nak() { if (template_selection != SPECIFIC_VALUE || single_value.union_selection != PapPayloadUnion::ALT_nak) { template_sel old_selection = template_selection; clean_up(); if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_nak = new PapAuthResp_template(ANY_VALUE); else single_value.field_nak = new PapAuthResp_template; single_value.union_selection = PapPayloadUnion::ALT_nak; set_selection(SPECIFIC_VALUE); } return *single_value.field_nak; } const PapAuthResp_template& PapPayloadUnion_template::nak() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field nak in a non-specific template of union type @PAP_Types.PapPayloadUnion."); if (single_value.union_selection != PapPayloadUnion::ALT_nak) TTCN_error("Accessing non-selected field nak in a template of union type @PAP_Types.PapPayloadUnion."); return *single_value.field_nak; } boolean PapPayloadUnion_template::ischosen(PapPayloadUnion::union_selection_type checked_selection) const { if (checked_selection == PapPayloadUnion::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @PAP_Types.PapPayloadUnion."); switch (template_selection) { case SPECIFIC_VALUE: if (single_value.union_selection == PapPayloadUnion::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type @PAP_Types.PapPayloadUnion."); 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 @PAP_Types.PapPayloadUnion 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 PapPayloadUnion_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: switch (single_value.union_selection) { case PapPayloadUnion::ALT_req: TTCN_Logger::log_event_str("{ req := "); single_value.field_req->log(); TTCN_Logger::log_event_str(" }"); break; case PapPayloadUnion::ALT_ack: TTCN_Logger::log_event_str("{ ack := "); single_value.field_ack->log(); TTCN_Logger::log_event_str(" }"); break; case PapPayloadUnion::ALT_nak: TTCN_Logger::log_event_str("{ nak := "); single_value.field_nak->log(); TTCN_Logger::log_event_str(" }"); break; default: 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 PapPayloadUnion_template::log_match(const PapPayloadUnion& 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 PapPayloadUnion::ALT_req: if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ TTCN_Logger::log_logmatch_info(".req"); single_value.field_req->log_match(match_value.req(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } else { TTCN_Logger::log_event_str("{ req := "); single_value.field_req->log_match(match_value.req(), legacy); TTCN_Logger::log_event_str(" }"); } break; case PapPayloadUnion::ALT_ack: if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ TTCN_Logger::log_logmatch_info(".ack"); single_value.field_ack->log_match(match_value.ack(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } else { TTCN_Logger::log_event_str("{ ack := "); single_value.field_ack->log_match(match_value.ack(), legacy); TTCN_Logger::log_event_str(" }"); } break; case PapPayloadUnion::ALT_nak: if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ TTCN_Logger::log_logmatch_info(".nak"); single_value.field_nak->log_match(match_value.nak(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } else { TTCN_Logger::log_event_str("{ nak := "); single_value.field_nak->log_match(match_value.nak(), legacy); TTCN_Logger::log_event_str(" }"); } break; default: TTCN_Logger::print_logmatch_buffer(); TTCN_Logger::log_event_str(""); } } 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 PapPayloadUnion_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 PapPayloadUnion::ALT_req: single_value.field_req->encode_text(text_buf); break; case PapPayloadUnion::ALT_ack: single_value.field_ack->encode_text(text_buf); break; case PapPayloadUnion::ALT_nak: single_value.field_nak->encode_text(text_buf); break; default: TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type @PAP_Types.PapPayloadUnion."); } 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 @PAP_Types.PapPayloadUnion."); } } void PapPayloadUnion_template::decode_text(Text_Buf& text_buf) { clean_up(); decode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: { single_value.union_selection = PapPayloadUnion::UNBOUND_VALUE; PapPayloadUnion::union_selection_type new_selection = (PapPayloadUnion::union_selection_type)text_buf.pull_int().get_val(); switch (new_selection) { case PapPayloadUnion::ALT_req: single_value.field_req = new PapAuthReq_template; single_value.field_req->decode_text(text_buf); break; case PapPayloadUnion::ALT_ack: single_value.field_ack = new PapAuthResp_template; single_value.field_ack->decode_text(text_buf); break; case PapPayloadUnion::ALT_nak: single_value.field_nak = new PapAuthResp_template; single_value.field_nak->decode_text(text_buf); break; default: TTCN_error("Text decoder: Unrecognized union selector was received for a template of type @PAP_Types.PapPayloadUnion."); } 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 PapPayloadUnion_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 @PAP_Types.PapPayloadUnion."); } } boolean PapPayloadUnion_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean PapPayloadUnion_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(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 `@PAP_Types.PapPayloadUnion'"); } if (strcmp("req", param_field) == 0) { req().set_param(param); return; } else if (strcmp("ack", param_field) == 0) { ack().set_param(param); return; } else if (strcmp("nak", param_field) == 0) { nak().set_param(param); return; } else param.error("Field `%s' not found in union template type `@PAP_Types.PapPayloadUnion'", param_field); } param.basic_check(Module_Param::BC_TEMPLATE, "union template"); Module_Param_Ptr m_p = ¶m; 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: { PapPayloadUnion_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_iget_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", "@PAP_Types.PapPayloadUnion"); 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, "req")) { req().set_param(*mp_last); break; } if (!strcmp(last_name, "ack")) { ack().set_param(*mp_last); break; } if (!strcmp(last_name, "nak")) { nak().set_param(*mp_last); break; } mp_last->error("Field %s does not exist in type @PAP_Types.PapPayloadUnion.", last_name); } break; case Module_Param::MP_Implication_Template: { PapPayloadUnion_template* precondition = new PapPayloadUnion_template; precondition->set_param(*m_p->get_elem(0)); PapPayloadUnion_template* implied_template = new PapPayloadUnion_template; implied_template->set_param(*m_p->get_elem(1)); *this = PapPayloadUnion_template(precondition, implied_template); } break; default: param.type_error("union template", "@PAP_Types.PapPayloadUnion"); } is_ifpresent = param.get_ifpresent(); } void PapPayloadUnion_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 PapPayloadUnion::ALT_req: single_value.field_req->check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapPayloadUnion"); return; case PapPayloadUnion::ALT_ack: single_value.field_ack->check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapPayloadUnion"); return; case PapPayloadUnion::ALT_nak: single_value.field_nak->check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapPayloadUnion"); return; default: TTCN_error("Internal error: Invalid selector in a specific value when performing check_restriction operation on a template of union type @PAP_Types.PapPayloadUnion."); } 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 : "@PAP_Types.PapPayloadUnion"); } PapAuthReq::PapAuthReq() { } PapAuthReq::PapAuthReq(const INTEGER& par_peer__id__len, const OCTETSTRING& par_peer__id, const INTEGER& par_passwd__len, const OCTETSTRING& par_passwd) : field_peer__id__len(par_peer__id__len), field_peer__id(par_peer__id), field_passwd__len(par_passwd__len), field_passwd(par_passwd) { } PapAuthReq::PapAuthReq(const PapAuthReq& other_value) { if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @PAP_Types.PapAuthReq."); if (other_value.peer__id__len().is_bound()) field_peer__id__len = other_value.peer__id__len(); else field_peer__id__len.clean_up(); if (other_value.peer__id().is_bound()) field_peer__id = other_value.peer__id(); else field_peer__id.clean_up(); if (other_value.passwd__len().is_bound()) field_passwd__len = other_value.passwd__len(); else field_passwd__len.clean_up(); if (other_value.passwd().is_bound()) field_passwd = other_value.passwd(); else field_passwd.clean_up(); } void PapAuthReq::clean_up() { field_peer__id__len.clean_up(); field_peer__id.clean_up(); field_passwd__len.clean_up(); field_passwd.clean_up(); } const TTCN_Typedescriptor_t* PapAuthReq::get_descriptor() const { return &PapAuthReq_descr_; } PapAuthReq& PapAuthReq::operator=(const PapAuthReq& other_value) { if (this != &other_value) { if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @PAP_Types.PapAuthReq."); if (other_value.peer__id__len().is_bound()) field_peer__id__len = other_value.peer__id__len(); else field_peer__id__len.clean_up(); if (other_value.peer__id().is_bound()) field_peer__id = other_value.peer__id(); else field_peer__id.clean_up(); if (other_value.passwd__len().is_bound()) field_passwd__len = other_value.passwd__len(); else field_passwd__len.clean_up(); if (other_value.passwd().is_bound()) field_passwd = other_value.passwd(); else field_passwd.clean_up(); } return *this; } boolean PapAuthReq::operator==(const PapAuthReq& other_value) const { return field_peer__id__len==other_value.field_peer__id__len && field_peer__id==other_value.field_peer__id && field_passwd__len==other_value.field_passwd__len && field_passwd==other_value.field_passwd; } boolean PapAuthReq::is_bound() const { return (field_peer__id__len.is_bound()) || (field_peer__id.is_bound()) || (field_passwd__len.is_bound()) || (field_passwd.is_bound()); } boolean PapAuthReq::is_value() const { return field_peer__id__len.is_value() && field_peer__id.is_value() && field_passwd__len.is_value() && field_passwd.is_value(); } void PapAuthReq::log() const { if (!is_bound()) { TTCN_Logger::log_event_unbound(); return; } TTCN_Logger::log_event_str("{ peer_id_len := "); field_peer__id__len.log(); TTCN_Logger::log_event_str(", peer_id := "); field_peer__id.log(); TTCN_Logger::log_event_str(", passwd_len := "); field_passwd__len.log(); TTCN_Logger::log_event_str(", passwd := "); field_passwd.log(); TTCN_Logger::log_event_str(" }"); } void PapAuthReq::set_implicit_omit() { if (peer__id__len().is_bound()) peer__id__len().set_implicit_omit(); if (peer__id().is_bound()) peer__id().set_implicit_omit(); if (passwd__len().is_bound()) passwd__len().set_implicit_omit(); if (passwd().is_bound()) passwd().set_implicit_omit(); } void PapAuthReq::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 (40 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) peer__id__len().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) peer__id().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) passwd__len().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) passwd().set_param(*param.get_elem(3)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "peer_id_len")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { peer__id__len().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "peer_id")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { peer__id().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "passwd_len")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { passwd__len().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "passwd")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { passwd().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @PAP_Types.PapAuthReq: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@PAP_Types.PapAuthReq"); } } void PapAuthReq::encode_text(Text_Buf& text_buf) const { field_peer__id__len.encode_text(text_buf); field_peer__id.encode_text(text_buf); field_passwd__len.encode_text(text_buf); field_passwd.encode_text(text_buf); } void PapAuthReq::decode_text(Text_Buf& text_buf) { field_peer__id__len.decode_text(text_buf); field_peer__id.decode_text(text_buf); field_passwd__len.decode_text(text_buf); field_passwd.decode_text(text_buf); } void PapAuthReq::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 PapAuthReq::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 PapAuthReq::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit* force_omit) { (void)no_err; int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding); limit-=prepaddlength; size_t last_decoded_pos = p_buf.get_pos_bit(); int decoded_length = 0; int decoded_field_length = 0; raw_order_t local_top_order; if(p_td.raw->top_bit_order==TOP_BIT_INHERITED)local_top_order=top_bit_ord; else if(p_td.raw->top_bit_order==TOP_BIT_RIGHT)local_top_order=ORDER_MSB; else local_top_order=ORDER_LSB; int value_of_length_field0 = 0; int value_of_length_field2 = 0; RAW_Force_Omit field_0_force_omit(0, force_omit, PapAuthReq_peer__id__len_descr_.raw->forceomit); decoded_field_length = field_peer__id__len.RAW_decode(PapAuthReq_peer__id__len_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_0_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); INTEGER tmp0 = field_peer__id__len.convert_to_Integer(PapAuthReq_peer__id__len_descr_); field_peer__id__len = tmp0; value_of_length_field0 += tmp0.get_long_long_val() * 8; RAW_Force_Omit field_1_force_omit(1, force_omit, PapAuthReq_peer__id_descr_.raw->forceomit); decoded_field_length = field_peer__id.RAW_decode(PapAuthReq_peer__id_descr_, p_buf, min_of_ints(2, limit, value_of_length_field0), local_top_order, no_err, -1, TRUE, &field_1_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); value_of_length_field0 -= decoded_field_length; RAW_Force_Omit field_2_force_omit(2, force_omit, PapAuthReq_passwd__len_descr_.raw->forceomit); decoded_field_length = field_passwd__len.RAW_decode(PapAuthReq_passwd__len_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_2_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); INTEGER tmp2 = field_passwd__len.convert_to_Integer(PapAuthReq_passwd__len_descr_); field_passwd__len = tmp2; value_of_length_field2 += tmp2.get_long_long_val() * 8; RAW_Force_Omit field_3_force_omit(3, force_omit, PapAuthReq_passwd_descr_.raw->forceomit); decoded_field_length = field_passwd.RAW_decode(PapAuthReq_passwd_descr_, p_buf, min_of_ints(2, limit, value_of_length_field2), local_top_order, no_err, -1, TRUE, &field_3_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); value_of_length_field2 -= decoded_field_length; p_buf.set_pos_bit(last_decoded_pos); return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding); } int PapAuthReq::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const { if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value."); int encoded_length = 0; myleaf.isleaf = FALSE; myleaf.body.node.num_of_nodes = 4; myleaf.body.node.nodes = init_nodes_of_enc_tree(4); myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, PapAuthReq_peer__id__len_descr_.raw); myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, PapAuthReq_peer__id_descr_.raw); myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, PapAuthReq_passwd__len_descr_.raw); myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, PapAuthReq_passwd_descr_.raw); encoded_length += 8; myleaf.body.node.nodes[0]->calc = CALC_LENGTH; myleaf.body.node.nodes[0]->coding_descr = &PapAuthReq_peer__id__len_descr_; myleaf.body.node.nodes[0]->calcof.lengthto.num_of_fields = 1; myleaf.body.node.nodes[0]->calcof.lengthto.unit = 8; myleaf.body.node.nodes[0]->calcof.lengthto.offset = 0; myleaf.body.node.nodes[0]->calcof.lengthto.fields = init_lengthto_fields_list(1); myleaf.body.node.nodes[0]->length = 8; myleaf.body.node.nodes[0]->calcof.lengthto.fields[0].level = myleaf.body.node.nodes[1]->curr_pos.level; myleaf.body.node.nodes[0]->calcof.lengthto.fields[0].pos = myleaf.body.node.nodes[1]->curr_pos.pos; encoded_length += field_peer__id.RAW_encode(PapAuthReq_peer__id_descr_, *myleaf.body.node.nodes[1]); encoded_length += 8; myleaf.body.node.nodes[2]->calc = CALC_LENGTH; myleaf.body.node.nodes[2]->coding_descr = &PapAuthReq_passwd__len_descr_; myleaf.body.node.nodes[2]->calcof.lengthto.num_of_fields = 1; myleaf.body.node.nodes[2]->calcof.lengthto.unit = 8; myleaf.body.node.nodes[2]->calcof.lengthto.offset = 0; myleaf.body.node.nodes[2]->calcof.lengthto.fields = init_lengthto_fields_list(1); myleaf.body.node.nodes[2]->length = 8; myleaf.body.node.nodes[2]->calcof.lengthto.fields[0].level = myleaf.body.node.nodes[3]->curr_pos.level; myleaf.body.node.nodes[2]->calcof.lengthto.fields[0].pos = myleaf.body.node.nodes[3]->curr_pos.pos; encoded_length += field_passwd.RAW_encode(PapAuthReq_passwd_descr_, *myleaf.body.node.nodes[3]); return myleaf.length = encoded_length; } struct PapAuthReq_template::single_value_struct { INTEGER_template field_peer__id__len; OCTETSTRING_template field_peer__id; INTEGER_template field_passwd__len; OCTETSTRING_template field_passwd; }; void PapAuthReq_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_peer__id__len = ANY_VALUE; single_value->field_peer__id = ANY_VALUE; single_value->field_passwd__len = ANY_VALUE; single_value->field_passwd = ANY_VALUE; } } } void PapAuthReq_template::copy_value(const PapAuthReq& other_value) { single_value = new single_value_struct; if (other_value.peer__id__len().is_bound()) { single_value->field_peer__id__len = other_value.peer__id__len(); } else { single_value->field_peer__id__len.clean_up(); } if (other_value.peer__id().is_bound()) { single_value->field_peer__id = other_value.peer__id(); } else { single_value->field_peer__id.clean_up(); } if (other_value.passwd__len().is_bound()) { single_value->field_passwd__len = other_value.passwd__len(); } else { single_value->field_passwd__len.clean_up(); } if (other_value.passwd().is_bound()) { single_value->field_passwd = other_value.passwd(); } else { single_value->field_passwd.clean_up(); } set_selection(SPECIFIC_VALUE); } void PapAuthReq_template::copy_template(const PapAuthReq_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.peer__id__len().get_selection()) { single_value->field_peer__id__len = other_value.peer__id__len(); } else { single_value->field_peer__id__len.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.peer__id().get_selection()) { single_value->field_peer__id = other_value.peer__id(); } else { single_value->field_peer__id.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.passwd__len().get_selection()) { single_value->field_passwd__len = other_value.passwd__len(); } else { single_value->field_passwd__len.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.passwd().get_selection()) { single_value->field_passwd = other_value.passwd(); } else { single_value->field_passwd.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 PapAuthReq_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 PapAuthReq_template(*other_value.implication_.precondition); implication_.implied_template = new PapAuthReq_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 @PAP_Types.PapAuthReq."); break; } set_selection(other_value); } PapAuthReq_template::PapAuthReq_template() { } PapAuthReq_template::PapAuthReq_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } PapAuthReq_template::PapAuthReq_template(const PapAuthReq& other_value) { copy_value(other_value); } PapAuthReq_template::PapAuthReq_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const PapAuthReq&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @PAP_Types.PapAuthReq from an unbound optional field."); } } PapAuthReq_template::PapAuthReq_template(PapAuthReq_template* p_precondition, PapAuthReq_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } PapAuthReq_template::PapAuthReq_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } PapAuthReq_template::PapAuthReq_template(const PapAuthReq_template& other_value) : Base_Template() { copy_template(other_value); } PapAuthReq_template::~PapAuthReq_template() { clean_up(); } PapAuthReq_template& PapAuthReq_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } PapAuthReq_template& PapAuthReq_template::operator=(const PapAuthReq& other_value) { clean_up(); copy_value(other_value); return *this; } PapAuthReq_template& PapAuthReq_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const PapAuthReq&)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 @PAP_Types.PapAuthReq."); } return *this; } PapAuthReq_template& PapAuthReq_template::operator=(const PapAuthReq_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean PapAuthReq_template::match(const PapAuthReq& 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.peer__id__len().is_bound()) return FALSE; if(!single_value->field_peer__id__len.match(other_value.peer__id__len(), legacy))return FALSE; if(!other_value.peer__id().is_bound()) return FALSE; if(!single_value->field_peer__id.match(other_value.peer__id(), legacy))return FALSE; if(!other_value.passwd__len().is_bound()) return FALSE; if(!single_value->field_passwd__len.match(other_value.passwd__len(), legacy))return FALSE; if(!other_value.passwd().is_bound()) return FALSE; if(!single_value->field_passwd.match(other_value.passwd(), 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 @PAP_Types.PapAuthReq."); } return FALSE; } boolean PapAuthReq_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_peer__id__len.is_bound() || single_value->field_peer__id.is_bound() || single_value->field_passwd__len.is_bound() || single_value->field_passwd.is_bound(); } boolean PapAuthReq_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_peer__id__len.is_value() && single_value->field_peer__id.is_value() && single_value->field_passwd__len.is_value() && single_value->field_passwd.is_value(); } void PapAuthReq_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; } PapAuthReq PapAuthReq_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 @PAP_Types.PapAuthReq."); PapAuthReq ret_val; if (single_value->field_peer__id__len.is_bound()) { ret_val.peer__id__len() = single_value->field_peer__id__len.valueof(); } if (single_value->field_peer__id.is_bound()) { ret_val.peer__id() = single_value->field_peer__id.valueof(); } if (single_value->field_passwd__len.is_bound()) { ret_val.passwd__len() = single_value->field_passwd__len.valueof(); } if (single_value->field_passwd.is_bound()) { ret_val.passwd() = single_value->field_passwd.valueof(); } return ret_val; } void PapAuthReq_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 @PAP_Types.PapAuthReq."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new PapAuthReq_template[list_length]; } PapAuthReq_template& PapAuthReq_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 @PAP_Types.PapAuthReq."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @PAP_Types.PapAuthReq."); return value_list.list_value[list_index]; } INTEGER_template& PapAuthReq_template::peer__id__len() { set_specific(); return single_value->field_peer__id__len; } const INTEGER_template& PapAuthReq_template::peer__id__len() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field peer_id_len of a non-specific template of type @PAP_Types.PapAuthReq."); return single_value->field_peer__id__len; } OCTETSTRING_template& PapAuthReq_template::peer__id() { set_specific(); return single_value->field_peer__id; } const OCTETSTRING_template& PapAuthReq_template::peer__id() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field peer_id of a non-specific template of type @PAP_Types.PapAuthReq."); return single_value->field_peer__id; } INTEGER_template& PapAuthReq_template::passwd__len() { set_specific(); return single_value->field_passwd__len; } const INTEGER_template& PapAuthReq_template::passwd__len() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field passwd_len of a non-specific template of type @PAP_Types.PapAuthReq."); return single_value->field_passwd__len; } OCTETSTRING_template& PapAuthReq_template::passwd() { set_specific(); return single_value->field_passwd; } const OCTETSTRING_template& PapAuthReq_template::passwd() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field passwd of a non-specific template of type @PAP_Types.PapAuthReq."); return single_value->field_passwd; } int PapAuthReq_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthReq 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 @PAP_Types.PapAuthReq 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 @PAP_Types.PapAuthReq containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthReq containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthReq containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthReq containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthReq containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthReq containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthReq containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @PAP_Types.PapAuthReq."); } return 0; } void PapAuthReq_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ peer_id_len := "); single_value->field_peer__id__len.log(); TTCN_Logger::log_event_str(", peer_id := "); single_value->field_peer__id.log(); TTCN_Logger::log_event_str(", passwd_len := "); single_value->field_passwd__len.log(); TTCN_Logger::log_event_str(", passwd := "); single_value->field_passwd.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 PapAuthReq_template::log_match(const PapAuthReq& 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_peer__id__len.match(match_value.peer__id__len(), legacy)){ TTCN_Logger::log_logmatch_info(".peer_id_len"); single_value->field_peer__id__len.log_match(match_value.peer__id__len(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_peer__id.match(match_value.peer__id(), legacy)){ TTCN_Logger::log_logmatch_info(".peer_id"); single_value->field_peer__id.log_match(match_value.peer__id(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_passwd__len.match(match_value.passwd__len(), legacy)){ TTCN_Logger::log_logmatch_info(".passwd_len"); single_value->field_passwd__len.log_match(match_value.passwd__len(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_passwd.match(match_value.passwd(), legacy)){ TTCN_Logger::log_logmatch_info(".passwd"); single_value->field_passwd.log_match(match_value.passwd(), 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("{ peer_id_len := "); single_value->field_peer__id__len.log_match(match_value.peer__id__len(), legacy); TTCN_Logger::log_event_str(", peer_id := "); single_value->field_peer__id.log_match(match_value.peer__id(), legacy); TTCN_Logger::log_event_str(", passwd_len := "); single_value->field_passwd__len.log_match(match_value.passwd__len(), legacy); TTCN_Logger::log_event_str(", passwd := "); single_value->field_passwd.log_match(match_value.passwd(), 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 PapAuthReq_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_peer__id__len.encode_text(text_buf); single_value->field_peer__id.encode_text(text_buf); single_value->field_passwd__len.encode_text(text_buf); single_value->field_passwd.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 @PAP_Types.PapAuthReq."); } } void PapAuthReq_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_peer__id__len.decode_text(text_buf); single_value->field_peer__id.decode_text(text_buf); single_value->field_passwd__len.decode_text(text_buf); single_value->field_passwd.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 PapAuthReq_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 @PAP_Types.PapAuthReq."); } } void PapAuthReq_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: { PapAuthReq_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_i0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) peer__id__len().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) peer__id().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) passwd__len().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) passwd().set_param(*param.get_elem(3)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "peer_id_len")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { peer__id__len().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "peer_id")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { peer__id().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "passwd_len")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { passwd__len().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "passwd")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { passwd().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @PAP_Types.PapAuthReq: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { PapAuthReq_template* precondition = new PapAuthReq_template; precondition->set_param(*param.get_elem(0)); PapAuthReq_template* implied_template = new PapAuthReq_template; implied_template->set_param(*param.get_elem(1)); *this = PapAuthReq_template(precondition, implied_template); } break; default: param.type_error("record template", "@PAP_Types.PapAuthReq"); } is_ifpresent = param.get_ifpresent(); } void PapAuthReq_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_peer__id__len.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapAuthReq"); single_value->field_peer__id.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapAuthReq"); single_value->field_passwd__len.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapAuthReq"); single_value->field_passwd.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapAuthReq"); 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 : "@PAP_Types.PapAuthReq"); } boolean PapAuthReq_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean PapAuthReq_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_idx0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) msg__len().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) msg().set_param(*param.get_elem(1)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "msg_len")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { msg__len().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "msg")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { msg().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @PAP_Types.PapAuthResp: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@PAP_Types.PapAuthResp"); } } void PapAuthResp::encode_text(Text_Buf& text_buf) const { field_msg__len.encode_text(text_buf); field_msg.encode_text(text_buf); } void PapAuthResp::decode_text(Text_Buf& text_buf) { field_msg__len.decode_text(text_buf); field_msg.decode_text(text_buf); } void PapAuthResp::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 PapAuthResp::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 PapAuthResp::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit* force_omit) { (void)no_err; int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding); limit-=prepaddlength; size_t last_decoded_pos = p_buf.get_pos_bit(); int decoded_length = 0; int decoded_field_length = 0; raw_order_t local_top_order; if(p_td.raw->top_bit_order==TOP_BIT_INHERITED)local_top_order=top_bit_ord; else if(p_td.raw->top_bit_order==TOP_BIT_RIGHT)local_top_order=ORDER_MSB; else local_top_order=ORDER_LSB; int value_of_length_field0 = 0; RAW_Force_Omit field_0_force_omit(0, force_omit, PapAuthResp_msg__len_descr_.raw->forceomit); decoded_field_length = field_msg__len.RAW_decode(PapAuthResp_msg__len_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_0_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); INTEGER tmp0 = field_msg__len.convert_to_Integer(PapAuthResp_msg__len_descr_); field_msg__len = tmp0; value_of_length_field0 += tmp0.get_long_long_val() * 8; RAW_Force_Omit field_1_force_omit(1, force_omit, PapAuthResp_msg_descr_.raw->forceomit); decoded_field_length = field_msg.RAW_decode(PapAuthResp_msg_descr_, p_buf, min_of_ints(2, limit, value_of_length_field0), local_top_order, no_err, -1, TRUE, &field_1_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); value_of_length_field0 -= decoded_field_length; p_buf.set_pos_bit(last_decoded_pos); return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding); } int PapAuthResp::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const { if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value."); int encoded_length = 0; myleaf.isleaf = FALSE; myleaf.body.node.num_of_nodes = 2; myleaf.body.node.nodes = init_nodes_of_enc_tree(2); myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, PapAuthResp_msg__len_descr_.raw); myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, PapAuthResp_msg_descr_.raw); encoded_length += 8; myleaf.body.node.nodes[0]->calc = CALC_LENGTH; myleaf.body.node.nodes[0]->coding_descr = &PapAuthResp_msg__len_descr_; myleaf.body.node.nodes[0]->calcof.lengthto.num_of_fields = 1; myleaf.body.node.nodes[0]->calcof.lengthto.unit = 8; myleaf.body.node.nodes[0]->calcof.lengthto.offset = 0; myleaf.body.node.nodes[0]->calcof.lengthto.fields = init_lengthto_fields_list(1); myleaf.body.node.nodes[0]->length = 8; myleaf.body.node.nodes[0]->calcof.lengthto.fields[0].level = myleaf.body.node.nodes[1]->curr_pos.level; myleaf.body.node.nodes[0]->calcof.lengthto.fields[0].pos = myleaf.body.node.nodes[1]->curr_pos.pos; encoded_length += field_msg.RAW_encode(PapAuthResp_msg_descr_, *myleaf.body.node.nodes[1]); return myleaf.length = encoded_length; } struct PapAuthResp_template::single_value_struct { INTEGER_template field_msg__len; CHARSTRING_template field_msg; }; void PapAuthResp_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_msg__len = ANY_VALUE; single_value->field_msg = ANY_VALUE; } } } void PapAuthResp_template::copy_value(const PapAuthResp& other_value) { single_value = new single_value_struct; if (other_value.msg__len().is_bound()) { single_value->field_msg__len = other_value.msg__len(); } else { single_value->field_msg__len.clean_up(); } if (other_value.msg().is_bound()) { single_value->field_msg = other_value.msg(); } else { single_value->field_msg.clean_up(); } set_selection(SPECIFIC_VALUE); } void PapAuthResp_template::copy_template(const PapAuthResp_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.msg__len().get_selection()) { single_value->field_msg__len = other_value.msg__len(); } else { single_value->field_msg__len.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.msg().get_selection()) { single_value->field_msg = other_value.msg(); } else { single_value->field_msg.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 PapAuthResp_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 PapAuthResp_template(*other_value.implication_.precondition); implication_.implied_template = new PapAuthResp_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 @PAP_Types.PapAuthResp."); break; } set_selection(other_value); } PapAuthResp_template::PapAuthResp_template() { } PapAuthResp_template::PapAuthResp_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } PapAuthResp_template::PapAuthResp_template(const PapAuthResp& other_value) { copy_value(other_value); } PapAuthResp_template::PapAuthResp_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const PapAuthResp&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @PAP_Types.PapAuthResp from an unbound optional field."); } } PapAuthResp_template::PapAuthResp_template(PapAuthResp_template* p_precondition, PapAuthResp_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } PapAuthResp_template::PapAuthResp_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } PapAuthResp_template::PapAuthResp_template(const PapAuthResp_template& other_value) : Base_Template() { copy_template(other_value); } PapAuthResp_template::~PapAuthResp_template() { clean_up(); } PapAuthResp_template& PapAuthResp_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } PapAuthResp_template& PapAuthResp_template::operator=(const PapAuthResp& other_value) { clean_up(); copy_value(other_value); return *this; } PapAuthResp_template& PapAuthResp_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const PapAuthResp&)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 @PAP_Types.PapAuthResp."); } return *this; } PapAuthResp_template& PapAuthResp_template::operator=(const PapAuthResp_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean PapAuthResp_template::match(const PapAuthResp& 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.msg__len().is_bound()) return FALSE; if(!single_value->field_msg__len.match(other_value.msg__len(), legacy))return FALSE; if(!other_value.msg().is_bound()) return FALSE; if(!single_value->field_msg.match(other_value.msg(), 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 @PAP_Types.PapAuthResp."); } return FALSE; } boolean PapAuthResp_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_msg__len.is_bound() || single_value->field_msg.is_bound(); } boolean PapAuthResp_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_msg__len.is_value() && single_value->field_msg.is_value(); } void PapAuthResp_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; } PapAuthResp PapAuthResp_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 @PAP_Types.PapAuthResp."); PapAuthResp ret_val; if (single_value->field_msg__len.is_bound()) { ret_val.msg__len() = single_value->field_msg__len.valueof(); } if (single_value->field_msg.is_bound()) { ret_val.msg() = single_value->field_msg.valueof(); } return ret_val; } void PapAuthResp_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 @PAP_Types.PapAuthResp."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new PapAuthResp_template[list_length]; } PapAuthResp_template& PapAuthResp_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 @PAP_Types.PapAuthResp."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @PAP_Types.PapAuthResp."); return value_list.list_value[list_index]; } INTEGER_template& PapAuthResp_template::msg__len() { set_specific(); return single_value->field_msg__len; } const INTEGER_template& PapAuthResp_template::msg__len() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field msg_len of a non-specific template of type @PAP_Types.PapAuthResp."); return single_value->field_msg__len; } CHARSTRING_template& PapAuthResp_template::msg() { set_specific(); return single_value->field_msg; } const CHARSTRING_template& PapAuthResp_template::msg() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field msg of a non-specific template of type @PAP_Types.PapAuthResp."); return single_value->field_msg; } int PapAuthResp_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthResp 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 @PAP_Types.PapAuthResp 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 @PAP_Types.PapAuthResp containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthResp containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthResp containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthResp containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthResp containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthResp containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapAuthResp containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @PAP_Types.PapAuthResp."); } return 0; } void PapAuthResp_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ msg_len := "); single_value->field_msg__len.log(); TTCN_Logger::log_event_str(", msg := "); single_value->field_msg.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 PapAuthResp_template::log_match(const PapAuthResp& 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_msg__len.match(match_value.msg__len(), legacy)){ TTCN_Logger::log_logmatch_info(".msg_len"); single_value->field_msg__len.log_match(match_value.msg__len(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_msg.match(match_value.msg(), legacy)){ TTCN_Logger::log_logmatch_info(".msg"); single_value->field_msg.log_match(match_value.msg(), 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("{ msg_len := "); single_value->field_msg__len.log_match(match_value.msg__len(), legacy); TTCN_Logger::log_event_str(", msg := "); single_value->field_msg.log_match(match_value.msg(), 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 PapAuthResp_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_msg__len.encode_text(text_buf); single_value->field_msg.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 @PAP_Types.PapAuthResp."); } } void PapAuthResp_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_msg__len.decode_text(text_buf); single_value->field_msg.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 PapAuthResp_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 @PAP_Types.PapAuthResp."); } } void PapAuthResp_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: { PapAuthResp_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_i0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) msg__len().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) msg().set_param(*param.get_elem(1)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "msg_len")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { msg__len().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "msg")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { msg().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @PAP_Types.PapAuthResp: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { PapAuthResp_template* precondition = new PapAuthResp_template; precondition->set_param(*param.get_elem(0)); PapAuthResp_template* implied_template = new PapAuthResp_template; implied_template->set_param(*param.get_elem(1)); *this = PapAuthResp_template(precondition, implied_template); } break; default: param.type_error("record template", "@PAP_Types.PapAuthResp"); } is_ifpresent = param.get_ifpresent(); } void PapAuthResp_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_msg__len.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapAuthResp"); single_value->field_msg.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapAuthResp"); 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 : "@PAP_Types.PapAuthResp"); } boolean PapAuthResp_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean PapAuthResp_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_idx0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) code().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) identifier().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) len().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) payload().set_param(*param.get_elem(3)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "code")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { code().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "identifier")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { identifier().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "len")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { len().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "payload")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { payload().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @PAP_Types.PapPacket: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@PAP_Types.PapPacket"); } } void PapPacket::encode_text(Text_Buf& text_buf) const { field_code.encode_text(text_buf); field_identifier.encode_text(text_buf); field_len.encode_text(text_buf); field_payload.encode_text(text_buf); } void PapPacket::decode_text(Text_Buf& text_buf) { field_code.decode_text(text_buf); field_identifier.decode_text(text_buf); field_len.decode_text(text_buf); field_payload.decode_text(text_buf); } void PapPacket::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 PapPacket::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 PapPacket::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit* force_omit) { (void)no_err; int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding); limit-=prepaddlength; size_t last_decoded_pos = p_buf.get_pos_bit(); int decoded_length = 0; int decoded_field_length = 0; raw_order_t local_top_order; int selected_field = -1; if(p_td.raw->top_bit_order==TOP_BIT_INHERITED)local_top_order=top_bit_ord; else if(p_td.raw->top_bit_order==TOP_BIT_RIGHT)local_top_order=ORDER_MSB; else local_top_order=ORDER_LSB; int value_of_length_field2 = 0; RAW_Force_Omit field_0_force_omit(0, force_omit, PapPacket_code_descr_.raw->forceomit); decoded_field_length = field_code.RAW_decode(PapPacket_code_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_0_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); value_of_length_field2 -= decoded_field_length; RAW_Force_Omit field_1_force_omit(1, force_omit, PapPacket_identifier_descr_.raw->forceomit); decoded_field_length = field_identifier.RAW_decode(PapPacket_identifier_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_1_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); value_of_length_field2 -= decoded_field_length; RAW_Force_Omit field_2_force_omit(2, force_omit, PapPacket_len_descr_.raw->forceomit); decoded_field_length = field_len.RAW_decode(PapPacket_len_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_2_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); INTEGER tmp2 = field_len.convert_to_Integer(PapPacket_len_descr_); field_len = tmp2; value_of_length_field2 += tmp2.get_long_long_val() * 8; value_of_length_field2 -= decoded_field_length; if (value_of_length_field2 < 0) return -1; if (field_code == PapCode::PAP__AuthenticateReq) selected_field = 0; else if (field_code == PapCode::PAP__AuthenticateAck) selected_field = 1; else if (field_code == PapCode::PAP__AuthenticateNak) selected_field = 2; else selected_field = -1; RAW_Force_Omit field_3_force_omit(3, force_omit, PapPacket_payload_descr_.raw->forceomit); decoded_field_length = field_payload.RAW_decode(PapPacket_payload_descr_, p_buf, min_of_ints(2, limit, value_of_length_field2), local_top_order, no_err, selected_field, TRUE, &field_3_force_omit); if (decoded_field_length < 0) return decoded_field_length; decoded_length+=decoded_field_length; limit-=decoded_field_length; last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit()); value_of_length_field2 -= decoded_field_length; p_buf.set_pos_bit(last_decoded_pos); return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding); } int PapPacket::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const { if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value."); int encoded_length = 0; myleaf.isleaf = FALSE; myleaf.body.node.num_of_nodes = 4; myleaf.body.node.nodes = init_nodes_of_enc_tree(4); myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, PapPacket_code_descr_.raw); myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, PapPacket_identifier_descr_.raw); myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, PapPacket_len_descr_.raw); myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, PapPacket_payload_descr_.raw); encoded_length += field_code.RAW_encode(PapPacket_code_descr_, *myleaf.body.node.nodes[0]); encoded_length += field_identifier.RAW_encode(PapPacket_identifier_descr_, *myleaf.body.node.nodes[1]); encoded_length += 16; myleaf.body.node.nodes[2]->calc = CALC_LENGTH; myleaf.body.node.nodes[2]->coding_descr = &PapPacket_len_descr_; myleaf.body.node.nodes[2]->calcof.lengthto.num_of_fields = 4; myleaf.body.node.nodes[2]->calcof.lengthto.unit = 8; myleaf.body.node.nodes[2]->calcof.lengthto.offset = 0; myleaf.body.node.nodes[2]->calcof.lengthto.fields = init_lengthto_fields_list(4); myleaf.body.node.nodes[2]->length = 16; myleaf.body.node.nodes[2]->calcof.lengthto.fields[0].level = myleaf.body.node.nodes[0]->curr_pos.level; myleaf.body.node.nodes[2]->calcof.lengthto.fields[0].pos = myleaf.body.node.nodes[0]->curr_pos.pos; myleaf.body.node.nodes[2]->calcof.lengthto.fields[1].level = myleaf.body.node.nodes[1]->curr_pos.level; myleaf.body.node.nodes[2]->calcof.lengthto.fields[1].pos = myleaf.body.node.nodes[1]->curr_pos.pos; myleaf.body.node.nodes[2]->calcof.lengthto.fields[2].level = myleaf.body.node.nodes[2]->curr_pos.level; myleaf.body.node.nodes[2]->calcof.lengthto.fields[2].pos = myleaf.body.node.nodes[2]->curr_pos.pos; myleaf.body.node.nodes[2]->calcof.lengthto.fields[3].level = myleaf.body.node.nodes[3]->curr_pos.level; myleaf.body.node.nodes[2]->calcof.lengthto.fields[3].pos = myleaf.body.node.nodes[3]->curr_pos.pos; encoded_length += field_payload.RAW_encode(PapPacket_payload_descr_, *myleaf.body.node.nodes[3]); switch (field_payload.get_selection()) { case PapPayloadUnion::ALT_req: if (field_code != PapCode::PAP__AuthenticateReq) { RAW_enc_tr_pos pr_pos; pr_pos.level = myleaf.curr_pos.level + 1; int new_pos[] = { 0 }; pr_pos.pos = init_new_tree_pos(myleaf.curr_pos, 1, new_pos); PapCode new_val(PapCode::PAP__AuthenticateReq); RAW_enc_tree* temp_leaf = myleaf.get_node(pr_pos); if (temp_leaf != NULL) new_val.RAW_encode(PapPacket_code_descr_,*temp_leaf); else TTCN_EncDec_ErrorContext::error (TTCN_EncDec::ET_OMITTED_TAG, "Encoding a tagged, but omitted value."); free_tree_pos(pr_pos.pos); } break; case PapPayloadUnion::ALT_ack: if (field_code != PapCode::PAP__AuthenticateAck) { RAW_enc_tr_pos pr_pos; pr_pos.level = myleaf.curr_pos.level + 1; int new_pos[] = { 0 }; pr_pos.pos = init_new_tree_pos(myleaf.curr_pos, 1, new_pos); PapCode new_val(PapCode::PAP__AuthenticateAck); RAW_enc_tree* temp_leaf = myleaf.get_node(pr_pos); if (temp_leaf != NULL) new_val.RAW_encode(PapPacket_code_descr_,*temp_leaf); else TTCN_EncDec_ErrorContext::error (TTCN_EncDec::ET_OMITTED_TAG, "Encoding a tagged, but omitted value."); free_tree_pos(pr_pos.pos); } break; case PapPayloadUnion::ALT_nak: if (field_code != PapCode::PAP__AuthenticateNak) { RAW_enc_tr_pos pr_pos; pr_pos.level = myleaf.curr_pos.level + 1; int new_pos[] = { 0 }; pr_pos.pos = init_new_tree_pos(myleaf.curr_pos, 1, new_pos); PapCode new_val(PapCode::PAP__AuthenticateNak); RAW_enc_tree* temp_leaf = myleaf.get_node(pr_pos); if (temp_leaf != NULL) new_val.RAW_encode(PapPacket_code_descr_,*temp_leaf); else TTCN_EncDec_ErrorContext::error (TTCN_EncDec::ET_OMITTED_TAG, "Encoding a tagged, but omitted value."); free_tree_pos(pr_pos.pos); } break; default:; } return myleaf.length = encoded_length; } struct PapPacket_template::single_value_struct { PapCode_template field_code; INTEGER_template field_identifier; INTEGER_template field_len; PapPayloadUnion_template field_payload; }; void PapPacket_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_code = ANY_VALUE; single_value->field_identifier = ANY_VALUE; single_value->field_len = ANY_VALUE; single_value->field_payload = ANY_VALUE; } } } void PapPacket_template::copy_value(const PapPacket& other_value) { single_value = new single_value_struct; if (other_value.code().is_bound()) { single_value->field_code = other_value.code(); } else { single_value->field_code.clean_up(); } if (other_value.identifier().is_bound()) { single_value->field_identifier = other_value.identifier(); } else { single_value->field_identifier.clean_up(); } if (other_value.len().is_bound()) { single_value->field_len = other_value.len(); } else { single_value->field_len.clean_up(); } if (other_value.payload().is_bound()) { single_value->field_payload = other_value.payload(); } else { single_value->field_payload.clean_up(); } set_selection(SPECIFIC_VALUE); } void PapPacket_template::copy_template(const PapPacket_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.code().get_selection()) { single_value->field_code = other_value.code(); } else { single_value->field_code.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.identifier().get_selection()) { single_value->field_identifier = other_value.identifier(); } else { single_value->field_identifier.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.len().get_selection()) { single_value->field_len = other_value.len(); } else { single_value->field_len.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.payload().get_selection()) { single_value->field_payload = other_value.payload(); } else { single_value->field_payload.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 PapPacket_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 PapPacket_template(*other_value.implication_.precondition); implication_.implied_template = new PapPacket_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 @PAP_Types.PapPacket."); break; } set_selection(other_value); } PapPacket_template::PapPacket_template() { } PapPacket_template::PapPacket_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } PapPacket_template::PapPacket_template(const PapPacket& other_value) { copy_value(other_value); } PapPacket_template::PapPacket_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const PapPacket&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @PAP_Types.PapPacket from an unbound optional field."); } } PapPacket_template::PapPacket_template(PapPacket_template* p_precondition, PapPacket_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } PapPacket_template::PapPacket_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } PapPacket_template::PapPacket_template(const PapPacket_template& other_value) : Base_Template() { copy_template(other_value); } PapPacket_template::~PapPacket_template() { clean_up(); } PapPacket_template& PapPacket_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } PapPacket_template& PapPacket_template::operator=(const PapPacket& other_value) { clean_up(); copy_value(other_value); return *this; } PapPacket_template& PapPacket_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const PapPacket&)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 @PAP_Types.PapPacket."); } return *this; } PapPacket_template& PapPacket_template::operator=(const PapPacket_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean PapPacket_template::match(const PapPacket& 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.code().is_bound()) return FALSE; if(!single_value->field_code.match(other_value.code(), legacy))return FALSE; if(!other_value.identifier().is_bound()) return FALSE; if(!single_value->field_identifier.match(other_value.identifier(), legacy))return FALSE; if(!other_value.len().is_bound()) return FALSE; if(!single_value->field_len.match(other_value.len(), legacy))return FALSE; if(!other_value.payload().is_bound()) return FALSE; if(!single_value->field_payload.match(other_value.payload(), 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 @PAP_Types.PapPacket."); } return FALSE; } boolean PapPacket_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_code.is_bound() || single_value->field_identifier.is_bound() || single_value->field_len.is_bound() || single_value->field_payload.is_bound(); } boolean PapPacket_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_code.is_value() && single_value->field_identifier.is_value() && single_value->field_len.is_value() && single_value->field_payload.is_value(); } void PapPacket_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; } PapPacket PapPacket_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 @PAP_Types.PapPacket."); PapPacket ret_val; if (single_value->field_code.is_bound()) { ret_val.code() = single_value->field_code.valueof(); } if (single_value->field_identifier.is_bound()) { ret_val.identifier() = single_value->field_identifier.valueof(); } if (single_value->field_len.is_bound()) { ret_val.len() = single_value->field_len.valueof(); } if (single_value->field_payload.is_bound()) { ret_val.payload() = single_value->field_payload.valueof(); } return ret_val; } void PapPacket_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 @PAP_Types.PapPacket."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new PapPacket_template[list_length]; } PapPacket_template& PapPacket_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 @PAP_Types.PapPacket."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @PAP_Types.PapPacket."); return value_list.list_value[list_index]; } PapCode_template& PapPacket_template::code() { set_specific(); return single_value->field_code; } const PapCode_template& PapPacket_template::code() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field code of a non-specific template of type @PAP_Types.PapPacket."); return single_value->field_code; } INTEGER_template& PapPacket_template::identifier() { set_specific(); return single_value->field_identifier; } const INTEGER_template& PapPacket_template::identifier() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field identifier of a non-specific template of type @PAP_Types.PapPacket."); return single_value->field_identifier; } INTEGER_template& PapPacket_template::len() { set_specific(); return single_value->field_len; } const INTEGER_template& PapPacket_template::len() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field len of a non-specific template of type @PAP_Types.PapPacket."); return single_value->field_len; } PapPayloadUnion_template& PapPacket_template::payload() { set_specific(); return single_value->field_payload; } const PapPayloadUnion_template& PapPacket_template::payload() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field payload of a non-specific template of type @PAP_Types.PapPacket."); return single_value->field_payload; } int PapPacket_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapPacket 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 @PAP_Types.PapPacket 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 @PAP_Types.PapPacket containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapPacket containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapPacket containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapPacket containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapPacket containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapPacket containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @PAP_Types.PapPacket containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @PAP_Types.PapPacket."); } return 0; } void PapPacket_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ code := "); single_value->field_code.log(); TTCN_Logger::log_event_str(", identifier := "); single_value->field_identifier.log(); TTCN_Logger::log_event_str(", len := "); single_value->field_len.log(); TTCN_Logger::log_event_str(", payload := "); single_value->field_payload.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 PapPacket_template::log_match(const PapPacket& 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_code.match(match_value.code(), legacy)){ TTCN_Logger::log_logmatch_info(".code"); single_value->field_code.log_match(match_value.code(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_identifier.match(match_value.identifier(), legacy)){ TTCN_Logger::log_logmatch_info(".identifier"); single_value->field_identifier.log_match(match_value.identifier(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_len.match(match_value.len(), legacy)){ TTCN_Logger::log_logmatch_info(".len"); single_value->field_len.log_match(match_value.len(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_payload.match(match_value.payload(), legacy)){ TTCN_Logger::log_logmatch_info(".payload"); single_value->field_payload.log_match(match_value.payload(), 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("{ code := "); single_value->field_code.log_match(match_value.code(), legacy); TTCN_Logger::log_event_str(", identifier := "); single_value->field_identifier.log_match(match_value.identifier(), legacy); TTCN_Logger::log_event_str(", len := "); single_value->field_len.log_match(match_value.len(), legacy); TTCN_Logger::log_event_str(", payload := "); single_value->field_payload.log_match(match_value.payload(), 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 PapPacket_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_code.encode_text(text_buf); single_value->field_identifier.encode_text(text_buf); single_value->field_len.encode_text(text_buf); single_value->field_payload.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 @PAP_Types.PapPacket."); } } void PapPacket_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_code.decode_text(text_buf); single_value->field_identifier.decode_text(text_buf); single_value->field_len.decode_text(text_buf); single_value->field_payload.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 PapPacket_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 @PAP_Types.PapPacket."); } } void PapPacket_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: { PapPacket_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_i0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) code().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) identifier().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) len().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) payload().set_param(*param.get_elem(3)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "code")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { code().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "identifier")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { identifier().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "len")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { len().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "payload")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { payload().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @PAP_Types.PapPacket: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { PapPacket_template* precondition = new PapPacket_template; precondition->set_param(*param.get_elem(0)); PapPacket_template* implied_template = new PapPacket_template; implied_template->set_param(*param.get_elem(1)); *this = PapPacket_template(precondition, implied_template); } break; default: param.type_error("record template", "@PAP_Types.PapPacket"); } is_ifpresent = param.get_ifpresent(); } void PapPacket_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_code.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapPacket"); single_value->field_identifier.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapPacket"); single_value->field_len.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapPacket"); single_value->field_payload.check_restriction(t_res, t_name ? t_name : "@PAP_Types.PapPacket"); 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 : "@PAP_Types.PapPacket"); } boolean PapPacket_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean PapPacket_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