/**********************************************
 * * Author: Zhibin Wu, WINLAB, Rutgers University
 * * Date  August 2003 
 * *
 * **********************************************/

#ifndef cmu_fixtable_h_
#define cmu_fixtable_h_

#include "config.h"
#include "scheduler.h"
//#include "queue.h"


#define NEW_ROUTE_SUCCESS_NEWENT       0
#define NEW_ROUTE_SUCCESS_OLDENT       1
#define NEW_ROUTE_METRIC_TOO_HIGH      2
#define NEW_ROUTE_ILLEGAL_CANCELLATION 3
#define NEW_ROUTE_INTERNAL_ERROR       4

#ifndef uint
typedef unsigned int uint;
#endif // !uint

/* NOTE: we depend on bzero setting the booleans to ``false''
   but if false != 0, so many things are screwed up, I don't
   know what to say... */

#define BIG   250

class fixrt_ent {
public:
  fixrt_ent () { bzero(this, sizeof(fixrt_ent ));}
  nsaddr_t     dst;     // destination
  nsaddr_t     hop;     // next hop
  uint         metric;  // distance

};

// AddEntry adds an entry to the routing table with metric ent->metric+em.
//   You get to free the goods.
//
// GetEntry gets the entry for an address.

class FixRTable {
  public:
    FixRTable();
    void AddEntry(const fixrt_ent  &ent);
    fixrt_ent  *GetEntry(nsaddr_t dest);

  private:
    int         maxelts; //maximum elements
    int         elts;  //elements
    int         ctr;  //counter

    fixrt_ent  *rtab;
  };
    
#endif
