click userlevel errors 3/11 cvs

David Scott Page page at cs.utexas.edu
Mon Mar 17 13:27:59 EST 2003


Hi,

> Can you 'cd userlevel' 'make driver.ii' and send us the resulting
> (preprocessed) driver.ii file?

I hope  reply-to was set in anticipation of a 6000 line message.

Also, not to belabor the point, but isn't the problem due to configure
concluding that dynamic linking is not available (resulting in the
test in driver.cc --- listed below --- evaluating false)?

--
Scott Page


config.log
...
configure:4447: checking for dlfcn.h
configure:4457: g++ -W -Wall -fno-exceptions -fno-rtti  -MD -E  conftest.cc
configure:4454:19: dlfcn.h: No such file or directory       
configure:4463: $? = 1
configure: failed program was:
#line 4453 "configure"
#include "confdefs.h"
#include <dlfcn.h>
configure:4482: result: no
configure:4494: checking for dlopen
configure:4531: g++ -W -Wall -fno-exceptions -fno-rtti  -MD -o conftest -g -O2
 conftest.cc  >&5
ld: Undefined symbols:    
_dlopen       
configure:4534: $? = 1
configure: failed program was:
#line 4500 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char dlopen (); below.  */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char dlopen ();
char (*f) ();

int
main ()
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_dlopen) || defined (__stub___dlopen)
choke me
#else
f = dlopen;
#endif

  ;
  return 0;
}
configure:4550: result: no
configure:4555: checking for dlopen in -ldl
configure:4582: g++ -W -Wall -fno-exceptions -fno-rtti  -MD -o conftest -g -O2   conftest.cc -ldl   >&5
ld: can't locate file for: -ldl
configure:4585: $? = 1
configure: failed program was:
#line 4563 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char dlopen ();
int
main ()
{
dlopen ();
  ;
  return 0;
}
configure:4602: result: no
...

------------------------------------------------------------------
driver.cc preprocessor conditional guarding archive_index definition:

#if HAVE_DYNAMIC_LINKING && !defined(CLICK_LINUXMODULE) && !defined(CLICK_BSDMODULE)
CLICK_DECLS

-----------------------driver.ii --------------------------
# 1 "../../click-20030316/lib/driver.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "../../click-20030316/lib/driver.cc"
# 20 "../../click-20030316/lib/driver.cc"
# 1 "../include/click/config.h" 1
# 93 "../include/click/config.h"
# 1 "../include/click/config-userlevel.h" 1
# 76 "../include/click/config-userlevel.h"
# 1 "/usr/include/gcc/darwin/3.1/inttypes.h" 1 3 4
# 33 "/usr/include/gcc/darwin/3.1/inttypes.h" 3 4
# 1 "/usr/include/gcc/darwin/3.1/stdint.h" 1 3 4
# 24 "/usr/include/gcc/darwin/3.1/stdint.h" 3 4
# 1 "/usr/include/machine/types.h" 1 3 4
# 30 "/usr/include/machine/types.h" 3 4
# 1 "/usr/include/ppc/types.h" 1 3 4
# 64 "/usr/include/ppc/types.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 65 "/usr/include/ppc/types.h" 2 3 4




typedef signed char int8_t;
typedef unsigned char u_int8_t;
typedef short int16_t;
typedef unsigned short u_int16_t;
typedef int int32_t;
typedef unsigned int u_int32_t;
typedef long long int64_t;
typedef unsigned long long u_int64_t;

typedef int32_t register_t;

typedef long int intptr_t;
typedef unsigned long int uintptr_t;
# 31 "/usr/include/machine/types.h" 2 3 4
# 25 "/usr/include/gcc/darwin/3.1/stdint.h" 2 3 4
# 34 "/usr/include/gcc/darwin/3.1/stdint.h" 3 4
typedef u_int8_t uint8_t;
typedef u_int16_t uint16_t;
typedef u_int32_t uint32_t;
typedef u_int64_t uint64_t;



typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;



typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
# 68 "/usr/include/gcc/darwin/3.1/stdint.h" 3 4
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
# 34 "/usr/include/gcc/darwin/3.1/inttypes.h" 2 3 4
# 77 "../include/click/config-userlevel.h" 2

# 1 "/usr/include/sys/types.h" 1 3 4
# 66 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/sys/appleapiopts.h" 1 3 4
# 67 "/usr/include/sys/types.h" 2 3 4







# 1 "/usr/include/machine/ansi.h" 1 3 4
# 33 "/usr/include/machine/ansi.h" 3 4
# 1 "/usr/include/ppc/ansi.h" 1 3 4
# 92 "/usr/include/ppc/ansi.h" 3 4
typedef union {
        char __mbstate8[128];
        long long _mbstateL;
} __mbstate_t;
# 34 "/usr/include/machine/ansi.h" 2 3 4
# 75 "/usr/include/sys/types.h" 2 3 4
# 1 "/usr/include/machine/endian.h" 1 3 4
# 30 "/usr/include/machine/endian.h" 3 4
# 1 "/usr/include/ppc/endian.h" 1 3 4
# 81 "/usr/include/ppc/endian.h" 3 4
extern "C" {
unsigned long htonl (unsigned long);
unsigned short htons (unsigned short);
unsigned long ntohl (unsigned long);
unsigned short ntohs (unsigned short);
}
# 31 "/usr/include/machine/endian.h" 2 3 4
# 76 "/usr/include/sys/types.h" 2 3 4


typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort;
typedef unsigned int uint;


typedef u_int64_t u_quad_t;
typedef int64_t quad_t;
typedef quad_t * qaddr_t;

typedef char * caddr_t;
typedef int32_t daddr_t;
typedef int32_t dev_t;
typedef u_int32_t fixpt_t;
typedef u_int32_t gid_t;
typedef u_int32_t in_addr_t;
typedef u_int16_t in_port_t;
typedef u_int32_t ino_t;
typedef long key_t;
typedef u_int16_t mode_t;
typedef u_int16_t nlink_t;
typedef quad_t off_t;
typedef int32_t pid_t;
typedef quad_t rlim_t;
typedef int32_t segsz_t;
typedef int32_t swblk_t;
typedef u_int32_t uid_t;
# 117 "/usr/include/sys/types.h" 3 4
typedef unsigned long clock_t;




typedef long unsigned int size_t;




typedef int ssize_t;




typedef long time_t;
# 146 "/usr/include/sys/types.h" 3 4
typedef int32_t fd_mask;






typedef struct fd_set {
        fd_mask fds_bits[(((1024) + (((sizeof(fd_mask) * 8)) - 1)) / ((sizeof(fd_mask) * 8)))];
} fd_set;
# 182 "/usr/include/sys/types.h" 3 4
struct _pthread_handler_rec
{
        void (*routine)(void *);
        void *arg;
        struct _pthread_handler_rec *next;
};
# 202 "/usr/include/sys/types.h" 3 4
typedef struct _opaque_pthread_t { long sig; struct _pthread_handler_rec *cleanup_stack; char opaque[596];} *pthread_t;

typedef struct _opaque_pthread_attr_t { long sig; char opaque[36]; } pthread_attr_t;

typedef struct _opaque_pthread_mutexattr_t { long sig; char opaque[8]; } pthread_mutexattr_t;

typedef struct _opaque_pthread_mutex_t { long sig; char opaque[40]; } pthread_mutex_t;

typedef struct _opaque_pthread_condattr_t { long sig; char opaque[4]; } pthread_condattr_t;

typedef struct _opaque_pthread_cond_t { long sig; char opaque[24]; } pthread_cond_t;

typedef struct _opaque_pthread_rwlockattr_t { long sig; char opaque[12]; } pthread_rwlockattr_t;

typedef struct _opaque_pthread_rwlock_t { long sig; char opaque[124]; } pthread_rwlock_t;

typedef struct { long sig; char opaque[4]; } pthread_once_t;



typedef unsigned long pthread_key_t;
# 79 "../include/click/config-userlevel.h" 2
# 94 "../include/click/config-userlevel.h"
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/cassert" 1 3
# 47 "/usr/include/gcc/darwin/3.1/g++-v3/cassert" 3

# 1 "/usr/include/gcc/darwin/3.1/assert.h" 1 3 4
# 14 "/usr/include/gcc/darwin/3.1/assert.h" 3 4
# 1 "/usr/include/stdlib.h" 1 3 4
# 71 "/usr/include/stdlib.h" 3 4
typedef int rune_t;





typedef int wchar_t;


typedef struct {
        int quot;
        int rem;
} div_t;

typedef struct {
        long quot;
        long rem;
} ldiv_t;
# 99 "/usr/include/stdlib.h" 3 4
extern int __mb_cur_max;




extern "C" {
 void
         abort (void);
 int
         abs (int);
int atexit (void (*)(void));
double atof (const char *);
int atoi (const char *);
long atol (const char *);
void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));

void *calloc (size_t, size_t);
 div_t
         div (int, int);
 void
         exit (int);
void free (void *);
char *getenv (const char *);
 long
         labs (long);
 ldiv_t
         ldiv (long, long);
void *malloc (size_t);
void qsort (void *, size_t, size_t, int (*)(const void *, const void *));

int rand (void);
void *realloc (void *, size_t);
void srand (unsigned);
double strtod (const char *, char **);
long strtol (const char *, char **, int);
unsigned long
         strtoul (const char *, char **, int);
int system (const char *);


int mblen (const char *, size_t);
size_t mbstowcs (wchar_t *, const char *, size_t);
int wctomb (char *, wchar_t);
int mbtowc (wchar_t *, const char *, size_t);
size_t wcstombs (char *, const wchar_t *, size_t);


int putenv (const char *);
int setenv (const char *, const char *, int);



double drand48 (void);
double erand48 (unsigned short[3]);
long jrand48 (unsigned short[3]);
void lcong48 (unsigned short[7]);
long lrand48 (void);
long mrand48 (void);
long nrand48 (unsigned short[3]);
unsigned short
        *seed48 (unsigned short[3]);
void srand48 (long);

void *alloca (size_t);

u_int32_t
         arc4random (void);
void arc4random_addrandom (unsigned char *dat, int datlen);
void arc4random_stir (void);
char *getbsize (int *, long *);
char *cgetcap (char *, char *, int);
int cgetclose (void);
int cgetent (char **, char **, char *);
int cgetfirst (char **, char **);
int cgetmatch (char *, char *);
int cgetnext (char **, char **);
int cgetnum (char *, char *, long *);
int cgetset (char *);
int cgetstr (char *, char *, char **);
int cgetustr (char *, char *, char **);

int daemon (int, int);
char *devname (int, int);
int getloadavg (double [], int);

long a64l (const char *);
char *l64a (long);

char *group_from_gid (unsigned long, int);
int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));

char *initstate (unsigned long, char *, long);
int mergesort (void *, size_t, size_t, int (*)(const void *, const void *));

int radixsort (const unsigned char **, int, const unsigned char *, unsigned);

int sradixsort (const unsigned char **, int, const unsigned char *, unsigned);

int rand_r (unsigned *);
long random (void);
void *reallocf (void *, size_t);
char *realpath (const char *, char resolved_path[]);
char *setstate (char *);
void srandom (unsigned long);
char *user_from_uid (unsigned long, int);

long long
         strtoll(const char *, char **, int);
unsigned long long
         strtoull(const char *, char **, int);
long long
         strtoq (const char *, char **, int);
unsigned long long
         strtouq (const char *, char **, int);

void unsetenv (const char *);

}
# 15 "/usr/include/gcc/darwin/3.1/assert.h" 2 3 4
# 40 "/usr/include/gcc/darwin/3.1/assert.h" 3 4
extern "C" {
extern void __eprintf (const char *, const char *, unsigned, const char *)
    __attribute__ ((noreturn));
}
# 49 "/usr/include/gcc/darwin/3.1/g++-v3/cassert" 2 3
# 95 "../include/click/config-userlevel.h" 2
# 111 "../include/click/config-userlevel.h"
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/new" 1 3
# 41 "/usr/include/gcc/darwin/3.1/g++-v3/new" 3
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/cstddef" 1 3
# 47 "/usr/include/gcc/darwin/3.1/g++-v3/cstddef" 3

# 1 "/usr/include/stddef.h" 1 3 4
# 66 "/usr/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 49 "/usr/include/gcc/darwin/3.1/g++-v3/cstddef" 2 3

namespace std
{
  using ::ptrdiff_t;
  using ::size_t;
}
# 42 "/usr/include/gcc/darwin/3.1/g++-v3/new" 2 3
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/exception" 1 3
# 40 "/usr/include/gcc/darwin/3.1/g++-v3/exception" 3
extern "C++" {

namespace std
{






  class exception
  {
  public:
    exception() throw() { }
    virtual ~exception() throw();


    virtual const char* what() const throw();
  };



  class bad_exception : public exception
  {
  public:
    bad_exception() throw() { }


    virtual ~bad_exception() throw();
  };


  typedef void (*terminate_handler) ();

  typedef void (*unexpected_handler) ();


  terminate_handler set_terminate(terminate_handler) throw();


  void terminate() __attribute__ ((__noreturn__));


  unexpected_handler set_unexpected(unexpected_handler) throw();


  void unexpected() __attribute__ ((__noreturn__));
# 98 "/usr/include/gcc/darwin/3.1/g++-v3/exception" 3
  bool uncaught_exception() throw();
}

namespace __gnu_cxx
{
# 111 "/usr/include/gcc/darwin/3.1/g++-v3/exception" 3
  void __verbose_terminate_handler ();
}

}
# 43 "/usr/include/gcc/darwin/3.1/g++-v3/new" 2 3

extern "C++" {

namespace std
{


  class bad_alloc : public exception
  {
  public:
    bad_alloc() throw() { }


    virtual ~bad_alloc() throw();
  };

  struct nothrow_t { };
  extern const nothrow_t nothrow;


  typedef void (*new_handler)();

  new_handler set_new_handler(new_handler);
}
# 79 "/usr/include/gcc/darwin/3.1/g++-v3/new" 3
void* operator new(std::size_t) throw (std::bad_alloc);
void* operator new[](std::size_t) throw (std::bad_alloc);
void operator delete(void*) throw();
void operator delete[](void*) throw();
void* operator new(std::size_t, const std::nothrow_t&) throw();
void* operator new[](std::size_t, const std::nothrow_t&) throw();
void operator delete(void*, const std::nothrow_t&) throw();
void operator delete[](void*, const std::nothrow_t&) throw();


inline void* operator new(std::size_t, void* __p) throw() { return __p; }
inline void* operator new[](std::size_t, void* __p) throw() { return __p; }

}
# 112 "../include/click/config-userlevel.h" 2
# 94 "../include/click/config.h" 2
# 21 "../../click-20030316/lib/driver.cc" 2
# 1 "../include/click/pathvars.h" 1
# 22 "../../click-20030316/lib/driver.cc" 2





# 1 "../../click-20030316/include/click/package.hh" 1


# 1 "../../click-20030316/include/click/vector.hh" 1



template <class T> class Subvector;

template <class T>
class Vector { public:

  Vector() : _l(0), _n(0), _cap(0) { }
  explicit Vector(int capacity) : _l(0), _n(0), _cap(0) { reserve(capacity); }
  Vector(int n, const T &e) : _l(0), _n(0), _cap(0) { resize(n, e); }
  Vector(const Vector<T> &);
  Vector(const Subvector<T> &);
  ~Vector();

  int size() const { return _n; }

