<div dir="ltr"><div>Hi,</div><div>I need to add and an <span style="font-family:monospace,monospace">Integer</span> and <span style="font-family:monospace,monospace">std::vector<std::string></span> type additional fields in the Interest packet. I have done following steps to do so:</div><div>1. Added private fields (say: <span style="font-family:monospace,monospace">m_MyInteger and m_MyVector</span>) in <b><span style="font-family:monospace,monospace">interest.hpp</span></b> file and write necessary getters, setters and helper functions to manipulate these private members<br></div><div>2. Added <span style="font-family:monospace,monospace">MyVector = 40002</span> and<span style="font-family:monospace,monospace"> MyInteger = 40003 </span>in the enum in<b> tlv.hpp</b> file</div><div>3. Added following code blocks in <span style="font-family:monospace,monospace">wireEncode</span> method in <b>interest.cpp</b></div><div>//for MyVector<br></div><div><span style="font-family:monospace,monospace">std::vector<std::string> myTempVector = this->getMyVector();<br>    totalLength += encoder.prependByteArray(<br>            reinterpret_cast<uint8_t*>(&myTempVector), sizeof(myTempVector));<br>    totalLength += encoder.prependVarNumber(sizeof(myTempVector));<br>    totalLength += encoder.prependVarNumber(tlv::MyVector);</span></div><div><br></div><div>//for MyInteger</div><div><div><span style="font-family:monospace,monospace">int myTempInt = this->getMyInteger();<br>    totalLength += encoder.prependByteArray(<br>            reinterpret_cast<uint8_t*>(&myTempInt), sizeof(myTempInt));<br>    totalLength += encoder.prependVarNumber(sizeof(myTempInt));<br>    totalLength += encoder.prependVarNumber(tlv::MyInteger);</span></div><div><br></div></div><div>4. Added following code blocks in <span style="font-family:monospace,monospace">wireDecode</span> method in <b>interest.cpp</b></div><div>//for MyVector</div><div><span style="font-family:monospace,monospace">val = m_wire.find(tlv::MyVector);<br>if (val == m_wire.elements_end()) {<br>    BOOST_THROW_EXCEPTION(Error("MyVector element is missing"));<br>}<br>std::vector<std::string> myTemVector;<br>if (val->value_size() != sizeof(myTemVector)) {<br>    BOOST_THROW_EXCEPTION(Error("<span style="font-family:monospace,monospace">myTemVector</span> element is malformed"));<br>}<br>std::memcpy(&myTemVector, val->value(), sizeof(myTemVector));<br>m_MyVector = myTemVector;</span></div><div><br></div><div>//for MyInteger</div><div><span style="font-family:monospace,monospace">val = m_wire.find(tlv::MyInteger);<br>if (val == m_wire.elements_end()) {<br>    BOOST_THROW_EXCEPTION(Error("MyInteger element is missing"));<br>}<br>uint32_t myTmpInteger = 0;<br>if (val->value_size() != sizeof(myTmpInteger)) {<br>    BOOST_THROW_EXCEPTION(Error("<span style="font-family:monospace,monospace">myTmpInteger</span> element is malformed"));<br>}<br>std::memcpy(&myTmpInteger, val->value(), sizeof(myTmpInteger));<br>m_MyInteger = myTmpInteger;<br></span></div><div><br></div><div>5. I need to create a copy of Interest from an existing Interest (say: existingInterest), so I'm using this way to create an Interest:</div><div><span style="font-family:monospace,monospace">auto myInterest = std::make_shared<Interest>(existingInterest.wireEncode());</span></div><div><br></div><div><b>Problem:</b> I'm following these 1-to-5 steps in order to add an Integer and a std::vector<std::string> fields in Interest packet but it gives an error on <b><span style="font-family:monospace,monospace">wireDecode</span></b> while decoding MyVector field and simulation stops and terminates. But it does not give error on MyInteger field. Am I doing it right? Am I missing something? Please help me solving this I'm stuck on this point from many days.<br></div><div><br></div><div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><span style="font-family:georgia,serif">Regards,<br></span></div><div><span style="font-family:georgia,serif">Mudasir Qazi<br></span></div></div></div></div></div></div></div></div></div></div></div>