]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/conn.h
Whitespace fixes: remove trailing tabulator characters.
[ngircd-alex.git] / src / ngircd / conn.h
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4  *
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.
10  *
11  * $Id: conn.h,v 1.46 2008/02/26 22:04:17 fw Exp $
12  *
13  * Connection management (header)
14  */
15
16
17 #ifndef __conn_h__
18 #define __conn_h__
19
20
21 #include <time.h>                       /* for time_t, see below */
22
23
24 #define CONN_ISCLOSING          1       /* Conn_Close() already called */
25 #define CONN_ISCONNECTING       2       /* connect() in progress */
26
27 #ifdef ZLIB
28 #define CONN_ZIP                4       /* zlib compressed link */
29 #endif
30
31 #include "conf-ssl.h"
32
33 #ifdef SSL_SUPPORT
34 #define CONN_SSL_CONNECT        8       /* wait for ssl connect to finish */
35 #define CONN_SSL                16      /* this connection is SSL encrypted */
36 #define CONN_SSL_WANT_WRITE     32      /* SSL/TLS library needs to write protocol data */
37 #define CONN_SSL_WANT_READ      64      /* SSL/TLS library needs to read protocol data */
38 #endif
39 typedef int CONN_ID;
40
41 #include "client.h"
42
43 #ifdef CONN_MODULE
44
45 #include "defines.h"
46 #include "resolve.h"
47 #include "array.h"
48 #include "tool.h"
49 #include "ng_ipaddr.h"
50
51 #ifdef ZLIB
52 #include <zlib.h>
53 typedef struct _ZipData
54 {
55         z_stream in;                    /* "Handle" for input stream */
56         z_stream out;                   /* "Handle" for output stream */
57         array rbuf;                     /* Read buffer (compressed) */
58         array wbuf;                     /* Write buffer (uncompressed) */
59         long bytes_in, bytes_out;       /* Counter for statistics (uncompressed!) */
60 } ZIPDATA;
61 #endif /* ZLIB */
62
63 typedef struct _Connection
64 {
65         int sock;                       /* Socket handle */
66         ng_ipaddr_t addr;               /* Client address */
67         RES_STAT res_stat;              /* Status of resolver process */
68         char host[HOST_LEN];            /* Hostname */
69         array rbuf;                     /* Read buffer */
70         array wbuf;                     /* Write buffer */
71         time_t signon;                  /* Signon ("connect") time */
72         time_t lastdata;                /* Last activity */
73         time_t lastping;                /* Last PING */
74         time_t lastprivmsg;             /* Last PRIVMSG */
75         time_t delaytime;               /* Ignore link ("penalty") */
76         long bytes_in, bytes_out;       /* Received and sent bytes */
77         long msg_in, msg_out;           /* Received and sent IRC messages */
78         int flag;                       /* Flag (see "irc-write" module) */
79         UINT16 options;                 /* Link options / connection state */
80         CLIENT *client;                 /* pointer to client structure */
81 #ifdef ZLIB
82         ZIPDATA zip;                    /* Compression information */
83 #endif  /* ZLIB */
84 #ifdef SSL_SUPPORT
85         struct ConnSSL_State    ssl_state;      /* SSL/GNUTLS state information */
86 #endif
87 } CONNECTION;
88
89 GLOBAL CONNECTION *My_Connections;
90 GLOBAL CONN_ID Pool_Size;
91 GLOBAL long WCounter;
92
93 #endif /* CONN_MODULE */
94
95
96 GLOBAL void Conn_Init PARAMS((void ));
97 GLOBAL void Conn_Exit PARAMS(( void ));
98
99 GLOBAL unsigned int Conn_InitListeners PARAMS(( void ));
100 GLOBAL void Conn_ExitListeners PARAMS(( void ));
101
102 GLOBAL void Conn_Handler PARAMS(( void ));
103
104 GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
105
106 GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
107
108 GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
109
110 GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i));
111 #ifdef SSL_SUPPORT
112 GLOBAL bool Conn_GetCipherInfo PARAMS((CONN_ID Idx, char *buf, size_t len));
113 GLOBAL bool Conn_UsesSSL PARAMS((CONN_ID Idx));
114 #else
115 static inline bool Conn_UsesSSL(UNUSED CONN_ID Idx) { return false; }
116 #endif
117 #endif
118
119 /* -eof- */