  const T &at(int i) const { ((void) ((i>=0 && i<_n) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/vector.hh", 18, "i>=0 && i<_n"), 0))); return _l[i]; }
  const T &operator[](int i) const { return at(i); }
  const T &back() const { return at(_n - 1); }
  const T &at_u(int i) const { return _l[i]; }

  T &at(int i) { ((void) ((i>=0 && i<_n) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/vector.hh", 23, "i>=0 && i<_n"), 0))); return _l[i]; }
  T &operator[](int i) { return at(i); }
  T &back() { return at(_n - 1); }
  T &at_u(int i) { return _l[i]; }

  void push_back(const T &);
  void pop_back();

  void clear() { shrink(0); }
  bool reserve(int);
  void resize(int nn, const T &e = T());

  Vector<T> &operator=(const Vector<T> &);
  Vector<T> &assign(int n, const T &e = T());
  void swap(Vector<T> &);

 private:

  T *_l;
  int _n;
  int _cap;

  void *velt(int i) const { return (void *)&_l[i]; }
  static void *velt(T *l, int i) { return (void *)&l[i]; }
  void shrink(int nn);

  friend class Subvector<T>;

};

template <class T> inline void
Vector<T>::push_back(const T &e)
{
  if (_n < _cap || reserve(-1)) {
    new(velt(_n)) T(e);
    _n++;
  }
}

template <class T> inline void
Vector<T>::pop_back()
{
  ((void) ((_n > 0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/vector.hh", 65, "_n > 0"), 0)));
  --_n;
  _l[_n].~T();
}


template <>
class Vector<void *> { public:

  Vector() : _l(0), _n(0), _cap(0) { }
  explicit Vector(int capacity) : _l(0), _n(0), _cap(0) { reserve(capacity); }
  Vector(int n, void *e) : _l(0), _n(0), _cap(0) { resize(n, e); }
  Vector(const Vector<void *> &);
  Vector(const Subvector<void *> &);
  ~Vector();

  int size() const { return _n; }

  void *at(int i) const { ((void) ((i>=0 && i<_n) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/vector.hh", 83, "i>=0 && i<_n"), 0))); return _l[i]; }
  void *operator[](int i) const { return at(i); }
  void *back() const { return at(_n - 1); }
  void *at_u(int i) const { return _l[i]; }

  void *&at(int i) { ((void) ((i>=0 && i<_n) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/vector.hh", 88, "i>=0 && i<_n"), 0))); return _l[i]; }
  void *&operator[](int i) { return at(i); }
  void *&back() { return at(_n - 1); }
  void *&at_u(int i) { return _l[i]; }

  void push_back(void *);
  void pop_back();

  void clear() { _n = 0; }
  bool reserve(int);
  void resize(int nn, void *e = 0);

  Vector<void *> &operator=(const Vector<void *> &);
  Vector<void *> &assign(int n, void *e = 0);
  void swap(Vector<void *> &);

 private:

  void **_l;
  int _n;
  int _cap;

  friend class Subvector<void *>;

};

inline void
Vector<void *>::push_back(void *e)
{
  if (_n < _cap || reserve(-1)) {
    _l[_n] = e;
    _n++;
  }
}

inline void
Vector<void *>::pop_back()
{
  ((void) ((_n > 0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/vector.hh", 126, "_n > 0"), 0)));
  --_n;
}


template <class T>
class Vector<T *>: private Vector<void *> {

  typedef Vector<void *> Base;

 public:

  Vector() : Base() { }
  explicit Vector(int capacity) : Base(capacity) { }
  Vector(int n, T *e) : Base(n, (void *)e) { }
  Vector(const Vector<T *> &o) : Base(o) { }
  Vector(const Subvector<T *> &o) : Base(o) { }
  ~Vector() { }

  int size() const { return Base::size(); }

  T *operator[](int i) const { return (T *)(Base::at(i)); }
  T *at(int i) const { return (T *)(Base::at(i)); }
  T *back() const { return (T *)(Base::back()); }
  T *at_u(int i) const { return (T *)(Base::at_u(i)); }

  T *&operator[](int i) { return (T *&)(Base::at(i)); }
  T *&at(int i) { return (T *&)(Base::at(i)); }
  T *&back() { return (T *&)(Base::back()); }
  T *&at_u(int i) { return (T *&)(Base::at_u(i)); }

  void push_back(T *e) { Base::push_back((void *)e); }
  void pop_back() { Base::pop_back(); }

  void clear() { Base::clear(); }
  bool reserve(int n) { return Base::reserve(n); }
  void resize(int n, T *e = 0) { Base::resize(n, (void *)e); }

  Vector<T *> &operator=(const Vector<T *> &o)
                { Base::operator=(o); return *this; }
  Vector<T *> &assign(int n, T *e = 0)
                { Base::assign(n, (void *)e); return *this; }
  void swap(Vector<T *> &o) { Base::swap(o); }

};


# 4 "../../click-20030316/include/click/package.hh" 2
# 1 "../../click-20030316/include/click/string.hh" 1








class String { public:




  struct Initializer { Initializer(); };
  friend class String::Initializer;
  static void static_initialize();
  static void static_cleanup();

  String();
  String(const String &s);
  String(const char *cc) { assign(cc, -1); }
  String(const char *cc, int l) { assign(cc, l); }



  explicit String(char);
  explicit String(unsigned char);
  explicit String(int);
  explicit String(unsigned);
  explicit String(long);
  explicit String(unsigned long);

  explicit String(int64_t);
  explicit String(uint64_t);


  explicit String(double);

  ~String();

  static const String &null_string() { return *null_string_p; }
  static const String &out_of_memory_string() { return *oom_string_p; }
  static String garbage_string(int n);
  static String stable_string(const char *, int = -1);

  bool out_of_memory() const { return _memo == oom_memo; }

  int length() const { return _length; }
  const char *data() const { return _data; }
  char *mutable_data();
  char *mutable_c_str();

  operator bool() { return _length != 0; }
  operator bool() const { return _length != 0; }






  const char *cc();
  const char *c_str() { return cc(); }

  char operator[](int e) const { return _data[e]; }
  char back() const { return _data[_length-1]; }
  int find_left(int c, int start = 0) const;
  int find_left(const String &s, int start = 0) const;
  int find_right(int c, int start = 0x7FFFFFFF) const;

  bool equals(const char *, int) const;







  int compare(const char *, int) const;
  int compare(const String &x) const { return compare(x._data, x._length); }
  static int compare(const String &a, const String &b);





  String substring(int, int) const;
  String substring(int left) const { return substring(left, _length); }

  String lower() const;
  String upper() const;
  String printable() const;
  String trim_space() const;

  String &operator=(const String &);
  String &operator=(const char *);




  void append(const char *, int len);
  void append_fill(int c, int len);
  void append_garbage(int len);
  String &operator+=(const String &);
  String &operator+=(const char *);
  String &operator+=(char);
# 120 "../../click-20030316/include/click/string.hh"
 private:

  struct Memo {
    int _refcount;
    int _capacity;
    int _dirty;
    char *_real_data;

    Memo();
    Memo(char *, int, int);
    Memo(int, int);
    ~Memo();
  };

  const char *_data;
  int _length;
  Memo *_memo;

  String(const char *, int, Memo *);

  void assign(const String &);
  void assign(const char *, int);



  void deref();
  void make_out_of_memory();

  static Memo *null_memo;
  static Memo *permanent_memo;
  static Memo *oom_memo;
  static String *null_string_p;
  static String *oom_string_p;

  static String claim_string(char *, int, int);

  friend class StringAccum;

};


inline
String::String(const char *data, int length, Memo *memo)
  : _data(data), _length(length), _memo(memo)
{
  _memo->_refcount++;
}

inline void
String::assign(const String &s)
{
  _data = s._data;
  _length = s._length;
  _memo = s._memo;
  _memo->_refcount++;
}

inline void
String::deref()
{
  if (--_memo->_refcount == 0)
    delete _memo;
}

inline
String::String()
  : _data(null_memo->_real_data), _length(0), _memo(null_memo)
{
  _memo->_refcount++;
}

inline
String::String(char c)
{
  assign(&c, 1);
}

inline
String::String(unsigned char c)
{
  assign(reinterpret_cast<char *>(&c), 1);
}

inline
String::String(const String &s)
{
  assign(s);
}

inline
String::~String()
{
  deref();
}


inline int
String::compare(const String &a, const String &b)
{
  return a.compare(b);
}

inline bool
operator==(const String &s1, const String &s2)
{
  return s1.equals(s2.data(), s2.length());
}

inline bool
operator==(const char *cc1, const String &s2)
{
  return s2.equals(cc1, -1);
}

inline bool
operator==(const String &s1, const char *cc2)
{
  return s1.equals(cc2, -1);
}

inline bool
operator!=(const String &s1, const String &s2)
{
  return !s1.equals(s2.data(), s2.length());
}

inline bool
operator!=(const char *cc1, const String &s2)
{
  return !s2.equals(cc1, -1);
}

inline bool
operator!=(const String &s1, const char *cc2)
{
  return !s1.equals(cc2, -1);
}

inline bool
operator<(const String &s1, const String &s2)
{
  return s1.compare(s2.data(), s2.length()) < 0;
}

inline bool
operator<=(const String &s1, const String &s2)
{
  return s1.compare(s2.data(), s2.length()) <= 0;
}

inline bool
operator>(const String &s1, const String &s2)
{
  return s1.compare(s2.data(), s2.length()) > 0;
}

inline bool
operator>=(const String &s1, const String &s2)
{
  return s1.compare(s2.data(), s2.length()) >= 0;
}


inline String &
String::operator=(const String &s)
{
  if (&s != this) {
    deref();
    assign(s);
  }
  return *this;
}

inline String &
String::operator=(const char *cc)
{
  deref();
  assign(cc, -1);
  return *this;
}

inline String &
String::operator+=(const String &s)
{
  append(s._data, s._length);
  return *this;
}

inline String &
String::operator+=(const char *cc)
{
  append(cc, -1);
  return *this;
}

inline String &
String::operator+=(char c)
{
  append(&c, 1);
  return *this;
}

inline String
operator+(String s1, const String &s2)
{
  s1 += s2;
  return s1;
}

inline String
operator+(String s1, const char *cc2)
{
  s1.append(cc2, -1);
  return s1;
}

inline String
operator+(const char *cc1, const String &s2)
{
  String s1(cc1);
  s1 += s2;
  return s1;
}

inline String
operator+(String s1, char c2)
{
  s1.append(&c2, 1);
  return s1;
}
# 445 "../../click-20030316/include/click/string.hh"
int hashcode(const String &);


# 5 "../../click-20030316/include/click/package.hh" 2


class Element;



extern "C" {

void click_provide(const char *);
void click_unprovide(const char *);
bool click_has_provision(const char *);
void click_public_packages(Vector<String> &);


int click_add_element_type(const char *, Element *);
void click_remove_element_type(int);


}
# 28 "../../click-20030316/lib/driver.cc" 2
# 1 "../../click-20030316/include/click/hashmap.hh" 1



# 19 "../../click-20030316/include/click/hashmap.hh"
template <class K, class V> class _HashMapIterator;

template <class K, class V>
class HashMap { public:

  typedef _HashMapIterator<K, V> iterator;

  HashMap();
  explicit HashMap(const V &);
  HashMap(const HashMap<K, V> &);
  ~HashMap() { delete[] _e; }

  int size() const { return _n; }
  bool empty() const { return _n == 0; }
  int capacity() const { return _capacity; }

  const V &find(const K &) const;
  V *findp(const K &) const;
  const V &operator[](const K &k) const;
  V &find_force(const K &);

  bool insert(const K &, const V &);
  void clear();

  iterator begin() const { return iterator(this); }

  HashMap<K, V> &operator=(const HashMap<K, V> &);
  void swap(HashMap<K, V> &);

  void resize(int size) { increase(size); }

 private:

  struct Elt { K k; V v; Elt(): k(), v() { } };

  int _capacity;
  int _grow_limit;
  int _n;
  Elt *_e;
  V _default_v;

  void increase(int);
  void check_capacity();
  int bucket(const K &) const;

  friend class _HashMapIterator<K, V>;

};

template <class K, class V>
class _HashMapIterator { public:

  _HashMapIterator(const HashMap<K, V> *);

  operator bool() const { return _pos < _hm->_capacity; }
  void operator++(int);

  const K &key() const { return _hm->_e[_pos].k; }
  V &value() { return _hm->_e[_pos].v; }
  const V &value() const { return _hm->_e[_pos].v; }

 private:

  const HashMap<K, V> *_hm;
  int _pos;

};


template <class K, class V>
inline int
HashMap<K, V>::bucket(const K &key) const
{
  int hc = hashcode(key);
  int i = hc & (_capacity - 1);
  int j = ((hc >> 6) & (_capacity - 1)) | 1;

  while (_e[i].k && !(_e[i].k == key))
    i = (i + j) & (_capacity - 1);

  return i;
}

template <class K, class V>
inline const V &
HashMap<K, V>::find(const K &key) const
{
  int i = bucket(key);
  const V *v = (_e[i].k ? &_e[i].v : &_default_v);
  return *v;
}

template <class K, class V>
inline const V &
HashMap<K, V>::operator[](const K &key) const
{
  return find(key);
}

template <class K, class V>
inline V *
HashMap<K, V>::findp(const K &key) const
{
  int i = bucket(key);
  return _e[i].k ? &_e[i].v : 0;
}

inline int
hashcode(int i)
{
  return i;
}

inline unsigned
hashcode(unsigned u)
{
  return u;
}


# 29 "../../click-20030316/lib/driver.cc" 2
# 1 "../../click-20030316/include/click/error.hh" 1





# 1 "/usr/include/gcc/darwin/3.1/g++-v3/cstdio" 1 3
# 48 "/usr/include/gcc/darwin/3.1/g++-v3/cstdio" 3

# 1 "/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin/bits/c++config.h" 1 3
# 34 "/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin/bits/c++config.h" 3
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin/bits/os_defines.h" 1 3
# 72 "/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin/bits/os_defines.h" 3
extern "C" {
# 83 "/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin/bits/os_defines.h" 3
typedef enum node_kinds {
        NODE_THREAD_SPECIFIC_DATA=1,
        NODE_PROCESSWIDE_PTR=2,
        NODE_LAST_KIND
        } TnodeKind ;





typedef enum node_mode {
        NM_ALLOW_RECURSION=1,
        NM_RECURSION_ILLEGAL=2,
        NM_ENHANCED_LOCKING=3,
        NM_LOCKED=4
        } TnodeMode ;



extern void * _keymgr_get_per_thread_data(unsigned int key) ;
extern void _keymgr_set_per_thread_data(unsigned int key, void *keydata) ;
extern void *_keymgr_get_and_lock_processwide_ptr(unsigned int key) ;
extern void _keymgr_set_and_unlock_processwide_ptr(unsigned int key, void *ptr) ;
extern void _keymgr_unlock_processwide_ptr(unsigned int key) ;
extern void _keymgr_set_lockmode_processwide_ptr(unsigned int key, unsigned int mode) ;
extern unsigned int _keymgr_get_lockmode_processwide_ptr(unsigned int key) ;
extern int _keymgr_get_lock_count_processwide_ptr(unsigned int key) ;
# 155 "/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin/bits/os_defines.h" 3
}
# 35 "/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin/bits/c++config.h" 2 3
# 50 "/usr/include/gcc/darwin/3.1/g++-v3/cstdio" 2 3


# 1 "/usr/include/stdio.h" 1 3 4
# 91 "/usr/include/stdio.h" 3 4
typedef off_t fpos_t;
# 107 "/usr/include/stdio.h" 3 4
struct __sbuf {
        unsigned char *_base;
        int _size;
};
# 138 "/usr/include/stdio.h" 3 4
typedef struct __sFILE {
        unsigned char *_p;
        int _r;
        int _w;
        short _flags;
        short _file;
        struct __sbuf _bf;
        int _lbfsize;


        void *_cookie;
        int (*_close) (void *);
        int (*_read) (void *, char *, int);
        fpos_t (*_seek) (void *, fpos_t, int);
        int (*_write) (void *, const char *, int);


        struct __sbuf _ub;
        unsigned char *_up;
        int _ur;


        unsigned char _ubuf[3];
        unsigned char _nbuf[1];


        struct __sbuf _lb;


        int _blksize;
        fpos_t _offset;
} FILE;

extern "C" {
extern FILE __sF[];
}
# 241 "/usr/include/stdio.h" 3 4
extern "C" {
void clearerr (FILE *);
int fclose (FILE *);
int feof (FILE *);
int ferror (FILE *);
int fflush (FILE *);
int fgetc (FILE *);
int fgetpos (FILE *, fpos_t *);
char *fgets (char *, int, FILE *);
FILE *fopen (const char *, const char *);
int fprintf (FILE *, const char *, ...);
int fputc (int, FILE *);
int fputs (const char *, FILE *);
size_t fread (void *, size_t, size_t, FILE *);
FILE *freopen (const char *, const char *, FILE *);
int fscanf (FILE *, const char *, ...);
int fseek (FILE *, long, int);
int fsetpos (FILE *, const fpos_t *);
long ftell (FILE *);
size_t fwrite (const void *, size_t, size_t, FILE *);
int getc (FILE *);
int getchar (void);
char *gets (char *);

extern const int sys_nerr;
extern const char *const sys_errlist[];

void perror (const char *);
int printf (const char *, ...);
int putc (int, FILE *);
int putchar (int);
int puts (const char *);
int remove (const char *);
int rename (const char *, const char *);
void rewind (FILE *);
int scanf (const char *, ...);
void setbuf (FILE *, char *);
int setvbuf (FILE *, char *, int, size_t);
int sprintf (char *, const char *, ...);
int sscanf (const char *, const char *, ...);
FILE *tmpfile (void);
char *tmpnam (char *);
int ungetc (int, FILE *);
int vfprintf (FILE *, const char *, __builtin_va_list);
int vprintf (const char *, __builtin_va_list);
int vsprintf (char *, const char *, __builtin_va_list);
int asprintf (char **, const char *, ...);
int vasprintf (char **, const char *, __builtin_va_list);
}
# 298 "/usr/include/stdio.h" 3 4
extern "C" {
char *ctermid (char *);
FILE *fdopen (int, const char *);
int fileno (FILE *);
}






extern "C" {
char *fgetln (FILE *, size_t *);
int fpurge (FILE *);
int fseeko (FILE *, fpos_t, int);
fpos_t ftello (FILE *);
int getw (FILE *);
int pclose (FILE *);
FILE *popen (const char *, const char *);
int putw (int, FILE *);
void setbuffer (FILE *, char *, int);
int setlinebuf (FILE *);
char *tempnam (const char *, const char *);
int snprintf (char *, size_t, const char *, ...);
int vsnprintf (char *, size_t, const char *, __builtin_va_list);
int vscanf (const char *, __builtin_va_list);
int vsscanf (const char *, const char *, __builtin_va_list);
FILE *zopen (const char *, const char *, int);
}
# 338 "/usr/include/stdio.h" 3 4
extern "C" {
FILE *funopen (const void *, int (*)(void *, char *, int), int (*)(void *, const char *, int), fpos_t (*)(void *, fpos_t, int), int (*)(void *));




}







extern "C" {
int __srget (FILE *);
int __svfscanf (FILE *, const char *, __builtin_va_list);
int __swbuf (int, FILE *);
}







static inline int __sputc(int _c, FILE *_p) {
        if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
                return (*_p->_p++ = _c);
        else
                return (__swbuf(_c, _p));
}
# 53 "/usr/include/gcc/darwin/3.1/g++-v3/cstdio" 2 3
# 97 "/usr/include/gcc/darwin/3.1/g++-v3/cstdio" 3
namespace std
{
  using ::FILE;
  using ::fpos_t;

  using ::clearerr;
  using ::fclose;
  using ::feof;
  using ::ferror;
  using ::fflush;
  using ::fgetc;
  using ::fgetpos;
  using ::fgets;
  using ::fopen;
  using ::fprintf;
  using ::fputc;
  using ::fputs;
  using ::fread;
  using ::freopen;
  using ::fscanf;
  using ::fseek;
  using ::fsetpos;
  using ::ftell;
  using ::fwrite;
  using ::getc;
  using ::getchar;
  using ::gets;
  using ::perror;
  using ::printf;
  using ::putc;
  using ::putchar;
  using ::puts;
  using ::remove;
  using ::rename;
  using ::rewind;
  using ::scanf;
  using ::setbuf;
  using ::setvbuf;
  using ::sprintf;
  using ::sscanf;
  using ::tmpfile;
  using ::tmpnam;
  using ::ungetc;
  using ::vfprintf;
  using ::vprintf;
  using ::vsprintf;
}
# 7 "../../click-20030316/include/click/error.hh" 2

# 1 "/usr/include/gcc/darwin/3.1/g++-v3/cstdarg" 1 3
# 47 "/usr/include/gcc/darwin/3.1/g++-v3/cstdarg" 3

# 1 "/usr/include/gcc/darwin/3.1/stdarg.h" 1 3 4
# 48 "/usr/include/gcc/darwin/3.1/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 115 "/usr/include/gcc/darwin/3.1/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
# 49 "/usr/include/gcc/darwin/3.1/g++-v3/cstdarg" 2 3






namespace std
{
  using ::va_list;
}
# 9 "../../click-20030316/include/click/error.hh" 2


class ErrorHandler { public:

  enum Seriousness {
    ERR_DEBUG, ERR_MESSAGE, ERR_WARNING, ERR_ERROR, ERR_FATAL
  };

  ErrorHandler() { }
  virtual ~ErrorHandler() { }

  static void static_initialize(ErrorHandler *);
  static void static_cleanup();

  static ErrorHandler *default_handler();
  static ErrorHandler *silent_handler();

  static bool has_default_handler();
  static void set_default_handler(ErrorHandler *);

  virtual int nwarnings() const = 0;
  virtual int nerrors() const = 0;
  virtual void reset_counts() = 0;



  static const int OK_RESULT = 0;
  static const int ERROR_RESULT;

  void debug(const char *format, ...);
  void message(const char *format, ...);
  int warning(const char *format, ...);
  int error(const char *format, ...);
  int fatal(const char *format, ...);

  void ldebug(const String &landmark, const char *format, ...);
  void lmessage(const String &landmark, const char *format, ...);
  int lwarning(const String &landmark, const char *format, ...);
  int lerror(const String &landmark, const char *format, ...);
  int lfatal(const String &landmark, const char *format, ...);

  int verror(Seriousness, const String &landmark, const char *format, va_list);
  int verror_text(Seriousness, const String &landmark, const String &text);

  String make_text(Seriousness, const char *, ...);
  virtual String make_text(Seriousness, const char *, va_list);
  virtual String decorate_text(Seriousness, const String &, const String &, const String &);
  virtual void handle_text(Seriousness, const String &) = 0;

  virtual void set_error_code(int);

  static String prepend_lines(const String &, const String &);


  struct Conversion;
  typedef String (*ConversionHook)(int flags, va_list *);
  enum ConversionFlags {
    ZERO_PAD = 1, PLUS_POSITIVE = 2, SPACE_POSITIVE = 4, LEFT_JUST = 8,
    ALTERNATE_FORM = 16, UPPERCASE = 32, SIGNED = 64, NEGATIVE = 128
  };
  static Conversion *add_conversion(const String &, ConversionHook);
  static int remove_conversion(Conversion *);

};


class FileErrorHandler : public ErrorHandler { public:

  FileErrorHandler(FILE *, const String & = String());

  int nwarnings() const;
  int nerrors() const;
  void reset_counts();

  void handle_text(Seriousness, const String &);

 private:

  FILE *_f;
  String _context;
  int _nwarnings;
  int _nerrors;

};


class ErrorVeneer : public ErrorHandler { public:

  ErrorVeneer(ErrorHandler *errh) : _errh(errh) { }

  int nwarnings() const;
  int nerrors() const;
  void reset_counts();

  String make_text(Seriousness, const char *, va_list);
  String decorate_text(Seriousness, const String &, const String &, const String &);
  void handle_text(Seriousness, const String &);

 protected:

  ErrorHandler *_errh;

};

class ContextErrorHandler : public ErrorVeneer { public:

  ContextErrorHandler(ErrorHandler *, const String &context,
                      const String &indent = "  ");

  String decorate_text(Seriousness, const String &, const String &, const String &);

 private:

  String _context;
  String _indent;

};

class PrefixErrorHandler : public ErrorVeneer { public:

  PrefixErrorHandler(ErrorHandler *, const String &prefix);

  String decorate_text(Seriousness, const String &, const String &, const String &);

 private:

  String _prefix;

};

class IndentErrorHandler : public ErrorVeneer { public:

  IndentErrorHandler(ErrorHandler *, const String &indent);

  String decorate_text(Seriousness, const String &, const String &, const String &);

 private:

  String _indent;

};

class LandmarkErrorHandler : public ErrorVeneer { public:

  LandmarkErrorHandler(ErrorHandler *, const String &);

  void set_landmark(const String &s) { _landmark = s; }

  String decorate_text(Seriousness, const String &, const String &, const String &);

 private:

  String _landmark;

};


class BailErrorHandler : public ErrorVeneer { public:

  BailErrorHandler(ErrorHandler *, Seriousness = ERR_ERROR);

  void handle_text(Seriousness, const String &);

 private:

  int _exit_seriousness;

};



# 30 "../../click-20030316/lib/driver.cc" 2


# 1 "../../click-20030316/include/click/userutils.hh" 1



# 1 "../../click-20030316/include/click/archive.hh" 1






class ErrorHandler;

struct ArchiveElement {

  String name;
  int date;
  int uid;
  int gid;
  int mode;
  String data;

  bool live() const { return name; }
  bool dead() const { return !name; }
  void kill() { name = String(); }

};

int separate_ar_string(const String &, Vector<ArchiveElement> &,
                       ErrorHandler * = 0);
String create_ar_string(const Vector<ArchiveElement> &, ErrorHandler * = 0);


# 5 "../../click-20030316/include/click/userutils.hh" 2


class ErrorHandler;

bool glob_match(const String &string, const String &pattern);

String percent_substitute(const String &string, int format1, ...);

int click_strcmp(const String &a, const String &b);

const char *filename_landmark(const char *, bool file_is_expr = false);

String file_string(FILE *, ErrorHandler * = 0);
String file_string(String, ErrorHandler * = 0);

String unique_tmpnam(const String &, ErrorHandler * = 0);
void remove_file_on_exit(const String &);
bool path_allows_default_path(String path);
String click_mktmpdir(ErrorHandler * = 0);

const char *clickpath();
void set_clickpath(const char *);

String clickpath_find_file(const String &filename, const char *subdir,
                           String default_path, ErrorHandler * = 0);

void parse_tabbed_lines(const String &, Vector<String> *, ...);

ArchiveElement init_archive_element(const String &, int);

bool compressed_data(const unsigned char *, int);
FILE *open_uncompress_pipe(const String &filename, const unsigned char *, int, ErrorHandler *);







# 33 "../../click-20030316/lib/driver.cc" 2
# 1 "/usr/include/unistd.h" 1 3 4
# 72 "/usr/include/unistd.h" 3 4
# 1 "/usr/include/sys/unistd.h" 1 3 4
# 73 "/usr/include/unistd.h" 2 3 4
# 91 "/usr/include/unistd.h" 3 4
extern "C" {
 void
         _exit (int);
int access (const char *, int);
unsigned int alarm (unsigned int);
int chdir (const char *);
int chown (const char *, uid_t, gid_t);
int close (int);
size_t confstr (int, char *, size_t);
int dup (int);
int dup2 (int, int);
int execl (const char *, const char *, ...);
int execle (const char *, const char *, ...);
int execlp (const char *, const char *, ...);
int execv (const char *, char * const *);
int execve (const char *, char * const *, char * const *);
int execvp (const char *, char * const *);
pid_t fork (void);
long fpathconf (int, int);
char *getcwd (char *, size_t);
gid_t getegid (void);
uid_t geteuid (void);
gid_t getgid (void);
int getgroups (int, gid_t []);
char *getlogin (void);
pid_t getpgrp (void);
pid_t getpid (void);
pid_t getppid (void);
uid_t getuid (void);
int isatty (int);
int link (const char *, const char *);
off_t lseek (int, off_t, int);
long pathconf (const char *, int);
int pause (void);
int pipe (int *);
ssize_t read (int, void *, size_t);
int rmdir (const char *);
int setgid (gid_t);
int setpgid (pid_t, pid_t);
pid_t setsid (void);
int setuid (uid_t);
unsigned int sleep (unsigned int);
long sysconf (int);
pid_t tcgetpgrp (int);
int tcsetpgrp (int, pid_t);
char *ttyname (int);
int unlink (const char *);
ssize_t write (int, const void *, size_t);

extern char *optarg;
extern int optind, opterr, optopt, optreset;
int getopt (int, char * const [], const char *);



struct timeval;

int acct (const char *);
int async_daemon (void);
char *brk (const char *);
int chroot (const char *);
char *crypt (const char *, const char *);
int des_cipher (const char *, char *, long, int);
int des_setkey (const char *key);
int encrypt (char *, int);
void endusershell (void);
int exect (const char *, char * const *, char * const *);
int fchdir (int);
int fchown (int, int, int);
char *fflagstostr (u_long);
int fsync (int);
int ftruncate (int, off_t);
int getdtablesize (void);
int getgrouplist (const char *, int, int *, int *);
long gethostid (void);
int gethostname (char *, int);
mode_t getmode (const void *, mode_t);
 int
         getpagesize (void);
char *getpass (const char *);
int getpgid (pid_t _pid);
int getsid (pid_t _pid);
char *getusershell (void);
char *getwd (char *);
int initgroups (const char *, int);
int iruserok (unsigned long, int, const char *, const char *);
int issetugid (void);
char *mkdtemp (char *);
int mknod (const char *, mode_t, dev_t);
int mkstemp (char *);
int mkstemps (char *, int);
char *mktemp (char *);
int nfssvc (int, void *);
int nice (int);
ssize_t pread (int, void *, size_t, off_t);




# 1 "/usr/include/signal.h" 1 3 4
# 62 "/usr/include/signal.h" 3 4
# 1 "/usr/include/sys/signal.h" 1 3 4
# 72 "/usr/include/sys/signal.h" 3 4
# 1 "/usr/include/machine/signal.h" 1 3 4
# 27 "/usr/include/machine/signal.h" 3 4
# 1 "/usr/include/ppc/signal.h" 1 3 4
# 32 "/usr/include/ppc/signal.h" 3 4
typedef int sig_atomic_t;
# 50 "/usr/include/ppc/signal.h" 3 4
typedef enum {
        REGS_SAVED_NONE,
        REGS_SAVED_CALLER,


        REGS_SAVED_ALL
} regs_saved_t;
# 66 "/usr/include/ppc/signal.h" 3 4
struct sigcontext {
    int sc_onstack;
    int sc_mask;
        int sc_ir;
    int sc_psw;
    int sc_sp;
        void *sc_regs;
};
# 28 "/usr/include/machine/signal.h" 2 3 4
# 73 "/usr/include/sys/signal.h" 2 3 4
# 134 "/usr/include/sys/signal.h" 3 4
typedef unsigned int sigset_t;

union sigval {

        int sigval_int;
        void *sigval_ptr;
};







typedef struct __siginfo {
        int si_signo;
        int si_errno;
        int si_code;
        int si_pid;
        unsigned int si_uid;
        int si_status;
        void *si_addr;
        union sigval si_value;
        long si_band;
        int pad[7];
} siginfo_t;
# 208 "/usr/include/sys/signal.h" 3 4
union __sigaction_u {
        void (*__sa_handler)(int);
        void (*__sa_sigaction)(int, struct __siginfo *,
                       void *);
};


struct __sigaction {
        union __sigaction_u __sigaction_u;
        void (*sa_tramp)(void *, int, int, siginfo_t *, void *);
        sigset_t sa_mask;
        int sa_flags;
};




struct sigaction {
        union __sigaction_u __sigaction_u;
        sigset_t sa_mask;
        int sa_flags;
};
# 263 "/usr/include/sys/signal.h" 3 4
typedef void (*sig_t) (int);




struct sigaltstack {
        char *ss_sp;
        int ss_size;
        int ss_flags;
};

typedef struct sigaltstack stack_t;
# 285 "/usr/include/sys/signal.h" 3 4
struct sigvec {
        void (*sv_handler)(int);
        int sv_mask;
        int sv_flags;
};
# 303 "/usr/include/sys/signal.h" 3 4
struct sigstack {
        char *ss_sp;
        int ss_onstack;
};
# 336 "/usr/include/sys/signal.h" 3 4
extern "C" {
void (*signal (int, void (*) (int))) (int);
}
# 63 "/usr/include/signal.h" 2 3 4


extern const char *const sys_signame[32];
extern const char *const sys_siglist[32];


extern "C" {
int raise (int);

int kill (pid_t, int);
int sigaction (int, const struct sigaction *, struct sigaction *);
int sigaddset (sigset_t *, int);
int sigdelset (sigset_t *, int);
int sigemptyset (sigset_t *);
int sigfillset (sigset_t *);
int sigismember (const sigset_t *, int);
int sigpending (sigset_t *);
int sigprocmask (int, const sigset_t *, sigset_t *);
int sigsuspend (const sigset_t *);

int killpg (pid_t, int);
int sigblock (int);
int siginterrupt (int, int);
int sighold (int);
int sigrelse (int);
int sigpause (int);
int sigreturn (struct sigcontext *);
int sigsetmask (int);
int sigvec (int, struct sigvec *, struct sigvec *);
void psignal (unsigned int, const char *);


}
# 191 "/usr/include/unistd.h" 2 3 4

int profil (char *, int, int, int);
ssize_t pwrite (int, const void *, size_t, off_t);
int rcmd (char **, int, const char *, const char *, const char *, int *);

char *re_comp (const char *);
int re_exec (const char *);
int readlink (const char *, char *, int);
int reboot (int);
int revoke (const char *);
int rresvport (int *);
int ruserok (const char *, int, const char *, const char *);
char *sbrk (int);
int select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
int setegid (gid_t);
int seteuid (uid_t);
int setgroups (int, const gid_t *);
void sethostid (long);
int sethostname (const char *, int);
int setkey (const char *);
int setlogin (const char *);
void *setmode (const char *);
int setpgrp (pid_t pid, pid_t pgrp);
int setregid (gid_t, gid_t);
int setreuid (uid_t, uid_t);
int setrgid (gid_t);
int setruid (uid_t);
void setusershell (void);
int strtofflags (char **, u_long *, u_long *);
int swapon (const char *);
int symlink (const char *, const char *);
void sync (void);
int syscall (int, ...);
int truncate (const char *, off_t);
int ttyslot (void);
unsigned int ualarm (unsigned int, unsigned int);
int unwhiteout (const char *);
int usleep (unsigned int);
void *valloc (size_t);
pid_t vfork (void);

extern char *suboptarg;
int getsubopt (char **, char * const *, char **);


int getattrlist (const char*,void*,void*,size_t,unsigned long);
int setattrlist (const char*,void*,void*,size_t,unsigned long);
int exchangedata (const char*,const char*,unsigned long);
int checkuseraccess (const char*,uid_t,gid_t*,int,int,unsigned long);
int getdirentriesattr (int,void*,void*,size_t,unsigned long*,unsigned long*,unsigned long*,unsigned long);
int searchfs (const char*,void*,void*,unsigned long,unsigned long,void*);

int fsctl (const char *,unsigned long,void*,unsigned long);



}
# 34 "../../click-20030316/lib/driver.cc" 2
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/cerrno" 1 3
# 47 "/usr/include/gcc/darwin/3.1/g++-v3/cerrno" 3

# 1 "/usr/include/errno.h" 1 3 4
# 22 "/usr/include/errno.h" 3 4
# 1 "/usr/include/sys/errno.h" 1 3 4
# 68 "/usr/include/sys/errno.h" 3 4
extern "C" {
extern int * __error (void);

}
# 23 "/usr/include/errno.h" 2 3 4
# 49 "/usr/include/gcc/darwin/3.1/g++-v3/cerrno" 2 3
# 35 "../../click-20030316/lib/driver.cc" 2
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/cstring" 1 3
# 48 "/usr/include/gcc/darwin/3.1/g++-v3/cstring" 3



# 1 "/usr/include/string.h" 1 3 4
# 72 "/usr/include/string.h" 3 4
extern "C" {
void *memchr (const void *, int, size_t);
int memcmp (const void *, const void *, size_t);
void *memcpy (void *, const void *, size_t);
void *memmove (void *, const void *, size_t);
void *memset (void *, int, size_t);
char *strcat (char *, const char *);
char *strchr (const char *, int);
int strcmp (const char *, const char *);
int strcoll (const char *, const char *);
char *strcpy (char *, const char *);
size_t strcspn (const char *, const char *);
char *strerror (int);
size_t strlen (const char *);
char *strncat (char *, const char *, size_t);
int strncmp (const char *, const char *, size_t);
char *strncpy (char *, const char *, size_t);
char *strpbrk (const char *, const char *);
char *strrchr (const char *, int);
size_t strspn (const char *, const char *);
char *strstr (const char *, const char *);
char *strtok (char *, const char *);
size_t strxfrm (char *, const char *, size_t);



int bcmp (const void *, const void *, size_t);
void bcopy (const void *, void *, size_t);
void bzero (void *, size_t);
int ffs (int);
char *index (const char *, int);
void *memccpy (void *, const void *, int, size_t);
char *rindex (const char *, int);
int strcasecmp (const char *, const char *);
char *strdup (const char *);
size_t strlcat (char *, const char *, size_t);
size_t strlcpy (char *, const char *, size_t);
void strmode (int, char *);
int strncasecmp (const char *, const char *, size_t);
char *strsep (char **, const char *);
char *strtok_r (char *, const char *, char **);
void swab (const void *, void *, size_t);

}
# 52 "/usr/include/gcc/darwin/3.1/g++-v3/cstring" 2 3
# 77 "/usr/include/gcc/darwin/3.1/g++-v3/cstring" 3
namespace std
{
  using ::memcpy;
  using ::memmove;
  using ::strcpy;
  using ::strncpy;
  using ::strcat;
  using ::strncat;
  using ::memcmp;
  using ::strcmp;
  using ::strcoll;
  using ::strncmp;
  using ::strxfrm;
  using ::strcspn;
  using ::strspn;
  using ::strtok;
  using ::memset;
  using ::strerror;
  using ::strlen;

  using ::memchr;

  inline void*
  memchr(void* __p, int __c, size_t __n)
  { return memchr(const_cast<const void*>(__p), __c, __n); }

  using ::strchr;

  inline char*
  strchr(char* __s1, int __n)
  { return __builtin_strchr(const_cast<const char*>(__s1), __n); }

  using ::strpbrk;

  inline char*
  strpbrk(char* __s1, const char* __s2)
  { return __builtin_strpbrk(const_cast<const char*>(__s1), __s2); }

  using ::strrchr;

  inline char*
  strrchr(char* __s1, int __n)
  { return __builtin_strrchr(const_cast<const char*>(__s1), __n); }

  using ::strstr;

  inline char*
  strstr(char* __s1, const char* __s2)
  { return __builtin_strstr(const_cast<const char*>(__s1), __s2); }
}
# 36 "../../click-20030316/lib/driver.cc" 2
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/cstdlib" 1 3
# 48 "/usr/include/gcc/darwin/3.1/g++-v3/cstdlib" 3
# 84 "/usr/include/gcc/darwin/3.1/g++-v3/cstdlib" 3
namespace std
{
  using ::div_t;
  using ::ldiv_t;

  using ::abort;
  using ::abs;
  using ::atexit;
  using ::atof;
  using ::atoi;
  using ::atol;
  using ::bsearch;
  using ::calloc;
  using ::div;
  using ::exit;
  using ::free;
  using ::getenv;
  using ::labs;
  using ::ldiv;
  using ::malloc;
  using ::mblen;
  using ::mbstowcs;
  using ::mbtowc;
  using ::qsort;
  using ::rand;
  using ::realloc;
  using ::srand;
  using ::strtod;
  using ::strtol;
  using ::strtoul;
  using ::system;
  using ::wcstombs;
  using ::wctomb;

  inline long
  abs(long __i) { return labs(__i); }

  inline ldiv_t
  div(long __i, long __j) { return ldiv(__i, __j); }
}
# 37 "../../click-20030316/lib/driver.cc" 2






# 1 "../../click-20030316/include/click/lexer.hh" 1




# 1 "../../click-20030316/include/click/router.hh" 1



# 1 "../../click-20030316/include/click/element.hh" 1



# 1 "../../click-20030316/include/click/glue.hh" 1
# 58 "../../click-20030316/include/click/glue.hh"
# 1 "/usr/include/gcc/darwin/3.1/g++-v3/cctype" 1 3
# 47 "/usr/include/gcc/darwin/3.1/g++-v3/cctype" 3

# 1 "/usr/include/ctype.h" 1 3 4
# 68 "/usr/include/ctype.h" 3 4
# 1 "/usr/include/runetype.h" 1 3 4
# 66 "/usr/include/runetype.h" 3 4
typedef struct {
        rune_t min;
        rune_t max;
        rune_t map;
        unsigned long *types;
} _RuneEntry;

typedef struct {
        int nranges;
        _RuneEntry *ranges;
} _RuneRange;

typedef struct {
        char magic[8];
        char encoding[32];

        rune_t (*sgetrune)
            (const char *, size_t, char const **);
        int (*sputrune)
            (rune_t, char *, size_t, char **);
        rune_t invalid_rune;

        unsigned long runetype[(1 <<8 )];
        rune_t maplower[(1 <<8 )];
        rune_t mapupper[(1 <<8 )];






        _RuneRange runetype_ext;
        _RuneRange maplower_ext;
        _RuneRange mapupper_ext;

        void *variable;
        int variable_len;
} _RuneLocale;



extern _RuneLocale _DefaultRuneLocale;
extern _RuneLocale *_CurrentRuneLocale;
# 69 "/usr/include/ctype.h" 2 3 4
# 100 "/usr/include/ctype.h" 3 4
extern "C" {
int isalnum (int);
int isalpha (int);
int iscntrl (int);
int isdigit (int);
int isgraph (int);
int islower (int);
int isprint (int);
int ispunct (int);
int isspace (int);
int isupper (int);
int isxdigit (int);
int tolower (int);
int toupper (int);


int digittoint (int);
int isascii (int);
int isblank (int);
int ishexnumber (int);
int isideogram (int);
int isnumber (int);
int isphonogram (int);
int isrune (int);
int isspecial (int);
int toascii (int);

}
# 158 "/usr/include/ctype.h" 3 4
extern "C" {
unsigned long ___runetype (int);
int ___tolower (int);
int ___toupper (int);
}
# 180 "/usr/include/ctype.h" 3 4
static inline int
__maskrune(int _c, unsigned long _f)
{
        return ((_c < 0 || _c >= (1 <<8 )) ? ___runetype(_c) :
                _CurrentRuneLocale->runetype[_c]) & _f;
}

static inline int
__istype(int c, unsigned long f)
{
        return !!(__maskrune(c, f));
}

static inline int
__isctype(int _c, unsigned long _f)
{
        return (_c < 0 || _c >= (1 <<8 )) ? 0 :
                !!(_DefaultRuneLocale.runetype[_c] & _f);
}

static inline int
__toupper(int _c)
{
        return (_c < 0 || _c >= (1 <<8 )) ? ___toupper(_c) :
                _CurrentRuneLocale->mapupper[_c];
}

static inline int
__tolower(int _c)
{
        return (_c < 0 || _c >= (1 <<8 )) ? ___tolower(_c) :
                _CurrentRuneLocale->maplower[_c];
}
# 49 "/usr/include/gcc/darwin/3.1/g++-v3/cctype" 2 3
# 69 "/usr/include/gcc/darwin/3.1/g++-v3/cctype" 3
extern "C" {
extern int isalnum(int c);
extern int isalpha(int c);
extern int iscntrl(int c);
extern int isdigit(int c);
extern int isgraph(int c);
extern int islower(int c);
extern int isprint(int c);
extern int ispunct(int c);
extern int isspace(int c);
extern int isupper(int c);
extern int isxdigit(int c);
}


namespace std
{
  using ::isalnum;
  using ::isalpha;
  using ::iscntrl;
  using ::isdigit;
  using ::isgraph;
  using ::islower;
  using ::isprint;
  using ::ispunct;
  using ::isspace;
  using ::isupper;
  using ::isxdigit;
  using ::tolower;
  using ::toupper;
}
# 59 "../../click-20030316/include/click/glue.hh" 2

# 1 "/usr/include/sys/socket.h" 1 3 4
# 67 "/usr/include/sys/socket.h" 3 4
# 1 "/usr/include/machine/param.h" 1 3 4
# 30 "/usr/include/machine/param.h" 3 4
# 1 "/usr/include/ppc/param.h" 1 3 4
# 31 "/usr/include/machine/param.h" 2 3 4
# 68 "/usr/include/sys/socket.h" 2 3 4
# 77 "/usr/include/sys/socket.h" 3 4
typedef u_char sa_family_t;
# 135 "/usr/include/sys/socket.h" 3 4
struct linger {
        int l_onoff;
        int l_linger;
};
# 211 "/usr/include/sys/socket.h" 3 4
struct sockaddr {
        u_char sa_len;
        u_char sa_family;
        char sa_data[14];
};






struct sockproto {
        u_short sp_family;
        u_short sp_protocol;
};
# 236 "/usr/include/sys/socket.h" 3 4
struct sockaddr_storage {
        u_char ss_len;
        sa_family_t ss_family;
        char __ss_pad1[((sizeof(int64_t)) - sizeof(u_char) - sizeof(sa_family_t))];
        int64_t __ss_align;
        char __ss_pad2[(128 - sizeof(u_char) - sizeof(sa_family_t) - ((sizeof(int64_t)) - sizeof(u_char) - sizeof(sa_family_t)) - (sizeof(int64_t)))];
};
# 371 "/usr/include/sys/socket.h" 3 4
struct msghdr {
        caddr_t msg_name;
        u_int msg_namelen;
        struct iovec *msg_iov;
        u_int msg_iovlen;
        caddr_t msg_control;
        u_int msg_controllen;
        int msg_flags;
};
# 405 "/usr/include/sys/socket.h" 3 4
struct cmsghdr {
        u_int cmsg_len;
        int cmsg_level;
        int cmsg_type;

};
# 468 "/usr/include/sys/socket.h" 3 4
struct osockaddr {
        u_short sa_family;
        char sa_data[14];
};




struct omsghdr {
        caddr_t msg_name;
        int msg_namelen;
        struct iovec *msg_iov;
        int msg_iovlen;
        caddr_t msg_accrights;
        int msg_accrightslen;
};
# 508 "/usr/include/sys/socket.h" 3 4
extern "C" {
int accept (int, struct sockaddr *, int *);
int bind (int, const struct sockaddr *, int);
int connect (int, const struct sockaddr *, int);
int getpeername (int, struct sockaddr *, int *);
int getsockname (int, struct sockaddr *, int *);
int getsockopt (int, int, int, void *, int *);
int listen (int, int);
ssize_t recv (int, void *, size_t, int);
ssize_t recvfrom (int, void *, size_t, int, struct sockaddr *, int *);
ssize_t recvmsg (int, struct msghdr *, int);
ssize_t send (int, const void *, size_t, int);
ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, int);

ssize_t sendmsg (int, const struct msghdr *, int);



int setsockopt (int, int, int, const void *, int);
int shutdown (int, int);
int socket (int, int, int);
int socketpair (int, int, int, int *);

void pfctlinput (int, struct sockaddr *);
}
# 61 "../../click-20030316/include/click/glue.hh" 2
# 1 "/usr/include/netinet/in.h" 1 3 4
# 254 "/usr/include/netinet/in.h" 3 4
struct in_addr {
        in_addr_t s_addr;
};
# 311 "/usr/include/netinet/in.h" 3 4
struct sockaddr_in {
        u_char sin_len;
        u_char sin_family;
        u_short sin_port;
        struct in_addr sin_addr;
        char sin_zero[8];
};
# 328 "/usr/include/netinet/in.h" 3 4
struct ip_opts {
        struct in_addr ip_dst;
        char ip_opts[40];
};
# 396 "/usr/include/netinet/in.h" 3 4
struct ip_mreq {
        struct in_addr imr_multiaddr;
        struct in_addr imr_interface;
};
# 517 "/usr/include/netinet/in.h" 3 4
# 1 "/usr/include/netinet6/in6.h" 1 3 4
# 121 "/usr/include/netinet6/in6.h" 3 4
struct in6_addr {
        union {
                u_int8_t __u6_addr8[16];
                u_int16_t __u6_addr16[8];
                u_int32_t __u6_addr32[4];
        } __u6_addr;
};
# 144 "/usr/include/netinet6/in6.h" 3 4
struct sockaddr_in6 {
        u_int8_t sin6_len;
        u_int8_t sin6_family;
        u_int16_t sin6_port;
        u_int32_t sin6_flowinfo;
        struct in6_addr sin6_addr;
        u_int32_t sin6_scope_id;
};
# 222 "/usr/include/netinet6/in6.h" 3 4
extern const struct in6_addr in6addr_any;
extern const struct in6_addr in6addr_loopback;
extern const struct in6_addr in6addr_nodelocal_allnodes;
extern const struct in6_addr in6addr_linklocal_allnodes;
extern const struct in6_addr in6addr_linklocal_allrouters;
# 382 "/usr/include/netinet6/in6.h" 3 4
struct route_in6 {
        struct rtentry *ro_rt;
        struct sockaddr_in6 ro_dst;
};
# 453 "/usr/include/netinet6/in6.h" 3 4
struct ipv6_mreq {
        struct in6_addr ipv6mr_multiaddr;
        unsigned int ipv6mr_interface;
};




struct in6_pktinfo {
        struct in6_addr ipi6_addr;
        unsigned int ipi6_ifindex;
};
# 612 "/usr/include/netinet6/in6.h" 3 4
extern "C" {
struct cmsghdr;

extern int inet6_option_space (int);
extern int inet6_option_init (void *, struct cmsghdr **, int);
extern int inet6_option_append (struct cmsghdr *, const u_int8_t *, int, int);

extern u_int8_t *inet6_option_alloc (struct cmsghdr *, int, int, int);
extern int inet6_option_next (const struct cmsghdr *, u_int8_t **);
extern int inet6_option_find (const struct cmsghdr *, u_int8_t **, int);

extern size_t inet6_rthdr_space (int, int);
extern struct cmsghdr *inet6_rthdr_init (void *, int);
extern int inet6_rthdr_add (struct cmsghdr *, const struct in6_addr *, unsigned int);

extern int inet6_rthdr_lasthop (struct cmsghdr *, unsigned int);



extern int inet6_rthdr_segments (const struct cmsghdr *);
extern struct in6_addr *inet6_rthdr_getaddr (struct cmsghdr *, int);
extern int inet6_rthdr_getflags (const struct cmsghdr *, int);

extern int inet6_opt_init (void *, size_t);
extern int inet6_opt_append (void *, size_t, int, u_int8_t, size_t, u_int8_t, void **);

extern int inet6_opt_finish (void *, size_t, int);
extern int inet6_opt_set_val (void *, size_t, void *, int);

extern int inet6_opt_next (void *, size_t, int, u_int8_t *, size_t *, void **);

extern int inet6_opt_find (void *, size_t, int, u_int8_t, size_t *, void **);

extern int inet6_opt_get_val (void *, size_t, void *, int);
extern size_t inet6_rth_space (int, int);
extern void *inet6_rth_init (void *, int, int, int);
extern int inet6_rth_add (void *, const struct in6_addr *);
extern int inet6_rth_reverse (const void *, void *);
extern int inet6_rth_segments (const void *);
extern struct in6_addr *inet6_rth_getaddr (const void *, int);
}
# 518 "/usr/include/netinet/in.h" 2 3 4
# 62 "../../click-20030316/include/click/glue.hh" 2
# 1 "/usr/include/sys/time.h" 1 3 4
# 68 "/usr/include/sys/time.h" 3 4
struct timeval {
        int32_t tv_sec;
        int32_t tv_usec;
};






struct timespec {
        time_t tv_sec;
        int32_t tv_nsec;
};
# 93 "/usr/include/sys/time.h" 3 4
struct timezone {
        int tz_minuteswest;
        int tz_dsttime;
};
# 141 "/usr/include/sys/time.h" 3 4
struct itimerval {
        struct timeval it_interval;
        struct timeval it_value;
};




struct clockinfo {
        int hz;
        int tick;
        int tickadj;
        int stathz;
        int profhz;
};
# 174 "/usr/include/sys/time.h" 3 4
# 1 "/usr/include/time.h" 1 3 4
# 94 "/usr/include/time.h" 3 4
struct tm {
        int tm_sec;
        int tm_min;
        int tm_hour;
        int tm_mday;
        int tm_mon;
        int tm_year;
        int tm_wday;
        int tm_yday;
        int tm_isdst;
        long tm_gmtoff;
        char *tm_zone;
};

# 1 "/usr/include/gcc/darwin/3.1/machine/limits.h" 1 3 4





# 1 "/usr/include/ppc/limits.h" 1 3 4
# 7 "/usr/include/gcc/darwin/3.1/machine/limits.h" 2 3 4
# 109 "/usr/include/time.h" 2 3 4






extern char *tzname[];


extern "C" {
char *asctime (const struct tm *);
clock_t clock (void);
char *ctime (const time_t *);
double difftime (time_t, time_t);
struct tm *gmtime (const time_t *);
struct tm *localtime (const time_t *);
time_t mktime (struct tm *);
size_t strftime (char *, size_t, const char *, const struct tm *);
time_t time (time_t *);


void tzset (void);



char *asctime_r (const struct tm *, char *);
char *ctime_r (const time_t *, char *);
struct tm *gmtime_r (const time_t *, struct tm *);
struct tm *localtime_r (const time_t *, struct tm *);
char *strptime (const char *, const char *, struct tm *);
char *timezone (int, int);
void tzsetwall (void);
time_t timelocal (struct tm * const);
time_t timegm (struct tm * const);



int nanosleep (const struct timespec *, struct timespec *);

}
# 175 "/usr/include/sys/time.h" 2 3 4




extern "C" {
int adjtime (const struct timeval *, struct timeval *);
int futimes (int, const struct timeval *);
int getitimer (int, struct itimerval *);
int gettimeofday (struct timeval *, struct timezone *);
int setitimer (int, const struct itimerval *, struct itimerval *);
int settimeofday (const struct timeval *, const struct timezone *);
int utimes (const char *, const struct timeval *);
}
# 63 "../../click-20030316/include/click/glue.hh" 2
# 71 "../../click-20030316/include/click/glue.hh"

void click_chatter(const char *fmt, ...);

# 88 "../../click-20030316/include/click/glue.hh"

extern void click_random_srandom();

# 176 "../../click-20030316/include/click/glue.hh"
typedef struct device net_device;
# 211 "../../click-20030316/include/click/glue.hh"

unsigned click_jiffies();

# 256 "../../click-20030316/include/click/glue.hh"
inline struct timeval
make_timeval(int sec, int usec)
{
  struct timeval tv;
  tv.tv_sec = sec;
  tv.tv_usec = usec;
  return tv;
}

inline bool
operator==(const struct timeval &a, const struct timeval &b)
{
  return a.tv_sec == b.tv_sec && a.tv_usec == b.tv_usec;
}

inline bool
operator!=(const struct timeval &a, const struct timeval &b)
{
  return a.tv_sec != b.tv_sec || a.tv_usec != b.tv_usec;
}

inline bool
operator<(const struct timeval &a, const struct timeval &b)
{
  return a.tv_sec < b.tv_sec || (a.tv_sec == b.tv_sec && a.tv_usec < b.tv_usec);
}

inline bool
operator<=(const struct timeval &a, const struct timeval &b)
{
  return a.tv_sec < b.tv_sec || (a.tv_sec == b.tv_sec && a.tv_usec <= b.tv_usec);
}

inline bool
operator>=(const struct timeval &a, const struct timeval &b)
{
  return a.tv_sec > b.tv_sec || (a.tv_sec == b.tv_sec && a.tv_usec >= b.tv_usec);
}

inline bool
operator>(const struct timeval &a, const struct timeval &b)
{
  return a.tv_sec > b.tv_sec || (a.tv_sec == b.tv_sec && a.tv_usec > b.tv_usec);
}

inline struct timeval &
operator+=(struct timeval &a, const struct timeval &b)
{
  a.tv_sec += b.tv_sec;
  a.tv_usec += b.tv_usec;
  if (a.tv_usec >= 1000000) {
    a.tv_sec++;
    a.tv_usec -= 1000000;
  }
  return a;
}

inline struct timeval &
operator-=(struct timeval &a, const struct timeval &b)
{
  a.tv_sec -= b.tv_sec;
  a.tv_usec -= b.tv_usec;
  if (a.tv_usec < 0) {
    a.tv_sec--;
    a.tv_usec += 1000000;
  }
  return a;
}

inline struct timeval
operator+(struct timeval a, const struct timeval &b)
{
  a += b;
  return a;
}

inline struct timeval
operator-(struct timeval a, const struct timeval &b)
{
  a -= b;
  return a;
}
# 366 "../../click-20030316/include/click/glue.hh"

inline uint64_t
click_get_cycles()
{
  return 0;
}

# 5 "../../click-20030316/include/click/element.hh" 2


# 1 "../../click-20030316/include/click/packet.hh" 1



# 1 "../../click-20030316/include/click/ipaddress.hh" 1





# 1 "../../click-20030316/include/clicknet/ip.h" 1




# 1 "../../click-20030316/include/click/cxxprotect.h" 1
# 6 "../../click-20030316/include/clicknet/ip.h" 2
extern "C" {







uint16_t click_in_cksum(const unsigned char *addr, int len);







struct click_ip {




    unsigned ip_v : 4;
    unsigned ip_hl : 4;



    uint8_t ip_tos;






    uint16_t ip_len;
    uint16_t ip_id;
    uint16_t ip_off;




    uint8_t ip_ttl;
    uint8_t ip_p;
    uint16_t ip_sum;
    struct in_addr ip_src;
    struct in_addr ip_dst;
};
# 114 "../../click-20030316/include/clicknet/ip.h"
static inline void
click_update_in_cksum(uint16_t *csum, uint16_t old_hw, uint16_t new_hw)
{


    uint32_t sum = (~*csum & 0xFFFF) + (~old_hw & 0xFFFF) + new_hw;
    sum = (sum & 0xFFFF) + (sum >> 16);
    *csum = ~(sum + (sum >> 16));
}

}
# 1 "../../click-20030316/include/click/cxxunprotect.h" 1
# 126 "../../click-20030316/include/clicknet/ip.h" 2
# 7 "../../click-20030316/include/click/ipaddress.hh" 2


class IPAddress { public:

  IPAddress() : _addr(0) { }
  explicit IPAddress(const unsigned char *);
  IPAddress(unsigned int);
  explicit IPAddress(int);
  explicit IPAddress(unsigned long);
  explicit IPAddress(long);
  explicit IPAddress(const String &);
  IPAddress(struct in_addr);
  static IPAddress make_prefix(int);

  operator bool() const { return _addr != 0; }
  operator uint32_t() const { return _addr; }
  uint32_t addr() const { return _addr; }

  operator struct in_addr() const;
  struct in_addr in_addr() const;

  unsigned char *data();
  const unsigned char *data() const;

  int mask_to_prefix_len() const;
  bool matches_prefix(IPAddress addr, IPAddress mask) const;
  bool mask_as_specific(IPAddress) const;
# 44 "../../click-20030316/include/click/ipaddress.hh"
  IPAddress &operator&=(IPAddress);
  IPAddress &operator|=(IPAddress);

  String unparse() const;
  String unparse_mask() const;
  String unparse_with_mask(IPAddress) const;

  operator String() const { return unparse(); }
  String s() const { return unparse(); }

 private:

  uint32_t _addr;

};

inline
IPAddress::IPAddress(unsigned int a)
  : _addr(a)
{
}

inline
IPAddress::IPAddress(int a)
  : _addr(a)
{
}

inline
IPAddress::IPAddress(unsigned long a)
  : _addr(a)
{
}

inline
IPAddress::IPAddress(long a)
  : _addr(a)
{
}

inline
IPAddress::IPAddress(struct in_addr ina)
  : _addr(ina.s_addr)
{
}

inline bool
operator==(IPAddress a, IPAddress b)
{
  return a.addr() == b.addr();
}

inline bool
operator==(IPAddress a, uint32_t b)
{
  return a.addr() == b;
}

inline bool
operator!=(IPAddress a, IPAddress b)
{
  return a.addr() != b.addr();
}

inline bool
operator!=(IPAddress a, uint32_t b)
{
  return a.addr() != b;
}

inline const unsigned char *
IPAddress::data() const
{
  return reinterpret_cast<const unsigned char *>(&_addr);
}

inline unsigned char *
IPAddress::data()
{
  return reinterpret_cast<unsigned char *>(&_addr);
}

inline struct in_addr
IPAddress::in_addr() const
{
  struct in_addr ia;
  ia.s_addr = _addr;
  return ia;
}

inline
IPAddress::operator struct in_addr() const
{
  return in_addr();
}

class StringAccum;
StringAccum &operator<<(StringAccum &, IPAddress);

inline bool
IPAddress::matches_prefix(IPAddress a, IPAddress mask) const
{
  return (addr() & mask.addr()) == a.addr();
}

inline bool
IPAddress::mask_as_specific(IPAddress mask) const
{
  return (addr() & mask.addr()) == mask.addr();
}

inline IPAddress
operator&(IPAddress a, IPAddress b)
{
  return IPAddress(a.addr() & b.addr());
}

inline IPAddress &
IPAddress::operator&=(IPAddress a)
{
  _addr &= a._addr;
  return *this;
}

inline IPAddress
operator|(IPAddress a, IPAddress b)
{
  return IPAddress(a.addr() | b.addr());
}

inline IPAddress &
IPAddress::operator|=(IPAddress a)
{
  _addr |= a._addr;
  return *this;
}

inline IPAddress
operator~(IPAddress a)
{
  return IPAddress(~a.addr());
}

inline unsigned
hashcode(IPAddress a)
{
  return a.addr();
}


# 5 "../../click-20030316/include/click/packet.hh" 2




struct click_ether;
struct click_ip;
struct click_icmp;
struct click_ip6;
struct click_tcp;
struct click_udp;







class IP6Address;
class WritablePacket;

class Packet { public:


  enum { DEFAULT_HEADROOM = 28, MIN_BUFFER_LENGTH = 64 };

  static WritablePacket *make(uint32_t);
  static WritablePacket *make(const char *, uint32_t);
  static WritablePacket *make(const unsigned char *, uint32_t);
  static WritablePacket *make(uint32_t, const unsigned char *, uint32_t, uint32_t);
# 51 "../../click-20030316/include/click/packet.hh"
  static WritablePacket *make(unsigned char *, uint32_t, void (*destructor)(unsigned char *, size_t));
  void kill() { if (--_use_count <= 0) delete this; }


  bool shared() const;
  Packet *clone();
  WritablePacket *uniqueify();
# 68 "../../click-20030316/include/click/packet.hh"
  const unsigned char *data() const { return _data; }
  const unsigned char *end_data() const { return _tail; }
  uint32_t length() const { return _tail - _data; }
  uint32_t headroom() const { return _data - _head; }
  uint32_t tailroom() const { return _end - _tail; }
  const unsigned char *buffer_data() const { return _head; }
  uint32_t buffer_length() const { return _end - _head; }


  WritablePacket *push(uint32_t nb);
  WritablePacket *push_mac_header(uint32_t nb);
  Packet *nonunique_push(uint32_t nb);
  void pull(uint32_t nb);
  WritablePacket *put(uint32_t nb);
  Packet *nonunique_put(uint32_t nb);
  void take(uint32_t nb);

  Packet *shift_data(int offset, bool free_on_failure = true);

  void shrink_data(const unsigned char *, uint32_t length);
  void change_headroom_and_length(uint32_t headroom, uint32_t length);
# 105 "../../click-20030316/include/click/packet.hh"
  const unsigned char *mac_header() const { return _mac.raw; }
  const click_ether *ether_header() const { return _mac.ethernet; }

  const unsigned char *network_header() const { return _nh.raw; }
  const click_ip *ip_header() const { return _nh.iph; }
  const click_ip6 *ip6_header() const { return _nh.ip6h; }

  const unsigned char *transport_header() const { return _h.raw; }
  const click_icmp *icmp_header() const { return _h.icmph; }
  const click_tcp *tcp_header() const { return _h.th; }
  const click_udp *udp_header() const { return _h.uh; }


  void set_mac_header(const unsigned char *);
  void set_mac_header(const unsigned char *, uint32_t);
  void set_ether_header(const click_ether *);
  void set_network_header(const unsigned char *, uint32_t);
  void set_network_header_length(uint32_t);
  void set_ip_header(const click_ip *, uint32_t);
  void set_ip6_header(const click_ip6 *);
  void set_ip6_header(const click_ip6 *, uint32_t);

  int mac_header_offset() const;
  uint32_t mac_header_length() const;

  int network_header_offset() const;
  uint32_t network_header_length() const;
  int ip_header_offset() const;
  uint32_t ip_header_length() const;
  int ip6_header_offset() const;
  uint32_t ip6_header_length() const;

  int transport_header_offset() const;






  int mac_length() const { return _tail - _mac.raw; }
  int network_length() const { return _tail - _nh.raw; }
  int transport_length() const { return _tail - _h.raw; }
# 155 "../../click-20030316/include/click/packet.hh"
  Packet *next() const { return _next; }
  Packet *&next() { return _next; }
  void set_next(Packet *p) { _next = p; }




 private:
  struct Anno;




  const Anno *anno() const { return (const Anno *)_cb; }
  Anno *anno() { return (Anno *)_cb; }

 public:

  enum PacketType {
    HOST = 0, BROADCAST = 1, MULTICAST = 2, OTHERHOST = 3, OUTGOING = 4,
    LOOPBACK = 5, FASTROUTE = 6
  };

  enum { ADDR_ANNO_SIZE = 16 };

  uint8_t *addr_anno() { return anno()->addr.c; }
  const uint8_t *addr_anno() const { return anno()->addr.c; }
  IPAddress dst_ip_anno() const;
  void set_dst_ip_anno(IPAddress);
  const IP6Address &dst_ip6_anno() const;
  void set_dst_ip6_anno(const IP6Address &);
# 203 "../../click-20030316/include/click/packet.hh"
  const struct timeval &timestamp_anno() const { return _timestamp; }
  struct timeval &timestamp_anno() { return _timestamp; }
  void set_timestamp_anno(const struct timeval &tv) { _timestamp = tv; }
  void set_timestamp_anno(int s, int us) { _timestamp.tv_sec = s; _timestamp.tv_usec = us; }
# 233 "../../click-20030316/include/click/packet.hh"
  net_device *device_anno() const { return 0; }
  void set_device_anno(net_device *) { }

  PacketType packet_type_anno() const { return _pkt_type; }
  void set_packet_type_anno(PacketType p) { _pkt_type = p; }


  enum { USER_ANNO_SIZE = 24,
         USER_ANNO_US_SIZE = 12,
         USER_ANNO_S_SIZE = 12,
         USER_ANNO_U_SIZE = 6,
         USER_ANNO_I_SIZE = 6 };

  uint8_t user_anno_c(int i) const { return anno()->user.c[i]; }
  void set_user_anno_c(int i, uint8_t v) { anno()->user.c[i] = v; }
  uint16_t user_anno_us(int i) const { return anno()->user.us[i]; }
  void set_user_anno_us(int i, uint16_t v) { anno()->user.us[i] = v; }
  int16_t user_anno_s(int i) const { return anno()->user.us[i]; }
  void set_user_anno_s(int i, int16_t v) { anno()->user.s[i] = v; }
  uint32_t user_anno_u(int i) const { return anno()->user.u[i]; }
  void set_user_anno_u(int i, uint32_t v) { anno()->user.u[i] = v; }
  int32_t user_anno_i(int i) const { return anno()->user.i[i]; }
  void set_user_anno_i(int i, int32_t v) { anno()->user.i[i] = v; }

  const uint8_t *all_user_anno() const { return &anno()->user.c[0]; }
  uint8_t *all_user_anno() { return &anno()->user.c[0]; }
  const uint32_t *all_user_anno_u() const { return &anno()->user.u[0]; }
  uint32_t *all_user_anno_u() { return &anno()->user.u[0]; }

  void clear_annotations();
  void copy_annotations(const Packet *);

 private:


  struct Anno {
    union {
      uint8_t c[ADDR_ANNO_SIZE];
      uint32_t ip4;
    } addr;

    union {
      uint8_t c[USER_ANNO_SIZE];
      uint16_t us[USER_ANNO_US_SIZE];
      int16_t s[USER_ANNO_S_SIZE];
      uint32_t u[USER_ANNO_U_SIZE];
      int32_t i[USER_ANNO_I_SIZE];
    } user;





  };





  int _use_count;
  Packet *_data_packet;

  unsigned char *_head;
  unsigned char *_data;
  unsigned char *_tail;
  unsigned char *_end;

  void (*_destructor)(unsigned char *, size_t);

  unsigned char _cb[48];
  union {
    unsigned char *raw;
    click_ether *ethernet;
  } _mac;
  union {
    unsigned char *raw;
    click_ip *iph;
    click_ip6 *ip6h;
  } _nh;
  union {
    unsigned char *raw;
    click_tcp *th;
    click_udp *uh;
    click_icmp *icmph;
  } _h;
  PacketType _pkt_type;
  struct timeval _timestamp;



  Packet *_next;





  Packet();
  Packet(const Packet &);
  ~Packet();
  Packet &operator=(const Packet &);


  Packet(int, int, int) { }
  static WritablePacket *make(int, int, int);
  bool alloc_data(uint32_t, uint32_t, uint32_t);






  inline void shift_header_annotations(int32_t shift);
  WritablePacket *expensive_uniqueify(int32_t extra_headroom, int32_t extra_tailroom, bool free_on_failure);
  WritablePacket *expensive_push(uint32_t nbytes);
  WritablePacket *expensive_put(uint32_t nbytes);

  friend class WritablePacket;

};


class WritablePacket : public Packet { public:
# 370 "../../click-20030316/include/click/packet.hh"
  unsigned char *data() const { return _data; }
  unsigned char *end_data() const { return _tail; }
  unsigned char *buffer_data() const { return _head; }
  unsigned char *mac_header() const { return _mac.raw; }
  click_ether *ether_header() const { return _mac.ethernet; }
  unsigned char *network_header() const { return _nh.raw; }
  click_ip *ip_header() const { return _nh.iph; }
  click_ip6 *ip6_header() const { return _nh.ip6h; }
  unsigned char *transport_header() const { return _h.raw; }
  click_icmp *icmp_header() const { return _h.icmph; }
  click_tcp *tcp_header() const { return _h.th; }
  click_udp *udp_header() const { return _h.uh; }


 private:

  WritablePacket() { }
  WritablePacket(const Packet &) { }
  ~WritablePacket() { }

  friend class Packet;

};


inline WritablePacket *
Packet::make(uint32_t len)
{
  return make(DEFAULT_HEADROOM, (const unsigned char *)0, len, 0);
}

inline WritablePacket *
Packet::make(const char *s, uint32_t len)
{
  return make(DEFAULT_HEADROOM, (const unsigned char *)s, len, 0);
}

inline WritablePacket *
Packet::make(const unsigned char *s, uint32_t len)
{
  return make(DEFAULT_HEADROOM, (const unsigned char *)s, len, 0);
}
# 485 "../../click-20030316/include/click/packet.hh"
inline bool
Packet::shared() const
{



  return (_data_packet || _use_count > 1);

}

inline WritablePacket *
Packet::uniqueify()
{
  if (!shared())
    return static_cast<WritablePacket *>(this);
  else
    return expensive_uniqueify(0, 0, true);
}

inline WritablePacket *
Packet::push(uint32_t nbytes)
{
  if (headroom() >= nbytes && !shared()) {
    WritablePacket *q = (WritablePacket *)this;



    q->_data -= nbytes;






    return q;
  } else
    return expensive_push(nbytes);
}

inline Packet *
Packet::nonunique_push(uint32_t nbytes)
{
  if (headroom() >= nbytes) {



    _data -= nbytes;






    return this;
  } else
    return expensive_push(nbytes);
}


inline void
Packet::pull(uint32_t nbytes)
{
  if (nbytes > length()) {
    click_chatter("Packet::pull %d > length %d\n", nbytes, length());
    nbytes = length();
  }



  _data += nbytes;






}

inline WritablePacket *
Packet::put(uint32_t nbytes)
{
  if (tailroom() >= nbytes && !shared()) {
    WritablePacket *q = (WritablePacket *)this;



    q->_tail += nbytes;





    return q;
  } else
    return expensive_put(nbytes);
}

inline Packet *
Packet::nonunique_put(uint32_t nbytes)
{
  if (tailroom() >= nbytes) {



    _tail += nbytes;





    return this;
  } else
    return expensive_put(nbytes);
}


inline void
Packet::take(uint32_t nbytes)
{
  if (nbytes > length()) {
    click_chatter("Packet::take %d > length %d\n", nbytes, length());
    nbytes = length();
  }




  _tail -= nbytes;





}


inline void
Packet::shrink_data(const unsigned char *d, uint32_t length)
{
  ((void) ((_data_packet) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/packet.hh", 624, "_data_packet"), 0)));
  if (d >= _head && d + length >= d && d + length <= _end) {
    _head = _data = const_cast<unsigned char *>(d);
    _tail = _end = const_cast<unsigned char *>(d + length);
  }
}

inline void
Packet::change_headroom_and_length(uint32_t headroom, uint32_t length)
{
  if (headroom + length <= buffer_length()) {
    _data = _head + headroom;
    _tail = _data + length;
  }
}


inline const IP6Address &
Packet::dst_ip6_anno() const
{
  return reinterpret_cast<const IP6Address &>(anno()->addr.c);
}

inline void
Packet::set_dst_ip6_anno(const IP6Address &a)
{
  memcpy(anno()->addr.c, &a, 16);
}

inline IPAddress
Packet::dst_ip_anno() const
{
  return IPAddress(anno()->addr.ip4);
}

inline void
Packet::set_dst_ip_anno(IPAddress a)
{
  anno()->addr.ip4 = a.addr();
}

inline void
Packet::set_mac_header(const unsigned char *h)
{



  _mac.raw = const_cast<unsigned char *>(h);

}

inline void
Packet::set_mac_header(const unsigned char *h, uint32_t len)
{




  _mac.raw = const_cast<unsigned char *>(h);
  _nh.raw = const_cast<unsigned char *>(h) + len;

}

inline void
Packet::set_ether_header(const click_ether *h)
{
  set_mac_header(reinterpret_cast<const unsigned char *>(h), 14);
}

inline WritablePacket *
Packet::push_mac_header(uint32_t nbytes)
{
  WritablePacket *q;
  if (headroom() >= nbytes && !shared()) {
    q = (WritablePacket *)this;



    q->_data -= nbytes;






  } else if ((q = expensive_push(nbytes)))
              ;
  else
    return 0;
  q->set_mac_header(q->data(), nbytes);
  return q;
}

inline void
Packet::set_network_header(const unsigned char *h, uint32_t len)
{




  _nh.raw = const_cast<unsigned char *>(h);
  _h.raw = const_cast<unsigned char *>(h) + len;

}

inline void
Packet::set_network_header_length(uint32_t len)
{



  _h.raw = _nh.raw + len;

}

inline void
Packet::set_ip_header(const click_ip *iph, uint32_t len)
{
  set_network_header(reinterpret_cast<const unsigned char *>(iph), len);
}

inline void
Packet::set_ip6_header(const click_ip6 *ip6h, uint32_t len)
{
  set_network_header(reinterpret_cast<const unsigned char *>(ip6h), len);
}

inline void
Packet::set_ip6_header(const click_ip6 *ip6h)
{
  set_ip6_header(ip6h, 40);
}

inline int
Packet::mac_header_offset() const
{
  return mac_header() - data();
}

inline uint32_t
Packet::mac_header_length() const
{
  return network_header() - mac_header();
}

inline int
Packet::network_header_offset() const
{
  return network_header() - data();
}

inline uint32_t
Packet::network_header_length() const
{
  return transport_header() - network_header();
}

inline int
Packet::ip_header_offset() const
{
  return network_header_offset();
}

inline uint32_t
Packet::ip_header_length() const
{
  return network_header_length();
}

inline int
Packet::ip6_header_offset() const
{
  return network_header_offset();
}

inline uint32_t
Packet::ip6_header_length() const
{
  return network_header_length();
}

inline int
Packet::transport_header_offset() const
{
  return transport_header() - data();
}

inline void
Packet::clear_annotations()
{
  memset(anno(), '\0', sizeof(Anno));
  set_packet_type_anno(HOST);
  set_device_anno(0);
  set_timestamp_anno(0, 0);
  set_mac_header(0);
  set_network_header(0, 0);
  set_next(0);
}

inline void
Packet::copy_annotations(const Packet *p)
{
  *anno() = *p->anno();
  set_packet_type_anno(p->packet_type_anno());
  set_device_anno(p->device_anno());
  set_timestamp_anno(p->timestamp_anno());
}

inline void
Packet::shift_header_annotations(int32_t shift)
{

  _mac.raw += (_mac.raw ? shift : 0);
  _nh.raw += (_nh.raw ? shift : 0);
  _h.raw += (_h.raw ? shift : 0);






}


# 8 "../../click-20030316/include/click/element.hh" 2

class Router;
class Task;
class Element;
class ErrorHandler;
class Bitvector;



typedef String (*ReadHandler)(Element *, void *);
typedef int (*WriteHandler)(const String &, Element *, void *, ErrorHandler *);

class Element { public:

  static const char * const AGNOSTIC, * const PUSH, * const PULL;
  static const char * const PUSH_TO_PULL, * const PULL_TO_PUSH;
  enum Processing { VAGNOSTIC, VPUSH, VPULL };

  static const char * const COMPLETE_FLOW;

  enum ConfigurePhase {
    CONFIGURE_PHASE_FIRST = 0,
    CONFIGURE_PHASE_INFO = 20,
    CONFIGURE_PHASE_DEFAULT = 100,
    CONFIGURE_PHASE_LAST = 2000
  };

  class Port;

  Element();
  Element(int ninputs, int noutputs);
  virtual ~Element();
  static int nelements_allocated;


  virtual const char *class_name() const = 0;
  virtual void *cast(const char *);
  virtual Element *clone() const = 0;

  String id() const;
  String declaration() const;
  String landmark() const;

  Router *router() const { return _router; }
  int eindex() const { return _eindex; }
  int eindex(Router *) const;


  int ninputs() const { return _ninputs; }
  int noutputs() const { return _noutputs; }
  void set_ninputs(int);
  void set_noutputs(int);
  void add_input() { set_ninputs(ninputs()+1); }
  void add_output() { set_noutputs(noutputs()+1); }
  bool ports_frozen() const;

  const Port &input(int) const;
  const Port &output(int) const;

  bool input_is_push(int) const;
  bool input_is_pull(int) const;
  bool output_is_push(int) const;
  bool output_is_pull(int) const;

  void checked_output_push(int, Packet *) const;


  virtual const char *processing() const;
  virtual const char *flow_code() const;
  virtual const char *flags() const;


  virtual void notify_ninputs(int);
  virtual void notify_noutputs(int);
  virtual int configure_phase() const;
  virtual int configure(Vector<String> &, ErrorHandler *);
  virtual int initialize(ErrorHandler *);


  enum CleanupStage { CLEANUP_NO_ROUTER, CLEANUP_CONFIGURE_FAILED,
                      CLEANUP_CONFIGURED, CLEANUP_INITIALIZE_FAILED,
                      CLEANUP_INITIALIZED, CLEANUP_ROUTER_INITIALIZED };
  virtual void cleanup(CleanupStage);


  virtual void configuration(Vector<String> &) const;
  String configuration() const;

  virtual bool can_live_reconfigure() const;
  virtual int live_reconfigure(Vector<String> &, ErrorHandler *);
  virtual void take_state(Element *, ErrorHandler *);


  virtual void add_handlers();

  void add_read_handler(const String &, ReadHandler, void *);
  void add_write_handler(const String &, WriteHandler, void *);
  void add_task_handlers(Task *, const String &prefix = String());

  static String read_positional_handler(Element *, void *);
  static String read_keyword_handler(Element *, void *);
  static int reconfigure_positional_handler(const String &, Element *, void *, ErrorHandler *);
  static int reconfigure_keyword_handler(const String &, Element *, void *, ErrorHandler *);

  virtual int llrpc(unsigned command, void *arg);
  int local_llrpc(unsigned command, void *arg);


  virtual void push(int port, Packet *);
  virtual Packet *pull(int port);
  virtual Packet *simple_action(Packet *);

  virtual bool run_task();
  virtual void run_timer();
  virtual void run_scheduled();


  enum { SELECT_READ = 1, SELECT_WRITE = 2 };
  int add_select(int fd, int mask) const;
  int remove_select(int fd, int mask) const;
  virtual void selected(int fd);



  void attach_router(Router *r, int n) { _router = r; _eindex = n; }

  void processing_vector(Subvector<int> &, Subvector<int> &, ErrorHandler *) const;
  void initialize_ports(const Subvector<int> &, const Subvector<int> &);

  void forward_flow(int, Bitvector *) const;
  void backward_flow(int, Bitvector *) const;

  int connect_input(int which, Element *, int);
  int connect_output(int which, Element *, int);

  void add_default_handlers(bool writable_config);
# 152 "../../click-20030316/include/click/element.hh"
  class Port { public:

    Port();
    Port(Element *, Element *, int);

    operator bool() const { return _e != 0; }
    bool allowed() const { return _port >= 0; }
    bool initialized() const { return _port >= -1; }

    Element *element() const { return _e; }
    int port() const { return _port; }

    void push(Packet *p) const;
    Packet *pull() const;





   private:

    Element *_e;
    int _port;
# 183 "../../click-20030316/include/click/element.hh"
  };

 private:

  enum { INLINE_PORTS = 4 };

  Port *_inputs;
  Port *_outputs;
  Port _ports0[INLINE_PORTS];

  int _ninputs;
  int _noutputs;

  Router *_router;
  int _eindex;

  Element(const Element &);
  Element &operator=(const Element &);

  void set_nports(int, int);

};


inline int
Element::eindex(Router *r) const
{
  return (router() == r ? eindex() : -1);
}

inline const Element::Port &
Element::input(int i) const
{
  ((void) ((i >= 0 && i < ninputs()) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/element.hh", 216, "i >= 0 && i < ninputs()"), 0)));
  return _inputs[i];
}

inline const Element::Port &
Element::output(int o) const
{
  ((void) ((o >= 0 && o < noutputs()) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/element.hh", 223, "o >= 0 && o < noutputs()"), 0)));
  return _outputs[o];
}

inline bool
Element::output_is_push(int o) const
{
  return o >= 0 && o < noutputs() && _outputs[o].allowed();
}

inline bool
Element::output_is_pull(int o) const
{
  return o >= 0 && o < noutputs() && !_outputs[o].allowed();
}

inline bool
Element::input_is_pull(int i) const
{
  return i >= 0 && i < ninputs() && _inputs[i].allowed();
}

inline bool
Element::input_is_push(int i) const
{
  return i >= 0 && i < ninputs() && !_inputs[i].allowed();
}
# 261 "../../click-20030316/include/click/element.hh"
inline
Element::Port::Port()
  : _e(0), _port(-2)
{
}

inline
Element::Port::Port(Element *owner, Element *e, int p)
  : _e(e), _port(p)
{
  (void) owner;
}

inline void
Element::Port::push(Packet *p) const
{
  ((void) ((_e) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/element.hh", 277, "_e"), 0)));
# 291 "../../click-20030316/include/click/element.hh"
  _e->push(_port, p);

}

inline Packet *
Element::Port::pull() const
{
  ((void) ((_e) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/element.hh", 298, "_e"), 0)));
# 309 "../../click-20030316/include/click/element.hh"
  Packet *p = _e->pull(_port);




  return p;
}

inline void
Element::checked_output_push(int o, Packet *p) const
{
  if ((unsigned)o < (unsigned)noutputs())
    _outputs[o].push(p);
  else
    p->kill();
}



# 5 "../../click-20030316/include/click/router.hh" 2
# 1 "../../click-20030316/include/click/timer.hh" 1



# 1 "../../click-20030316/include/click/sync.hh" 1



# 1 "../../click-20030316/include/click/atomic.hh" 1



# 83 "../../click-20030316/include/click/atomic.hh"
class uatomic32_t { public:




  operator uint32_t() const { return _val; }
  uint32_t value() const { return _val; }

  uatomic32_t &operator=(uint32_t u) { _val = u; return *this; }
  uatomic32_t &operator+=(int x) { _val += x; return *this; }
  uatomic32_t &operator-=(int x) { _val -= x; return *this; }
  void operator++(int) { _val++; }
  void operator--(int) { _val--; }

  uint32_t read_and_add(int x);
  uint32_t compare_and_swap(uint32_t old_value, uint32_t new_value);


  bool dec_and_test() { _val--; return _val == 0; }

 private:

  uint32_t _val;

};

inline uint32_t
uatomic32_t::read_and_add(int x)
{
  uint32_t ov = _val;
  _val += x;
  return ov;
}

inline uint32_t
uatomic32_t::compare_and_swap(uint32_t old_value, uint32_t new_value)
{
  uint32_t ov = _val;
  if (_val == old_value) _val = new_value;
  return ov;
}



inline uint32_t
operator+(const uatomic32_t &a, const uatomic32_t &b)
{
  return a.value() + b.value();
}

inline uint32_t
operator-(const uatomic32_t &a, const uatomic32_t &b)
{
  return a.value() - b.value();
}

inline bool
operator==(const uatomic32_t &a, const uatomic32_t &b)
{
  return a.value() == b.value();
}

inline bool
operator!=(const uatomic32_t &a, const uatomic32_t &b)
{
  return a.value() != b.value();
}

inline bool
operator>(const uatomic32_t &a, const uatomic32_t &b)
{
  return a.value() > b.value();
}

inline bool
operator<(const uatomic32_t &a, const uatomic32_t &b)
{
  return a.value() < b.value();
}

inline bool
operator>=(const uatomic32_t &a, const uatomic32_t &b)
{
  return a.value() >= b.value();
}

inline bool
operator<=(const uatomic32_t &a, const uatomic32_t &b)
{
  return a.value() <= b.value();
}


# 5 "../../click-20030316/include/click/sync.hh" 2
# 14 "../../click-20030316/include/click/sync.hh"

# 120 "../../click-20030316/include/click/sync.hh"
class Spinlock { public:

  Spinlock() { }
  ~Spinlock() { }

  void acquire() { }
  void release() { }
  bool attempt() { return true; }

};
# 235 "../../click-20030316/include/click/sync.hh"
class ReadWriteLock { public:

  ReadWriteLock() { }

  void acquire_read() { }
  bool attempt_read() { return true; }
  void release_read() { }
  void acquire_write() { }
  bool attempt_write() { return true; }
  void release_write() { }

};




# 5 "../../click-20030316/include/click/timer.hh" 2


class Element;
class Router;
class Timer;
class TimerList;
class Task;

typedef void (*TimerHook)(Timer *, void *);

class Timer { public:

  Timer(TimerHook, void *);
  Timer(Element *);
  Timer(Task *);
  ~Timer() { if (scheduled()) unschedule(); }

  bool initialized() const { return _head != 0; }
  bool scheduled() const { return _prev != 0; }
  const struct timeval &when() const { return _expires; }
  bool is_list() const;

  void initialize(TimerList *);
  void initialize(Router *);
  void initialize(Element *);
  void cleanup() { unschedule(); }
  void uninitialize() { cleanup(); }

  void schedule_at(const struct timeval &);
  void reschedule_at(const struct timeval &);

  void schedule_now();
  void schedule_after_s(uint32_t);
  void schedule_after_ms(uint32_t);
  void reschedule_after_s(uint32_t);
  void reschedule_after_ms(uint32_t);

  void unschedule();

 private:

  Timer *_prev;
  Timer *_next;
  struct timeval _expires;
  TimerHook _hook;
  void *_thunk;
  TimerList *_head;

  Timer(const Timer &);
  Timer &operator=(const Timer &);

  friend class TimerList;

};

class TimerList : public Timer { public:

  TimerList();

  void run();
  int get_next_delay(struct timeval *tv);

  void unschedule_all();

 private:

  Spinlock _lock;

  void acquire_lock() { _lock.acquire(); }
  bool attempt_lock() { return _lock.attempt(); }
  void release_lock() { _lock.release(); }

  friend class Timer;

};

inline void
Timer::initialize(TimerList *t)
{
  ((void) ((!initialized()) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/timer.hh", 84, "!initialized()"), 0)));
  _head = t;
}

inline bool
Timer::is_list() const
{
  return _head == this;
}

inline void
Timer::schedule_now()
{
  schedule_after_ms(0);
}

inline void
Timer::reschedule_at(const struct timeval &tv)
{
  schedule_at(tv);
}


# 6 "../../click-20030316/include/click/router.hh" 2

# 1 "../../click-20030316/include/click/bitvector.hh" 1






class Bitvector { public:

    class Bit;

    Bitvector() : _max(-1), _data(&_f0), _f0(0), _f1(0) { }
    explicit Bitvector(int);
    explicit Bitvector(unsigned);
    explicit Bitvector(bool b) : _max(0), _data(&_f0), _f0(b), _f1(0) { }
    Bitvector(int, bool);
    Bitvector(unsigned, bool);
    Bitvector(const Bitvector &);
    ~Bitvector() { if (_data != &_f0) delete[] _data; }

    int size() const { return _max + 1; }

    bool zero() const;
    operator bool() const { return !zero(); }

    Bit operator[](int);
    bool operator[](int) const;
    Bit force_bit(int);

    void clear();
    void resize(int n);

    bool operator==(const Bitvector &) const;
    bool operator!=(const Bitvector &) const;

    Bitvector operator~() const;
    Bitvector operator&(const Bitvector &) const;
    Bitvector operator|(const Bitvector &) const;
    Bitvector operator^(const Bitvector &) const;
    Bitvector operator-(const Bitvector &) const;

    Bitvector &operator=(const Bitvector &);
    void negate();
    Bitvector &operator&=(const Bitvector &);
    Bitvector &operator|=(const Bitvector &);
    Bitvector &operator^=(const Bitvector &);
    Bitvector &operator-=(const Bitvector &);
    Bitvector &assign(int, bool);

    void or_at(const Bitvector &, int);
    void or_with_difference(const Bitvector &, Bitvector &diff);
    bool nonzero_intersection(const Bitvector &) const;


    int max_word() const { return (_max < 0 ? -1 : _max>>5); }
    uint32_t *data_words() { return _data; }
    const uint32_t *data_words() const { return _data; }

  private:

    enum { MAX_INLINE_BIT = 63, MAX_INLINE_WORD = 1 };

    int _max;
    uint32_t *_data;
    uint32_t _f0;
    uint32_t _f1;

    void finish_copy_constructor(const Bitvector &);
    void clear_last();
    void resize_to_max(int, bool);

};

class Bitvector::Bit { public:

    Bit(uint32_t &p, int off) : _p(p), _mask(1U<<off) { }

    operator bool() const { return (_p & _mask) != 0; }
    operator bool() { return (_p & _mask) != 0; }

    bool operator=(bool b);
    bool operator=(const Bit &);

  private:

    uint32_t &_p;
    uint32_t _mask;

};


inline
Bitvector::Bitvector(int n)
    : _max(n - 1), _data(&_f0), _f0(0), _f1(0)
{
    if (_max > MAX_INLINE_BIT)
        resize_to_max(_max, false);
}

inline
Bitvector::Bitvector(unsigned n)
    : _max(n - 1), _data(&_f0), _f0(0), _f1(0)
{
    if (_max > MAX_INLINE_BIT)
        resize_to_max(_max, false);
}

inline
Bitvector::Bitvector(int n, bool b)
    : _max(n - 1), _data(&_f0), _f0(0), _f1(0)
{
    if (_max > MAX_INLINE_BIT)
        resize_to_max(_max, false);
    if (b)
        assign(n, b);
}

inline
Bitvector::Bitvector(unsigned n, bool b)
    : _max(n - 1), _data(&_f0), _f0(0), _f1(0)
{
    if (_max > MAX_INLINE_BIT)
        resize_to_max(_max, false);
    if (b)
        assign(n, b);
}

inline
Bitvector::Bitvector(const Bitvector &o)
    : _max(o._max), _data(&_f0), _f0(o._data[0]), _f1(o._data[1])
{
    if (_max > MAX_INLINE_BIT)
        finish_copy_constructor(o);
}

inline void
Bitvector::resize(int n)
{
    if (n - 1 > MAX_INLINE_BIT)
        resize_to_max(n - 1, true);
    _max = n - 1;
}

inline bool
Bitvector::Bit::operator=(bool b)
{
    if (b)
        _p |= _mask;
    else
        _p &= ~_mask;
    return b;
}

inline bool
Bitvector::Bit::operator=(const Bit &o)
{
    return *this = (bool)o;
}

inline Bitvector::Bit
Bitvector::operator[](int i)
{
    ((void) ((i >= 0 && i <= _max) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/bitvector.hh", 162, "i >= 0 && i <= _max"), 0)));
    return Bit(_data[i>>5], i&31);
}

inline Bitvector::Bit
Bitvector::force_bit(int i)
{
    ((void) ((i >= 0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/bitvector.hh", 169, "i >= 0"), 0)));
    if (i > _max)
        resize(i + 1);
    return Bit(_data[i>>5], i&31);
}

inline bool
Bitvector::operator[](int i) const
{
    ((void) ((i >= 0 && i <= _max) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/bitvector.hh", 178, "i >= 0 && i <= _max"), 0)));
    return (_data[i>>5] & (1<<(i&31))) != 0;
}

inline bool
Bitvector::operator==(const Bitvector &o) const
{
    if (_max != o._max)
        return false;
    else if (_max <= MAX_INLINE_BIT)
        return memcmp(_data, o._data, 8) == 0;
    else
        return memcmp(_data, o._data, (max_word() + 1)*4) == 0;
}

inline bool
Bitvector::operator!=(const Bitvector &o) const
{
    return !(*this == o);
}

inline Bitvector &
Bitvector::operator-=(const Bitvector &o)
{
    return *this &= ~o;
}

inline Bitvector
Bitvector::operator~() const
{
    Bitvector m = *this;
    m.negate();
    return m;
}

inline Bitvector
Bitvector::operator&(const Bitvector &o) const
{
    Bitvector m = *this;
    m &= o;
    return m;
}

inline Bitvector
Bitvector::operator|(const Bitvector &o) const
{
    Bitvector m = *this;
    m |= o;
    return m;
}

inline Bitvector
Bitvector::operator^(const Bitvector &o) const
{
    Bitvector m = *this;
    m ^= o;
    return m;
}

inline Bitvector
Bitvector::operator-(const Bitvector &o) const
{
    return *this & ~o;
}


# 8 "../../click-20030316/include/click/router.hh" 2
# 1 "../../click-20030316/include/click/task.hh" 1
# 10 "../../click-20030316/include/click/task.hh"




typedef bool (*TaskHook)(Task *, void *);
class RouterThread;
class TaskList;

class Task { public:


  enum { STRIDE1 = 1U<<16, MAX_STRIDE = 1U<<31 };
  enum { MAX_TICKETS = 1<<15, DEFAULT_TICKETS = 1<<10 };





  Task(TaskHook, void *);
  Task(Element *);
  ~Task();

  bool initialized() const { return _all_prev; }
  bool scheduled() const { return _prev != 0; }

  TaskHook hook() const { return _hook; }
  void *thunk() const { return _thunk; }
  Element *element() const;

  Task *scheduled_next() const { return _next; }
  Task *scheduled_prev() const { return _prev; }
  RouterThread *scheduled_list() const { return _thread; }


  int tickets() const { return _tickets; }
  void set_tickets(int);
  void adj_tickets(int);


  void initialize(Element *, bool scheduled);
  void initialize(Router *, bool scheduled);
  void cleanup();
  void uninitialize() { cleanup(); }

  void unschedule();
  void reschedule();

  int fast_unschedule();
  void fast_reschedule();

  void strong_unschedule();
  void strong_reschedule();

  int thread_preference() const { return _thread_preference; }
  void change_thread(int);





  void call_hook();
# 81 "../../click-20030316/include/click/task.hh"
  Task *all_tasks_prev() const { return _all_prev; }
  Task *all_tasks_next() const { return _all_next; }

 private:




  Task *_prev;
  Task *_next;

  unsigned _pass;
  unsigned _stride;
  int _tickets;


  TaskHook _hook;
  void *_thunk;
# 109 "../../click-20030316/include/click/task.hh"
  RouterThread *_thread;
  int _thread_preference;

  Task *_all_prev;
  Task *_all_next;
  TaskList *_all_list;

  enum { RESCHEDULE = 1, CHANGE_THREAD = 2 };
  unsigned _pending;
  Task *_pending_next;

  Task(const Task &);
  Task &operator=(const Task &);

  void add_pending(int);
  void process_pending(RouterThread *);
  void fast_schedule();
  inline void lock_tasks();
  inline bool attempt_lock_tasks();

  static bool error_hook(Task *, void *);

  friend class TaskList;
  friend class RouterThread;

};

class TaskList : public Task { public:

  TaskList();

  bool empty() const;

  void lock();
  void unlock();

 private:

  Spinlock _lock;

};




# 1 "../../click-20030316/include/click/routerthread.hh" 1





# 1 "../../click-20030316/include/click/ewma.hh" 1




# 1 "../../click-20030316/include/click/confparse.hh" 1






class ErrorHandler;
class StringAccum;

class Element;
class Router;
class HandlerCall;
# 22 "../../click-20030316/include/click/confparse.hh"
bool cp_eat_space(String &);
bool cp_is_space(const String &);
bool cp_is_word(const String &);
bool cp_is_click_id(const String &);

String cp_unquote(const String &);
String cp_quote(const String &, bool allow_newlines = false);
String cp_uncomment(const String &);
int cp_process_backslash(const char *, int pos, int len, StringAccum &);


void cp_argvec(const String &, Vector<String> &);
String cp_unargvec(const Vector<String> &);
void cp_spacevec(const String &, Vector<String> &);
String cp_unspacevec(const Vector<String> &);
String cp_pop_spacevec(String &);

enum CpErrors {
    CPE_OK = 0,
    CPE_FORMAT,
    CPE_NEGATIVE,
    CPE_OVERFLOW,
    CPE_INVALID
};
extern int cp_errno;


bool cp_string(const String &, String *, String *rest = 0);
bool cp_word(const String &, String *, String *rest = 0);
bool cp_keyword(const String &, String *, String *rest = 0);


bool cp_bool(const String &, bool *);
bool cp_integer(const String &, int32_t *);
bool cp_integer(const String &, int base, int32_t *);
bool cp_unsigned(const String &, uint32_t *);
bool cp_unsigned(const String &, int base, uint32_t *);

bool cp_integer64(const String &, int64_t *);
bool cp_integer64(const String &, int base, int64_t *);
bool cp_unsigned64(const String &, uint64_t *);
bool cp_unsigned64(const String &, int base, uint64_t *);


bool cp_real2(const String &, int frac_bits, int32_t *);
bool cp_unsigned_real2(const String &, int frac_bits, uint32_t *);
bool cp_real10(const String &, int frac_digits, int32_t *);
bool cp_unsigned_real10(const String &, int frac_digits, uint32_t *);
bool cp_unsigned_real10(const String &, int frac_dig, uint32_t *, uint32_t *);

bool cp_double(const String &, double *);

bool cp_seconds_as(int want_power, const String &, uint32_t *);
bool cp_seconds_as_milli(const String &, uint32_t *);
bool cp_seconds_as_micro(const String &, uint32_t *);
bool cp_timeval(const String &, struct timeval *);

String cp_unparse_bool(bool);

String cp_unparse_integer64(int64_t, int base, bool uppercase);
String cp_unparse_unsigned64(uint64_t, int base, bool uppercase);

String cp_unparse_real2(int32_t, int frac_bits);
String cp_unparse_real2(uint32_t, int frac_bits);

String cp_unparse_real2(int64_t, int frac_bits);
String cp_unparse_real2(uint64_t, int frac_bits);

String cp_unparse_real10(int32_t, int frac_digits);
String cp_unparse_real10(uint32_t, int frac_digits);
String cp_unparse_milliseconds(uint32_t);
String cp_unparse_microseconds(uint32_t);
String cp_unparse_interval(const struct timeval &);


class IPAddress;
class IPAddressSet;
bool cp_ip_address(const String &, unsigned char * , Element *context = 0);
bool cp_ip_address(const String &, IPAddress * , Element *context = 0);
bool cp_ip_prefix(const String &, unsigned char *, unsigned char *, bool allow_bare_address , Element *context = 0);
bool cp_ip_prefix(const String &, IPAddress *, IPAddress *, bool allow_bare_address , Element *context = 0);
bool cp_ip_prefix(const String &, unsigned char *, unsigned char * , Element *context = 0);
bool cp_ip_prefix(const String &, IPAddress *, IPAddress * , Element *context = 0);
bool cp_ip_address_set(const String &, IPAddressSet * , Element *context = 0);
# 117 "../../click-20030316/include/click/confparse.hh"
class EtherAddress;
bool cp_ethernet_address(const String &, unsigned char * , Element *context = 0);
bool cp_ethernet_address(const String &, EtherAddress * , Element *context = 0);


Element *cp_element(const String &, Element *, ErrorHandler *);
Element *cp_element(const String &, Router *, ErrorHandler *);
bool cp_handler(const String &, Element *, Element **, String *, ErrorHandler *);
bool cp_handler(const String &, Element *, Element **, int *, ErrorHandler *);
bool cp_handler(const String &, Element *, bool need_r, bool need_w, Element **, int *, ErrorHandler *);
bool cp_handler_call(const String &, Element *, bool is_write, HandlerCall **, ErrorHandler *);







bool cp_filename(const String &, String *);


typedef const char * const CpVaParseCmd;
static const CpVaParseCmd cpEnd = 0;
extern CpVaParseCmd
    cpOptional,
    cpKeywords,
    cpConfirmKeywords,
    cpMandatoryKeywords,
    cpIgnore,
    cpIgnoreRest,

    cpArgument,
    cpArguments,
    cpString,
    cpWord,
    cpKeyword,
    cpBool,
    cpByte,
    cpShort,
    cpUnsignedShort,
    cpInteger,
    cpUnsigned,

    cpInteger64,
    cpUnsigned64,

    cpUnsignedReal2,
    cpReal10,
    cpUnsignedReal10,

    cpDouble,

    cpSeconds,
    cpSecondsAsMilli,
    cpSecondsAsMicro,
    cpTimeval,
    cpInterval,
    cpIPAddress,
    cpIPPrefix,
    cpIPAddressOrPrefix,
    cpIPAddressSet,
    cpEthernetAddress,
    cpElement,
    cpHandlerName,
    cpHandler,
    cpReadHandler,
    cpWriteHandler,
    cpReadHandlerCall,
    cpWriteHandlerCall,
    cpIP6Address,
    cpIP6Prefix,
    cpIP6AddressOrPrefix,
    cpDesCblock,
    cpFilename,

    cpMilliseconds,
    cpUnsignedLongLong,
    cpNonnegReal2,
    cpNonnegReal10,
    cpEtherAddress;

int cp_va_parse(const Vector<String> &, Element *, ErrorHandler *, ...);
int cp_va_parse(const String &, Element *, ErrorHandler *, ...);
int cp_va_space_parse(const String &, Element *, ErrorHandler *, ...);
int cp_va_parse_keyword(const String &, Element *, ErrorHandler *, ...);
int cp_va_parse_remove_keywords(Vector<String> &, int, Element *, ErrorHandler *, ...);
# 213 "../../click-20030316/include/click/confparse.hh"
void cp_va_static_initialize();
void cp_va_static_cleanup();


struct cp_value;
struct cp_argtype;

typedef void (*cp_parsefunc)(cp_value *, const String &arg,
                             ErrorHandler *, const char *argdesc , Element *context);
typedef void (*cp_storefunc)(cp_value * , Element *context);

enum { cpArgNormal = 0, cpArgStore2 = 1, cpArgExtraInt = 2, cpArgAllowNumbers = 4 };
int cp_register_argtype(const char *name, const char *description,
                        int flags, cp_parsefunc, cp_storefunc);
void cp_unregister_argtype(const char *name);

int cp_register_stringlist_argtype(const char *name, const char *description,
                                   int flags);
int cp_extend_stringlist_argtype(const char *name, ...);


struct cp_argtype {
    const char *name;
    cp_argtype *next;
    cp_parsefunc parse;
    cp_storefunc store;
    void *user_data;
    int flags;
    const char *description;
    int internal;
    int use_count;
};

struct cp_value {

    const cp_argtype *argtype;
    const char *keyword;
    const char *description;
    int extra;
    void *store;
    void *store2;
    bool *store_confirm;

    union {
        bool b;
        int32_t i;
        uint32_t u;

        int64_t i64;
        uint64_t u64;


        double d;

        unsigned char address[16];
        int is[4];

        Element *element;

    } v, v2;
    String v_string;
    String v2_string;
};





# 6 "../../click-20030316/include/click/ewma.hh" 2


template <unsigned Stability_shift, unsigned Scale>
class DirectEWMAX { public:

  DirectEWMAX() { _avg = 0; }

  unsigned average() const { return _avg; }
  static const unsigned stability_shift = Stability_shift;
  static const unsigned scale = Scale;
  static const unsigned compensation = 1 << (Stability_shift - 1);

  void clear() { _avg = 0; }

  inline void update_with(unsigned);
  void update_zero_period(unsigned);

  String unparse() const;

 private:

  unsigned _avg;

};

template <unsigned Stability_shift, unsigned Scale, unsigned N, class Timer>
class RateEWMAX { public:

  RateEWMAX() { }


  int average(unsigned which = 0) const { return _avg[which].average(); }
  int rate(unsigned which = 0) const;

  static const int stability_shift = Stability_shift;
  static const int scale = Scale;
  static unsigned now() { return Timer::now(); }
  static unsigned freq() { return Timer::freq(); }

  String unparse(unsigned which = 0) const;
  void initialize();

  inline void update_time(unsigned now);
  inline void update_time();
  inline void update_now(int delta, unsigned which = 0);
  inline void update(int delta, unsigned which = 0);

 private:

  unsigned _now_time;
  unsigned _total[N];
  DirectEWMAX<Stability_shift, Scale> _avg[N];

};

struct JiffiesTimer {
  static unsigned now() { return click_jiffies(); }
  static unsigned freq() { return 100; }
};

typedef DirectEWMAX<4, 10> DirectEWMA;
typedef DirectEWMAX<3, 10> FastDirectEWMA;
typedef RateEWMAX<4, 10, 1, JiffiesTimer> RateEWMA;

template <unsigned stability_shift, unsigned scale>
inline void
DirectEWMAX<stability_shift, scale>::update_with(unsigned val)
{
  int val_scaled = val << scale;
  _avg += static_cast<int>(val_scaled - _avg + compensation) >> stability_shift;

}

template <unsigned stability_shift, unsigned scale, unsigned n, class Timer>
inline void
RateEWMAX<stability_shift, scale, n, Timer>::initialize()
{
  _now_time = now();
  for (unsigned i = 0; i < n; i++) {
    _total[i] = 0;
    _avg[i].clear();
  }
}

template <unsigned stability_shift, unsigned scale, unsigned n, class Timer>
inline void
RateEWMAX<stability_shift, scale, n, Timer>::update_time(unsigned now)
{
  unsigned jj = _now_time;
  if (now != jj) {
    for (unsigned i = 0; i < n; i++) {

      _avg[i].update_with(_total[i]);


      if (jj + 1 != now)
        _avg[i].update_zero_period(now - jj - 1);
      _total[i] = 0;
    }
    _now_time = now;
  }
}

template <unsigned stability_shift, unsigned scale, unsigned n, class Timer>
inline void
RateEWMAX<stability_shift, scale, n, Timer>::update_now(int delta,
                                                        unsigned which)
{
  _total[which] += delta;
}

template <unsigned stability_shift, unsigned scale, unsigned n, class Timer>
inline void
RateEWMAX<stability_shift, scale, n, Timer>::update_time()
{
  update_time(now());
}

template <unsigned stability_shift, unsigned scale, unsigned n, class Timer>
inline void
RateEWMAX<stability_shift, scale, n, Timer>::update(int delta, unsigned which)
{
  update_time();
  update_now(delta, which);
}

template <unsigned stability_shift, unsigned scale, unsigned n, class Timer>
inline int
RateEWMAX<stability_shift, scale, n, Timer>::rate(unsigned which) const
{
  return (average(which) * Timer::freq()) >> scale;
}

template <unsigned stability_shift, unsigned scale>
inline String
DirectEWMAX<stability_shift, scale>::unparse() const
{
  return cp_unparse_real2(average(), scale);
}

template <unsigned stability_shift, unsigned scale, unsigned n, class Timer>
inline String
RateEWMAX<stability_shift, scale, n, Timer>::unparse(unsigned which) const
{
  return cp_unparse_real2(average(which) * Timer::freq(), scale);
}


# 7 "../../click-20030316/include/click/routerthread.hh" 2





class RouterThread : public Task { public:

    RouterThread(Router *);
    ~RouterThread();

    Router *router() const { return _router; }
    int thread_id() const { return _id; }

    void driver();
    void driver_once();


    bool empty() const;

    void lock_tasks();
    bool attempt_lock_tasks();
    void unlock_tasks();

    void unschedule_all_tasks();
# 41 "../../click-20030316/include/click/routerthread.hh"
  private:

    Router *_router;
    int _id;

    Spinlock _lock;
    uatomic32_t _task_lock_waiting;
    uatomic32_t _pending;
# 71 "../../click-20030316/include/click/routerthread.hh"
    void set_thread_id(int i) { _id = i; }


    void add_pending() { _pending++; }
    void process_task_requests();


    inline void nice_lock_tasks();
    inline void run_tasks(int ntasks);
    inline void run_os();





    void wait(int iter);

    friend class Task;
    friend class Router;

};


inline bool
RouterThread::empty() const
{
    return (const Task *)_next == this;
}

inline void
RouterThread::lock_tasks()
{
    _task_lock_waiting++;
    _lock.acquire();
    _task_lock_waiting--;
}

inline bool
RouterThread::attempt_lock_tasks()
{
    return _lock.attempt();
}

inline void
RouterThread::unlock_tasks()
{
    _lock.release();
}


# 155 "../../click-20030316/include/click/task.hh" 2



inline
Task::Task(TaskHook hook, void *thunk)
  : _prev(0), _next(0),

    _pass(0), _stride(0), _tickets(-1),

    _hook(hook), _thunk(thunk),






    _thread(0), _thread_preference(-1),
    _all_prev(0), _all_next(0), _all_list(0),
    _pending(0), _pending_next(0)
{
}

inline
Task::Task(Element *e)
  : _prev(0), _next(0),

    _pass(0), _stride(0), _tickets(-1),

    _hook(0), _thunk(e),






    _thread(0), _thread_preference(-1),
    _all_prev(0), _all_next(0), _all_list(0),
    _pending(0), _pending_next(0)
{
}

inline bool
TaskList::empty() const
{
  return (const Task *)_next == this;
}

inline Element *
Task::element() const
{
  return _hook ? 0 : reinterpret_cast<Element*>(_thunk);
}

inline int
Task::fast_unschedule()
{
  if (_prev) {
    _next->_prev = _prev;
    _prev->_next = _next;
    _next = _prev = 0;
  }



  return 0;

}



inline void
Task::set_tickets(int n)
{
  if (n > MAX_TICKETS)
    n = MAX_TICKETS;
  else if (n < 1)
    n = 1;
  _tickets = n;
  _stride = STRIDE1 / n;
  ((void) ((_stride < MAX_STRIDE) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/task.hh", 234, "_stride < MAX_STRIDE"), 0)));
}

inline void
Task::adj_tickets(int delta)
{
  set_tickets(_tickets + delta);
}

inline void
Task::fast_reschedule()
{

  ((void) ((_thread && !_prev) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/task.hh", 247, "_thread && !_prev"), 0)));


  _pass += _stride;
# 265 "../../click-20030316/include/click/task.hh"
  Task *n = _thread->_next;
  while (n != _thread && !((int)(n->_pass - _pass) > 0))
    n = n->_next;


  _prev = n->_prev;
  _next = n;
  _prev->_next = this;
  n->_prev = this;

}

inline void
Task::fast_schedule()
{
  ((void) ((_tickets >= 1) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/task.hh", 280, "_tickets >= 1"), 0)));
  _pass = _thread->_next->_pass;
  fast_reschedule();
}
# 319 "../../click-20030316/include/click/task.hh"
inline void
Task::call_hook()
{
# 332 "../../click-20030316/include/click/task.hh"
  if (!_hook)
    (void) ((Element *)_thunk)->run_task();
  else
    (void) _hook(this, _thunk);

}
# 362 "../../click-20030316/include/click/task.hh"
inline void
TaskList::lock()
{
  _lock.acquire();
}

inline void
TaskList::unlock()
{
  _lock.release();
}


# 9 "../../click-20030316/include/click/router.hh" 2







class ElementFilter;
class RouterThread;
class BigHashMap_ArenaFactory;

class Router { public:

  struct Handler;
  struct Hookup {
    int idx;
    int port;
    Hookup() : idx(-1) { }
    Hookup(int i, int p) : idx(i), port(p) { }
  };

  Router(const String &configuration = String());
  ~Router();
  void use() { _refcount++; }
  void unuse();

  static void static_initialize();
  static void static_cleanup();

  bool initialized() const { return _initialized; }


  int nelements() const { return _elements.size(); }
  const Vector<Element *> &elements() const { return _elements; }
  static Element *element(const Router *, int);
  Element *element(int e) const { return element(this, e); }

  Element *root_element() const { return _root_element; }

  const String &ename(int) const;
  const String &elandmark(int) const;
  const String &default_configuration_string(int) const;
  void set_default_configuration_string(int, const String &);

  Element *find(const String &, ErrorHandler * = 0) const;
  Element *find(const String &, Element *context, ErrorHandler * = 0) const;
  Element *find(const String &, String prefix, ErrorHandler * = 0) const;

  int downstream_elements(Element *, int o, ElementFilter*, Vector<Element*>&);
  int downstream_elements(Element *, int o, Vector<Element *> &);
  int downstream_elements(Element *, Vector<Element *> &);
  int upstream_elements(Element *, int i, ElementFilter*, Vector<Element*>&);
  int upstream_elements(Element *, int i, Vector<Element *> &);
  int upstream_elements(Element *, Vector<Element *> &);


  enum { FIRST_GLOBAL_HANDLER = 0x40000000 };
  int nhandlers() const { return _nhandlers; }
  static int nglobal_handlers();
  static int hindex(const Element *, const String &);
  static void element_hindexes(const Element *, Vector<int> &);


  static const Handler *handler(const Router *, int);
  static const Handler *handler(const Element *, int);
  const Handler *handler(int) const;
  static const Handler *handler(const Element *, const String &);

  static void add_read_handler(const Element *, const String &, ReadHandler, void *);
  static void add_write_handler(const Element *, const String &, WriteHandler, void *);
  static int change_handler_flags(const Element *, const String &, uint32_t clear_flags, uint32_t set_flags);


  void *attachment(const String &) const;
  void *&force_attachment(const String &);
  void *set_attachment(const String &, void *);
  const Vector<String> &requirements() const { return _requirements; }

  ErrorHandler *chatter_channel(const String &) const;
  BigHashMap_ArenaFactory *arena_factory() const;


  int nthreads() const { return _threads.size() - 1; }
  RouterThread *thread(int id) const { return _threads[id + 1]; }

  void add_thread(RouterThread *);
  void remove_thread(RouterThread *);


  void please_stop_driver() { adjust_driver_reservations(-1); }
  void reserve_driver() { adjust_driver_reservations(1); }
  void set_driver_reservations(int);
  void adjust_driver_reservations(int);
  bool check_driver();
  const volatile int *driver_runcount_ptr() const { return &_driver_runcount; }


  TimerList *timer_list() { return &_timer_list; }
  TaskList *task_list() { return &_task_list; }

  enum { SELECT_READ = Element::SELECT_READ, SELECT_WRITE = Element::SELECT_WRITE };
  int add_select(int fd, int element, int mask);
  int remove_select(int fd, int element, int mask);



  void run_selects(bool more_tasks);

  void run_timers();


  const String &configuration_string() const { return _configuration; }
  void unparse(StringAccum &, const String & = String()) const;
  void unparse_requirements(StringAccum &, const String & = String()) const;
  void unparse_classes(StringAccum &, const String & = String()) const;
  void unparse_declarations(StringAccum &, const String & = String()) const;
  void unparse_connections(StringAccum &, const String & = String()) const;

  String element_ports_string(int) const;


  void add_requirement(const String &);
  int add_element(Element *, const String &name, const String &conf, const String &landmark);
  int add_connection(int from_idx, int from_port, int to_idx, int to_port);

  void preinitialize();
  int initialize(ErrorHandler *, bool verbose_errors = true);
  void take_state(Router *, ErrorHandler *);
# 160 "../../click-20030316/include/click/router.hh"
 private:

  TimerList _timer_list;
  TaskList _task_list;
  volatile int _driver_runcount;
  Spinlock _runcount_lock;


  enum { SELECT_RELEVANT = (SELECT_READ | SELECT_WRITE) };
  struct Selector;
  fd_set _read_select_fd_set;
  fd_set _write_select_fd_set;
  int _max_select_fd;
  Vector<Selector> _selectors;
  Spinlock _wait_lock;


  uatomic32_t _refcount;

  Vector<Element *> _elements;
  Vector<String> _element_names;
  Vector<String> _element_configurations;
  Vector<String> _element_landmarks;
  Vector<int> _element_configure_order;

  Vector<RouterThread *> _threads;

  Vector<Hookup> _hookup_from;
  Vector<Hookup> _hookup_to;

  Vector<int> _input_pidx;
  Vector<int> _output_pidx;
  Vector<int> _input_eidx;
  Vector<int> _output_eidx;

  Vector<int> _hookpidx_from;
  Vector<int> _hookpidx_to;

  Vector<String> _requirements;

  bool _preinitialized : 1;
  bool _initialized : 1;
  bool _initialize_attempted : 1;
  bool _cleaned : 1;
  bool _have_connections : 1;
  bool _have_hookpidx : 1;

  Vector<int> _ehandler_first_by_element;
  Vector<int> _ehandler_to_handler;
  Vector<int> _ehandler_next;

  Vector<int> _handler_first_by_name;

  Handler *_handlers;
  int _nhandlers;
  int _handlers_cap;

  Vector<String> _attachment_names;
  Vector<void *> _attachments;

  Element *_root_element;
  String _configuration;

  BigHashMap_ArenaFactory *_arena_factory;

  Router(const Router &);
  Router &operator=(const Router &);

  void remove_hookup(int);
  void hookup_error(const Hookup &, bool, const char *, ErrorHandler *);
  int check_hookup_elements(ErrorHandler *);
  void notify_hookup_range();
  void check_hookup_range(ErrorHandler *);
  void check_hookup_completeness(ErrorHandler *);

  int processing_error(const Hookup&, const Hookup&, bool, int, ErrorHandler*);
  int check_push_and_pull(ErrorHandler *);

  void make_pidxes();
  int ninput_pidx() const { return _input_eidx.size(); }
  int noutput_pidx() const { return _output_eidx.size(); }
  inline int input_pidx(const Hookup &) const;
  inline int input_pidx_element(int) const;
  inline int input_pidx_port(int) const;
  inline int output_pidx(const Hookup &) const;
  inline int output_pidx_element(int) const;
  inline int output_pidx_port(int) const;
  void make_hookpidxes();

  void set_connections();

  String context_message(int element_no, const char *) const;
  int element_lerror(ErrorHandler *, Element *, const char *, ...) const;


  void initialize_handlers(bool, bool);
  int find_ehandler(int, const String &, bool star_ok = false) const;
  static inline Handler fetch_handler(const Element *, const String &);
  void store_local_handler(int, const Handler &);
  static void store_global_handler(const Handler &);
  static inline void store_handler(const Element *, const Handler &);

  int downstream_inputs(Element *, int o, ElementFilter *, Bitvector &);
  int upstream_outputs(Element *, int i, ElementFilter *, Bitvector &);


  static String router_read_handler(Element *, void *);

};


class Router::Handler { public:

  enum { DRIVER_FLAG_0 = 1, DRIVER_FLAG_1 = 2,
         DRIVER_FLAG_2 = 4, DRIVER_FLAG_3 = 8,
         USER_FLAG_SHIFT = 4, USER_FLAG_0 = 1 << USER_FLAG_SHIFT };

  const String &name() const { return _name; }
  uint32_t flags() const { return _flags; }

  bool readable() const { return _read; }
  bool read_visible() const { return _read; }
  bool writable() const { return _write; }
  bool write_visible() const { return _write; }
  bool visible() const { return read_visible() || write_visible(); }

  String call_read(Element *) const;
  int call_write(const String &, Element *, ErrorHandler *) const;

  String unparse_name(Element *) const;
  static String unparse_name(Element *, const String &);

 private:

  String _name;
  ReadHandler _read;
  void *_read_thunk;
  WriteHandler _write;
  void *_write_thunk;
  int _flags;
  int _use_count;
  int _next_by_name;

  Handler();
  Handler(const String &);

  bool compatible(const Handler &) const;

  friend class Router;

};






struct Router::Selector {
  int fd;
  int element;
  int mask;
  Selector() : fd(-1), element(-1), mask(0) { }
  Selector(int f, int e, int m) : fd(f), element(e), mask(m) { }
};



inline bool
operator==(const Router::Hookup &a, const Router::Hookup &b)
{
  return a.idx == b.idx && a.port == b.port;
}

inline bool
operator!=(const Router::Hookup &a, const Router::Hookup &b)
{
  return a.idx != b.idx || a.port != b.port;
}

inline Element *
Router::find(const String &name, ErrorHandler *errh) const
{
  return find(name, "", errh);
}

inline const Router::Handler *
Router::handler(const Element *e, int hi)
{
  return handler(e ? e->router() : 0, hi);
}

inline const Router::Handler *
Router::handler(int hi) const
{
  return handler(this, hi);
}

inline
Router::Handler::Handler()
  : _read(0), _read_thunk(0), _write(0), _write_thunk(0),
    _flags(0), _use_count(0), _next_by_name(-1)
{
}

inline
Router::Handler::Handler(const String &name)
  : _name(name), _read(0), _read_thunk(0), _write(0), _write_thunk(0),
    _flags(0), _use_count(0), _next_by_name(-1)
{
}

inline String
Router::Handler::call_read(Element *e) const
{
  return _read(e, _read_thunk);
}

inline int
Router::Handler::call_write(const String &s, Element *e, ErrorHandler *errh) const
{
  return _write(s, e, _write_thunk, errh);
}

inline bool
Router::Handler::compatible(const Handler &h) const
{
  return (_read == h._read && _read_thunk == h._read_thunk
          && _write == h._write && _write_thunk == h._write_thunk
          && _flags == h._flags);
}

inline void
Router::run_timers()
{
  _timer_list.run();
}

inline BigHashMap_ArenaFactory *
Router::arena_factory() const
{
  return _arena_factory;
}


# 6 "../../click-20030316/include/click/lexer.hh" 2


class LexerExtra;
class VariableEnvironment;

enum Lexemes {
  lexEOF = 0,
  lexIdent = 256,
  lexVariable,
  lexArrow,
  lex2Colon,
  lex2Bar,
  lex3Dot,
  lexTunnel,
  lexElementclass,
  lexRequire
};

class Lexeme { public:

  Lexeme() : _kind(lexEOF) { }
  Lexeme(int k, const String &s) : _kind(k), _s(s) { }

  int kind() const { return _kind; }
  bool is(int k) const { return _kind == k; }

  const String &string() const { return _s; }
  String &string() { return _s; }

 private:

  int _kind;
  String _s;

};

class Lexer { public:

  enum { TUNNEL_TYPE = 0, ERROR_TYPE = 1 };

  class TunnelEnd;
  class Compound;
  class Synonym;
  typedef Router::Hookup Hookup;

  Lexer();
  virtual ~Lexer();

  int begin_parse(const String &data, const String &filename, LexerExtra *, ErrorHandler * = 0);
  void end_parse(int);

  ErrorHandler *errh() const { return _errh; }

  String remaining_text() const;
  void set_remaining_text(const String &);

  const Lexeme &lex();
  void unlex(const Lexeme &);
  String lex_config();
  String landmark() const;

  bool expect(int, bool report_error = true);

  int add_element_type(Element *);
  int add_element_type(String, Element *);
  int element_type(const String &) const;
  int force_element_type(String);

  void element_type_names(Vector<String> &) const;

  void remove_element_type(int);

  void connect(int element1, int port1, int element2, int port2);
  String element_name(int) const;
  String element_landmark(int) const;

  void add_tunnel(String, String);

  bool yport(int &port);
  bool yelement(int &element, bool comma_ok);
  void ydeclaration(const String &first_element = String());
  bool yconnection();
  void yelementclass();
  void ytunnel();
  void ycompound_arguments(Compound *);
  int ycompound(String name = String());
  void yrequire();
  bool ystatement(bool nested = false);

  void find_connections(const Hookup &, bool, Vector<Hookup> &) const;
  void expand_connection(const Hookup &, bool, Vector<Hookup> &) const;

  Router *create_router();

 private:


  String _big_string;

  const char *_data;
  unsigned _len;
  unsigned _pos;

  String _filename;
  String _original_filename;
  unsigned _lineno;
  LexerExtra *_lextra;

  unsigned skip_line(unsigned);
  unsigned skip_slash_star(unsigned);
  unsigned skip_backslash_angle(unsigned);
  unsigned skip_quote(unsigned, char);
  unsigned process_line_directive(unsigned);
  Lexeme next_lexeme();
  static String lexeme_string(int);


  enum { TCIRCLE_SIZE = 8 };
  Lexeme _tcircle[TCIRCLE_SIZE];
  int _tpos;
  int _tfull;


  HashMap<String, int> _element_type_map;
  Vector<Element *> _element_types;
  Vector<String> _element_type_names;
  Vector<int> _element_type_next;
  int _last_element_type;
  int _free_element_type;


  HashMap<String, int> _element_map;
  Vector<int> _elements;
  Vector<String> _element_names;
  Vector<String> _element_configurations;
  Vector<String> _element_landmarks;

  Vector<Hookup> _hookup_from;
  Vector<Hookup> _hookup_to;

  TunnelEnd *_definputs;
  TunnelEnd *_defoutputs;


  int _anonymous_offset;
  int _compound_depth;


  Vector<String> _requirements;


  ErrorHandler *_errh;

  int lerror(const char *, ...);

  String anon_element_name(const String &) const;
  String deanonymize_element_name(const String &, int);
  int get_element(String, int, const String & = String(), const String & = String());
  int lexical_scoping_in() const;
  void lexical_scoping_out(int);
  int make_compound_element(int);
  void expand_compound_element(int, const VariableEnvironment &);
  void add_router_connections(int, const Vector<int> &, Router *);

  friend class Compound;

};

class LexerExtra { public:

  LexerExtra() { }
  virtual ~LexerExtra() { }

  virtual void require(String, ErrorHandler *);

};


# 44 "../../click-20030316/lib/driver.cc" 2



# 1 "../../click-20030316/include/click/driver.hh" 1
# 9 "../../click-20030316/include/click/driver.hh"


void click_static_initialize();
void click_static_cleanup();

Router *click_read_router(String filename, bool is_expr, ErrorHandler * = 0, bool initialize = true);


# 48 "../../click-20030316/lib/driver.cc" 2
# 1 "../../click-20030316/include/click/straccum.hh" 1
# 13 "../../click-20030316/include/click/straccum.hh"


class StringAccum { public:

  StringAccum() : _s(0), _len(0), _cap(0) { }
  explicit StringAccum(int);
  ~StringAccum() { if (_cap >= 0) delete[] _s; }

  char *data() const { return (char *)_s; }
  int length() const { return _len; }

  operator bool() { return _len != 0; }
  operator bool() const { return _len != 0; }

  bool out_of_memory() const { return _cap < 0; }

  const char *cc() { return c_str(); }
  const char *c_str();

  char operator[](int i) const { ((void) ((i>=0&&i<_len) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 32, "i>=0&&i<_len"), 0))); return (char)_s[i]; }
  char &operator[](int i) { ((void) ((i>=0&&i<_len) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 33, "i>=0&&i<_len"), 0))); return (char &)_s[i]; }
  char back() const { ((void) ((_len>0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 34, "_len>0"), 0))); return (char)_s[_len-1]; }
  char &back() { ((void) ((_len>0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 35, "_len>0"), 0))); return (char &)_s[_len-1]; }

  void clear();

  char *extend(int, int = 0);

  void append(char);
  void append(unsigned char);
  void append(const char *, int);
  void append(const unsigned char *, int);
  void append_fill(int c, int len);

  char *reserve(int);
  void set_length(int l) { ((void) ((l>=0 && _len<=_cap) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 48, "l>=0 && _len<=_cap"), 0))); _len = l; }
  void forward(int n) { ((void) ((n>=0 && _len+n<=_cap) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 49, "n>=0 && _len+n<=_cap"), 0))); _len += n; }
  void pop_back(int n = 1) { ((void) ((n>=0 && _len>=n) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 50, "n>=0 && _len>=n"), 0))); _len -= n; }


  StringAccum &snprintf(int, const char *, ...);


  void take(unsigned char *&s, int &l) { s = _s; l = _len; erase(); }
  char *take();
  unsigned char *take_bytes();
  String take_string();



 private:

  unsigned char *_s;
  int _len;
  int _cap;

  void make_out_of_memory();
  void safe_append(const char *, int);
  bool grow(int);
  void erase() { _s = 0; _len = 0; _cap = 0; }

  StringAccum(const StringAccum &);
  StringAccum &operator=(const StringAccum &);

  friend StringAccum &operator<<(StringAccum &, const char *);

};

StringAccum &operator<<(StringAccum &, char);
StringAccum &operator<<(StringAccum &, unsigned char);
StringAccum &operator<<(StringAccum &, const char *);
StringAccum &operator<<(StringAccum &, const String &);
StringAccum &operator<<(StringAccum &, const StringAccum &);




StringAccum &operator<<(StringAccum &, bool);
StringAccum &operator<<(StringAccum &, short);
StringAccum &operator<<(StringAccum &, unsigned short);
StringAccum &operator<<(StringAccum &, int);
StringAccum &operator<<(StringAccum &, unsigned);
StringAccum &operator<<(StringAccum &, long);
StringAccum &operator<<(StringAccum &, unsigned long);

StringAccum &operator<<(StringAccum &, int64_t);
StringAccum &operator<<(StringAccum &, uint64_t);


StringAccum &operator<<(StringAccum &, double);

StringAccum &operator<<(StringAccum &, const struct timeval &);


inline
StringAccum::StringAccum(int cap)
  : _s(new unsigned char[cap]), _len(0), _cap(cap)
{
  ((void) ((cap > 0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 111, "cap > 0"), 0)));
  if (!_s)
    _cap = -1;
}

inline void
StringAccum::append(unsigned char c)
{
  if (_len < _cap || grow(_len))
    _s[_len++] = c;
}

inline void
StringAccum::append(char c)
{
  append(static_cast<unsigned char>(c));
}

inline char *
StringAccum::reserve(int hm)
{
  ((void) ((hm >= 0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 132, "hm >= 0"), 0)));
  if (_len + hm <= _cap || grow(_len + hm))
    return (char *)(_s + _len);
  else
    return 0;
}

inline char *
StringAccum::extend(int amt, int extra)
{
  ((void) ((extra >= 0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../../click-20030316/include/click/straccum.hh", 142, "extra >= 0"), 0)));
  char *c = reserve(amt + extra);
  if (c)
    _len += amt;
  return c;
}

inline void
StringAccum::safe_append(const char *s, int len)
{
  if (char *x = extend(len))
    memcpy(x, s, len);
}

inline void
StringAccum::append(const char *s, int len)
{
  if (len < 0)
    len = strlen(s);
  else if (len == 0 && s == String::out_of_memory_string().data())
    make_out_of_memory();
  safe_append(s, len);
}

inline void
StringAccum::append(const unsigned char *s, int len)
{
  append(reinterpret_cast<const char *>(s), len);
}

inline unsigned char *
StringAccum::take_bytes()
{
  unsigned char *str = _s;
  erase();
  return str;
}

inline char *
StringAccum::take()
{
  return reinterpret_cast<char *>(take_bytes());
}

inline void
StringAccum::clear()
{
  if (_cap < 0)
    _cap = 0, _s = 0;
  _len = 0;
}

inline StringAccum &
operator<<(StringAccum &sa, char c)
{
  sa.append(c);
  return sa;
}

inline StringAccum &
operator<<(StringAccum &sa, unsigned char c)
{
  sa.append(c);
  return sa;
}

inline StringAccum &
operator<<(StringAccum &sa, const char *s)
{
  sa.safe_append(s, strlen(s));
  return sa;
}

inline StringAccum &
operator<<(StringAccum &sa, bool b)
{
  return sa << (b ? "true" : "false");
}

inline StringAccum &
operator<<(StringAccum &sa, short i)
{
  return sa << static_cast<long>(i);
}

inline StringAccum &
operator<<(StringAccum &sa, unsigned short u)
{
  return sa << static_cast<unsigned long>(u);
}

inline StringAccum &
operator<<(StringAccum &sa, int i)
{
  return sa << static_cast<long>(i);
}

inline StringAccum &
operator<<(StringAccum &sa, unsigned u)
{
  return sa << static_cast<unsigned long>(u);
}
# 254 "../../click-20030316/include/click/straccum.hh"
inline StringAccum &
operator<<(StringAccum &sa, const String &s)
{
  sa.append(s.data(), s.length());
  return sa;
}

inline StringAccum &
operator<<(StringAccum &sa, const StringAccum &sb)
{
  sa.append(sb.data(), sb.length());
  return sa;
}


# 49 "../../click-20030316/lib/driver.cc" 2





struct ClickProvision {
    String name;
    bool loaded : 1;
    int provided;
};
static int nprovisions;
static int provisions_cap;
static ClickProvision *provisions;

static ClickProvision *
find_provision(const String &name)
{
    for (int i = 0; i < nprovisions; i++)
        if (provisions[i].name == name)
            return &provisions[i];


    ClickProvision *npf;
    if (nprovisions >= provisions_cap) {
        int n = (nprovisions ? nprovisions * 2 : 4);
        if (!(npf = new ClickProvision[n]))
            return 0;
        for (int i = 0; i < nprovisions; i++)
            npf[i] = provisions[i];
        provisions_cap = n;
        delete[] provisions;
        provisions = npf;
    } else
        npf = provisions;

    npf[nprovisions].name = name;
    npf[nprovisions].loaded = false;
    npf[nprovisions].provided = 0;
    return &npf[nprovisions++];
}


extern "C" void
click_provide(const char *package)
{
    ClickProvision *p = find_provision(package);
    if (p) {

        ;

        p->provided++;
    }
}

extern "C" void
click_unprovide(const char *package)
{
    ClickProvision *p = find_provision(package);
    if (p && p->provided > 0) {

        ;

        p->provided--;
    }
}

extern "C" bool
click_has_provision(const char *package)
{
    ClickProvision *p = find_provision(package);
    return (p && p->provided > 0);
}

extern "C" void
click_public_packages(Vector<String> &v)
{
    for (int i = 0; i < nprovisions; i++)
        if (provisions[i].provided > 0 && provisions[i].name && provisions[i].name[0] != '@')
            v.push_back(provisions[i].name);
}
# 288 "../../click-20030316/lib/driver.cc"
extern void click_export_elements(Lexer *);


namespace {

class RequireLexerExtra : public LexerExtra { public:
    RequireLexerExtra(const Vector<ArchiveElement> *a) : _archive(a) { }
    void require(String, ErrorHandler *);
  private:
    const Vector<ArchiveElement> *_archive;
};

void
RequireLexerExtra::require(String name, ErrorHandler *errh)
{




    if (!click_has_provision(name.c_str()))
        errh->error("requirement `%s' not available", name.cc());
}

}


static Lexer *click_lexer;

extern "C" int
click_add_element_type(const char *ename, Element *e)
{
    return click_lexer->add_element_type(ename, e);
}

extern "C" void
click_remove_element_type(int which)
{
    click_lexer->remove_element_type(which);
}


enum { GH_CLASSES, GH_PACKAGES };

static String
read_handler(Element *, void *thunk)
{
    Vector<String> v;
    switch (reinterpret_cast<intptr_t>(thunk)) {
      case GH_CLASSES:
        if (click_lexer)
            click_lexer->element_type_names(v);
        break;
      case GH_PACKAGES:
        click_public_packages(v);
        break;
      default:
        return "<error>\n";
    }

    StringAccum sa;
    for (int i = 0; i < v.size(); i++)
        sa << v[i] << '\n';
    return sa.take_string();
}

void
click_static_initialize()
{
    String::static_initialize();
    cp_va_static_initialize();

    ErrorHandler::static_initialize(new FileErrorHandler((&__sF[2]), ""));

    Router::static_initialize();
    ;

    Router::add_read_handler(0, "classes", read_handler, (void *)GH_CLASSES);
    Router::add_read_handler(0, "packages", read_handler, (void *)GH_PACKAGES);
}

void
click_static_cleanup()
{
    delete click_lexer;
    click_lexer = 0;

    Router::static_cleanup();
    ErrorHandler::static_cleanup();
    cp_va_static_cleanup();
    String::static_cleanup();
}

Router *
click_read_router(String filename, bool is_expr, ErrorHandler *errh, bool initialize)
{
    if (!errh)
        errh = ErrorHandler::silent_handler();
    int before = errh->nerrors();


    String config_str;
    if (is_expr) {
        config_str = filename;
        filename = "<expr>";
    } else {
        config_str = file_string(filename, errh);
        if (!filename || filename == "-")
            filename = "<stdin>";
    }
    if (errh->nerrors() > before)
        return 0;


    Vector<ArchiveElement> archive;
    if (config_str.length() != 0 && config_str[0] == '!') {
        separate_ar_string(config_str, archive, errh);
        int i = archive_index(&archive, "config");
        if (i >= 0)
            config_str = archive[i].data;
        else {
            errh->error("archive has no `config' section");
            config_str = String();
        }
    }


    if (!click_lexer) {
        click_lexer = new Lexer;
        click_export_elements(click_lexer);
    }
    RequireLexerExtra lextra(&archive);
    int cookie = click_lexer->begin_parse(config_str, filename, &lextra, errh);
    while (click_lexer->ystatement())
                        ;
    Router *router = click_lexer->create_router();
    click_lexer->end_parse(cookie);


    if (initialize)
        if (errh->nerrors() > before || router->initialize(errh) < 0) {
            delete router;
            return 0;
        }

    return router;
}




More information about the click mailing list