[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Adding a new header.
Dear fellows,
I want to add a new simple header without associating it with a new agent, i.e., a header like the common header.
However, I don't want to modified the common header. So I did the following:
--------- file: header-df.h ---------
#include "packet.h"
struct hdr_df {
u_int8_t numdf_;
static int offset_;
inline static int& offset() { return offset_; }
inline static hdr_df* access(const Packet* p) {
return (hdr_df*) p->access(offset_);
}
/* per-field member functions */
u_int8_t& numdf() { return numdf_; }
};
--------- file: header-df.cc ---------
#include "header-df.h"
int hdr_df::offset_;
static class DfHeaderClass : public PacketHeaderClass {
public:
DfHeaderClass() : PacketHeaderClass("PacketHeader/Df",
sizeof(hdr_df)) {
bind_offset(&hdr_df::offset_);
}
void export_offsets() {
field_offset("numdf_", OFFSET(hdr_df, numdf_));
}
} class_dfhdr;
------------------------------------
I modified "ns-packet.tcl" accordingly.
Since there's no new agent, I didn't modify the "packet.h".
------------------------------------
I used the header in my classifier file "classifier-deflect.cc" as follows:
int num = hdr_df::access(p)->numdf();
and got the following error message:
classifier-deflect.cc: In method `int DeflectClassifier::classify (Packet *, Handler *)':
classifier-deflect.cc:503: `hdr_df' undeclared (first use this
function)
classifier-deflect.cc:503: (Each undeclared identifier is reported only once for each function it appears in.)
classifier-deflect.cc:503: parse error before `::'
classifier-deflect.cc:513: parse error before `::'
make: *** [classifier-deflect.o] Error 1
---------------------------------
Could someone help me out?
Thanks a lot!
Jingyi