add error handling to TTCN3 socket handlers

This commit is contained in:
Andre Puschmann 2020-02-13 21:07:06 +01:00
parent 42920d508f
commit b15cd3fdaa
5 changed files with 39 additions and 13 deletions

View File

@ -118,7 +118,9 @@ private:
std::string resp = ttcn3_helpers::get_drbmux_common_ind_cnf(); std::string resp = ttcn3_helpers::get_drbmux_common_ind_cnf();
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
};
} }
}; };

View File

@ -127,7 +127,9 @@ private:
string resp = ttcn3_helpers::get_ctrl_cnf(protocol.GetString(), ip_version, addr.GetString()); string resp = ttcn3_helpers::get_ctrl_cnf(protocol.GetString(), ip_version, addr.GetString());
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
}; };

View File

@ -52,7 +52,9 @@ public:
{ {
if (running) { if (running) {
log->info_hex(pdu->msg, pdu->N_bytes, "Sending %d B to Titan\n", pdu->N_bytes); log->info_hex(pdu->msg, pdu->N_bytes, "Sending %d B to Titan\n", pdu->N_bytes);
srslte_netsource_write(&net_source, (void*)pdu->msg, pdu->N_bytes); if (srslte_netsource_write(&net_source, (void*)pdu->msg, pdu->N_bytes) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
};
} else { } else {
log->error("Trying to transmit but port not connected.\n"); log->error("Trying to transmit but port not connected.\n");
} }

View File

@ -113,7 +113,9 @@ private:
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_name.GetString(), "Cell"); std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_name.GetString(), "Cell");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
} }
@ -125,7 +127,9 @@ private:
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id, "Cell"); std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id, "Cell");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
void handle_request_cell(Document& document, const uint8_t* payload, const uint16_t len) void handle_request_cell(Document& document, const uint8_t* payload, const uint16_t len)
@ -183,7 +187,9 @@ private:
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "L1MacIndCtrl"); std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "L1MacIndCtrl");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
} }
@ -242,7 +248,9 @@ private:
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "RadioBearerList"); std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "RadioBearerList");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
void handle_request_cell_attenuation_list(Document& document) void handle_request_cell_attenuation_list(Document& document)
@ -291,7 +299,9 @@ private:
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "CellAttenuationList"); std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "CellAttenuationList");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
void handle_request_pdcp_count(Document& document) void handle_request_pdcp_count(Document& document)
@ -328,7 +338,9 @@ private:
std::string resp = ttcn3_helpers::get_pdcp_count_response(cell_id.GetString(), bearers); std::string resp = ttcn3_helpers::get_pdcp_count_response(cell_id.GetString(), bearers);
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
void handle_request_as_security(Document& document) void handle_request_as_security(Document& document)
@ -417,7 +429,9 @@ private:
if (config_flag.GetBool() == true) { if (config_flag.GetBool() == true) {
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "AS_Security"); std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "AS_Security");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} else { } else {
log->info("Skipping response for AS_Security message.\n"); log->info("Skipping response for AS_Security message.\n");
} }
@ -455,7 +469,9 @@ private:
ttcn3_helpers::get_sys_req_cnf_with_time(cell_id.GetString(), "EnquireTiming", syssim->get_tti()); ttcn3_helpers::get_sys_req_cnf_with_time(cell_id.GetString(), "EnquireTiming", syssim->get_tti());
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
void handle_request_paging(Document& document, const uint8_t* payload, const uint16_t len) void handle_request_paging(Document& document, const uint8_t* payload, const uint16_t len)
@ -496,7 +512,9 @@ private:
std::string resp = ttcn3_helpers::get_sys_req_cnf_with_time(cell_id.GetString(), "Paging", syssim->get_tti()); std::string resp = ttcn3_helpers::get_sys_req_cnf_with_time(cell_id.GetString(), "Paging", syssim->get_tti());
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length()); log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()); if (srslte_netsource_write(&net_source, (char*)resp.c_str(), resp.length()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} else { } else {
log->info("Skipping response for Paging message.\n"); log->info("Skipping response for Paging message.\n");
} }

View File

@ -161,7 +161,9 @@ private:
resp.Accept(writer); resp.Accept(writer);
log->info("Sending %s to tester (%zd B)\n", buffer.GetString(), buffer.GetSize()); log->info("Sending %s to tester (%zd B)\n", buffer.GetString(), buffer.GetSize());
srslte_netsource_write(&net_source, (char*)buffer.GetString(), buffer.GetSize()); if (srslte_netsource_write(&net_source, (char*)buffer.GetString(), buffer.GetSize()) != SRSLTE_SUCCESS) {
log->error("Error sending message to tester.\n");
}
} }
void handle_at_command(Document& document) void handle_at_command(Document& document)