/* 
 * $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 */

/* psyndemo instance */
struct psyndemo_instance {
  /* First the base class structure */
  struct rp_instance rootinstance;
};

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


/* function prototypes */
void psyndemo_init_class(void);
struct rp_class *psyndemo_get_class(void);
struct rp_instance *psyndemo_create_instance(struct rp_class *, u_int32_t);
void psyndemo_handle_packet(struct rp_instance *, void *);
void psyndemo_free_instance(struct rp_instance *);
void psyndemo_bind_instance(struct rp_instance *);
void psyndemo_unbind_instance(struct rp_instance *);
int  psyndemo_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 psyndemo(struct lkm_table *, int , int);
#else
int psyndemo(struct lkm_table *, int , int, struct kernel_plugin_fct_struct * );
#endif
int psyndemo_load(struct lkm_table *, int);
int psyndemo_unload(struct lkm_table *, int);

