2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2008 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 * Connection management (header)
19 #include <time.h> /* for time_t, see below */
22 * connection state flags. this is a bitmask -- all values must
23 * be unique and a power of two.
25 * If you introduce new ones in between, make sure to adjust all
28 #define CONN_ISCLOSING 1 /* Conn_Close() already called */
29 #define CONN_ISCONNECTING 2 /* connect() in progress */
30 #define CONN_RFC1459 4 /* RFC 1459 compatibility mode */
32 #define CONN_ZIP 8 /* zlib compressed link */
38 #define CONN_SSL_CONNECT 16 /* wait for ssl connect to finish */
39 #define CONN_SSL 32 /* this connection is SSL encrypted */
40 #define CONN_SSL_WANT_WRITE 64 /* SSL/TLS library needs to write protocol data */
41 #define CONN_SSL_WANT_READ 128 /* SSL/TLS library needs to read protocol data */
53 #include "ng_ipaddr.h"
57 typedef struct _ZipData
59 z_stream in; /* "Handle" for input stream */
60 z_stream out; /* "Handle" for output stream */
61 array rbuf; /* Read buffer (compressed) */
62 array wbuf; /* Write buffer (uncompressed) */
63 long bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
67 typedef struct _Connection
69 int sock; /* Socket handle */
70 ng_ipaddr_t addr; /* Client address */
71 RES_STAT res_stat; /* Status of resolver process */
72 char host[HOST_LEN]; /* Hostname */
73 array rbuf; /* Read buffer */
74 array wbuf; /* Write buffer */
75 time_t signon; /* Signon ("connect") time */
76 time_t lastdata; /* Last activity */
77 time_t lastping; /* Last PING */
78 time_t lastprivmsg; /* Last PRIVMSG */
79 time_t delaytime; /* Ignore link ("penalty") */
80 long bytes_in, bytes_out; /* Received and sent bytes */
81 long msg_in, msg_out; /* Received and sent IRC messages */
82 int flag; /* Flag (see "irc-write" module) */
83 UINT16 options; /* Link options / connection state */
84 CLIENT *client; /* pointer to client structure */
86 ZIPDATA zip; /* Compression information */
89 struct ConnSSL_State ssl_state; /* SSL/GNUTLS state information */
93 GLOBAL CONNECTION *My_Connections;
94 GLOBAL CONN_ID Pool_Size;
97 #endif /* CONN_MODULE */
100 GLOBAL void Conn_Init PARAMS((void ));
101 GLOBAL void Conn_Exit PARAMS(( void ));
103 GLOBAL unsigned int Conn_InitListeners PARAMS(( void ));
104 GLOBAL void Conn_ExitListeners PARAMS(( void ));
106 GLOBAL void Conn_Handler PARAMS(( void ));
108 GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
110 GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
112 GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
114 GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i));
116 GLOBAL bool Conn_GetCipherInfo PARAMS((CONN_ID Idx, char *buf, size_t len));
117 GLOBAL bool Conn_UsesSSL PARAMS((CONN_ID Idx));
119 static inline bool Conn_UsesSSL(UNUSED CONN_ID Idx) { return false; }