Reputation: 1
I am trying to implement the standard advice for creating a new protocol header in NS3. I have been following the brief tutorial at http://www.nsnam.org/wiki/HOWTO_create_a_new_type_of_protocol_header_or_trailer.
Even just by copying the code into the relevant files, I get errors saying SetData and GetData are undefined.
./libns3.21-applications-debug.so: undefined reference to
ns3::LocHeader::GetData() const'./libns3.21-applications-debug.so: undefined reference to
vtable for ns3::LocHeader'
./libns3.21-applications-debug.so: undefined reference to
ns3::LocHeader::SetData(unsigned int)'clang: error: linker command failed with exit code 1 (use -v to see invocation)`
I don't see function definitions for SetData() or GetData() in any of the example code. Was I supposed to write code that does this myself? It seems like that would have been included in the example code.
Upvotes: 0
Views: 303
Reputation: 1
The answer is yes, it does work if GetData and SetData are implemented by the user.
However, there are two steps missing from the example code given.
The the new .h and .cc files have to be added to ./wscript, which wasn't immediately obvious.
The type definition of GetInstanceTypeId contains an error. There was a missing "const":
TypeId YHeader::GetInstanceTypeId (void) { return GetTypeId (); }
should have read:
TypeId
YHeader::GetInstanceTypeId (void) const
{
return GetTypeId ();
}
I'll suggest an update to the page maintainer.
Upvotes: 0