我正在用 c++ 修改 ns2 的 aodv 协议。当我调用函数rft_add时出现错误。我会把文件放在这里。
声明文件:aodv_rftable.h
class aodv_rft_entry
{
friend class aodv_rftable;
friend class AODV;
friend class LocalRepairTimer;
public:
aodv_rft_entry(); //Constructor
~aodv_rft_entry();
protected:
LIST_ENTRY(aodv_rft_entry) rft_link;
nsaddr_t rft_dst;
nsaddr_t rft_src;
double rft_lifetime;
u_int8_t rft_relay;
u_int8_t rft_forward;
};
class aodv_rftable
{
public:
aodv_rftable() { LIST_INIT(&rfthead); }
aodv_rft_entry* head() { return rfthead.lh_first; }
aodv_rft_entry* rft_add(nsaddr_t dst, nsaddr_t src);
void rft_delete(nsaddr_t dst, nsaddr_t src);
aodv_rft_entry* rft_lookup(nsaddr_t dst, nsaddr_t src);
private:
LIST_HEAD(aodv_rfthead, aodv_rft_entry) rfthead;
};
实现文件:aodv_rftable.cc
aodv_rft_entry*
aodv_rftable::rft_add(nsaddr_t dst, nsaddr_t src)
{
aodv_rft_entry *rft;
rft = new aodv_rft_entry;
rft->rft_dst = dst;
rft->rft_src = src;
LIST_INSERT_HEAD(&rfthead, rft, rft_link);
return rft;
}
从 aodv 协议文件调用:aodv.cc
void
AODV::sendRequest(nsaddr_t dst)
{
// Allocate a RREQ packet
Packet *p = Packet::alloc();
struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_ip *ih = HDR_IP(p);
struct hdr_aodv_request *rq = HDR_AODV_REQUEST(p);
aodv_rt_entry *rt = rtable.rt_lookup(dst);
aodv_rft_entry *rft = aodv_rftable.rft_add(dst, index);
//Here i declare and fill the components of RREQ packet
rft = rftable.rft_add(dst, index);
}
当我尝试重建 ns2 时,出现以下错误
对 aodv_rftable(int, int) 的未定义引用