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

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

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

/* Including header files */

#include "NS_Provider_FR.hh"

namespace NS__Provider__FR {

/* Literal string constants */

extern const CHARSTRING cs_0(6, "-FRemu");
const unsigned char module_checksum[] = { 0x6e, 0xbd, 0xa3, 0xba, 0x17, 0xf2, 0x5a, 0xe1, 0xb0, 0xbf, 0xd8, 0x0d, 0x67, 0xfd, 0xdd, 0xd4 };

/* Global variable definitions */

const TTCN_Typedescriptor_t& NS__Provider__FR__CT_descr_ = COMPONENT_descr_;
COMPONENT NS__Provider__FR__CT_component_vc__FREMU;
BOOLEAN NS__Provider__FR__CT_component_link__available;
BOOLEAN NS__Provider__FR__CT_component_pvc__active;
TTCN_Module module_object("NS_Provider_FR", __DATE__, __TIME__, module_checksum, pre_init_module, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, post_init_module, NULL, NULL, NULL, init_comp_type, init_system_port, start_ptc_function, 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);

/* Bodies of functions, altsteps and testcases */

void main_(const NS__Emulation::NSVCConfiguration& config, const NS__Emulation::NSConfiguration& nsconfig, const CHARSTRING& id)
{
TTCN_Location current_location("NS_Provider_FR.ttcn", 30, TTCN_Location::LOCATION_FUNCTION, "main");
current_location.update_lineno(33);
/* NS_Provider_FR.ttcn, line 33 */
NS__Provider__FR__CT_component_vc__FREMU = TTCN_Runtime::create_component("FrameRelay_Emulation", "FR_Emulation_CT", (id + cs_0), NULL, TRUE);
current_location.update_lineno(34);
/* NS_Provider_FR.ttcn, line 34 */
FrameRelay__Emulation::Q933em__Config q933__cfg(FrameRelay__Emulation::ts__Q933em__Config((!(const_cast< const NS__Emulation::NSConfiguration&>(nsconfig).role__sgsn())), FALSE).valueof());
current_location.update_lineno(35);
/* NS_Provider_FR.ttcn, line 35 */
q933__cfg.T391() = 1.0;
current_location.update_lineno(36);
/* NS_Provider_FR.ttcn, line 36 */
{
Map_Params tmp_2(1);
tmp_2.set_param(0, ttcn_to_string(CHARSTRING(const_cast< const NS__Emulation::NSVCConfiguration&>(config).provider().fr().netdev())));
TTCN_Runtime::map_port(NS__Provider__FR__CT_component_vc__FREMU, FrameRelay__Emulation::FR__Emulation__CT_component_FR.get_name(), SYSTEM_COMPREF, AF__PACKET__PortType::af__packet_component_AF__PACKET.get_name(), tmp_2);
}
current_location.update_lineno(37);
/* NS_Provider_FR.ttcn, line 37 */
FrameRelay__Emulation::start_main_(NS__Provider__FR__CT_component_vc__FREMU, q933__cfg);
current_location.update_lineno(40);
/* NS_Provider_FR.ttcn, line 40 */
TTCN_Runtime::connect_port(self, FrameRelay__Emulation::FR__Client__CT_component_FR.get_name(), NS__Provider__FR__CT_component_vc__FREMU, FrameRelay__Emulation::FR__Emulation__CT_component_CLIENT.get_name());
current_location.update_lineno(41);
/* NS_Provider_FR.ttcn, line 41 */
TTCN_Runtime::connect_port(self, FrameRelay__Emulation::FR__Client__CT_component_FR__PROC.get_name(), NS__Provider__FR__CT_component_vc__FREMU, FrameRelay__Emulation::FR__Emulation__CT_component_PROC.get_name());
current_location.update_lineno(44);
/* NS_Provider_FR.ttcn, line 44 */
FrameRelay__Emulation::f__fremu__register(const_cast< const NS__Emulation::NSVCConfiguration&>(config).provider().fr().dlci());
for ( ; ; ) {
current_location.update_lineno(48);
/* NS_Provider_FR.ttcn, line 48 */
FrameRelay__Types::FrameRelayFrame rx__fr;
current_location.update_lineno(49);
/* NS_Provider_FR.ttcn, line 49 */
FrameRelay__Emulation::FRemu__Event rx__frevt;
current_location.update_lineno(50);
/* NS_Provider_FR.ttcn, line 50 */
NS__Types::PDU__NS rx__pdu;
current_location.update_lineno(51);
/* NS_Provider_FR.ttcn, line 51 */
{
tmp_3:
alt_status tmp_3_alt_flag_0 = ALT_UNCHECKED;
alt_status tmp_3_alt_flag_1 = ALT_UNCHECKED;
alt_status tmp_3_alt_flag_2 = ALT_UNCHECKED;
alt_status tmp_3_alt_flag_3 = ALT_MAYBE;
alt_status tmp_3_alt_flag_4 = ALT_MAYBE;
alt_status tmp_3_alt_flag_5 = ALT_MAYBE;
alt_status tmp_3_alt_flag_6 = ALT_MAYBE;
alt_status tmp_3_alt_flag_7 = ALT_MAYBE;
alt_status tmp_3_alt_flag_8 = ALT_MAYBE;
alt_status tmp_3_alt_flag_9 = ALT_MAYBE;
alt_status tmp_3_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_3_alt_flag_0 == ALT_UNCHECKED) {
current_location.update_lineno(53);
/* NS_Provider_FR.ttcn, line 53 */
if ((!(NS__Provider__FR__CT_component_link__available))) tmp_3_alt_flag_0 = ALT_MAYBE;
else tmp_3_alt_flag_0 = ALT_NO;
}
if (tmp_3_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(53);
/* NS_Provider_FR.ttcn, line 53 */
tmp_3_alt_flag_0 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(FrameRelay__Types::FrameRelayFrame_template(ANY_VALUE), &(rx__fr), any_compref, NULL, NULL, NULL);
if (tmp_3_alt_flag_0 == ALT_YES) {
current_location.update_lineno(54);
/* NS_Provider_FR.ttcn, line 54 */
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Dropping Rx Msg because FR link not yet available");
rx__fr.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
break;
}
}
if (tmp_3_alt_flag_1 == ALT_UNCHECKED) {
current_location.update_lineno(58);
/* NS_Provider_FR.ttcn, line 58 */
if ((NS__Provider__FR__CT_component_link__available && NS__Provider__FR__CT_component_pvc__active)) tmp_3_alt_flag_1 = ALT_MAYBE;
else tmp_3_alt_flag_1 = ALT_NO;
}
if (tmp_3_alt_flag_1 == ALT_MAYBE) {
current_location.update_lineno(58);
/* NS_Provider_FR.ttcn, line 58 */
tmp_3_alt_flag_1 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(FrameRelay__Types::tr__FR(INTEGER_template(const_cast< const NS__Emulation::NSVCConfiguration&>(config).provider().fr().dlci()), FrameRelay__Types::tr__FR_payload_defval, FrameRelay__Types::tr__FR_c__r_defval, FrameRelay__Types::tr__FR_fecn_defval, FrameRelay__Types::tr__FR_becn_defval, FrameRelay__Types::tr__FR_de_defval), &(rx__fr), any_compref, NULL, NULL, NULL);
if (tmp_3_alt_flag_1 == ALT_YES) {
current_location.update_lineno(59);
/* NS_Provider_FR.ttcn, line 59 */
NS__Types::PDU__NS ns(NS__Types::dec__PDU__NS(const_cast< const FrameRelay__Types::FrameRelayFrame&>(rx__fr).payload()));
current_location.update_lineno(60);
/* NS_Provider_FR.ttcn, line 60 */
NS__Emulation::NS__Provider__CT_component_NSE.send(ns, NULL);
break;
}
}
if (tmp_3_alt_flag_2 == ALT_UNCHECKED) {
current_location.update_lineno(62);
/* NS_Provider_FR.ttcn, line 62 */
if ((!(NS__Provider__FR__CT_component_pvc__active))) tmp_3_alt_flag_2 = ALT_MAYBE;
else tmp_3_alt_flag_2 = ALT_NO;
}
if (tmp_3_alt_flag_2 == ALT_MAYBE) {
current_location.update_lineno(62);
/* NS_Provider_FR.ttcn, line 62 */
tmp_3_alt_flag_2 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(FrameRelay__Types::tr__FR(INTEGER_template(const_cast< const NS__Emulation::NSVCConfiguration&>(config).provider().fr().dlci()), FrameRelay__Types::tr__FR_payload_defval, FrameRelay__Types::tr__FR_c__r_defval, FrameRelay__Types::tr__FR_fecn_defval, FrameRelay__Types::tr__FR_becn_defval, FrameRelay__Types::tr__FR_de_defval), &(rx__fr), any_compref, NULL, NULL, NULL);
if (tmp_3_alt_flag_2 == ALT_YES) {
current_location.update_lineno(63);
/* NS_Provider_FR.ttcn, line 63 */
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Dropping Rx Msg because FR DLC not yet available");
rx__fr.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
break;
}
}
if (tmp_3_alt_flag_3 == ALT_MAYBE) {
current_location.update_lineno(65);
/* NS_Provider_FR.ttcn, line 65 */
tmp_3_alt_flag_3 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(FrameRelay__Types::tr__FR(INTEGER_template(ANY_VALUE), FrameRelay__Types::tr__FR_payload_defval, FrameRelay__Types::tr__FR_c__r_defval, FrameRelay__Types::tr__FR_fecn_defval, FrameRelay__Types::tr__FR_becn_defval, FrameRelay__Types::tr__FR_de_defval), &(rx__fr), any_compref, NULL, NULL, NULL);
if (tmp_3_alt_flag_3 == ALT_YES) {
current_location.update_lineno(66);
/* NS_Provider_FR.ttcn, line 66 */
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Dropping Rx Msg because DLCI unknown");
rx__fr.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(67);
/* NS_Provider_FR.ttcn, line 67 */
TTCN_Runtime::setverdict(FAIL);
break;
}
}
if (tmp_3_alt_flag_4 == ALT_MAYBE) {
current_location.update_lineno(70);
/* NS_Provider_FR.ttcn, line 70 */
{
FrameRelay__Emulation::FRemu__Event_template tmp_4;
tmp_4.link__status() = FrameRelay__Emulation::FRemu__LinkStatus::FR__LINK__STS__AVAILABLE;
tmp_3_alt_flag_4 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(tmp_4, &(rx__frevt), any_compref, NULL, NULL, NULL);
}
if (tmp_3_alt_flag_4 == ALT_YES) {
current_location.update_lineno(71);
/* NS_Provider_FR.ttcn, line 71 */
{
boolean tmp_5;
tmp_5 = (NS__Provider__FR__CT_component_link__available == FALSE);
if (tmp_5) tmp_5 = (NS__Provider__FR__CT_component_pvc__active == TRUE);
if (tmp_5) {
current_location.update_lineno(72);
/* NS_Provider_FR.ttcn, line 72 */
{
NS__Emulation::NS__Provider__Evt_template tmp_6;
tmp_6.link__status() = NS__Emulation::NS__Provider__LinkStatus::NS__PROV__LINK__STATUS__UP;
NS__Emulation::NS__Provider__CT_component_NSE.send(tmp_6, NULL);
}
}
}
current_location.update_lineno(74);
/* NS_Provider_FR.ttcn, line 74 */
NS__Provider__FR__CT_component_link__available = TRUE;
break;
}
}
if (tmp_3_alt_flag_5 == ALT_MAYBE) {
current_location.update_lineno(76);
/* NS_Provider_FR.ttcn, line 76 */
{
FrameRelay__Emulation::FRemu__Event_template tmp_8;
tmp_8.link__status() = FrameRelay__Emulation::FRemu__LinkStatus::FR__LINK__STS__UNAVAILABLE;
tmp_3_alt_flag_5 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(tmp_8, &(rx__frevt), any_compref, NULL, NULL, NULL);
}
if (tmp_3_alt_flag_5 == ALT_YES) {
current_location.update_lineno(77);
/* NS_Provider_FR.ttcn, line 77 */
NS__Provider__FR__CT_component_link__available = FALSE;
current_location.update_lineno(78);
/* NS_Provider_FR.ttcn, line 78 */
NS__Provider__FR__CT_component_pvc__active = FALSE;
current_location.update_lineno(79);
/* NS_Provider_FR.ttcn, line 79 */
{
NS__Emulation::NS__Provider__Evt_template tmp_11;
tmp_11.link__status() = NS__Emulation::NS__Provider__LinkStatus::NS__PROV__LINK__STATUS__DOWN;
NS__Emulation::NS__Provider__CT_component_NSE.send(tmp_11, NULL);
}
break;
}
}
if (tmp_3_alt_flag_6 == ALT_MAYBE) {
current_location.update_lineno(81);
/* NS_Provider_FR.ttcn, line 81 */
tmp_3_alt_flag_6 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(FrameRelay__Emulation::tr__FRemu__PvcStatusAct(INTEGER_template(const_cast< const NS__Emulation::NSVCConfiguration&>(config).provider().fr().dlci()), BOOLEAN_template(TRUE)), &(rx__frevt), any_compref, NULL, NULL, NULL);
if (tmp_3_alt_flag_6 == ALT_YES) {
current_location.update_lineno(82);
/* NS_Provider_FR.ttcn, line 82 */
{
boolean tmp_12;
tmp_12 = (NS__Provider__FR__CT_component_pvc__active == FALSE);
if (tmp_12) tmp_12 = (NS__Provider__FR__CT_component_link__available == TRUE);
if (tmp_12) {
current_location.update_lineno(83);
/* NS_Provider_FR.ttcn, line 83 */
{
NS__Emulation::NS__Provider__Evt_template tmp_13;
tmp_13.link__status() = NS__Emulation::NS__Provider__LinkStatus::NS__PROV__LINK__STATUS__UP;
NS__Emulation::NS__Provider__CT_component_NSE.send(tmp_13, NULL);
}
}
}
current_location.update_lineno(85);
/* NS_Provider_FR.ttcn, line 85 */
NS__Provider__FR__CT_component_pvc__active = TRUE;
break;
}
}
if (tmp_3_alt_flag_7 == ALT_MAYBE) {
current_location.update_lineno(87);
/* NS_Provider_FR.ttcn, line 87 */
tmp_3_alt_flag_7 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(FrameRelay__Emulation::tr__FRemu__PvcStatusAct(INTEGER_template(const_cast< const NS__Emulation::NSVCConfiguration&>(config).provider().fr().dlci()), BOOLEAN_template(FALSE)), &(rx__frevt), any_compref, NULL, NULL, NULL);
if (tmp_3_alt_flag_7 == ALT_YES) {
current_location.update_lineno(88);
/* NS_Provider_FR.ttcn, line 88 */
NS__Provider__FR__CT_component_pvc__active = FALSE;
current_location.update_lineno(89);
/* NS_Provider_FR.ttcn, line 89 */
{
NS__Emulation::NS__Provider__Evt_template tmp_16;
tmp_16.link__status() = NS__Emulation::NS__Provider__LinkStatus::NS__PROV__LINK__STATUS__DOWN;
NS__Emulation::NS__Provider__CT_component_NSE.send(tmp_16, NULL);
}
break;
}
}
if (tmp_3_alt_flag_8 == ALT_MAYBE) {
current_location.update_lineno(91);
/* NS_Provider_FR.ttcn, line 91 */
tmp_3_alt_flag_8 = FrameRelay__Emulation::FR__Client__CT_component_FR.receive(FrameRelay__Emulation::FRemu__Event_template(ANY_VALUE), &(rx__frevt), any_compref, NULL, NULL, NULL);
if (tmp_3_alt_flag_8 == ALT_YES) {
current_location.update_lineno(92);
/* NS_Provider_FR.ttcn, line 92 */
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Unhandled FRemu_event: ");
rx__frevt.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
break;
}
}
if (tmp_3_alt_flag_9 == ALT_MAYBE) {
current_location.update_lineno(94);
/* NS_Provider_FR.ttcn, line 94 */
tmp_3_alt_flag_9 = NS__Emulation::NS__Provider__CT_component_NSE.receive(NS__Types::PDU__NS_template(ANY_VALUE), &(rx__pdu), any_compref, NULL, NULL, NULL);
if (tmp_3_alt_flag_9 == ALT_YES) {
current_location.update_lineno(95);
/* NS_Provider_FR.ttcn, line 95 */
FrameRelay__Emulation::FR__Client__CT_component_FR.send(FrameRelay__Types::ts__FR(const_cast< const NS__Emulation::NSVCConfiguration&>(config).provider().fr().dlci(), NS__Types::enc__PDU__NS(rx__pdu), TRUE, FrameRelay__Types::ts__FR_fecn_defval, FrameRelay__Types::ts__FR_becn_defval, FrameRelay__Types::ts__FR_de_defval), NULL);
break;
}
}
if (tmp_3_default_flag == ALT_MAYBE) {
tmp_3_default_flag = TTCN_Default::try_altsteps();
if (tmp_3_default_flag == ALT_YES || tmp_3_default_flag == ALT_BREAK) break;
else if (tmp_3_default_flag == ALT_REPEAT) goto tmp_3;
}
current_location.update_lineno(51);
/* NS_Provider_FR.ttcn, line 51 */
if (tmp_3_alt_flag_0 == ALT_NO && tmp_3_alt_flag_1 == ALT_NO && tmp_3_alt_flag_2 == ALT_NO && tmp_3_alt_flag_3 == ALT_NO && tmp_3_alt_flag_4 == ALT_NO && tmp_3_alt_flag_5 == ALT_NO && tmp_3_alt_flag_6 == ALT_NO && tmp_3_alt_flag_7 == ALT_NO && tmp_3_alt_flag_8 == ALT_NO && tmp_3_alt_flag_9 == ALT_NO && tmp_3_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file NS_Provider_FR.ttcn between lines 51 and 98.");
TTCN_Snapshot::take_new(TRUE);
}
}
}
}

