/***************************************************************************
 *
 * Copyright (c) 2000 BalaBit IT Ltd, Budapest, Hungary
 *
 * $Id: plugtrack.c,v 1.4.2.1 2001/05/14 08:31:51 bazsi Exp $
 *
 ***************************************************************************/

#include <zorp/ctrack.h>
#include <zorp/log.h>
#include <zorp/proxy.h>

#if ENABLE_CONNTRACK

typedef struct _PlugTracker
{
  ZCProxy super;
  struct _PlugTracker *other;
} PlugTracker;
                    
PlugTracker *
plug_tracker_sub_new(PlugTracker *old)
{
  PlugTracker *self;
  
  self = g_new0(PlugTracker, 1);
  z_tracker_sender_init(&self->super, &old->super);

  z_enter();
  self->super.user_data = self;
  
  z_leave();
  return self;
}

void plug_tracker_config(ZCProxy *s)
{
  PlugTracker *self = (PlugTracker *) s;

  ZPROXY_SET_STATE(self, PS_CONFIG);
  z_tracker_config_event(&self->super);
  
  ZPROXY_SET_STATE(self, PS_WORKING);
  
  self->other = plug_tracker_sub_new(self);
  
  z_tracker_tune(&self->super, &self->other->super, NULL);

}

ZCProxy *
plug_tracker_new(ZPolicyObj *handler, ZCTRouter *router)
{
  PlugTracker *self;
  
  self = g_new0(PlugTracker, 1);
  z_tracker_init(&self->super, handler, router);

  z_enter();  
  self->super.free = NULL;
  self->super.config = plug_tracker_config;
  
  z_leave();
  return &self->super;
}
  
#endif
