0

Am modifying aodv protocol of ns2 in c++. Am getting error when i call a function rft_add. I will put the files here.

Declaration file: 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;
};

Implementation file: 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;
}

Calling from aodv protocol file: 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);
}

When i try to rebuild ns2, following error appears

Undefined reference to aodv_rftable(int, int)

Sam DeHaan
  • 10,246
  • 2
  • 40
  • 48

1 Answers1

1

Error occured in linking ..? Its probably a problem in your makefile. Make sure the aodv_rftable.cc object is linked to create the target executable.

Manikandaraj Srinivasan
  • 3,557
  • 5
  • 35
  • 62