// 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 "UDP_Types.hh" namespace UDP__Types { /* Literal string constants */ const unsigned char module_checksum[] = { 0x69, 0xb0, 0xb4, 0x87, 0x6b, 0x79, 0x35, 0x7d, 0x6b, 0xb4, 0xd7, 0x46, 0xfd, 0xa3, 0x3d, 0xc9 }; /* Global variable definitions */ const TTCN_RAWdescriptor_t UDP__header_srcport_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 UDP__header_srcport_xer_ = { {"srcport>\n", "srcport>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__header_srcport_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__header_srcport_descr_ = { "@UDP_Types.UDP_header.srcport", &INTEGER_ber_, &UDP__header_srcport_raw_, &INTEGER_text_, &UDP__header_srcport_xer_, &INTEGER_json_, &UDP__header_srcport_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__header_srcport_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__header_dstport_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 UDP__header_dstport_xer_ = { {"dstport>\n", "dstport>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__header_dstport_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__header_dstport_descr_ = { "@UDP_Types.UDP_header.dstport", &INTEGER_ber_, &UDP__header_dstport_raw_, &INTEGER_text_, &UDP__header_dstport_xer_, &INTEGER_json_, &UDP__header_dstport_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__header_dstport_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__header_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 UDP__header_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 UDP__header_len_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__header_len_descr_ = { "@UDP_Types.UDP_header.len", &INTEGER_ber_, &UDP__header_len_raw_, &INTEGER_text_, &UDP__header_len_xer_, &INTEGER_json_, &UDP__header_len_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__header_len_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__header_cksum_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 UDP__header_cksum_xer_ = { {"cksum>\n", "cksum>\n"}, {7, 7}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__header_cksum_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__header_cksum_descr_ = { "@UDP_Types.UDP_header.cksum", &INTEGER_ber_, &UDP__header_cksum_raw_, &INTEGER_text_, &UDP__header_cksum_xer_, &INTEGER_json_, &UDP__header_cksum_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__header_cksum_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__header_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 UDP__header const TTCN_Typedescriptor_t UDP__header_descr_ = { "@UDP_Types.UDP_header", NULL, &UDP__header_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__header_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__packet_header_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 UDP__packet_header const TTCN_Typedescriptor_t UDP__packet_header_descr_ = { "@UDP_Types.UDP_packet.header", NULL, &UDP__packet_header_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__packet_header_default_coding("RAW"); const XERdescriptor_t UDP__packet_payload_xer_ = { {"payload>\n", "payload>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const int UDP__packet_payload_oer_ext_arr_[0] = {}; const int UDP__packet_payload_oer_p_[0] = {}; const TTCN_OERdescriptor_t UDP__packet_payload_oer_ = { -1, TRUE, -1, FALSE, 0, 0, UDP__packet_payload_oer_ext_arr_, 0, UDP__packet_payload_oer_p_}; const TTCN_Typedescriptor_t UDP__packet_payload_descr_ = { "@UDP_Types.UDP_packet.payload", &OCTETSTRING_ber_, &OCTETSTRING_raw_, &OCTETSTRING_text_, &UDP__packet_payload_xer_, &OCTETSTRING_json_, &UDP__packet_payload_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__packet_payload_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__packet_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; // No XER for UDP__packet const TTCN_Typedescriptor_t UDP__packet_descr_ = { "@UDP_Types.UDP_packet", NULL, &UDP__packet_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__packet_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header_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 UDP__pseudo__header const TTCN_Typedescriptor_t UDP__pseudo__header_descr_ = { "@UDP_Types.UDP_pseudo_header", NULL, &UDP__pseudo__header_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv4_srcaddr_raw_ = {32,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,4,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t UDP__pseudo__header__IPv4_srcaddr_xer_ = { {"srcaddr>\n", "srcaddr>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const int UDP__pseudo__header__IPv4_srcaddr_oer_ext_arr_[0] = {}; const int UDP__pseudo__header__IPv4_srcaddr_oer_p_[0] = {}; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv4_srcaddr_oer_ = { -1, TRUE, 4, FALSE, 0, 0, UDP__pseudo__header__IPv4_srcaddr_oer_ext_arr_, 0, UDP__pseudo__header__IPv4_srcaddr_oer_p_}; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv4_srcaddr_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv4.srcaddr", &OCTETSTRING_ber_, &UDP__pseudo__header__IPv4_srcaddr_raw_, &OCTETSTRING_text_, &UDP__pseudo__header__IPv4_srcaddr_xer_, &OCTETSTRING_json_, &UDP__pseudo__header__IPv4_srcaddr_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv4_srcaddr_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv4_dstaddr_raw_ = {32,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,4,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t UDP__pseudo__header__IPv4_dstaddr_xer_ = { {"dstaddr>\n", "dstaddr>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const int UDP__pseudo__header__IPv4_dstaddr_oer_ext_arr_[0] = {}; const int UDP__pseudo__header__IPv4_dstaddr_oer_p_[0] = {}; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv4_dstaddr_oer_ = { -1, TRUE, 4, FALSE, 0, 0, UDP__pseudo__header__IPv4_dstaddr_oer_ext_arr_, 0, UDP__pseudo__header__IPv4_dstaddr_oer_p_}; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv4_dstaddr_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv4.dstaddr", &OCTETSTRING_ber_, &UDP__pseudo__header__IPv4_dstaddr_raw_, &OCTETSTRING_text_, &UDP__pseudo__header__IPv4_dstaddr_xer_, &OCTETSTRING_json_, &UDP__pseudo__header__IPv4_dstaddr_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv4_dstaddr_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv4_zero_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}; const XERdescriptor_t UDP__pseudo__header__IPv4_zero_xer_ = { {"zero>\n", "zero>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv4_zero_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv4_zero_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv4.zero", &INTEGER_ber_, &UDP__pseudo__header__IPv4_zero_raw_, &INTEGER_text_, &UDP__pseudo__header__IPv4_zero_xer_, &INTEGER_json_, &UDP__pseudo__header__IPv4_zero_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv4_zero_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv4_proto_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}; const XERdescriptor_t UDP__pseudo__header__IPv4_proto_xer_ = { {"proto>\n", "proto>\n"}, {7, 7}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv4_proto_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv4_proto_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv4.proto", &INTEGER_ber_, &UDP__pseudo__header__IPv4_proto_raw_, &INTEGER_text_, &UDP__pseudo__header__IPv4_proto_xer_, &INTEGER_json_, &UDP__pseudo__header__IPv4_proto_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv4_proto_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv4_plen_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 UDP__pseudo__header__IPv4_plen_xer_ = { {"plen>\n", "plen>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv4_plen_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv4_plen_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv4.plen", &INTEGER_ber_, &UDP__pseudo__header__IPv4_plen_raw_, &INTEGER_text_, &UDP__pseudo__header__IPv4_plen_xer_, &INTEGER_json_, &UDP__pseudo__header__IPv4_plen_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv4_plen_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv4_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 UDP__pseudo__header__IPv4 const TTCN_Typedescriptor_t UDP__pseudo__header__IPv4_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv4", NULL, &UDP__pseudo__header__IPv4_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv4_default_coding("RAW"); UNIVERSAL_CHARSTRING UDP__pseudo__header_ipv4_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv6_srcaddr_raw_ = {128,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,16,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t UDP__pseudo__header__IPv6_srcaddr_xer_ = { {"srcaddr>\n", "srcaddr>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const int UDP__pseudo__header__IPv6_srcaddr_oer_ext_arr_[0] = {}; const int UDP__pseudo__header__IPv6_srcaddr_oer_p_[0] = {}; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv6_srcaddr_oer_ = { -1, TRUE, 16, FALSE, 0, 0, UDP__pseudo__header__IPv6_srcaddr_oer_ext_arr_, 0, UDP__pseudo__header__IPv6_srcaddr_oer_p_}; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv6_srcaddr_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv6.srcaddr", &OCTETSTRING_ber_, &UDP__pseudo__header__IPv6_srcaddr_raw_, &OCTETSTRING_text_, &UDP__pseudo__header__IPv6_srcaddr_xer_, &OCTETSTRING_json_, &UDP__pseudo__header__IPv6_srcaddr_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv6_srcaddr_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv6_dstaddr_raw_ = {128,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,16,CharCoding::UNKNOWN,NULL,false}; const XERdescriptor_t UDP__pseudo__header__IPv6_dstaddr_xer_ = { {"dstaddr>\n", "dstaddr>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const int UDP__pseudo__header__IPv6_dstaddr_oer_ext_arr_[0] = {}; const int UDP__pseudo__header__IPv6_dstaddr_oer_p_[0] = {}; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv6_dstaddr_oer_ = { -1, TRUE, 16, FALSE, 0, 0, UDP__pseudo__header__IPv6_dstaddr_oer_ext_arr_, 0, UDP__pseudo__header__IPv6_dstaddr_oer_p_}; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv6_dstaddr_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv6.dstaddr", &OCTETSTRING_ber_, &UDP__pseudo__header__IPv6_dstaddr_raw_, &OCTETSTRING_text_, &UDP__pseudo__header__IPv6_dstaddr_xer_, &OCTETSTRING_json_, &UDP__pseudo__header__IPv6_dstaddr_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv6_dstaddr_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv6_plen_raw_ = {32,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 UDP__pseudo__header__IPv6_plen_xer_ = { {"plen>\n", "plen>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv6_plen_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv6_plen_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv6.plen", &INTEGER_ber_, &UDP__pseudo__header__IPv6_plen_raw_, &INTEGER_text_, &UDP__pseudo__header__IPv6_plen_xer_, &INTEGER_json_, &UDP__pseudo__header__IPv6_plen_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv6_plen_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv6_zero_raw_ = {24,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 UDP__pseudo__header__IPv6_zero_xer_ = { {"zero>\n", "zero>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv6_zero_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv6_zero_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv6.zero", &INTEGER_ber_, &UDP__pseudo__header__IPv6_zero_raw_, &INTEGER_text_, &UDP__pseudo__header__IPv6_zero_xer_, &INTEGER_json_, &UDP__pseudo__header__IPv6_zero_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv6_zero_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv6_nextheader_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}; const XERdescriptor_t UDP__pseudo__header__IPv6_nextheader_xer_ = { {"nextheader>\n", "nextheader>\n"}, {12, 12}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t UDP__pseudo__header__IPv6_nextheader_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t UDP__pseudo__header__IPv6_nextheader_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv6.nextheader", &INTEGER_ber_, &UDP__pseudo__header__IPv6_nextheader_raw_, &INTEGER_text_, &UDP__pseudo__header__IPv6_nextheader_xer_, &INTEGER_json_, &UDP__pseudo__header__IPv6_nextheader_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv6_nextheader_default_coding("RAW"); const TTCN_RAWdescriptor_t UDP__pseudo__header__IPv6_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 UDP__pseudo__header__IPv6 const TTCN_Typedescriptor_t UDP__pseudo__header__IPv6_descr_ = { "@UDP_Types.UDP_pseudo_header_IPv6", NULL, &UDP__pseudo__header__IPv6_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING UDP__pseudo__header__IPv6_default_coding("RAW"); UNIVERSAL_CHARSTRING UDP__pseudo__header_ipv6_default_coding("RAW"); UNIVERSAL_CHARSTRING UDP__pseudo__header_default_coding("RAW"); TTCN_Module module_object("UDP_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 */ UDP__header::UDP__header() { } UDP__header::UDP__header(const INTEGER& par_srcport, const INTEGER& par_dstport, const INTEGER& par_len, const INTEGER& par_cksum) : field_srcport(par_srcport), field_dstport(par_dstport), field_len(par_len), field_cksum(par_cksum) { } UDP__header::UDP__header(const UDP__header& other_value) { if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @UDP_Types.UDP_header."); if (other_value.srcport().is_bound()) field_srcport = other_value.srcport(); else field_srcport.clean_up(); if (other_value.dstport().is_bound()) field_dstport = other_value.dstport(); else field_dstport.clean_up(); if (other_value.len().is_bound()) field_len = other_value.len(); else field_len.clean_up(); if (other_value.cksum().is_bound()) field_cksum = other_value.cksum(); else field_cksum.clean_up(); } void UDP__header::clean_up() { field_srcport.clean_up(); field_dstport.clean_up(); field_len.clean_up(); field_cksum.clean_up(); } const TTCN_Typedescriptor_t* UDP__header::get_descriptor() const { return &UDP__header_descr_; } UDP__header& UDP__header::operator=(const UDP__header& other_value) { if (this != &other_value) { if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @UDP_Types.UDP_header."); if (other_value.srcport().is_bound()) field_srcport = other_value.srcport(); else field_srcport.clean_up(); if (other_value.dstport().is_bound()) field_dstport = other_value.dstport(); else field_dstport.clean_up(); if (other_value.len().is_bound()) field_len = other_value.len(); else field_len.clean_up(); if (other_value.cksum().is_bound()) field_cksum = other_value.cksum(); else field_cksum.clean_up(); } return *this; } boolean UDP__header::operator==(const UDP__header& other_value) const { return field_srcport==other_value.field_srcport && field_dstport==other_value.field_dstport && field_len==other_value.field_len && field_cksum==other_value.field_cksum; } boolean UDP__header::is_bound() const { return (field_srcport.is_bound()) || (field_dstport.is_bound()) || (field_len.is_bound()) || (field_cksum.is_bound()); } boolean UDP__header::is_value() const { return field_srcport.is_value() && field_dstport.is_value() && field_len.is_value() && field_cksum.is_value(); } void UDP__header::log() const { if (!is_bound()) { TTCN_Logger::log_event_unbound(); return; } TTCN_Logger::log_event_str("{ srcport := "); field_srcport.log(); TTCN_Logger::log_event_str(", dstport := "); field_dstport.log(); TTCN_Logger::log_event_str(", len := "); field_len.log(); TTCN_Logger::log_event_str(", cksum := "); field_cksum.log(); TTCN_Logger::log_event_str(" }"); } void UDP__header::set_implicit_omit() { if (srcport().is_bound()) srcport().set_implicit_omit(); if (dstport().is_bound()) dstport().set_implicit_omit(); if (len().is_bound()) len().set_implicit_omit(); if (cksum().is_bound()) cksum().set_implicit_omit(); } void UDP__header::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) srcport().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) dstport().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) cksum().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(), "srcport")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { srcport().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "dstport")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { dstport().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(), "cksum")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { cksum().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @UDP_Types.UDP_header: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@UDP_Types.UDP_header"); } } void UDP__header::encode_text(Text_Buf& text_buf) const { field_srcport.encode_text(text_buf); field_dstport.encode_text(text_buf); field_len.encode_text(text_buf); field_cksum.encode_text(text_buf); } void UDP__header::decode_text(Text_Buf& text_buf) { field_srcport.decode_text(text_buf); field_dstport.decode_text(text_buf); field_len.decode_text(text_buf); field_cksum.decode_text(text_buf); } void UDP__header::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 UDP__header::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 UDP__header::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; RAW_Force_Omit field_0_force_omit(0, force_omit, UDP__header_srcport_descr_.raw->forceomit); decoded_field_length = field_srcport.RAW_decode(UDP__header_srcport_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()); RAW_Force_Omit field_1_force_omit(1, force_omit, UDP__header_dstport_descr_.raw->forceomit); decoded_field_length = field_dstport.RAW_decode(UDP__header_dstport_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()); RAW_Force_Omit field_2_force_omit(2, force_omit, UDP__header_len_descr_.raw->forceomit); decoded_field_length = field_len.RAW_decode(UDP__header_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()); RAW_Force_Omit field_3_force_omit(3, force_omit, UDP__header_cksum_descr_.raw->forceomit); decoded_field_length = field_cksum.RAW_decode(UDP__header_cksum_descr_, p_buf, limit, 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()); p_buf.set_pos_bit(last_decoded_pos); return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding); } int UDP__header::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, UDP__header_srcport_descr_.raw); myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, UDP__header_dstport_descr_.raw); myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, UDP__header_len_descr_.raw); myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, UDP__header_cksum_descr_.raw); encoded_length += field_srcport.RAW_encode(UDP__header_srcport_descr_, *myleaf.body.node.nodes[0]); encoded_length += field_dstport.RAW_encode(UDP__header_dstport_descr_, *myleaf.body.node.nodes[1]); encoded_length += field_len.RAW_encode(UDP__header_len_descr_, *myleaf.body.node.nodes[2]); encoded_length += field_cksum.RAW_encode(UDP__header_cksum_descr_, *myleaf.body.node.nodes[3]); return myleaf.length = encoded_length; } struct UDP__header_template::single_value_struct { INTEGER_template field_srcport; INTEGER_template field_dstport; INTEGER_template field_len; INTEGER_template field_cksum; }; void UDP__header_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_srcport = ANY_VALUE; single_value->field_dstport = ANY_VALUE; single_value->field_len = ANY_VALUE; single_value->field_cksum = ANY_VALUE; } } } void UDP__header_template::copy_value(const UDP__header& other_value) { single_value = new single_value_struct; if (other_value.srcport().is_bound()) { single_value->field_srcport = other_value.srcport(); } else { single_value->field_srcport.clean_up(); } if (other_value.dstport().is_bound()) { single_value->field_dstport = other_value.dstport(); } else { single_value->field_dstport.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.cksum().is_bound()) { single_value->field_cksum = other_value.cksum(); } else { single_value->field_cksum.clean_up(); } set_selection(SPECIFIC_VALUE); } void UDP__header_template::copy_template(const UDP__header_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.srcport().get_selection()) { single_value->field_srcport = other_value.srcport(); } else { single_value->field_srcport.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.dstport().get_selection()) { single_value->field_dstport = other_value.dstport(); } else { single_value->field_dstport.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.cksum().get_selection()) { single_value->field_cksum = other_value.cksum(); } else { single_value->field_cksum.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 UDP__header_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 UDP__header_template(*other_value.implication_.precondition); implication_.implied_template = new UDP__header_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 @UDP_Types.UDP_header."); break; } set_selection(other_value); } UDP__header_template::UDP__header_template() { } UDP__header_template::UDP__header_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } UDP__header_template::UDP__header_template(const UDP__header& other_value) { copy_value(other_value); } UDP__header_template::UDP__header_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__header&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @UDP_Types.UDP_header from an unbound optional field."); } } UDP__header_template::UDP__header_template(UDP__header_template* p_precondition, UDP__header_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } UDP__header_template::UDP__header_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; } UDP__header_template::UDP__header_template(const UDP__header_template& other_value) : Base_Template() { copy_template(other_value); } UDP__header_template::~UDP__header_template() { clean_up(); } UDP__header_template& UDP__header_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } UDP__header_template& UDP__header_template::operator=(const UDP__header& other_value) { clean_up(); copy_value(other_value); return *this; } UDP__header_template& UDP__header_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__header&)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 @UDP_Types.UDP_header."); } return *this; } UDP__header_template& UDP__header_template::operator=(const UDP__header_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean UDP__header_template::match(const UDP__header& 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.srcport().is_bound()) return FALSE; if(!single_value->field_srcport.match(other_value.srcport(), legacy))return FALSE; if(!other_value.dstport().is_bound()) return FALSE; if(!single_value->field_dstport.match(other_value.dstport(), 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.cksum().is_bound()) return FALSE; if(!single_value->field_cksum.match(other_value.cksum(), 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 @UDP_Types.UDP_header."); } return FALSE; } boolean UDP__header_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_srcport.is_bound() || single_value->field_dstport.is_bound() || single_value->field_len.is_bound() || single_value->field_cksum.is_bound(); } boolean UDP__header_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_srcport.is_value() && single_value->field_dstport.is_value() && single_value->field_len.is_value() && single_value->field_cksum.is_value(); } void UDP__header_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; } UDP__header UDP__header_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 @UDP_Types.UDP_header."); UDP__header ret_val; if (single_value->field_srcport.is_bound()) { ret_val.srcport() = single_value->field_srcport.valueof(); } if (single_value->field_dstport.is_bound()) { ret_val.dstport() = single_value->field_dstport.valueof(); } if (single_value->field_len.is_bound()) { ret_val.len() = single_value->field_len.valueof(); } if (single_value->field_cksum.is_bound()) { ret_val.cksum() = single_value->field_cksum.valueof(); } return ret_val; } void UDP__header_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 @UDP_Types.UDP_header."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new UDP__header_template[list_length]; } UDP__header_template& UDP__header_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 @UDP_Types.UDP_header."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @UDP_Types.UDP_header."); return value_list.list_value[list_index]; } INTEGER_template& UDP__header_template::srcport() { set_specific(); return single_value->field_srcport; } const INTEGER_template& UDP__header_template::srcport() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field srcport of a non-specific template of type @UDP_Types.UDP_header."); return single_value->field_srcport; } INTEGER_template& UDP__header_template::dstport() { set_specific(); return single_value->field_dstport; } const INTEGER_template& UDP__header_template::dstport() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field dstport of a non-specific template of type @UDP_Types.UDP_header."); return single_value->field_dstport; } INTEGER_template& UDP__header_template::len() { set_specific(); return single_value->field_len; } const INTEGER_template& UDP__header_template::len() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field len of a non-specific template of type @UDP_Types.UDP_header."); return single_value->field_len; } INTEGER_template& UDP__header_template::cksum() { set_specific(); return single_value->field_cksum; } const INTEGER_template& UDP__header_template::cksum() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field cksum of a non-specific template of type @UDP_Types.UDP_header."); return single_value->field_cksum; } int UDP__header_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_header 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 @UDP_Types.UDP_header 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 @UDP_Types.UDP_header containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_header containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_header containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_header containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_header containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_header containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_header containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @UDP_Types.UDP_header."); } return 0; } void UDP__header_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ srcport := "); single_value->field_srcport.log(); TTCN_Logger::log_event_str(", dstport := "); single_value->field_dstport.log(); TTCN_Logger::log_event_str(", len := "); single_value->field_len.log(); TTCN_Logger::log_event_str(", cksum := "); single_value->field_cksum.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 UDP__header_template::log_match(const UDP__header& 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_srcport.match(match_value.srcport(), legacy)){ TTCN_Logger::log_logmatch_info(".srcport"); single_value->field_srcport.log_match(match_value.srcport(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_dstport.match(match_value.dstport(), legacy)){ TTCN_Logger::log_logmatch_info(".dstport"); single_value->field_dstport.log_match(match_value.dstport(), 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_cksum.match(match_value.cksum(), legacy)){ TTCN_Logger::log_logmatch_info(".cksum"); single_value->field_cksum.log_match(match_value.cksum(), 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("{ srcport := "); single_value->field_srcport.log_match(match_value.srcport(), legacy); TTCN_Logger::log_event_str(", dstport := "); single_value->field_dstport.log_match(match_value.dstport(), legacy); TTCN_Logger::log_event_str(", len := "); single_value->field_len.log_match(match_value.len(), legacy); TTCN_Logger::log_event_str(", cksum := "); single_value->field_cksum.log_match(match_value.cksum(), 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 UDP__header_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_srcport.encode_text(text_buf); single_value->field_dstport.encode_text(text_buf); single_value->field_len.encode_text(text_buf); single_value->field_cksum.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 @UDP_Types.UDP_header."); } } void UDP__header_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_srcport.decode_text(text_buf); single_value->field_dstport.decode_text(text_buf); single_value->field_len.decode_text(text_buf); single_value->field_cksum.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 UDP__header_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 @UDP_Types.UDP_header."); } } void UDP__header_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: { UDP__header_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) srcport().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) dstport().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) cksum().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(), "srcport")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { srcport().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "dstport")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { dstport().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(), "cksum")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { cksum().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @UDP_Types.UDP_header: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { UDP__header_template* precondition = new UDP__header_template; precondition->set_param(*param.get_elem(0)); UDP__header_template* implied_template = new UDP__header_template; implied_template->set_param(*param.get_elem(1)); *this = UDP__header_template(precondition, implied_template); } break; default: param.type_error("record template", "@UDP_Types.UDP_header"); } is_ifpresent = param.get_ifpresent(); } void UDP__header_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_srcport.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_header"); single_value->field_dstport.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_header"); single_value->field_len.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_header"); single_value->field_cksum.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_header"); 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 : "@UDP_Types.UDP_header"); } boolean UDP__header_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean UDP__header_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) header().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) payload().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(), "header")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { header().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 @UDP_Types.UDP_packet: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@UDP_Types.UDP_packet"); } } void UDP__packet::encode_text(Text_Buf& text_buf) const { field_header.encode_text(text_buf); field_payload.encode_text(text_buf); } void UDP__packet::decode_text(Text_Buf& text_buf) { field_header.decode_text(text_buf); field_payload.decode_text(text_buf); } void UDP__packet::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 UDP__packet::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 UDP__packet::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, UDP__packet_header_descr_.raw->forceomit); decoded_field_length = field_header.RAW_decode(UDP__packet_header_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 tmp = field_header.len().convert_to_Integer(UDP__header_len_descr_); field_header.len() = tmp; value_of_length_field0 += tmp.get_long_long_val() * 8; value_of_length_field0 -= decoded_field_length; if (value_of_length_field0 < 0) return -1; RAW_Force_Omit field_1_force_omit(1, force_omit, OCTETSTRING_descr_.raw->forceomit); decoded_field_length = field_payload.RAW_decode(OCTETSTRING_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 UDP__packet::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, UDP__packet_header_descr_.raw); myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, OCTETSTRING_descr_.raw); encoded_length += field_header.RAW_encode(UDP__packet_header_descr_, *myleaf.body.node.nodes[0]); encoded_length += field_payload.RAW_encode(OCTETSTRING_descr_, *myleaf.body.node.nodes[1]); if (myleaf.body.node.nodes[0]->body.node.nodes[2]) { int tmp_length = myleaf.body.node.nodes[0]->body.node.nodes[2]->length; delete myleaf.body.node.nodes[0]->body.node.nodes[2]; myleaf.body.node.nodes[0]->body.node.nodes[2] = new RAW_enc_tree(TRUE, myleaf.body.node.nodes[0], &(myleaf.body.node.nodes[0]->curr_pos), 2, UDP__header_len_descr_.raw); myleaf.body.node.nodes[0]->body.node.nodes[2]->length = tmp_length; myleaf.body.node.nodes[0]->body.node.nodes[2]->calc = CALC_LENGTH; myleaf.body.node.nodes[0]->body.node.nodes[2]->coding_descr = &UDP__header_len_descr_; myleaf.body.node.nodes[0]->body.node.nodes[2]->calcof.lengthto.num_of_fields = 2; myleaf.body.node.nodes[0]->body.node.nodes[2]->calcof.lengthto.unit = 8; myleaf.body.node.nodes[0]->body.node.nodes[2]->calcof.lengthto.offset = 0; myleaf.body.node.nodes[0]->body.node.nodes[2]->calcof.lengthto.fields = init_lengthto_fields_list(2); myleaf.body.node.nodes[0]->body.node.nodes[2]->calcof.lengthto.fields[0].level = myleaf.body.node.nodes[0]->curr_pos.level; myleaf.body.node.nodes[0]->body.node.nodes[2]->calcof.lengthto.fields[0].pos = myleaf.body.node.nodes[0]->curr_pos.pos; myleaf.body.node.nodes[0]->body.node.nodes[2]->calcof.lengthto.fields[1].level = myleaf.body.node.nodes[1]->curr_pos.level; myleaf.body.node.nodes[0]->body.node.nodes[2]->calcof.lengthto.fields[1].pos = myleaf.body.node.nodes[1]->curr_pos.pos; } return myleaf.length = encoded_length; } struct UDP__packet_template::single_value_struct { UDP__header_template field_header; OCTETSTRING_template field_payload; }; void UDP__packet_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_header = ANY_VALUE; single_value->field_payload = ANY_VALUE; } } } void UDP__packet_template::copy_value(const UDP__packet& other_value) { single_value = new single_value_struct; if (other_value.header().is_bound()) { single_value->field_header = other_value.header(); } else { single_value->field_header.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 UDP__packet_template::copy_template(const UDP__packet_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.header().get_selection()) { single_value->field_header = other_value.header(); } else { single_value->field_header.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 UDP__packet_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 UDP__packet_template(*other_value.implication_.precondition); implication_.implied_template = new UDP__packet_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 @UDP_Types.UDP_packet."); break; } set_selection(other_value); } UDP__packet_template::UDP__packet_template() { } UDP__packet_template::UDP__packet_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } UDP__packet_template::UDP__packet_template(const UDP__packet& other_value) { copy_value(other_value); } UDP__packet_template::UDP__packet_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__packet&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @UDP_Types.UDP_packet from an unbound optional field."); } } UDP__packet_template::UDP__packet_template(UDP__packet_template* p_precondition, UDP__packet_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } UDP__packet_template::UDP__packet_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; } UDP__packet_template::UDP__packet_template(const UDP__packet_template& other_value) : Base_Template() { copy_template(other_value); } UDP__packet_template::~UDP__packet_template() { clean_up(); } UDP__packet_template& UDP__packet_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } UDP__packet_template& UDP__packet_template::operator=(const UDP__packet& other_value) { clean_up(); copy_value(other_value); return *this; } UDP__packet_template& UDP__packet_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__packet&)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 @UDP_Types.UDP_packet."); } return *this; } UDP__packet_template& UDP__packet_template::operator=(const UDP__packet_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean UDP__packet_template::match(const UDP__packet& 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.header().is_bound()) return FALSE; if(!single_value->field_header.match(other_value.header(), 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 @UDP_Types.UDP_packet."); } return FALSE; } boolean UDP__packet_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_header.is_bound() || single_value->field_payload.is_bound(); } boolean UDP__packet_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_header.is_value() && single_value->field_payload.is_value(); } void UDP__packet_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; } UDP__packet UDP__packet_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 @UDP_Types.UDP_packet."); UDP__packet ret_val; if (single_value->field_header.is_bound()) { ret_val.header() = single_value->field_header.valueof(); } if (single_value->field_payload.is_bound()) { ret_val.payload() = single_value->field_payload.valueof(); } return ret_val; } void UDP__packet_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 @UDP_Types.UDP_packet."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new UDP__packet_template[list_length]; } UDP__packet_template& UDP__packet_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 @UDP_Types.UDP_packet."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @UDP_Types.UDP_packet."); return value_list.list_value[list_index]; } UDP__header_template& UDP__packet_template::header() { set_specific(); return single_value->field_header; } const UDP__header_template& UDP__packet_template::header() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field header of a non-specific template of type @UDP_Types.UDP_packet."); return single_value->field_header; } OCTETSTRING_template& UDP__packet_template::payload() { set_specific(); return single_value->field_payload; } const OCTETSTRING_template& UDP__packet_template::payload() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field payload of a non-specific template of type @UDP_Types.UDP_packet."); return single_value->field_payload; } int UDP__packet_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_packet 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 @UDP_Types.UDP_packet 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 @UDP_Types.UDP_packet containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_packet containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_packet containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_packet containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_packet containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_packet containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_packet containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @UDP_Types.UDP_packet."); } return 0; } void UDP__packet_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ header := "); single_value->field_header.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 UDP__packet_template::log_match(const UDP__packet& 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_header.match(match_value.header(), legacy)){ TTCN_Logger::log_logmatch_info(".header"); single_value->field_header.log_match(match_value.header(), 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("{ header := "); single_value->field_header.log_match(match_value.header(), 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 UDP__packet_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_header.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 @UDP_Types.UDP_packet."); } } void UDP__packet_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_header.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 UDP__packet_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 @UDP_Types.UDP_packet."); } } void UDP__packet_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: { UDP__packet_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) header().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) payload().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(), "header")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { header().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 @UDP_Types.UDP_packet: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { UDP__packet_template* precondition = new UDP__packet_template; precondition->set_param(*param.get_elem(0)); UDP__packet_template* implied_template = new UDP__packet_template; implied_template->set_param(*param.get_elem(1)); *this = UDP__packet_template(precondition, implied_template); } break; default: param.type_error("record template", "@UDP_Types.UDP_packet"); } is_ifpresent = param.get_ifpresent(); } void UDP__packet_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_header.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_packet"); single_value->field_payload.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_packet"); 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 : "@UDP_Types.UDP_packet"); } boolean UDP__packet_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean UDP__packet_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_idxis_value(); case ALT_ipv6: return field_ipv6->is_value(); default: TTCN_error("Invalid selection in union is_bound");} } void UDP__pseudo__header::clean_up() { switch (union_selection) { case ALT_ipv4: delete field_ipv4; break; case ALT_ipv6: delete field_ipv6; break; default: break; } union_selection = UNBOUND_VALUE; } void UDP__pseudo__header::log() const { switch (union_selection) { case ALT_ipv4: TTCN_Logger::log_event_str("{ ipv4 := "); field_ipv4->log(); TTCN_Logger::log_event_str(" }"); break; case ALT_ipv6: TTCN_Logger::log_event_str("{ ipv6 := "); field_ipv6->log(); TTCN_Logger::log_event_str(" }"); break; default: TTCN_Logger::log_event_unbound(); } } void UDP__pseudo__header::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, "ipv4")) { ipv4().set_param(*mp_last); if (!ipv4().is_bound()) clean_up(); return; } if (!strcmp(last_name, "ipv6")) { ipv6().set_param(*mp_last); if (!ipv6().is_bound()) clean_up(); return; } mp_last->error("Field %s does not exist in type @UDP_Types.UDP_pseudo_header.", last_name); } void UDP__pseudo__header::set_implicit_omit() { switch (union_selection) { case ALT_ipv4: field_ipv4->set_implicit_omit(); break; case ALT_ipv6: field_ipv6->set_implicit_omit(); break; default: break; } } void UDP__pseudo__header::encode_text(Text_Buf& text_buf) const { text_buf.push_int(union_selection); switch (union_selection) { case ALT_ipv4: field_ipv4->encode_text(text_buf); break; case ALT_ipv6: field_ipv6->encode_text(text_buf); break; default: TTCN_error("Text encoder: Encoding an unbound value of union type @UDP_Types.UDP_pseudo_header."); } } void UDP__pseudo__header::decode_text(Text_Buf& text_buf) { switch ((union_selection_type)text_buf.pull_int().get_val()) { case ALT_ipv4: ipv4().decode_text(text_buf); break; case ALT_ipv6: ipv6().decode_text(text_buf); break; default: TTCN_error("Text decoder: Unrecognized union selector was received for type @UDP_Types.UDP_pseudo_header."); } } void UDP__pseudo__header::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 UDP__pseudo__header::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 UDP__pseudo__header::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, UDP__pseudo__header__IPv4_descr_.raw->forceomit); decoded_length = ipv4().RAW_decode(UDP__pseudo__header__IPv4_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, UDP__pseudo__header__IPv6_descr_.raw->forceomit); decoded_length = ipv6().RAW_decode(UDP__pseudo__header__IPv6_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, UDP__pseudo__header__IPv4_descr_.raw->forceomit); decoded_length = ipv4().RAW_decode(UDP__pseudo__header__IPv4_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, UDP__pseudo__header__IPv6_descr_.raw->forceomit); decoded_length = ipv6().RAW_decode(UDP__pseudo__header__IPv6_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; } } clean_up(); return -1; } int UDP__pseudo__header::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const { int encoded_length = 0; myleaf.isleaf = FALSE; myleaf.body.node.num_of_nodes = 2; myleaf.body.node.nodes = init_nodes_of_enc_tree(2); memset(myleaf.body.node.nodes, 0, 2 * sizeof(RAW_enc_tree *)); switch (union_selection) { case ALT_ipv4: myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 0, UDP__pseudo__header__IPv4_descr_.raw); encoded_length = field_ipv4->RAW_encode(UDP__pseudo__header__IPv4_descr_, *myleaf.body.node.nodes[0]); myleaf.body.node.nodes[0]->coding_descr = &UDP__pseudo__header__IPv4_descr_; break; case ALT_ipv6: myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 1, UDP__pseudo__header__IPv6_descr_.raw); encoded_length = field_ipv6->RAW_encode(UDP__pseudo__header__IPv6_descr_, *myleaf.body.node.nodes[1]); myleaf.body.node.nodes[1]->coding_descr = &UDP__pseudo__header__IPv6_descr_; break; default: TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value."); } return encoded_length; } void UDP__pseudo__header_template::copy_value(const UDP__pseudo__header& other_value) { single_value.union_selection = other_value.get_selection(); switch (single_value.union_selection) { case UDP__pseudo__header::ALT_ipv4: single_value.field_ipv4 = new UDP__pseudo__header__IPv4_template(other_value.ipv4()); break; case UDP__pseudo__header::ALT_ipv6: single_value.field_ipv6 = new UDP__pseudo__header__IPv6_template(other_value.ipv6()); break; default: TTCN_error("Initializing a template with an unbound value of type @UDP_Types.UDP_pseudo_header."); } set_selection(SPECIFIC_VALUE); } void UDP__pseudo__header_template::copy_template(const UDP__pseudo__header_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 UDP__pseudo__header::ALT_ipv4: single_value.field_ipv4 = new UDP__pseudo__header__IPv4_template(*other_value.single_value.field_ipv4); break; case UDP__pseudo__header::ALT_ipv6: single_value.field_ipv6 = new UDP__pseudo__header__IPv6_template(*other_value.single_value.field_ipv6); break; default: TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type @UDP_Types.UDP_pseudo_header."); } 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 UDP__pseudo__header_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 UDP__pseudo__header_template(*other_value.implication_.precondition); implication_.implied_template = new UDP__pseudo__header_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 @UDP_Types.UDP_pseudo_header."); } set_selection(other_value); } UDP__pseudo__header_template::UDP__pseudo__header_template() { } UDP__pseudo__header_template::UDP__pseudo__header_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } UDP__pseudo__header_template::UDP__pseudo__header_template(const UDP__pseudo__header& other_value) { copy_value(other_value); } UDP__pseudo__header_template::UDP__pseudo__header_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__pseudo__header&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of union type @UDP_Types.UDP_pseudo_header from an unbound optional field."); } } UDP__pseudo__header_template::UDP__pseudo__header_template(UDP__pseudo__header_template* p_precondition, UDP__pseudo__header_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } UDP__pseudo__header_template::UDP__pseudo__header_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; } UDP__pseudo__header_template::UDP__pseudo__header_template(const UDP__pseudo__header_template& other_value) : Base_Template(){ copy_template(other_value); } UDP__pseudo__header_template::~UDP__pseudo__header_template() { clean_up(); } void UDP__pseudo__header_template::clean_up() { switch (template_selection) { case SPECIFIC_VALUE: switch (single_value.union_selection) { case UDP__pseudo__header::ALT_ipv4: delete single_value.field_ipv4; break; case UDP__pseudo__header::ALT_ipv6: delete single_value.field_ipv6; 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; } UDP__pseudo__header_template& UDP__pseudo__header_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } UDP__pseudo__header_template& UDP__pseudo__header_template::operator=(const UDP__pseudo__header& other_value) { clean_up(); copy_value(other_value); return *this; } UDP__pseudo__header_template& UDP__pseudo__header_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__pseudo__header&)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 @UDP_Types.UDP_pseudo_header."); } return *this; } UDP__pseudo__header_template& UDP__pseudo__header_template::operator=(const UDP__pseudo__header_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean UDP__pseudo__header_template::match(const UDP__pseudo__header& 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: { UDP__pseudo__header::union_selection_type value_selection = other_value.get_selection(); if (value_selection == UDP__pseudo__header::UNBOUND_VALUE) return FALSE; if (value_selection != single_value.union_selection) return FALSE; switch (value_selection) { case UDP__pseudo__header::ALT_ipv4: return single_value.field_ipv4->match(other_value.ipv4(), legacy); case UDP__pseudo__header::ALT_ipv6: return single_value.field_ipv6->match(other_value.ipv6(), legacy); default: TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type @UDP_Types.UDP_pseudo_header."); } } 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 @UDP_Types.UDP_pseudo_header."); } return FALSE; } boolean UDP__pseudo__header_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; switch (single_value.union_selection) { case UDP__pseudo__header::ALT_ipv4: return single_value.field_ipv4->is_value(); case UDP__pseudo__header::ALT_ipv6: return single_value.field_ipv6->is_value(); default: TTCN_error("Internal error: Invalid selector in a specific value when performing is_value operation on a template of union type @UDP_Types.UDP_pseudo_header."); } } UDP__pseudo__header UDP__pseudo__header_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 @UDP_Types.UDP_pseudo_header."); UDP__pseudo__header ret_val; switch (single_value.union_selection) { case UDP__pseudo__header::ALT_ipv4: ret_val.ipv4() = single_value.field_ipv4->valueof(); break; case UDP__pseudo__header::ALT_ipv6: ret_val.ipv6() = single_value.field_ipv6->valueof(); break; default: TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type @UDP_Types.UDP_pseudo_header."); } return ret_val; } UDP__pseudo__header_template& UDP__pseudo__header_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 @UDP_Types.UDP_pseudo_header."); if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of union type @UDP_Types.UDP_pseudo_header."); return value_list.list_value[list_index]; } void UDP__pseudo__header_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 @UDP_Types.UDP_pseudo_header."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new UDP__pseudo__header_template[list_length]; } UDP__pseudo__header__IPv4_template& UDP__pseudo__header_template::ipv4() { if (template_selection != SPECIFIC_VALUE || single_value.union_selection != UDP__pseudo__header::ALT_ipv4) { template_sel old_selection = template_selection; clean_up(); if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_ipv4 = new UDP__pseudo__header__IPv4_template(ANY_VALUE); else single_value.field_ipv4 = new UDP__pseudo__header__IPv4_template; single_value.union_selection = UDP__pseudo__header::ALT_ipv4; set_selection(SPECIFIC_VALUE); } return *single_value.field_ipv4; } const UDP__pseudo__header__IPv4_template& UDP__pseudo__header_template::ipv4() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field ipv4 in a non-specific template of union type @UDP_Types.UDP_pseudo_header."); if (single_value.union_selection != UDP__pseudo__header::ALT_ipv4) TTCN_error("Accessing non-selected field ipv4 in a template of union type @UDP_Types.UDP_pseudo_header."); return *single_value.field_ipv4; } UDP__pseudo__header__IPv6_template& UDP__pseudo__header_template::ipv6() { if (template_selection != SPECIFIC_VALUE || single_value.union_selection != UDP__pseudo__header::ALT_ipv6) { template_sel old_selection = template_selection; clean_up(); if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_ipv6 = new UDP__pseudo__header__IPv6_template(ANY_VALUE); else single_value.field_ipv6 = new UDP__pseudo__header__IPv6_template; single_value.union_selection = UDP__pseudo__header::ALT_ipv6; set_selection(SPECIFIC_VALUE); } return *single_value.field_ipv6; } const UDP__pseudo__header__IPv6_template& UDP__pseudo__header_template::ipv6() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field ipv6 in a non-specific template of union type @UDP_Types.UDP_pseudo_header."); if (single_value.union_selection != UDP__pseudo__header::ALT_ipv6) TTCN_error("Accessing non-selected field ipv6 in a template of union type @UDP_Types.UDP_pseudo_header."); return *single_value.field_ipv6; } boolean UDP__pseudo__header_template::ischosen(UDP__pseudo__header::union_selection_type checked_selection) const { if (checked_selection == UDP__pseudo__header::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @UDP_Types.UDP_pseudo_header."); switch (template_selection) { case SPECIFIC_VALUE: if (single_value.union_selection == UDP__pseudo__header::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type @UDP_Types.UDP_pseudo_header."); 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 @UDP_Types.UDP_pseudo_header 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 UDP__pseudo__header_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: switch (single_value.union_selection) { case UDP__pseudo__header::ALT_ipv4: TTCN_Logger::log_event_str("{ ipv4 := "); single_value.field_ipv4->log(); TTCN_Logger::log_event_str(" }"); break; case UDP__pseudo__header::ALT_ipv6: TTCN_Logger::log_event_str("{ ipv6 := "); single_value.field_ipv6->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 UDP__pseudo__header_template::log_match(const UDP__pseudo__header& 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 UDP__pseudo__header::ALT_ipv4: if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ TTCN_Logger::log_logmatch_info(".ipv4"); single_value.field_ipv4->log_match(match_value.ipv4(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } else { TTCN_Logger::log_event_str("{ ipv4 := "); single_value.field_ipv4->log_match(match_value.ipv4(), legacy); TTCN_Logger::log_event_str(" }"); } break; case UDP__pseudo__header::ALT_ipv6: if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ TTCN_Logger::log_logmatch_info(".ipv6"); single_value.field_ipv6->log_match(match_value.ipv6(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } else { TTCN_Logger::log_event_str("{ ipv6 := "); single_value.field_ipv6->log_match(match_value.ipv6(), 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 UDP__pseudo__header_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 UDP__pseudo__header::ALT_ipv4: single_value.field_ipv4->encode_text(text_buf); break; case UDP__pseudo__header::ALT_ipv6: single_value.field_ipv6->encode_text(text_buf); break; default: TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type @UDP_Types.UDP_pseudo_header."); } 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 @UDP_Types.UDP_pseudo_header."); } } void UDP__pseudo__header_template::decode_text(Text_Buf& text_buf) { clean_up(); decode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: { single_value.union_selection = UDP__pseudo__header::UNBOUND_VALUE; UDP__pseudo__header::union_selection_type new_selection = (UDP__pseudo__header::union_selection_type)text_buf.pull_int().get_val(); switch (new_selection) { case UDP__pseudo__header::ALT_ipv4: single_value.field_ipv4 = new UDP__pseudo__header__IPv4_template; single_value.field_ipv4->decode_text(text_buf); break; case UDP__pseudo__header::ALT_ipv6: single_value.field_ipv6 = new UDP__pseudo__header__IPv6_template; single_value.field_ipv6->decode_text(text_buf); break; default: TTCN_error("Text decoder: Unrecognized union selector was received for a template of type @UDP_Types.UDP_pseudo_header."); } 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 UDP__pseudo__header_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 @UDP_Types.UDP_pseudo_header."); } } boolean UDP__pseudo__header_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean UDP__pseudo__header_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 `@UDP_Types.UDP_pseudo_header'"); } if (strcmp("ipv4", param_field) == 0) { ipv4().set_param(param); return; } else if (strcmp("ipv6", param_field) == 0) { ipv6().set_param(param); return; } else param.error("Field `%s' not found in union template type `@UDP_Types.UDP_pseudo_header'", 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: { UDP__pseudo__header_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", "@UDP_Types.UDP_pseudo_header"); 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, "ipv4")) { ipv4().set_param(*mp_last); break; } if (!strcmp(last_name, "ipv6")) { ipv6().set_param(*mp_last); break; } mp_last->error("Field %s does not exist in type @UDP_Types.UDP_pseudo_header.", last_name); } break; case Module_Param::MP_Implication_Template: { UDP__pseudo__header_template* precondition = new UDP__pseudo__header_template; precondition->set_param(*m_p->get_elem(0)); UDP__pseudo__header_template* implied_template = new UDP__pseudo__header_template; implied_template->set_param(*m_p->get_elem(1)); *this = UDP__pseudo__header_template(precondition, implied_template); } break; default: param.type_error("union template", "@UDP_Types.UDP_pseudo_header"); } is_ifpresent = param.get_ifpresent(); } void UDP__pseudo__header_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 UDP__pseudo__header::ALT_ipv4: single_value.field_ipv4->check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header"); return; case UDP__pseudo__header::ALT_ipv6: single_value.field_ipv6->check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header"); return; default: TTCN_error("Internal error: Invalid selector in a specific value when performing check_restriction operation on a template of union type @UDP_Types.UDP_pseudo_header."); } 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 : "@UDP_Types.UDP_pseudo_header"); } UDP__pseudo__header__IPv4::UDP__pseudo__header__IPv4() { } UDP__pseudo__header__IPv4::UDP__pseudo__header__IPv4(const OCTETSTRING& par_srcaddr, const OCTETSTRING& par_dstaddr, const INTEGER& par_zero, const INTEGER& par_proto, const INTEGER& par_plen) : field_srcaddr(par_srcaddr), field_dstaddr(par_dstaddr), field_zero(par_zero), field_proto(par_proto), field_plen(par_plen) { } UDP__pseudo__header__IPv4::UDP__pseudo__header__IPv4(const UDP__pseudo__header__IPv4& other_value) { if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @UDP_Types.UDP_pseudo_header_IPv4."); if (other_value.srcaddr().is_bound()) field_srcaddr = other_value.srcaddr(); else field_srcaddr.clean_up(); if (other_value.dstaddr().is_bound()) field_dstaddr = other_value.dstaddr(); else field_dstaddr.clean_up(); if (other_value.zero().is_bound()) field_zero = other_value.zero(); else field_zero.clean_up(); if (other_value.proto().is_bound()) field_proto = other_value.proto(); else field_proto.clean_up(); if (other_value.plen().is_bound()) field_plen = other_value.plen(); else field_plen.clean_up(); } void UDP__pseudo__header__IPv4::clean_up() { field_srcaddr.clean_up(); field_dstaddr.clean_up(); field_zero.clean_up(); field_proto.clean_up(); field_plen.clean_up(); } const TTCN_Typedescriptor_t* UDP__pseudo__header__IPv4::get_descriptor() const { return &UDP__pseudo__header__IPv4_descr_; } UDP__pseudo__header__IPv4& UDP__pseudo__header__IPv4::operator=(const UDP__pseudo__header__IPv4& other_value) { if (this != &other_value) { if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @UDP_Types.UDP_pseudo_header_IPv4."); if (other_value.srcaddr().is_bound()) field_srcaddr = other_value.srcaddr(); else field_srcaddr.clean_up(); if (other_value.dstaddr().is_bound()) field_dstaddr = other_value.dstaddr(); else field_dstaddr.clean_up(); if (other_value.zero().is_bound()) field_zero = other_value.zero(); else field_zero.clean_up(); if (other_value.proto().is_bound()) field_proto = other_value.proto(); else field_proto.clean_up(); if (other_value.plen().is_bound()) field_plen = other_value.plen(); else field_plen.clean_up(); } return *this; } boolean UDP__pseudo__header__IPv4::operator==(const UDP__pseudo__header__IPv4& other_value) const { return field_srcaddr==other_value.field_srcaddr && field_dstaddr==other_value.field_dstaddr && field_zero==other_value.field_zero && field_proto==other_value.field_proto && field_plen==other_value.field_plen; } boolean UDP__pseudo__header__IPv4::is_bound() const { return (field_srcaddr.is_bound()) || (field_dstaddr.is_bound()) || (field_zero.is_bound()) || (field_proto.is_bound()) || (field_plen.is_bound()); } boolean UDP__pseudo__header__IPv4::is_value() const { return field_srcaddr.is_value() && field_dstaddr.is_value() && field_zero.is_value() && field_proto.is_value() && field_plen.is_value(); } void UDP__pseudo__header__IPv4::log() const { if (!is_bound()) { TTCN_Logger::log_event_unbound(); return; } TTCN_Logger::log_event_str("{ srcaddr := "); field_srcaddr.log(); TTCN_Logger::log_event_str(", dstaddr := "); field_dstaddr.log(); TTCN_Logger::log_event_str(", zero := "); field_zero.log(); TTCN_Logger::log_event_str(", proto := "); field_proto.log(); TTCN_Logger::log_event_str(", plen := "); field_plen.log(); TTCN_Logger::log_event_str(" }"); } void UDP__pseudo__header__IPv4::set_implicit_omit() { if (srcaddr().is_bound()) srcaddr().set_implicit_omit(); if (dstaddr().is_bound()) dstaddr().set_implicit_omit(); if (zero().is_bound()) zero().set_implicit_omit(); if (proto().is_bound()) proto().set_implicit_omit(); if (plen().is_bound()) plen().set_implicit_omit(); } void UDP__pseudo__header__IPv4::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 (50 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) srcaddr().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) dstaddr().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) zero().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) proto().set_param(*param.get_elem(3)); if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) plen().set_param(*param.get_elem(4)); 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(), "srcaddr")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { srcaddr().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "dstaddr")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { dstaddr().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "zero")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { zero().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "proto")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { proto().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "plen")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { plen().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @UDP_Types.UDP_pseudo_header_IPv4: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@UDP_Types.UDP_pseudo_header_IPv4"); } } void UDP__pseudo__header__IPv4::encode_text(Text_Buf& text_buf) const { field_srcaddr.encode_text(text_buf); field_dstaddr.encode_text(text_buf); field_zero.encode_text(text_buf); field_proto.encode_text(text_buf); field_plen.encode_text(text_buf); } void UDP__pseudo__header__IPv4::decode_text(Text_Buf& text_buf) { field_srcaddr.decode_text(text_buf); field_dstaddr.decode_text(text_buf); field_zero.decode_text(text_buf); field_proto.decode_text(text_buf); field_plen.decode_text(text_buf); } void UDP__pseudo__header__IPv4::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 UDP__pseudo__header__IPv4::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 UDP__pseudo__header__IPv4::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; RAW_Force_Omit field_0_force_omit(0, force_omit, UDP__pseudo__header__IPv4_srcaddr_descr_.raw->forceomit); decoded_field_length = field_srcaddr.RAW_decode(UDP__pseudo__header__IPv4_srcaddr_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()); RAW_Force_Omit field_1_force_omit(1, force_omit, UDP__pseudo__header__IPv4_dstaddr_descr_.raw->forceomit); decoded_field_length = field_dstaddr.RAW_decode(UDP__pseudo__header__IPv4_dstaddr_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()); RAW_Force_Omit field_2_force_omit(2, force_omit, UDP__pseudo__header__IPv4_zero_descr_.raw->forceomit); decoded_field_length = field_zero.RAW_decode(UDP__pseudo__header__IPv4_zero_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()); RAW_Force_Omit field_3_force_omit(3, force_omit, UDP__pseudo__header__IPv4_proto_descr_.raw->forceomit); decoded_field_length = field_proto.RAW_decode(UDP__pseudo__header__IPv4_proto_descr_, p_buf, limit, 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()); RAW_Force_Omit field_4_force_omit(4, force_omit, UDP__pseudo__header__IPv4_plen_descr_.raw->forceomit); decoded_field_length = field_plen.RAW_decode(UDP__pseudo__header__IPv4_plen_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_4_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()); p_buf.set_pos_bit(last_decoded_pos); return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding); } int UDP__pseudo__header__IPv4::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 = 5; myleaf.body.node.nodes = init_nodes_of_enc_tree(5); myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, UDP__pseudo__header__IPv4_srcaddr_descr_.raw); myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, UDP__pseudo__header__IPv4_dstaddr_descr_.raw); myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, UDP__pseudo__header__IPv4_zero_descr_.raw); myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, UDP__pseudo__header__IPv4_proto_descr_.raw); myleaf.body.node.nodes[4] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 4, UDP__pseudo__header__IPv4_plen_descr_.raw); encoded_length += field_srcaddr.RAW_encode(UDP__pseudo__header__IPv4_srcaddr_descr_, *myleaf.body.node.nodes[0]); encoded_length += field_dstaddr.RAW_encode(UDP__pseudo__header__IPv4_dstaddr_descr_, *myleaf.body.node.nodes[1]); encoded_length += field_zero.RAW_encode(UDP__pseudo__header__IPv4_zero_descr_, *myleaf.body.node.nodes[2]); encoded_length += field_proto.RAW_encode(UDP__pseudo__header__IPv4_proto_descr_, *myleaf.body.node.nodes[3]); encoded_length += field_plen.RAW_encode(UDP__pseudo__header__IPv4_plen_descr_, *myleaf.body.node.nodes[4]); return myleaf.length = encoded_length; } struct UDP__pseudo__header__IPv4_template::single_value_struct { OCTETSTRING_template field_srcaddr; OCTETSTRING_template field_dstaddr; INTEGER_template field_zero; INTEGER_template field_proto; INTEGER_template field_plen; }; void UDP__pseudo__header__IPv4_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_srcaddr = ANY_VALUE; single_value->field_dstaddr = ANY_VALUE; single_value->field_zero = ANY_VALUE; single_value->field_proto = ANY_VALUE; single_value->field_plen = ANY_VALUE; } } } void UDP__pseudo__header__IPv4_template::copy_value(const UDP__pseudo__header__IPv4& other_value) { single_value = new single_value_struct; if (other_value.srcaddr().is_bound()) { single_value->field_srcaddr = other_value.srcaddr(); } else { single_value->field_srcaddr.clean_up(); } if (other_value.dstaddr().is_bound()) { single_value->field_dstaddr = other_value.dstaddr(); } else { single_value->field_dstaddr.clean_up(); } if (other_value.zero().is_bound()) { single_value->field_zero = other_value.zero(); } else { single_value->field_zero.clean_up(); } if (other_value.proto().is_bound()) { single_value->field_proto = other_value.proto(); } else { single_value->field_proto.clean_up(); } if (other_value.plen().is_bound()) { single_value->field_plen = other_value.plen(); } else { single_value->field_plen.clean_up(); } set_selection(SPECIFIC_VALUE); } void UDP__pseudo__header__IPv4_template::copy_template(const UDP__pseudo__header__IPv4_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.srcaddr().get_selection()) { single_value->field_srcaddr = other_value.srcaddr(); } else { single_value->field_srcaddr.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.dstaddr().get_selection()) { single_value->field_dstaddr = other_value.dstaddr(); } else { single_value->field_dstaddr.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.zero().get_selection()) { single_value->field_zero = other_value.zero(); } else { single_value->field_zero.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.proto().get_selection()) { single_value->field_proto = other_value.proto(); } else { single_value->field_proto.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.plen().get_selection()) { single_value->field_plen = other_value.plen(); } else { single_value->field_plen.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 UDP__pseudo__header__IPv4_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 UDP__pseudo__header__IPv4_template(*other_value.implication_.precondition); implication_.implied_template = new UDP__pseudo__header__IPv4_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 @UDP_Types.UDP_pseudo_header_IPv4."); break; } set_selection(other_value); } UDP__pseudo__header__IPv4_template::UDP__pseudo__header__IPv4_template() { } UDP__pseudo__header__IPv4_template::UDP__pseudo__header__IPv4_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } UDP__pseudo__header__IPv4_template::UDP__pseudo__header__IPv4_template(const UDP__pseudo__header__IPv4& other_value) { copy_value(other_value); } UDP__pseudo__header__IPv4_template::UDP__pseudo__header__IPv4_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__pseudo__header__IPv4&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @UDP_Types.UDP_pseudo_header_IPv4 from an unbound optional field."); } } UDP__pseudo__header__IPv4_template::UDP__pseudo__header__IPv4_template(UDP__pseudo__header__IPv4_template* p_precondition, UDP__pseudo__header__IPv4_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } UDP__pseudo__header__IPv4_template::UDP__pseudo__header__IPv4_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; } UDP__pseudo__header__IPv4_template::UDP__pseudo__header__IPv4_template(const UDP__pseudo__header__IPv4_template& other_value) : Base_Template() { copy_template(other_value); } UDP__pseudo__header__IPv4_template::~UDP__pseudo__header__IPv4_template() { clean_up(); } UDP__pseudo__header__IPv4_template& UDP__pseudo__header__IPv4_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } UDP__pseudo__header__IPv4_template& UDP__pseudo__header__IPv4_template::operator=(const UDP__pseudo__header__IPv4& other_value) { clean_up(); copy_value(other_value); return *this; } UDP__pseudo__header__IPv4_template& UDP__pseudo__header__IPv4_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__pseudo__header__IPv4&)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 @UDP_Types.UDP_pseudo_header_IPv4."); } return *this; } UDP__pseudo__header__IPv4_template& UDP__pseudo__header__IPv4_template::operator=(const UDP__pseudo__header__IPv4_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean UDP__pseudo__header__IPv4_template::match(const UDP__pseudo__header__IPv4& 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.srcaddr().is_bound()) return FALSE; if(!single_value->field_srcaddr.match(other_value.srcaddr(), legacy))return FALSE; if(!other_value.dstaddr().is_bound()) return FALSE; if(!single_value->field_dstaddr.match(other_value.dstaddr(), legacy))return FALSE; if(!other_value.zero().is_bound()) return FALSE; if(!single_value->field_zero.match(other_value.zero(), legacy))return FALSE; if(!other_value.proto().is_bound()) return FALSE; if(!single_value->field_proto.match(other_value.proto(), legacy))return FALSE; if(!other_value.plen().is_bound()) return FALSE; if(!single_value->field_plen.match(other_value.plen(), 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 @UDP_Types.UDP_pseudo_header_IPv4."); } return FALSE; } boolean UDP__pseudo__header__IPv4_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_srcaddr.is_bound() || single_value->field_dstaddr.is_bound() || single_value->field_zero.is_bound() || single_value->field_proto.is_bound() || single_value->field_plen.is_bound(); } boolean UDP__pseudo__header__IPv4_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_srcaddr.is_value() && single_value->field_dstaddr.is_value() && single_value->field_zero.is_value() && single_value->field_proto.is_value() && single_value->field_plen.is_value(); } void UDP__pseudo__header__IPv4_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; } UDP__pseudo__header__IPv4 UDP__pseudo__header__IPv4_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 @UDP_Types.UDP_pseudo_header_IPv4."); UDP__pseudo__header__IPv4 ret_val; if (single_value->field_srcaddr.is_bound()) { ret_val.srcaddr() = single_value->field_srcaddr.valueof(); } if (single_value->field_dstaddr.is_bound()) { ret_val.dstaddr() = single_value->field_dstaddr.valueof(); } if (single_value->field_zero.is_bound()) { ret_val.zero() = single_value->field_zero.valueof(); } if (single_value->field_proto.is_bound()) { ret_val.proto() = single_value->field_proto.valueof(); } if (single_value->field_plen.is_bound()) { ret_val.plen() = single_value->field_plen.valueof(); } return ret_val; } void UDP__pseudo__header__IPv4_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 @UDP_Types.UDP_pseudo_header_IPv4."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new UDP__pseudo__header__IPv4_template[list_length]; } UDP__pseudo__header__IPv4_template& UDP__pseudo__header__IPv4_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 @UDP_Types.UDP_pseudo_header_IPv4."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @UDP_Types.UDP_pseudo_header_IPv4."); return value_list.list_value[list_index]; } OCTETSTRING_template& UDP__pseudo__header__IPv4_template::srcaddr() { set_specific(); return single_value->field_srcaddr; } const OCTETSTRING_template& UDP__pseudo__header__IPv4_template::srcaddr() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field srcaddr of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv4."); return single_value->field_srcaddr; } OCTETSTRING_template& UDP__pseudo__header__IPv4_template::dstaddr() { set_specific(); return single_value->field_dstaddr; } const OCTETSTRING_template& UDP__pseudo__header__IPv4_template::dstaddr() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field dstaddr of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv4."); return single_value->field_dstaddr; } INTEGER_template& UDP__pseudo__header__IPv4_template::zero() { set_specific(); return single_value->field_zero; } const INTEGER_template& UDP__pseudo__header__IPv4_template::zero() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field zero of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv4."); return single_value->field_zero; } INTEGER_template& UDP__pseudo__header__IPv4_template::proto() { set_specific(); return single_value->field_proto; } const INTEGER_template& UDP__pseudo__header__IPv4_template::proto() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field proto of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv4."); return single_value->field_proto; } INTEGER_template& UDP__pseudo__header__IPv4_template::plen() { set_specific(); return single_value->field_plen; } const INTEGER_template& UDP__pseudo__header__IPv4_template::plen() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field plen of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv4."); return single_value->field_plen; } int UDP__pseudo__header__IPv4_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv4 which has an ifpresent attribute."); switch (template_selection) { case SPECIFIC_VALUE: return 5; case VALUE_LIST: { if (value_list.n_values<1) TTCN_error("Internal error: Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv4 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 @UDP_Types.UDP_pseudo_header_IPv4 containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv4 containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv4 containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv4 containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv4 containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv4 containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv4 containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @UDP_Types.UDP_pseudo_header_IPv4."); } return 0; } void UDP__pseudo__header__IPv4_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ srcaddr := "); single_value->field_srcaddr.log(); TTCN_Logger::log_event_str(", dstaddr := "); single_value->field_dstaddr.log(); TTCN_Logger::log_event_str(", zero := "); single_value->field_zero.log(); TTCN_Logger::log_event_str(", proto := "); single_value->field_proto.log(); TTCN_Logger::log_event_str(", plen := "); single_value->field_plen.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 UDP__pseudo__header__IPv4_template::log_match(const UDP__pseudo__header__IPv4& 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_srcaddr.match(match_value.srcaddr(), legacy)){ TTCN_Logger::log_logmatch_info(".srcaddr"); single_value->field_srcaddr.log_match(match_value.srcaddr(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_dstaddr.match(match_value.dstaddr(), legacy)){ TTCN_Logger::log_logmatch_info(".dstaddr"); single_value->field_dstaddr.log_match(match_value.dstaddr(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_zero.match(match_value.zero(), legacy)){ TTCN_Logger::log_logmatch_info(".zero"); single_value->field_zero.log_match(match_value.zero(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_proto.match(match_value.proto(), legacy)){ TTCN_Logger::log_logmatch_info(".proto"); single_value->field_proto.log_match(match_value.proto(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_plen.match(match_value.plen(), legacy)){ TTCN_Logger::log_logmatch_info(".plen"); single_value->field_plen.log_match(match_value.plen(), 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("{ srcaddr := "); single_value->field_srcaddr.log_match(match_value.srcaddr(), legacy); TTCN_Logger::log_event_str(", dstaddr := "); single_value->field_dstaddr.log_match(match_value.dstaddr(), legacy); TTCN_Logger::log_event_str(", zero := "); single_value->field_zero.log_match(match_value.zero(), legacy); TTCN_Logger::log_event_str(", proto := "); single_value->field_proto.log_match(match_value.proto(), legacy); TTCN_Logger::log_event_str(", plen := "); single_value->field_plen.log_match(match_value.plen(), 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 UDP__pseudo__header__IPv4_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_srcaddr.encode_text(text_buf); single_value->field_dstaddr.encode_text(text_buf); single_value->field_zero.encode_text(text_buf); single_value->field_proto.encode_text(text_buf); single_value->field_plen.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 @UDP_Types.UDP_pseudo_header_IPv4."); } } void UDP__pseudo__header__IPv4_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_srcaddr.decode_text(text_buf); single_value->field_dstaddr.decode_text(text_buf); single_value->field_zero.decode_text(text_buf); single_value->field_proto.decode_text(text_buf); single_value->field_plen.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 UDP__pseudo__header__IPv4_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 @UDP_Types.UDP_pseudo_header_IPv4."); } } void UDP__pseudo__header__IPv4_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: { UDP__pseudo__header__IPv4_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) srcaddr().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) dstaddr().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) zero().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) proto().set_param(*param.get_elem(3)); if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) plen().set_param(*param.get_elem(4)); 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(), "srcaddr")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { srcaddr().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "dstaddr")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { dstaddr().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "zero")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { zero().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "proto")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { proto().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "plen")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { plen().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @UDP_Types.UDP_pseudo_header_IPv4: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { UDP__pseudo__header__IPv4_template* precondition = new UDP__pseudo__header__IPv4_template; precondition->set_param(*param.get_elem(0)); UDP__pseudo__header__IPv4_template* implied_template = new UDP__pseudo__header__IPv4_template; implied_template->set_param(*param.get_elem(1)); *this = UDP__pseudo__header__IPv4_template(precondition, implied_template); } break; default: param.type_error("record template", "@UDP_Types.UDP_pseudo_header_IPv4"); } is_ifpresent = param.get_ifpresent(); } void UDP__pseudo__header__IPv4_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_srcaddr.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv4"); single_value->field_dstaddr.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv4"); single_value->field_zero.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv4"); single_value->field_proto.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv4"); single_value->field_plen.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv4"); 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 : "@UDP_Types.UDP_pseudo_header_IPv4"); } boolean UDP__pseudo__header__IPv4_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean UDP__pseudo__header__IPv4_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) srcaddr().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) dstaddr().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) plen().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) zero().set_param(*param.get_elem(3)); if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) nextheader().set_param(*param.get_elem(4)); 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(), "srcaddr")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { srcaddr().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "dstaddr")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { dstaddr().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "plen")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { plen().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "zero")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { zero().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "nextheader")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { nextheader().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @UDP_Types.UDP_pseudo_header_IPv6: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@UDP_Types.UDP_pseudo_header_IPv6"); } } void UDP__pseudo__header__IPv6::encode_text(Text_Buf& text_buf) const { field_srcaddr.encode_text(text_buf); field_dstaddr.encode_text(text_buf); field_plen.encode_text(text_buf); field_zero.encode_text(text_buf); field_nextheader.encode_text(text_buf); } void UDP__pseudo__header__IPv6::decode_text(Text_Buf& text_buf) { field_srcaddr.decode_text(text_buf); field_dstaddr.decode_text(text_buf); field_plen.decode_text(text_buf); field_zero.decode_text(text_buf); field_nextheader.decode_text(text_buf); } void UDP__pseudo__header__IPv6::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 UDP__pseudo__header__IPv6::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 UDP__pseudo__header__IPv6::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; RAW_Force_Omit field_0_force_omit(0, force_omit, UDP__pseudo__header__IPv6_srcaddr_descr_.raw->forceomit); decoded_field_length = field_srcaddr.RAW_decode(UDP__pseudo__header__IPv6_srcaddr_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()); RAW_Force_Omit field_1_force_omit(1, force_omit, UDP__pseudo__header__IPv6_dstaddr_descr_.raw->forceomit); decoded_field_length = field_dstaddr.RAW_decode(UDP__pseudo__header__IPv6_dstaddr_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()); RAW_Force_Omit field_2_force_omit(2, force_omit, UDP__pseudo__header__IPv6_plen_descr_.raw->forceomit); decoded_field_length = field_plen.RAW_decode(UDP__pseudo__header__IPv6_plen_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()); RAW_Force_Omit field_3_force_omit(3, force_omit, UDP__pseudo__header__IPv6_zero_descr_.raw->forceomit); decoded_field_length = field_zero.RAW_decode(UDP__pseudo__header__IPv6_zero_descr_, p_buf, limit, 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()); RAW_Force_Omit field_4_force_omit(4, force_omit, UDP__pseudo__header__IPv6_nextheader_descr_.raw->forceomit); decoded_field_length = field_nextheader.RAW_decode(UDP__pseudo__header__IPv6_nextheader_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_4_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()); p_buf.set_pos_bit(last_decoded_pos); return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding); } int UDP__pseudo__header__IPv6::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 = 5; myleaf.body.node.nodes = init_nodes_of_enc_tree(5); myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, UDP__pseudo__header__IPv6_srcaddr_descr_.raw); myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, UDP__pseudo__header__IPv6_dstaddr_descr_.raw); myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, UDP__pseudo__header__IPv6_plen_descr_.raw); myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, UDP__pseudo__header__IPv6_zero_descr_.raw); myleaf.body.node.nodes[4] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 4, UDP__pseudo__header__IPv6_nextheader_descr_.raw); encoded_length += field_srcaddr.RAW_encode(UDP__pseudo__header__IPv6_srcaddr_descr_, *myleaf.body.node.nodes[0]); encoded_length += field_dstaddr.RAW_encode(UDP__pseudo__header__IPv6_dstaddr_descr_, *myleaf.body.node.nodes[1]); encoded_length += field_plen.RAW_encode(UDP__pseudo__header__IPv6_plen_descr_, *myleaf.body.node.nodes[2]); encoded_length += field_zero.RAW_encode(UDP__pseudo__header__IPv6_zero_descr_, *myleaf.body.node.nodes[3]); encoded_length += field_nextheader.RAW_encode(UDP__pseudo__header__IPv6_nextheader_descr_, *myleaf.body.node.nodes[4]); return myleaf.length = encoded_length; } struct UDP__pseudo__header__IPv6_template::single_value_struct { OCTETSTRING_template field_srcaddr; OCTETSTRING_template field_dstaddr; INTEGER_template field_plen; INTEGER_template field_zero; INTEGER_template field_nextheader; }; void UDP__pseudo__header__IPv6_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_srcaddr = ANY_VALUE; single_value->field_dstaddr = ANY_VALUE; single_value->field_plen = ANY_VALUE; single_value->field_zero = ANY_VALUE; single_value->field_nextheader = ANY_VALUE; } } } void UDP__pseudo__header__IPv6_template::copy_value(const UDP__pseudo__header__IPv6& other_value) { single_value = new single_value_struct; if (other_value.srcaddr().is_bound()) { single_value->field_srcaddr = other_value.srcaddr(); } else { single_value->field_srcaddr.clean_up(); } if (other_value.dstaddr().is_bound()) { single_value->field_dstaddr = other_value.dstaddr(); } else { single_value->field_dstaddr.clean_up(); } if (other_value.plen().is_bound()) { single_value->field_plen = other_value.plen(); } else { single_value->field_plen.clean_up(); } if (other_value.zero().is_bound()) { single_value->field_zero = other_value.zero(); } else { single_value->field_zero.clean_up(); } if (other_value.nextheader().is_bound()) { single_value->field_nextheader = other_value.nextheader(); } else { single_value->field_nextheader.clean_up(); } set_selection(SPECIFIC_VALUE); } void UDP__pseudo__header__IPv6_template::copy_template(const UDP__pseudo__header__IPv6_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.srcaddr().get_selection()) { single_value->field_srcaddr = other_value.srcaddr(); } else { single_value->field_srcaddr.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.dstaddr().get_selection()) { single_value->field_dstaddr = other_value.dstaddr(); } else { single_value->field_dstaddr.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.plen().get_selection()) { single_value->field_plen = other_value.plen(); } else { single_value->field_plen.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.zero().get_selection()) { single_value->field_zero = other_value.zero(); } else { single_value->field_zero.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.nextheader().get_selection()) { single_value->field_nextheader = other_value.nextheader(); } else { single_value->field_nextheader.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 UDP__pseudo__header__IPv6_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 UDP__pseudo__header__IPv6_template(*other_value.implication_.precondition); implication_.implied_template = new UDP__pseudo__header__IPv6_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 @UDP_Types.UDP_pseudo_header_IPv6."); break; } set_selection(other_value); } UDP__pseudo__header__IPv6_template::UDP__pseudo__header__IPv6_template() { } UDP__pseudo__header__IPv6_template::UDP__pseudo__header__IPv6_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } UDP__pseudo__header__IPv6_template::UDP__pseudo__header__IPv6_template(const UDP__pseudo__header__IPv6& other_value) { copy_value(other_value); } UDP__pseudo__header__IPv6_template::UDP__pseudo__header__IPv6_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__pseudo__header__IPv6&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @UDP_Types.UDP_pseudo_header_IPv6 from an unbound optional field."); } } UDP__pseudo__header__IPv6_template::UDP__pseudo__header__IPv6_template(UDP__pseudo__header__IPv6_template* p_precondition, UDP__pseudo__header__IPv6_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } UDP__pseudo__header__IPv6_template::UDP__pseudo__header__IPv6_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; } UDP__pseudo__header__IPv6_template::UDP__pseudo__header__IPv6_template(const UDP__pseudo__header__IPv6_template& other_value) : Base_Template() { copy_template(other_value); } UDP__pseudo__header__IPv6_template::~UDP__pseudo__header__IPv6_template() { clean_up(); } UDP__pseudo__header__IPv6_template& UDP__pseudo__header__IPv6_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } UDP__pseudo__header__IPv6_template& UDP__pseudo__header__IPv6_template::operator=(const UDP__pseudo__header__IPv6& other_value) { clean_up(); copy_value(other_value); return *this; } UDP__pseudo__header__IPv6_template& UDP__pseudo__header__IPv6_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const UDP__pseudo__header__IPv6&)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 @UDP_Types.UDP_pseudo_header_IPv6."); } return *this; } UDP__pseudo__header__IPv6_template& UDP__pseudo__header__IPv6_template::operator=(const UDP__pseudo__header__IPv6_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean UDP__pseudo__header__IPv6_template::match(const UDP__pseudo__header__IPv6& 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.srcaddr().is_bound()) return FALSE; if(!single_value->field_srcaddr.match(other_value.srcaddr(), legacy))return FALSE; if(!other_value.dstaddr().is_bound()) return FALSE; if(!single_value->field_dstaddr.match(other_value.dstaddr(), legacy))return FALSE; if(!other_value.plen().is_bound()) return FALSE; if(!single_value->field_plen.match(other_value.plen(), legacy))return FALSE; if(!other_value.zero().is_bound()) return FALSE; if(!single_value->field_zero.match(other_value.zero(), legacy))return FALSE; if(!other_value.nextheader().is_bound()) return FALSE; if(!single_value->field_nextheader.match(other_value.nextheader(), 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 @UDP_Types.UDP_pseudo_header_IPv6."); } return FALSE; } boolean UDP__pseudo__header__IPv6_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_srcaddr.is_bound() || single_value->field_dstaddr.is_bound() || single_value->field_plen.is_bound() || single_value->field_zero.is_bound() || single_value->field_nextheader.is_bound(); } boolean UDP__pseudo__header__IPv6_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_srcaddr.is_value() && single_value->field_dstaddr.is_value() && single_value->field_plen.is_value() && single_value->field_zero.is_value() && single_value->field_nextheader.is_value(); } void UDP__pseudo__header__IPv6_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; } UDP__pseudo__header__IPv6 UDP__pseudo__header__IPv6_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 @UDP_Types.UDP_pseudo_header_IPv6."); UDP__pseudo__header__IPv6 ret_val; if (single_value->field_srcaddr.is_bound()) { ret_val.srcaddr() = single_value->field_srcaddr.valueof(); } if (single_value->field_dstaddr.is_bound()) { ret_val.dstaddr() = single_value->field_dstaddr.valueof(); } if (single_value->field_plen.is_bound()) { ret_val.plen() = single_value->field_plen.valueof(); } if (single_value->field_zero.is_bound()) { ret_val.zero() = single_value->field_zero.valueof(); } if (single_value->field_nextheader.is_bound()) { ret_val.nextheader() = single_value->field_nextheader.valueof(); } return ret_val; } void UDP__pseudo__header__IPv6_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 @UDP_Types.UDP_pseudo_header_IPv6."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new UDP__pseudo__header__IPv6_template[list_length]; } UDP__pseudo__header__IPv6_template& UDP__pseudo__header__IPv6_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 @UDP_Types.UDP_pseudo_header_IPv6."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @UDP_Types.UDP_pseudo_header_IPv6."); return value_list.list_value[list_index]; } OCTETSTRING_template& UDP__pseudo__header__IPv6_template::srcaddr() { set_specific(); return single_value->field_srcaddr; } const OCTETSTRING_template& UDP__pseudo__header__IPv6_template::srcaddr() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field srcaddr of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv6."); return single_value->field_srcaddr; } OCTETSTRING_template& UDP__pseudo__header__IPv6_template::dstaddr() { set_specific(); return single_value->field_dstaddr; } const OCTETSTRING_template& UDP__pseudo__header__IPv6_template::dstaddr() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field dstaddr of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv6."); return single_value->field_dstaddr; } INTEGER_template& UDP__pseudo__header__IPv6_template::plen() { set_specific(); return single_value->field_plen; } const INTEGER_template& UDP__pseudo__header__IPv6_template::plen() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field plen of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv6."); return single_value->field_plen; } INTEGER_template& UDP__pseudo__header__IPv6_template::zero() { set_specific(); return single_value->field_zero; } const INTEGER_template& UDP__pseudo__header__IPv6_template::zero() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field zero of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv6."); return single_value->field_zero; } INTEGER_template& UDP__pseudo__header__IPv6_template::nextheader() { set_specific(); return single_value->field_nextheader; } const INTEGER_template& UDP__pseudo__header__IPv6_template::nextheader() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field nextheader of a non-specific template of type @UDP_Types.UDP_pseudo_header_IPv6."); return single_value->field_nextheader; } int UDP__pseudo__header__IPv6_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv6 which has an ifpresent attribute."); switch (template_selection) { case SPECIFIC_VALUE: return 5; case VALUE_LIST: { if (value_list.n_values<1) TTCN_error("Internal error: Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv6 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 @UDP_Types.UDP_pseudo_header_IPv6 containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv6 containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv6 containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv6 containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv6 containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv6 containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @UDP_Types.UDP_pseudo_header_IPv6 containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @UDP_Types.UDP_pseudo_header_IPv6."); } return 0; } void UDP__pseudo__header__IPv6_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ srcaddr := "); single_value->field_srcaddr.log(); TTCN_Logger::log_event_str(", dstaddr := "); single_value->field_dstaddr.log(); TTCN_Logger::log_event_str(", plen := "); single_value->field_plen.log(); TTCN_Logger::log_event_str(", zero := "); single_value->field_zero.log(); TTCN_Logger::log_event_str(", nextheader := "); single_value->field_nextheader.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 UDP__pseudo__header__IPv6_template::log_match(const UDP__pseudo__header__IPv6& 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_srcaddr.match(match_value.srcaddr(), legacy)){ TTCN_Logger::log_logmatch_info(".srcaddr"); single_value->field_srcaddr.log_match(match_value.srcaddr(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_dstaddr.match(match_value.dstaddr(), legacy)){ TTCN_Logger::log_logmatch_info(".dstaddr"); single_value->field_dstaddr.log_match(match_value.dstaddr(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_plen.match(match_value.plen(), legacy)){ TTCN_Logger::log_logmatch_info(".plen"); single_value->field_plen.log_match(match_value.plen(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_zero.match(match_value.zero(), legacy)){ TTCN_Logger::log_logmatch_info(".zero"); single_value->field_zero.log_match(match_value.zero(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_nextheader.match(match_value.nextheader(), legacy)){ TTCN_Logger::log_logmatch_info(".nextheader"); single_value->field_nextheader.log_match(match_value.nextheader(), 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("{ srcaddr := "); single_value->field_srcaddr.log_match(match_value.srcaddr(), legacy); TTCN_Logger::log_event_str(", dstaddr := "); single_value->field_dstaddr.log_match(match_value.dstaddr(), legacy); TTCN_Logger::log_event_str(", plen := "); single_value->field_plen.log_match(match_value.plen(), legacy); TTCN_Logger::log_event_str(", zero := "); single_value->field_zero.log_match(match_value.zero(), legacy); TTCN_Logger::log_event_str(", nextheader := "); single_value->field_nextheader.log_match(match_value.nextheader(), 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 UDP__pseudo__header__IPv6_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_srcaddr.encode_text(text_buf); single_value->field_dstaddr.encode_text(text_buf); single_value->field_plen.encode_text(text_buf); single_value->field_zero.encode_text(text_buf); single_value->field_nextheader.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 @UDP_Types.UDP_pseudo_header_IPv6."); } } void UDP__pseudo__header__IPv6_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_srcaddr.decode_text(text_buf); single_value->field_dstaddr.decode_text(text_buf); single_value->field_plen.decode_text(text_buf); single_value->field_zero.decode_text(text_buf); single_value->field_nextheader.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 UDP__pseudo__header__IPv6_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 @UDP_Types.UDP_pseudo_header_IPv6."); } } void UDP__pseudo__header__IPv6_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: { UDP__pseudo__header__IPv6_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) srcaddr().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) dstaddr().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) plen().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) zero().set_param(*param.get_elem(3)); if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) nextheader().set_param(*param.get_elem(4)); 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(), "srcaddr")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { srcaddr().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "dstaddr")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { dstaddr().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "plen")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { plen().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "zero")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { zero().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "nextheader")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { nextheader().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @UDP_Types.UDP_pseudo_header_IPv6: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { UDP__pseudo__header__IPv6_template* precondition = new UDP__pseudo__header__IPv6_template; precondition->set_param(*param.get_elem(0)); UDP__pseudo__header__IPv6_template* implied_template = new UDP__pseudo__header__IPv6_template; implied_template->set_param(*param.get_elem(1)); *this = UDP__pseudo__header__IPv6_template(precondition, implied_template); } break; default: param.type_error("record template", "@UDP_Types.UDP_pseudo_header_IPv6"); } is_ifpresent = param.get_ifpresent(); } void UDP__pseudo__header__IPv6_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_srcaddr.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv6"); single_value->field_dstaddr.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv6"); single_value->field_plen.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv6"); single_value->field_zero.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv6"); single_value->field_nextheader.check_restriction(t_res, t_name ? t_name : "@UDP_Types.UDP_pseudo_header_IPv6"); 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 : "@UDP_Types.UDP_pseudo_header_IPv6"); } boolean UDP__pseudo__header__IPv6_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean UDP__pseudo__header__IPv6_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_idxitem_selection) { case MESSAGE_0: delete (my_head)->message_0; break; default: TTCN_error("Internal error: Invalid message selector in the queue of port %s.", port_name); } msg_queue_item_base *next_item = msg_queue_head->next_item; delete (msg_queue_item*)msg_queue_head; msg_queue_head = next_item; if (next_item == NULL) msg_queue_tail = NULL; TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::extract__msg, port_name, 0, ++msg_head_count, CHARSTRING(0,NULL), CHARSTRING(0,NULL));} void UDPmsg__SP__PT::clear_queue() { while (msg_queue_head != NULL) remove_msg_queue_head(); } UDPmsg__SP__PT::UDPmsg__SP__PT(const char *par_port_name) : PORT(par_port_name) { msg_queue_head = NULL; msg_queue_tail = NULL; } UDPmsg__SP__PT::~UDPmsg__SP__PT() { clear_queue(); } void UDPmsg__SP__PT::send(const UDP__packet& send_par, const COMPONENT& destination_component, FLOAT* timestamp_redirect) { if (!is_started) TTCN_error("Sending a message on port %s, which is not started.", port_name); if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of send operation."); const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMSEND:TTCN_Logger::PORTEVENT_MCSEND; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_msgport_send(port_name, destination_component, (TTCN_Logger::begin_event(log_sev, TRUE), TTCN_Logger::log_event_str(" @UDP_Types.UDP_packet : "), send_par.log(), TTCN_Logger::end_event_log2str())); } if (destination_component == SYSTEM_COMPREF) TTCN_error("Message cannot be sent to system on internal port %s.", port_name); else { Text_Buf text_buf; prepare_message(text_buf, "@UDP_Types.UDP_packet"); send_par.encode_text(text_buf); send_data(text_buf, destination_component); } } void UDPmsg__SP__PT::send(const UDP__packet& send_par, FLOAT* timestamp_redirect) { send(send_par, COMPONENT(get_default_destination()), timestamp_redirect); } void UDPmsg__SP__PT::send(const UDP__packet_template& send_par, const COMPONENT& destination_component, FLOAT* timestamp_redirect) { const UDP__packet& send_par_value = UDP__packet(send_par.valueof()); send(send_par_value, destination_component, timestamp_redirect); } void UDPmsg__SP__PT::send(const UDP__packet_template& send_par, FLOAT* timestamp_redirect) { const UDP__packet& send_par_value = UDP__packet(send_par.valueof()); send(send_par_value, COMPONENT(get_default_destination()), timestamp_redirect); } alt_status UDPmsg__SP__PT::receive(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { msg_queue_item *my_head = (msg_queue_item*)msg_queue_head; if (msg_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(my_head->sender_component)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name); sender_template.log_match(my_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else { if (sender_ptr != NULL) *sender_ptr = my_head->sender_component; TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name); const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV; if (TTCN_Logger::log_this_event(log_sev)) { switch (my_head->item_selection) { case MESSAGE_0: TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::receive__op, my_head->sender_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @UDP_Types.UDP_packet: "), my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); break; default: TTCN_error("Internal error: unknown message"); } } remove_msg_queue_head(); return ALT_YES; } } alt_status UDPmsg__SP__PT::check_receive(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { msg_queue_item *my_head = (msg_queue_item*)msg_queue_head; if (msg_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(my_head->sender_component)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name); sender_template.log_match(my_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else { if (sender_ptr != NULL) *sender_ptr = my_head->sender_component; TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name); const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV; if (TTCN_Logger::log_this_event(log_sev)) { switch (my_head->item_selection) { case MESSAGE_0: TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::check__receive__op, my_head->sender_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @UDP_Types.UDP_packet: "), my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); break; default: TTCN_error("Internal error: unknown message"); } } return ALT_YES; } } alt_status UDPmsg__SP__PT::trigger(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { msg_queue_item *my_head = (msg_queue_item*)msg_queue_head; if (msg_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(my_head->sender_component)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s will drop a message: Sender of the first message in the queue does not match the from clause: ", port_name); sender_template.log_match(my_head->sender_component); TTCN_Logger::end_event(); } remove_msg_queue_head(); return ALT_REPEAT; } else { if (sender_ptr != NULL) *sender_ptr = my_head->sender_component; TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name); const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV; if (TTCN_Logger::log_this_event(log_sev)) { switch (my_head->item_selection) { case MESSAGE_0: TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::trigger__op, my_head->sender_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @UDP_Types.UDP_packet: "), my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); break; default: TTCN_error("Internal error: unknown message"); } } remove_msg_queue_head(); return ALT_YES; } } alt_status UDPmsg__SP__PT::receive(const UDP__packet_template& value_template, UDP__packet *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Receive operation using '*' as matching template"); msg_queue_item *my_head = (msg_queue_item*)msg_queue_head; if (msg_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(my_head->sender_component)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name); sender_template.log_match(my_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else if (my_head->item_selection != MESSAGE_0) { TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s failed: Type of the first message in the queue is not @UDP_Types.UDP_packet.", port_name); return ALT_NO; } else if (!value_template.match(*my_head->message_0)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__, port_name, my_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { if (value_redirect != NULL) { *value_redirect = *my_head->message_0; } if (sender_ptr != NULL) *sender_ptr = my_head->sender_component; TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__, port_name, my_head->sender_component, (TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0), TTCN_Logger::end_event_log2str())); } log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::receive__op, my_head->sender_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @UDP_Types.UDP_packet : "), my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } remove_msg_queue_head(); return ALT_YES; } } alt_status UDPmsg__SP__PT::check_receive(const UDP__packet_template& value_template, UDP__packet *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Check-receive operation using '*' as matching template"); msg_queue_item *my_head = (msg_queue_item*)msg_queue_head; if (msg_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(my_head->sender_component)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name); sender_template.log_match(my_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else if (my_head->item_selection != MESSAGE_0) { TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s failed: Type of the first message in the queue is not @UDP_Types.UDP_packet.", port_name); return ALT_NO; } else if (!value_template.match(*my_head->message_0)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__, port_name, my_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { if (value_redirect != NULL) { *value_redirect = *my_head->message_0; } if (sender_ptr != NULL) *sender_ptr = my_head->sender_component; TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__, port_name, my_head->sender_component, (TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0), TTCN_Logger::end_event_log2str())); } log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::check__receive__op, my_head->sender_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @UDP_Types.UDP_packet : "), my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } return ALT_YES; } } alt_status UDPmsg__SP__PT::trigger(const UDP__packet_template& value_template, UDP__packet *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Trigger operation using '*' as matching template"); msg_queue_item *my_head = (msg_queue_item*)msg_queue_head; if (msg_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(my_head->sender_component)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s will drop a message: Sender of the first message in the queue does not match the from clause: ", port_name); sender_template.log_match(my_head->sender_component); TTCN_Logger::end_event(); } remove_msg_queue_head(); return ALT_REPEAT; } else if (my_head->item_selection != MESSAGE_0) { TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s will drop a message: Type of the first message in the queue is not @UDP_Types.UDP_packet.", port_name); remove_msg_queue_head(); return ALT_REPEAT; } else if (!value_template.match(*my_head->message_0)) { const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__, port_name, my_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0), TTCN_Logger::end_event_log2str())); } remove_msg_queue_head(); return ALT_REPEAT; } else { if (value_redirect != NULL) { *value_redirect = *my_head->message_0; } if (sender_ptr != NULL) *sender_ptr = my_head->sender_component; TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__, port_name, my_head->sender_component, (TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0), TTCN_Logger::end_event_log2str())); } log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::trigger__op, my_head->sender_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @UDP_Types.UDP_packet : "), my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } remove_msg_queue_head(); return ALT_YES; } } void UDPmsg__SP__PT::incoming_message(const UDP__packet& incoming_par, component sender_component) { if (!is_started) { if (is_halted) { TTCN_warning("A message that arrived on port %s has been discarded, because the port is not started.", port_name); return; } else { TTCN_error("Port %s is not started but a message has arrived on it.", port_name); } } msg_tail_count++; if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_MQUEUE)) { TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__msg, port_name, sender_component, msg_tail_count, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_MQUEUE, TRUE), TTCN_Logger::log_event_str(" @UDP_Types.UDP_packet : "), incoming_par.log(), TTCN_Logger::end_event_log2str())); } msg_queue_item *new_item = new msg_queue_item; new_item->item_selection = MESSAGE_0; new_item->message_0 = new UDP__packet(incoming_par); new_item->sender_component = sender_component; append_to_msg_queue(new_item); } boolean UDPmsg__SP__PT::process_message(const char *message_type, Text_Buf& incoming_buf, component sender_component, OCTETSTRING&) { if (!strcmp(message_type, "@UDP_Types.UDP_packet")) { UDP__packet incoming_par; incoming_par.decode_text(incoming_buf); incoming_message(incoming_par, sender_component); return TRUE; } else return FALSE; } /* Bodies of functions, altsteps and testcases */ void UDP__header_srcport_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__header_srcport_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__header_srcport_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__header_srcport_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__header_dstport_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__header_dstport_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__header_dstport_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__header_dstport_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__header_len_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__header_len_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__header_len_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__header_len_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__header_cksum_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__header_cksum_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__header_cksum_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__header_cksum_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__header_encoder(const UDP__header& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_header' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__header_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__header_decoder(OCTETSTRING& input_stream, UDP__header& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_header' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__header_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__packet_header_encoder(const UDP__header& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_header' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__packet_header_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__packet_header_decoder(OCTETSTRING& input_stream, UDP__header& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_header' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__packet_header_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__packet_payload_encoder(const OCTETSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(OCTETSTRING_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__packet_payload_decoder(OCTETSTRING& input_stream, OCTETSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(OCTETSTRING_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__packet_encoder(const UDP__packet& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_packet' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__packet_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__packet_decoder(OCTETSTRING& input_stream, UDP__packet& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_packet' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__packet_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv4_srcaddr_encoder(const OCTETSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv4_srcaddr_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv4_srcaddr_decoder(OCTETSTRING& input_stream, OCTETSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv4_srcaddr_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv4_dstaddr_encoder(const OCTETSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv4_dstaddr_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv4_dstaddr_decoder(OCTETSTRING& input_stream, OCTETSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv4_dstaddr_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv4_zero_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv4_zero_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv4_zero_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv4_zero_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv4_proto_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv4_proto_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv4_proto_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv4_proto_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv4_plen_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv4_plen_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv4_plen_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv4_plen_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv4_encoder(const UDP__pseudo__header__IPv4& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_pseudo_header_IPv4' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv4_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv4_decoder(OCTETSTRING& input_stream, UDP__pseudo__header__IPv4& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_pseudo_header_IPv4' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv4_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv6_srcaddr_encoder(const OCTETSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv6_srcaddr_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv6_srcaddr_decoder(OCTETSTRING& input_stream, OCTETSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv6_srcaddr_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv6_dstaddr_encoder(const OCTETSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv6_dstaddr_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv6_dstaddr_decoder(OCTETSTRING& input_stream, OCTETSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `octetstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv6_dstaddr_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv6_plen_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv6_plen_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv6_plen_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv6_plen_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv6_zero_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv6_zero_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv6_zero_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv6_zero_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv6_nextheader_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv6_nextheader_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv6_nextheader_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv6_nextheader_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header__IPv6_encoder(const UDP__pseudo__header__IPv6& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_pseudo_header_IPv6' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header__IPv6_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header__IPv6_decoder(OCTETSTRING& input_stream, UDP__pseudo__header__IPv6& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_pseudo_header_IPv6' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header__IPv6_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } void UDP__pseudo__header_encoder(const UDP__pseudo__header& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_pseudo_header' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf; input_value.encode(UDP__pseudo__header_descr_, ttcn_buf, coding_type, extra_options); ttcn_buf.get_string(output_stream); } INTEGER UDP__pseudo__header_decoder(OCTETSTRING& input_stream, UDP__pseudo__header& output_value, const UNIVERSAL_CHARSTRING& coding_name) { TTCN_EncDec::coding_t coding_type; unsigned int extra_options = 0; TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE); if (coding_type != TTCN_EncDec::CT_RAW) { TTCN_Logger::begin_event_log2str(); coding_name.log(); TTCN_error("Type `@UDP_Types.UDP_pseudo_header' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str()); } TTCN_Buffer ttcn_buf(input_stream); output_value.decode(UDP__pseudo__header_descr_, ttcn_buf, coding_type, extra_options); switch (TTCN_EncDec::get_last_error_type()) { case TTCN_EncDec::ET_NONE: ttcn_buf.cut(); ttcn_buf.get_string(input_stream); return 0; case TTCN_EncDec::ET_INCOMPL_MSG: case TTCN_EncDec::ET_LEN_ERR: return 2; default: return 1; } } /* Bodies of static functions */ void pre_init_module() { TTCN_Location current_location("UDP_Types.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "UDP_Types"); General__Types::module_object.pre_init_module(); module_object.add_function("f_UDP_enc", (genericfunc_t)&f__UDP__enc, NULL); module_object.add_function("f_UDP_pseudo_header_enc", (genericfunc_t)&f__UDP__pseudo__header__enc, NULL); module_object.add_function("f_UDP_dec", (genericfunc_t)&f__UDP__dec, NULL); module_object.add_function("f_UDP_checksum", (genericfunc_t)&f__UDP__checksum, NULL); } void post_init_module() { TTCN_Location current_location("UDP_Types.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "UDP_Types"); General__Types::module_object.post_init_module(); } } /* end of namespace */