void start_main_(const COMPONENT& component_reference, const NS__Emulation::NSVCConfiguration& config, const NS__Emulation::NSConfiguration& nsconfig, const CHARSTRING& id)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function main(");
config.log();
TTCN_Logger::log_event_str(", ");
nsconfig.log();
TTCN_Logger::log_event_str(", ");
id.log();
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "NS_Provider_FR", "main", text_buf);
config.encode_text(text_buf);
nsconfig.encode_text(text_buf);
id.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}


/* Bodies of static functions */

void pre_init_module()
{
TTCN_Location current_location("NS_Provider_FR.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "NS_Provider_FR");
NS__Emulation::module_object.pre_init_module();
NS__Types::module_object.pre_init_module();
FrameRelay__Emulation::module_object.pre_init_module();
module_object.add_function("main", (genericfunc_t)&main_, (genericfunc_t)&start_main_);
}

void post_init_module()
{
TTCN_Location current_location("NS_Provider_FR.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "NS_Provider_FR");
NS__Emulation::module_object.post_init_module();
NS__Types::module_object.post_init_module();
FrameRelay__Emulation::module_object.post_init_module();
}

boolean init_comp_type(const char *component_type, boolean init_base_comps)
{
(void)init_base_comps;
if (!strcmp(component_type, "NS_Provider_FR_CT")) {
if (init_base_comps) {
Module_List::initialize_component("FrameRelay_Emulation", "FR_Client_CT", FALSE);
Module_List::initialize_component("NS_Emulation", "NS_Provider_CT", FALSE);
}
NS__Provider__FR__CT_component_vc__FREMU.clean_up();
NS__Provider__FR__CT_component_link__available = FALSE;
NS__Provider__FR__CT_component_pvc__active = FALSE;
return TRUE;
} else return FALSE;
}

boolean init_system_port(const char* component_type, const char* port_name)
{
if (!strcmp(component_type, "NS_Provider_FR_CT")) {
if (!strcmp(port_name, "FR")) {
FrameRelay__Emulation::FR__Client__CT_component_FR.safe_start();
return TRUE;
}
if (!strcmp(port_name, "FR_PROC")) {
FrameRelay__Emulation::FR__Client__CT_component_FR__PROC.safe_start();
return TRUE;
}
if (!strcmp(port_name, "NSE")) {
NS__Emulation::NS__Provider__CT_component_NSE.safe_start();
return TRUE;
}
}
return FALSE;
}

boolean start_ptc_function(const char *function_name, Text_Buf& function_arguments)
{
if (!strcmp(function_name, "main")) {
NS__Emulation::NSVCConfiguration config;
NS__Emulation::NSConfiguration nsconfig;
CHARSTRING id;
config.decode_text(function_arguments);
nsconfig.decode_text(function_arguments);
id.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function main(");
config.log();
TTCN_Logger::log_event_str(", ");
nsconfig.log();
TTCN_Logger::log_event_str(", ");
id.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
main_(config, nsconfig, id);
TTCN_Runtime::function_finished("main");
return TRUE;
} else return FALSE;
}


} /* end of namespace */
