2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
11 * $Id: conn.h,v 1.34 2005/04/18 21:08:31 fw Exp $
13 * Connection management (header)
21 #include <time.h> /* for time_t, see below */
24 #define CONN_ISCLOSING 1U /* Conn_Close() already called */
25 #define CONN_ISCONNECTING 2U /* connect() in progress */
28 #define CONN_ZIP 4U /* zlib compressed link */
42 typedef struct _ZipData
44 z_stream in; /* "Handle" for input stream */
45 z_stream out; /* "Handle" for output stream */
46 char rbuf[READBUFFER_LEN]; /* Read buffer */
47 int rdatalen; /* Length of data in read buffer (compressed) */
48 char wbuf[WRITEBUFFER_LEN]; /* Write buffer */
49 int wdatalen; /* Length of data in write buffer (uncompressed) */
50 long bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
54 typedef struct _Connection
56 int sock; /* Socket handle */
57 struct sockaddr_in addr; /* Client address */
58 RES_STAT *res_stat; /* Status of resolver process, if any */
59 char host[HOST_LEN]; /* Hostname */
60 char rbuf[READBUFFER_LEN]; /* Read buffer */
61 int rdatalen; /* Length of data in read buffer */
62 char wbuf[WRITEBUFFER_LEN]; /* Write buffer */
63 int wdatalen; /* Length of data in write buffer */
64 time_t starttime; /* Start time of link */
65 time_t lastdata; /* Last activity */
66 time_t lastping; /* Last PING */
67 time_t lastprivmsg; /* Last PRIVMSG */
68 time_t delaytime; /* Ignore link ("penalty") */
69 long bytes_in, bytes_out; /* Received and sent bytes */
70 long msg_in, msg_out; /* Received and sent IRC messages */
71 int flag; /* Flag (see "irc-write" module) */
72 UINT16 options; /* Link options / connection state */
74 ZIPDATA zip; /* Compression information */
78 GLOBAL CONNECTION *My_Connections;
79 GLOBAL CONN_ID Pool_Size;
82 #endif /* CONN_MODULE */
85 GLOBAL void Conn_Init PARAMS((void ));
86 GLOBAL void Conn_Exit PARAMS(( void ));
88 GLOBAL int Conn_InitListeners PARAMS(( void ));
89 GLOBAL void Conn_ExitListeners PARAMS(( void ));
91 GLOBAL bool Conn_NewListener PARAMS(( const UINT16 Port ));
93 GLOBAL void Conn_Handler PARAMS(( void ));
95 GLOBAL bool Conn_Write PARAMS(( CONN_ID Idx, char *Data, int Len ));
96 GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
98 GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
100 GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
102 GLOBAL int Conn_MaxFD;