/* 
 * $Source: /b/cvsroot/wu_arl/msr/rp/plugins/testEM/testEM.h,v $
 * $Author: fredk $
 * $Date: 2004/12/22 20:14:34 $
 * $Revision: 1.1 $
 *
 * Copyright (c) 2000 ETH Zurich/Washington University in St. Louis.
 * All rights reserved.
 * 
 * Changes:
 * 2000/11/23 Initial version (keller)
 *
 */

#ifndef _TESTEM_H
#define _TESTEM_H

#define TEST_EM_QID 256

#define TESTEM_CMD_SETN       0
#define TESTEM_CMD_SETQID     1
#define TESTEM_CMD_SETPRIO    2
#define TESTEM_CMD_SETPN      3
#define TESTEM_CMD_SETSP      4
#define TESTEM_CMD_GETVALS    5
#define TESTEM_CMD_START      6
#define TESTEM_CMD_STOP       7

/* testEM instance */
typedef struct testEM_instance {
  struct rp_instance rootinstance; /* "base class" part */
  MSR_GenFilter_t  fltr;
  CFY_FltrParams_t params;
#define TESTEM_N  100
  int N;    // rotates EM filter every N packets
#define TESTEM_QID 256
  int QID;  // QID to assign to EM filter
#define TESTEM_PRIO 40
  int PRIO; // priority to use for EM filter
#define TESTEM_PORT 4
  int PN; // output port to send to
#define TESTEM_SPORT 0
  int SP;
#define TESTEM_FLAGS_Filtering   0x01
#define TESTEM_FLAGS_Running     0x02
  unsigned int flags;
  unsigned int pkt_count;
} testEM_instance;

static inline testem_ison(struct testEM_instance *, unsigned int);
static inline testem_turnon(struct testEM_instance *, unsigned int);
static inline testem_turnoff(struct testEM_instance *, unsigned int);

static inline testem_ison(struct testEM_instance *myinst, unsigned int flag)
{
  return (myinst->flags & flag);
}
static inline testem_turnon(struct testEM_instance *myinst, unsigned int flag)
{
  myinst->flags |= flag;
}
static inline testem_turnoff(struct testEM_instance *myinst, unsigned int flag)
{
  myinst->flags &= ~flag;
}

static inline int testem_isfiltered (struct testEM_instance *);
static inline void testem_setfiltered (struct testEM_instance *);
static inline void testem_unsetfiltered (struct testEM_instance *);

static inline int testem_isrunning (struct testEM_instance *);
static inline void testem_setrunning (struct testEM_instance *);
static inline void testem_unsetrunning (struct testEM_instance *);

static inline int testem_isfiltered (struct testEM_instance *myinst)
{ return testem_ison(myinst, TESTEM_FLAGS_Filtering); }
static inline void testem_setfiltered (struct testEM_instance *myinst)
{ testem_turnon(myinst, TESTEM_FLAGS_Filtering); }
static inline void testem_unsetfiltered (struct testEM_instance *myinst)
{ testem_turnoff(myinst, TESTEM_FLAGS_Filtering); }

static inline int testem_isrunning (struct testEM_instance *myinst)
{ return testem_ison(myinst, TESTEM_FLAGS_Running); }
static inline void testem_setrunning (struct testEM_instance *myinst)
{ testem_turnon(myinst, TESTEM_FLAGS_Running); }
static inline void testem_unsetrunning (struct testEM_instance *myinst)
{ testem_turnoff(myinst, TESTEM_FLAGS_Running); }

// /* function prototypes */
// void testEM_init_class();
// struct rp_class *testEM_get_class();
// struct rp_instance *testEM_create_instance(struct rp_class *, u_int32_t);
// void testEM_handle_packet(struct rp_instance *, void *);
// void testEM_free_instance(struct rp_instance *);
// void testEM_bind_instance(struct rp_instance *);
// void testEM_unbind_instance(struct rp_instance *);
// int  testEM_handle_msg(struct rp_instance *, void *, u_int8_t, u_int8_t, u_int8_t *);
// 
// /* XXX return type int or void */
// int testEM  (struct lkm_table *, int, int, struct kernel_plugin_fct_struct *);
// int testEM_load(struct lkm_table *, int);
// int testEM_unload(struct lkm_table *, int);

#endif
