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.32 2003/12/26 15:55:07 alex Exp $
13 * Connection management (header)
21 #include <time.h> /* fro time_t, see below */
24 #define CONN_ISCLOSING 1 /* Conn_Close() already called */
27 #define CONN_ZIP 2 /* zlib compressed link */
41 typedef struct _ZipData
43 z_stream in; /* "Handle" for input stream */
44 z_stream out; /* "Handle" for output stream */
45 CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
46 INT rdatalen; /* Length of data in read buffer (compressed) */
47 CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
48 INT wdatalen; /* Length of data in write buffer (uncompressed) */
49 LONG bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
53 typedef struct _Connection
55 INT sock; /* Socket handle */
56 struct sockaddr_in addr; /* Client address */
57 RES_STAT *res_stat; /* Status of resolver process, if any */
58 CHAR host[HOST_LEN]; /* Hostname */
59 CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
60 INT rdatalen; /* Length of data in read buffer */
61 CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
62 INT wdatalen; /* Length of data in write buffer */
63 time_t starttime; /* Start time of link */
64 time_t lastdata; /* Last activity */
65 time_t lastping; /* Last PING */
66 time_t lastprivmsg; /* Last PRIVMSG */
67 time_t delaytime; /* Ignore link ("penalty") */
68 LONG bytes_in, bytes_out; /* Received and sent bytes */
69 LONG msg_in, msg_out; /* Received and sent IRC messages */
70 INT flag; /* Flag (see "irc-write" module) */
71 INT options; /* Link options */
73 ZIPDATA zip; /* Compression information */
77 GLOBAL CONNECTION *My_Connections;
78 GLOBAL CONN_ID Pool_Size;
81 #endif /* CONN_MODULE */
84 GLOBAL VOID Conn_Init PARAMS((VOID ));
85 GLOBAL VOID Conn_Exit PARAMS(( VOID ));
87 GLOBAL INT Conn_InitListeners PARAMS(( VOID ));
88 GLOBAL VOID Conn_ExitListeners PARAMS(( VOID ));
90 GLOBAL BOOLEAN Conn_NewListener PARAMS(( CONST UINT Port ));
92 GLOBAL VOID Conn_Handler PARAMS(( VOID ));
94 GLOBAL BOOLEAN Conn_Write PARAMS(( CONN_ID Idx, CHAR *Data, INT Len ));
95 GLOBAL BOOLEAN Conn_WriteStr PARAMS(( CONN_ID Idx, CHAR *Format, ... ));
97 GLOBAL VOID Conn_Close PARAMS(( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ));
99 GLOBAL VOID Conn_SyncServerStruct PARAMS(( VOID ));
101 GLOBAL INT Conn_MaxFD;