[Click] Error in compiling a new element-Urgent
kunal shah
shakuni2 at yahoo.co.in
Wed Nov 30 23:16:29 EST 2005
Hi Frederic,
I have tried to put these lines in my file, but it
still gives me the same error.
Attached document contains my .cc file
--- Frederic Van Quickenborne
<frederic.vanquickenborne at intec.ugent.be> wrote:
> Hi,
>
> maybe you can try to put this at the end of the
> file:
>
> #include <lib/vectorv.cc>
> template class Vector<int>;
> template class Vector<uint16_t>;
> CLICK_ENDDECLS
> ELEMENT_PROVIDES(IPTable2)
> EXPORT_ELEMENT(IPTable2)
>
>
> Let us know if it helps you,
> Frederic.
>
> kunal shah wrote:
>
> >Hi,
> >
> >I am getting the following error when I tried to
> >compile a new element called iptable2(which is
> lulea
> >implementation). I have put this element in
> >elements/ip directory.
> >
> >My iptable2.cc file is
> >
> >---------------------------------------------
> >#include <click/config.h>
> >#include "iptable2.hh"
> >#include <click/ipaddress.hh>
> >#include <click/error.hh>
> >#include <click/integers.hh>
> >CLICK_DECLS
> >
> >#define MT_MAX 675
> >#define DIRECT_POINTER (MT_MAX + 5) //
> >arbitrary value > MT_MAX
> >
> >bool IPTable2::_mt_done = false;
> >uint8_t IPTable2::_maptable[MT_MAX+1][8];
> >uint16_t IPTable2::_mask2index[256][256]; //
> see
> >build_maptable()
> >
> >IPTable2::IPTable2()
> > : entries(0), dirty(false)
> >{
> > if(!_mt_done)
> > build_maptable();
> >}
> >
> >IPTable2::~IPTable2()
> >{
> >}
> >
> >
> >// Adds an entry to the simple routing table if not
> in
> >there already.
> >// Allows only one gateway for equals dst/mask
> >combination.
> >void
> >IPTable2::add(unsigned dst, unsigned mask, unsigned
> >gw)
> >{
> > for(int i = 0; i < _v.size(); i++)
> > if(_v[i]._valid && (_v[i]._dst == dst) &&
> >(_v[i]._mask == mask))
> > return;
> >
> > struct Entry e;
> > e._dst = dst;
> > e._mask = mask;
> > e._gw = gw;
> > e._valid = 1;
> > _v.push_back(e);
> >
> > entries++;
> > dirty = true;
> >}
> >
> >
> >// Deletes an entry from the routing table.
> >void
> >IPTable2::del(unsigned dst, unsigned mask)
> >{
> > for(int i = 0; i < _v.size(); i++){
> > if(_v[i]._valid && (_v[i]._dst == dst) &&
> >(_v[i]._mask == mask)) {
> > _v[i]._valid = 0;
> > entries--;
> > dirty = true;
> > return;
> > }
> > }
> >}
> >
> >// Returns the i-th record.
> >bool
> >IPTable2::get(int i, unsigned &dst, unsigned &mask,
> >unsigned &gw)
> >{
> > assert(i >= 0 && i < _v.size());
> >
> > if(i < 0 || i >= _v.size() || _v[i]._valid == 0)
> {
> > dst = mask = gw = 0;
> > return(false);
> > }
> >
> > dst = _v[i]._dst;
> > mask = _v[i]._mask;
> > gw = _v[i]._gw;
> > return(true);
> >}
> >
> >
> >// Use the fast routing table to perform the
> lookup.
> >bool
> >IPTable2::lookup(unsigned dst, unsigned &gw, int
> >&index)
> >{
> > if(!entries)
> > return false;
> >
> > // Just in time. XXX: Change this to timer.
> > if(dirty) {
> > build();
> > dirty = false;
> > }
> >
> > // XXX: don't do it this way.
> > dst = ntohl(dst);
> >
> > uint16_t ix = (dst & 0xfff00000) >> 20; //
> >upper 12 bits.
> > uint16_t bix = (dst & 0xffc00000) >> 22; //
> >upper 10 bits.
> > uint8_t bit = (dst & 0x000f0000) >> 16; //
> >lower 4 of upper 16 bits.
> > uint16_t codeword = codewords1[ix];
> > uint16_t ten = (codeword & 0xffc0) >> 6; //
> >upper 10 bits.
> > uint8_t six = codeword & 0x003f; //
> >lower 6 bits.
> >
> > // Offset is not offset but pointer to routing
> >table. See 4.2.1 of Degermark.
> > if(ten == DIRECT_POINTER) {
> > index = six;
> > goto done;
> > }
> >
> > // Figure 10 in Degermark is wrong.
> > int offset = _maptable[ten][bit >> 1];
> > if(bit & 0x0001) // odd
> > offset &= 0x0f;
> > else
> > offset >>= 4;
> > uint16_t pix = baseindex1[bix] + six + offset;
> > index = l1ptrs[pix];
> >
> >done:
> > gw = _v[index & 0x3fff]._gw;
> > return(true);
> >}
> >
> >// Builds the whole structure as described by the
> >Lulea Algorithm.
> >// After execution l1ptrs, codewords1 and
> baseindex1
> >represent routing table.
> >//
> >// (NOT FINISHED: level 2 and 3)
> >//
> >// bitvector1 contains bitvector as described in
> >section 4.2 of Degermark.
> >// bit_admin contains an entry for each bit in
> >bitvector1.
> >// Both are temporary.
> >void
> >IPTable2::build()
> >{
> > uint16_t bitvector1[4096];
> > struct bit bit_admin[65536];
> >
> > for(register int i = 0; i < 65536; i++)
> > bit_admin[i].from_level = bit_admin[i].value =
> 0;
> > for(register int i = 0; i < 4096; i++)
> > codewords1[i] = bitvector1[i] = 0;
> > for(register int i = 0; i < 1024; i++)
> > baseindex1[i] = 0;
> > l1ptrs.clear();
> >
> > Vector<int> affected;
> > for(int i = 0; i < entries; i++) {
> > if(_v[i]._valid == 0)
>
=== message truncated ===
__________________________________________________________
Enjoy this Diwali with Y! India Click here http://in.promos.yahoo.com/fabmall/index.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iptable2.cc
Type: text/x-c++src
Size: 15217 bytes
Desc: 2266473178-iptable2.cc
Url : https://amsterdam.lcs.mit.edu/pipermail/click/attachments/20051201/d11e6ada/iptable2.bin
More information about the click
mailing list