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 #define CONN_ISCLOSING 1 /* Conn_Close() already called */
23 #define CONN_ISCONNECTING 2 /* connect() in progress */
24 #define CONN_RFC1459 4 /* RFC 1459 compatibility mode */
26 #define CONN_ZIP 8 /* zlib compressed link */
32 #define CONN_SSL_CONNECT 8 /* wait for ssl connect to finish */
33 #define CONN_SSL 16 /* this connection is SSL encrypted */
34 #define CONN_SSL_WANT_WRITE 32 /* SSL/TLS library needs to write protocol data */
35 #define CONN_SSL_WANT_READ 64 /* SSL/TLS library needs to read protocol data */
47 #include "ng_ipaddr.h"
51 typedef struct _ZipData
53 z_stream in; /* "Handle" for input stream */
54 z_stream out; /* "Handle" for output stream */
55 array rbuf; /* Read buffer (compressed) */
56 array wbuf; /* Write buffer (uncompressed) */
57 long bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
61 typedef struct _Connection
63 int sock; /* Socket handle */
64 ng_ipaddr_t addr; /* Client address */
65 RES_STAT res_stat; /* Status of resolver process */
66 char host[HOST_LEN]; /* Hostname */
67 array rbuf; /* Read buffer */
68 array wbuf; /* Write buffer */
69 time_t signon; /* Signon ("connect") time */
70 time_t lastdata; /* Last activity */
71 time_t lastping; /* Last PING */
72 time_t lastprivmsg; /* Last PRIVMSG */
73 time_t delaytime; /* Ignore link ("penalty") */
74 long bytes_in, bytes_out; /* Received and sent bytes */
75 long msg_in, msg_out; /* Received and sent IRC messages */
76 int flag; /* Flag (see "irc-write" module) */
77 UINT16 options; /* Link options / connection state */
78 CLIENT *client; /* pointer to client structure */
80 ZIPDATA zip; /* Compression information */
83 struct ConnSSL_State ssl_state; /* SSL/GNUTLS state information */
87 GLOBAL CONNECTION *My_Connections;
88 GLOBAL CONN_ID Pool_Size;
91 #endif /* CONN_MODULE */
94 GLOBAL void Conn_Init PARAMS((void ));
95 GLOBAL void Conn_Exit PARAMS(( void ));
97 GLOBAL unsigned int Conn_InitListeners PARAMS(( void ));
98 GLOBAL void Conn_ExitListeners PARAMS(( void ));
100 GLOBAL void Conn_Handler PARAMS(( void ));
102 GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
104 GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
106 GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
108 GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i));
110 GLOBAL bool Conn_GetCipherInfo PARAMS((CONN_ID Idx, char *buf, size_t len));
111 GLOBAL bool Conn_UsesSSL PARAMS((CONN_ID Idx));
113 static inline bool Conn_UsesSSL(UNUSED CONN_ID Idx) { return false; }