/* 
 * $Source: /b/cvsroot//wu_arl/msr/rp/plugins/syn_demo/syn_demo.h,v $
 * $Author: fredk $
 * $Date: 2003/06/26 15:42:30 $
 * $Revision: 1.3 $
 *
 *
 */

#include <msr/msr.h>
#include <rp/rp_plugin.h>

/* includes here */
struct lkmtp;
struct lkm_table;

/* information the plugin retains about pending connection requests */
struct conn_info {
  TAILQ_ENTRY(conn_info) clist;
  u_int32_t sa, da, seq;
  u_int16_t sp, dp;
  int synack_sent;
  int time;
};

// #define CONN_QUEUE_SIZE 1024
#define CONN_QUEUE_SIZE 10000
#define CONN_TIMEOUT_RUN_MSEC 2000
/* retain connections in the queue longer if we are not "running". */
/* this way, if we switch from non-running to running, we're better */
/* able to make room in the server's queue right away (which avoids */
/* needing to wait 30 seconds during the demo) */
//#define CONN_TIMEOUT_WALK_MSEC 29000
#define CONN_TIMEOUT_WALK_MSEC 180000

#define SYNDEMO_EMQID             256 /* reserved QIDs are 256 - 439 */

/* syn_demo instance */
struct syn_demo_instance {
  /* First the base class structure */
  struct rp_instance rootinstance;
};

/* pending connection queue */
struct syn_demo_queue {
  struct conn_info conn_array[CONN_QUEUE_SIZE];
  TAILQ_HEAD(conn_head, conn_info) conn_head, free_head;
};


/* function prototypes */
void syn_demo_init_class(void);
struct rp_class *syn_demo_get_class(void);
struct rp_instance *syn_demo_create_instance(struct rp_class *, u_int32_t);
void syn_demo_handle_packet(struct rp_instance *, void *);
void syn_demo_free_instance(struct rp_instance *);
void syn_demo_bind_instance(struct rp_instance *);
void syn_demo_unbind_instance(struct rp_instance *);
int  syn_demo_handle_msg(struct rp_instance *, void *, u_int8_t, u_int8_t, u_int8_t *);
/* XXX return type int or void */
#ifdef PLUGIN_DEBUG
int syn_demo(struct lkm_table *, int , int);
#else
int syn_demo(struct lkm_table *, int , int, struct kernel_plugin_fct_struct * );
#endif
int syn_demo_load(struct lkm_table *, int);
int syn_demo_unload(struct lkm_table *, int);

