/* Analyze.h 
   =========
   Definitions for the routing vector analysis program

   $Id: rv.h,v 1.1 2002/08/15 23:15:48 ttraffic Exp $
*/

/* Subroutine definitions */
/* ====================== */
int   check_route  (unsigned int, unsigned int, int, int, unsigned int[]);
int   check_vector (unsigned int , unsigned int , int , unsigned int *);
void  clear_data   ();
void  dump_route   (char *);
void  dump_vector  (char *);
unsigned int rv_iptoint (char *);
char* rv_inttoip (unsigned int, char *);
int   write_route  (char *);
int   write_vector (char *);
//int   read_line    (FILE *, unsigned int*, unsigned int* , int*, int*, unsigned int*);
int   rv_read_route   (char *, int);
int   rv_read_vector  (char *, int);

/* Global constants */
/* ================ */

/* Uncomment to switch on debugging output */
/* #define DEBUG     */
/* Maximum number of hops in a traceroute */
#define MAXHOPS  30
/* Maximum number of routes that the program can handle */
#define MAXROUTES  2999
/* Maximum number of vectors that the program can handle */
#define MAXVECTORS 299999
/* TRUE and FALSE */
#ifndef TRUE
  #define TRUE (1)
  #define FALSE (0)
#endif


/* Data structures */
/* =============== */

/* There are 2 main data structures: route_by_time and vector by elements.
   route_by_time contains start and end point of a route, plus a pointer to
   a list with {id;time} pairs.  The entries on the {id;time} give the
   last time when a vector id was still used as a path.  
   vector_by_element contains all vectors that we have seen so far.

   There are 2 ways to navigate through the vector_by_element list:
   the array all_vectors[i] returns a pointer to the i-th vector that we've
   found.  id_to_vector[i] returns a pointer to a vector with id i.
*/

struct time_id_list {
   int id;        /* Vector id */
   int time;      /* Last time that this vector was valid */
   int nmeasure;  /* Number of measurements */
};

struct route_by_time {
   unsigned int         source;    /* Starting point */
   unsigned int         dest;      /* End point */
   int                  starttime; /* First time this route was measured */
   int                  entries;   /* # entries on {time, ID} list */
   struct time_id_list *list;      /* Pointer to the first entry */
};


struct vector_by_elements {
   int  ID;                    /* Unique identifier */
   unsigned int  source;       /* Starting point */
   unsigned int  dest;         /* End point */
   int           naddress;     /* Number of addresses */
   unsigned int *address_list; /* Pointer to List of Addresses of intermediate
                                  Points */
};

/* Global variables */
/* ================ */

struct route_by_time      *route_list  [MAXROUTES];
int knownroutes;

/* id_to_vector[i] returns the address of vector with index i */
struct vector_by_elements *id_to_vector[MAXVECTORS];
/* all_vectors[i] is a list of vectors in sorted order.  */
struct vector_by_elements *all_vectors [MAXVECTORS];
int knownvectors;

