Commit 28891cd2 authored by Daniel Krebs's avatar Daniel Krebs

ips/switch: add more sanity checks for making connections

parent ae908407
......@@ -73,9 +73,26 @@ bool
AxiStreamSwitch::connectInternal(const std::string& portSlave,
const std::string& portMaster)
{
// check if slave port exists
try {
getSlavePort(portSlave);
} catch(const std::out_of_range&) {
logger->error("Switch doesn't have a slave port named '{}'", portSlave);
return false;
}
// check if master port exists
try {
getMasterPort(portMaster);
} catch(const std::out_of_range&) {
logger->error("Switch doesn't have a master port named '{}'", portMaster);
return false;
}
if(portSlave.substr(0, 1) != "S" or
portMaster.substr(0, 1) != "M") {
logger->error("sanity check failed");
logger->error("sanity check failed: master {} slave {}",
portMaster, portSlave);
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment