2001-12-12 18:18:38 +01:00
|
|
|
/*
|
|
|
|
* ngIRCd -- The Next Generation IRC Daemon
|
2002-01-02 03:44:36 +01:00
|
|
|
* Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
|
2001-12-12 18:18:38 +01:00
|
|
|
*
|
2002-12-12 13:23:43 +01:00
|
|
|
* 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.
|
|
|
|
* Please read the file COPYING, README and AUTHORS for more information.
|
2001-12-12 18:18:38 +01:00
|
|
|
*
|
2005-07-31 00:53:16 +02:00
|
|
|
* $Id: conn.h,v 1.38 2005/07/30 22:53:16 alex Exp $
|
2001-12-12 18:18:38 +01:00
|
|
|
*
|
2002-12-12 13:23:43 +01:00
|
|
|
* Connection management (header)
|
2001-12-12 18:18:38 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __conn_h__
|
|
|
|
#define __conn_h__
|
|
|
|
|
|
|
|
|
2005-03-19 19:43:48 +01:00
|
|
|
#include <time.h> /* for time_t, see below */
|
2002-11-27 00:06:51 +01:00
|
|
|
|
|
|
|
|
2005-07-31 00:53:16 +02:00
|
|
|
#define CONN_ISCLOSING 1 /* Conn_Close() already called */
|
|
|
|
#define CONN_ISCONNECTING 2 /* connect() in progress */
|
2003-02-21 20:18:48 +01:00
|
|
|
|
2003-12-26 16:55:07 +01:00
|
|
|
#ifdef ZLIB
|
2005-07-31 00:53:16 +02:00
|
|
|
#define CONN_ZIP 4 /* zlib compressed link */
|
2002-11-27 00:06:51 +01:00
|
|
|
#endif
|
2002-02-23 01:03:54 +01:00
|
|
|
|
|
|
|
|
2005-03-19 19:43:48 +01:00
|
|
|
typedef int CONN_ID;
|
2001-12-14 09:15:45 +01:00
|
|
|
|
2002-01-02 03:44:36 +01:00
|
|
|
|
2002-12-30 18:14:59 +01:00
|
|
|
#ifdef CONN_MODULE
|
2002-12-30 17:07:23 +01:00
|
|
|
|
|
|
|
#include "defines.h"
|
|
|
|
#include "resolve.h"
|
2005-07-07 20:45:33 +02:00
|
|
|
#include "array.h"
|
2002-12-30 17:07:23 +01:00
|
|
|
|
2003-12-26 16:55:07 +01:00
|
|
|
#ifdef ZLIB
|
2002-12-30 17:07:23 +01:00
|
|
|
#include <zlib.h>
|
|
|
|
typedef struct _ZipData
|
|
|
|
{
|
|
|
|
z_stream in; /* "Handle" for input stream */
|
|
|
|
z_stream out; /* "Handle" for output stream */
|
2005-07-07 20:45:33 +02:00
|
|
|
array rbuf; /* Read buffer (compressed) */
|
|
|
|
array wbuf; /* Write buffer (uncompressed) */
|
2005-03-19 19:43:48 +01:00
|
|
|
long bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
|
2002-12-30 17:07:23 +01:00
|
|
|
} ZIPDATA;
|
2003-12-26 16:55:07 +01:00
|
|
|
#endif /* ZLIB */
|
2002-12-30 17:07:23 +01:00
|
|
|
|
|
|
|
typedef struct _Connection
|
|
|
|
{
|
2005-03-19 19:43:48 +01:00
|
|
|
int sock; /* Socket handle */
|
2002-12-30 17:07:23 +01:00
|
|
|
struct sockaddr_in addr; /* Client address */
|
|
|
|
RES_STAT *res_stat; /* Status of resolver process, if any */
|
2005-03-19 19:43:48 +01:00
|
|
|
char host[HOST_LEN]; /* Hostname */
|
2005-07-07 20:45:33 +02:00
|
|
|
array rbuf; /* Read buffer */
|
|
|
|
array wbuf; /* Write buffer */
|
2002-12-30 17:07:23 +01:00
|
|
|
time_t lastdata; /* Last activity */
|
|
|
|
time_t lastping; /* Last PING */
|
|
|
|
time_t lastprivmsg; /* Last PRIVMSG */
|
|
|
|
time_t delaytime; /* Ignore link ("penalty") */
|
2005-04-18 23:08:31 +02:00
|
|
|
long bytes_in, bytes_out; /* Received and sent bytes */
|
|
|
|
long msg_in, msg_out; /* Received and sent IRC messages */
|
2005-03-19 19:43:48 +01:00
|
|
|
int flag; /* Flag (see "irc-write" module) */
|
2005-04-18 23:08:31 +02:00
|
|
|
UINT16 options; /* Link options / connection state */
|
2003-12-26 16:55:07 +01:00
|
|
|
#ifdef ZLIB
|
2002-12-30 17:07:23 +01:00
|
|
|
ZIPDATA zip; /* Compression information */
|
2003-12-26 16:55:07 +01:00
|
|
|
#endif /* ZLIB */
|
2002-12-30 17:07:23 +01:00
|
|
|
} CONNECTION;
|
|
|
|
|
|
|
|
GLOBAL CONNECTION *My_Connections;
|
|
|
|
GLOBAL CONN_ID Pool_Size;
|
2005-03-19 19:43:48 +01:00
|
|
|
GLOBAL long WCounter;
|
2002-12-30 17:07:23 +01:00
|
|
|
|
2002-12-30 18:14:59 +01:00
|
|
|
#endif /* CONN_MODULE */
|
2002-12-30 17:07:23 +01:00
|
|
|
|
|
|
|
|
2005-03-19 19:43:48 +01:00
|
|
|
GLOBAL void Conn_Init PARAMS((void ));
|
|
|
|
GLOBAL void Conn_Exit PARAMS(( void ));
|
2001-12-14 09:15:45 +01:00
|
|
|
|
2005-03-19 19:43:48 +01:00
|
|
|
GLOBAL int Conn_InitListeners PARAMS(( void ));
|
|
|
|
GLOBAL void Conn_ExitListeners PARAMS(( void ));
|
2002-11-22 18:58:19 +01:00
|
|
|
|
2005-03-19 19:43:48 +01:00
|
|
|
GLOBAL void Conn_Handler PARAMS(( void ));
|
2001-12-12 18:18:38 +01:00
|
|
|
|
2005-07-07 20:45:33 +02:00
|
|
|
GLOBAL bool Conn_Write PARAMS(( CONN_ID Idx, char *Data, unsigned int Len ));
|
2005-03-19 19:43:48 +01:00
|
|
|
GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
|
2001-12-12 18:18:38 +01:00
|
|
|
|
2005-03-19 19:43:48 +01:00
|
|
|
GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
|
2001-12-15 01:08:27 +01:00
|
|
|
|
2005-03-19 19:43:48 +01:00
|
|
|
GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
|
2002-05-27 15:09:26 +02:00
|
|
|
|
2005-07-07 20:45:33 +02:00
|
|
|
GLOBAL void Read_Resolver_Result PARAMS(( int x ));
|
|
|
|
|
2005-03-19 19:43:48 +01:00
|
|
|
GLOBAL int Conn_MaxFD;
|
2001-12-31 03:18:51 +01:00
|
|
|
|
2001-12-12 18:18:38 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* -eof- */
|