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

Change-Id: I954b13d0e26fec7bc7fe23edcbc015dfac654ef8
Refs: #1494
This commit is contained in:
Alexander Afanasyev committed 2014-04-25 22:55:24 -07:00
1 parent d35176cf0e
commit 650028d5c5
7 files changed
+614 -170

No files matched your search

+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