/*
 * ----------------------------------------------------------------
 * Night Light IRC Proxy - Client Header
 * ----------------------------------------------------------------
 * Copyright (C) 1997-2007 Jonas Kvinge <jonas@night-light.net>
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Last modified by:
 * Jonas Kvinge (24.11.2007)
 *
 */

#ifdef CLIENT_H
#warning "client.h already included."
#else
#define CLIENT_H

struct in_addr;
#if IPV6_SUPPORT
struct in6_addr;
#endif

struct Listen_Struct;

/* DEFINES - JONAS (24.06.2000) */

#define CLIENT_VERIFYTIMEOUT				45
#define CLIENT_ERRORTIMEOUT				6
#define CLIENT_IDLETIMEBEFOREPING			300
#define CLIENT_PINGTIMEOUT				240

/* BIT MASKS - JONAS (24.06.2000) */

#define CLIENT_BITMASK_SSL				1
#define CLIENT_BITMASK_IPV6				2
#define CLIENT_BITMASK_SOCKET				4
#define CLIENT_BITMASK_SSLHANDSHAKE			8
#define CLIENT_BITMASK_VERIFIED				16
#define CLIENT_BITMASK_SENTPING				32
#define CLIENT_BITMASK_SENTERROR			64

/* MACROS - JONAS (24.06.2000) */

#define Client_SetSSL(x)				((x)->Flags |= CLIENT_BITMASK_SSL)
#define Client_SetIPv6(x)				((x)->Flags |= CLIENT_BITMASK_IPV6)
#define Client_SetSocket(x)				((x)->Flags |= CLIENT_BITMASK_SOCKET)
#define Client_SetSSLHandshake(x)			((x)->Flags |= CLIENT_BITMASK_SSLHANDSHAKE)
#define Client_SetVerified(x)				((x)->Flags |= CLIENT_BITMASK_VERIFIED)
#define Client_SetSentPing(x)				((x)->Flags |= CLIENT_BITMASK_SENTPING)
#define Client_SetSentError(x)				((x)->Flags |= CLIENT_BITMASK_SENTERROR)

#define Client_ClearSSL(x)				((x)->Flags &= ~CLIENT_BITMASK_SSL)
#define Client_ClearIPv6(x)				((x)->Flags &= ~CLIENT_BITMASK_IPV6)
#define Client_ClearSocket(x)				((x)->Flags &= ~CLIENT_BITMASK_SOCKET)
#define Client_ClearSSLHandshake(x)			((x)->Flags &= ~CLIENT_BITMASK_SSLHANDSHAKE)
#define Client_ClearVerified(x)				((x)->Flags &= ~CLIENT_BITMASK_VERIFIED)
#define Client_ClearSentPing(x)				((x)->Flags &= ~CLIENT_BITMASK_SENTPING)
#define Client_ClearSentError(x)			((x)->Flags &= ~CLIENT_BITMASK_SENTERROR)

#define Client_IsSSL(x)					((x)->Flags & CLIENT_BITMASK_SSL)
#define Client_IsIPv6(x)				((x)->Flags & CLIENT_BITMASK_IPV6)
#define Client_IsSocket(x)				((x)->Flags & CLIENT_BITMASK_SOCKET)
#define Client_IsSSLHandshake(x)			((x)->Flags & CLIENT_BITMASK_SSLHANDSHAKE)
#define Client_IsVerified(x)				((x)->Flags & CLIENT_BITMASK_VERIFIED)
#define Client_IsSentPing(x)				((x)->Flags & CLIENT_BITMASK_SENTPING)
#define Client_IsSentError(x)				((x)->Flags & CLIENT_BITMASK_SENTERROR)

/* STRUCTURES - JONAS (18.07.2001) */

struct Client_Struct {

  struct Listen_Struct *ListenS;

  char *Nick;
  char *User;
  char *Host;
  char *Pass;

  unsigned long int ResolveFlags;
  unsigned long int Flags;

  char *HostName;
  char *HostIPS;

  struct in_addr INAddr;
#if IPV6_SUPPORT
  struct in6_addr INAddr6;
#endif
  unsigned long int PortH;
  unsigned long int PortN;

  signed long int FD;

  time_t Time;
  time_t LastRecvTime;
  time_t SentPingTime;
  time_t SentErrorTime;

  char *RecvBuffer;
  char *SendBuffer;

  struct UserConf_Struct *UserConf;
  struct Conn_Struct *ConnS;
  struct Who_Struct *Who_Head;

  unsigned long int Lines;
  time_t LineTime;

  struct Client_Struct *Prev;
  struct Client_Struct *Next;

#if SSL_SUPPORT
  SSL *SSL_H;
  X509 *Cert;
#endif

};

/* FUNCTION PROTOTYPES - JONAS (18.07.2001) */

struct Client_Struct *client_add(struct Listen_Struct *ListenS, const char *const HostIPSPT);
void client_rem(struct Client_Struct *ClientS);

#endif


syntax highlighted by Code2HTML, v. 0.9.1