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.28 2002/12/30 16:07:23 alex Exp $
13 * Connection management (header)
21 #include <time.h> /* wg. time_t, s.u. */
25 #define CONN_ZIP 4 /* Kompression mit zlib */
32 #if defined(__conn_c__) || defined(__conn_zip_c__)
39 typedef struct _ZipData
41 z_stream in; /* "Handle" for input stream */
42 z_stream out; /* "Handle" for output stream */
43 CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
44 INT rdatalen; /* Length of data in read buffer (compressed) */
45 CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
46 INT wdatalen; /* Length of data in write buffer (uncompressed) */
47 LONG bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
51 typedef struct _Connection
53 INT sock; /* Socket handle */
54 struct sockaddr_in addr; /* Client address */
55 RES_STAT *res_stat; /* Status of resolver process, if any */
56 CHAR host[HOST_LEN]; /* Hostname */
57 CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
58 INT rdatalen; /* Length of data in read buffer */
59 CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
60 INT wdatalen; /* Length of data in write buffer */
61 time_t starttime; /* Start time of link */
62 time_t lastdata; /* Last activity */
63 time_t lastping; /* Last PING */
64 time_t lastprivmsg; /* Last PRIVMSG */
65 time_t delaytime; /* Ignore link ("penalty") */
66 LONG bytes_in, bytes_out; /* Received and sent bytes */
67 LONG msg_in, msg_out; /* Received and sent IRC messages */
68 INT flag; /* Flag (see "irc-write" module) */
69 INT options; /* Link options */
71 ZIPDATA zip; /* Compression information */
75 GLOBAL CONNECTION *My_Connections;
76 GLOBAL CONN_ID Pool_Size;
78 #endif /* defined() */
81 GLOBAL VOID Conn_Init PARAMS((VOID ));
82 GLOBAL VOID Conn_Exit PARAMS(( VOID ));
84 GLOBAL INT Conn_InitListeners PARAMS(( VOID ));
85 GLOBAL VOID Conn_ExitListeners PARAMS(( VOID ));
87 GLOBAL BOOLEAN Conn_NewListener PARAMS(( CONST UINT Port ));
89 GLOBAL VOID Conn_Handler PARAMS(( VOID ));
91 GLOBAL BOOLEAN Conn_Write PARAMS(( CONN_ID Idx, CHAR *Data, INT Len ));
92 GLOBAL BOOLEAN Conn_WriteStr PARAMS(( CONN_ID Idx, CHAR *Format, ... ));
94 GLOBAL VOID Conn_Close PARAMS(( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ));
96 GLOBAL VOID Conn_UpdateIdle PARAMS(( CONN_ID Idx ));
97 GLOBAL time_t Conn_GetIdle PARAMS(( CONN_ID Idx ));
98 GLOBAL time_t Conn_LastPing PARAMS(( CONN_ID Idx ));
99 GLOBAL time_t Conn_StartTime PARAMS(( CONN_ID Idx ));
100 GLOBAL INT Conn_SendQ PARAMS(( CONN_ID Idx ));
101 GLOBAL INT Conn_RecvQ PARAMS(( CONN_ID Idx ));
102 GLOBAL LONG Conn_SendMsg PARAMS(( CONN_ID Idx ));
103 GLOBAL LONG Conn_RecvMsg PARAMS(( CONN_ID Idx ));
104 GLOBAL LONG Conn_SendBytes PARAMS(( CONN_ID Idx ));
105 GLOBAL LONG Conn_RecvBytes PARAMS(( CONN_ID Idx ));
107 GLOBAL VOID Conn_SetPenalty PARAMS(( CONN_ID Idx, time_t Seconds ));
108 GLOBAL VOID Conn_ResetPenalty PARAMS(( CONN_ID Idx ));
110 GLOBAL VOID Conn_ClearFlags PARAMS(( VOID ));
111 GLOBAL INT Conn_Flag PARAMS(( CONN_ID Idx ));
112 GLOBAL VOID Conn_SetFlag PARAMS(( CONN_ID Idx, INT Flag ));
114 GLOBAL CONN_ID Conn_First PARAMS(( VOID ));
115 GLOBAL CONN_ID Conn_Next PARAMS(( CONN_ID Idx ));
117 GLOBAL VOID Conn_SetOption PARAMS(( CONN_ID Idx, INT Option ));
118 GLOBAL VOID Conn_UnsetOption PARAMS(( CONN_ID Idx, INT Option ));
119 GLOBAL INT Conn_Options PARAMS(( CONN_ID Idx ));
121 GLOBAL VOID Conn_ResetWCounter PARAMS(( VOID ));
122 GLOBAL LONG Conn_WCounter PARAMS(( VOID ));
125 GLOBAL INT Conn_MaxFD;