I modified AODV into a new protocol in ns2-2.30, whose name is "proto". But 
when I compile ns,  there is a error when linking: 
trace/cmu-trace.o(.gnu.linkonce.t._ZN9hdr_proto6accessEPK6Packet[hdr_proto::access(Packet
 const*)]+0x7): In function `hdr_proto::access(Packet const*)':
./proto/proto_packet.h:80: undefined reference to `hdr_proto::offset_'
collect2: ld returned 1 exit status
make: *** [ns] Error 1
 
 
 
The definition of proto_packet.h is follows:
/* General proto Header - shared by all formats */
struct hdr_proto {
u_int8_t ah_type;
// Header access methods
static int offset_; // required by PacketHeaderManager, this the address offset 
in the header in bytes. how to bind
// the offset with the actual address is done by PackerHeaderManager
inline static int& offset() { return offset_; } //return the address
inline static hdr_proto* access(const Packet* p) { // access the header
return (hdr_proto*) p->access(offset_);
}
};
 
 
Part of proto.cc:
int hdr_proto::offset_; //this return the address of offset for proto packet 
header
static class PROTOHeaderClass : public PacketHeaderClass {
public:
PROTOHeaderClass() : PacketHeaderClass("PacketHeader/PROTO",
sizeof(hdr_all_proto)) {
bind_offset(&hdr_proto::offset_); //this function must be called 
here(PROTOHeaderClass's constructor), which
// makes object of PacketHeaderManager to know where the offset is stored.
}
} class_rtProtoPROTO_hdr;  

Reply via email to