face: Gracefully handle tlv::Error when received TLV block is malformed

Change-Id: I954b13d0e26fec7bc7fe23edcbc015dfac654ef8
Refs: #1494
This commit is contained in:
Alexander Afanasyev
2014-04-25 18:39:10 -07:00
parent d35176cf0e
commit 650028d5c5
7 changed files with 614 additions and 170 deletions
+21 -16
View File
@@ -90,24 +90,29 @@ Face::isUp() const
bool
Face::decodeAndDispatchInput(const Block& element)
{
/// \todo Ensure lazy field decoding process
try {
/// \todo Ensure lazy field decoding process
if (element.type() == tlv::Interest)
{
shared_ptr<Interest> i = make_shared<Interest>();
i->wireDecode(element);
this->onReceiveInterest(*i);
}
else if (element.type() == tlv::Data)
{
shared_ptr<Data> d = make_shared<Data>();
d->wireDecode(element);
this->onReceiveData(*d);
}
else
if (element.type() == tlv::Interest)
{
shared_ptr<Interest> i = make_shared<Interest>();
i->wireDecode(element);
this->onReceiveInterest(*i);
}
else if (element.type() == tlv::Data)
{
shared_ptr<Data> d = make_shared<Data>();
d->wireDecode(element);
this->onReceiveData(*d);
}
else
return false;
return true;
}
catch (tlv::Error&) {
return false;
return true;
}
}
} //namespace nfd