{
if (msg->isSelfMessage())
{
bool ret = conn->processTimer(msg);
if (!ret)
removeConnection(conn);
}
else if (msg->arrivedOn("ipIn") || msg->arrivedOn("ipv6In"))
{
if (dynamic_cast<ICMPMessage *>(msg) || dynamic_cast<ICMPv6Message *>(msg))
{
tcpEV << "ICMP error received -- discarding\n";
delete msg;
}
else
{
TCPSegment *tcpseg = check_and_cast<TCPSegment *>(msg);
IPvXAddress srcAddr, destAddr;
if (dynamic_cast<IPControlInfo *>(tcpseg->getControlInfo())!=NULL)
{
IPControlInfo *controlInfo = (IPControlInfo *)tcpseg->removeControlInfo();
srcAddr = controlInfo->getSrcAddr();
destAddr = controlInfo->getDestAddr();
delete controlInfo;
}
else if (dynamic_cast<IPv6ControlInfo *>(tcpseg->getControlInfo())!=NULL)
{
IPv6ControlInfo *controlInfo = (IPv6ControlInfo *)tcpseg->removeControlInfo();
srcAddr = controlInfo->getSrcAddr();
destAddr = controlInfo->getDestAddr();
delete controlInfo;
}
else
{
error(
"(%s)%s arrived without control info", tcpseg->getClassName(), tcpseg->getName());
}
if (conn)
{
bool ret = conn->processTCPSegment(tcpseg, srcAddr, destAddr);
if (!ret)
removeConnection(conn);
}
else
{
}
}
}
else
{
TCPCommand *controlInfo = check_and_cast<TCPCommand *>(msg->getControlInfo());
int appGateIndex = msg->getArrivalGate()->getIndex();
int connId = controlInfo->getConnId();
if (!conn)
{
AppConnKey key;
key.appGateIndex = appGateIndex;
key.connId = connId;
tcpAppConnMap[key] = conn;
tcpEV << "TCP connection created for " << msg << "\n";
}
bool ret = conn->processAppCommand(msg);
if (!ret)
removeConnection(conn);
}
if (ev.isGUI())
updateDisplayString();
}