]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/conn.h
IPv6 support.
[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
32 typedef int CONN_ID;
33
34 #include "client.h"
35
36 #ifdef CONN_MODULE
37
38 #include "defines.h"
39 #include "resolve.h"
40 #include "array.h"
41 #include "tool.h"
42 #include "ng_ipaddr.h"
43
44 #ifdef ZLIB
45 #include <zlib.h>
46 typedef struct _ZipData
47 {
48         z_stream in;                    /* "Handle" for input stream */
49         z_stream out;                   /* "Handle" for output stream */
50         array rbuf;                     /* Read buffer (compressed) */
51         array wbuf;                     /* Write buffer (uncompressed) */
52         long bytes_in, bytes_out;       /* Counter for statistics (uncompressed!) */
53 } ZIPDATA;
54 #endif /* ZLIB */
55
56 typedef struct _Connection
57 {
58         int sock;                       /* Socket handle */
59         ng_ipaddr_t addr;               /* Client address */
60         RES_STAT res_stat;              /* Status of resolver process */
61         char host[HOST_LEN];            /* Hostname */
62         array rbuf;                     /* Read buffer */
63         array wbuf;                     /* Write buffer */
64         time_t signon;                  /* Signon ("connect") time */
65         time_t lastdata;                /* Last activity */
66         time_t lastping;                /* Last PING */
67         time_t lastprivmsg;             /* Last PRIVMSG */
68         time_t delaytime;               /* Ignore link ("penalty") */
69         long bytes_in, bytes_out;       /* Received and sent bytes */
70         long msg_in, msg_out;           /* Received and sent IRC messages */
71         int flag;                       /* Flag (see "irc-write" module) */
72         UINT16 options;                 /* Link options / connection state */
73         CLIENT *client;                 /* pointer to client structure */
74 #ifdef ZLIB
75         ZIPDATA zip;                    /* Compression information */
76 #endif  /* ZLIB */
77 } CONNECTION;
78
79 GLOBAL CONNECTION *My_Connections;
80 GLOBAL CONN_ID Pool_Size;
81 GLOBAL long WCounter;
82
83 #endif /* CONN_MODULE */
84
85
86 GLOBAL void Conn_Init PARAMS((void ));
87 GLOBAL void Conn_Exit PARAMS(( void ));
88
89 GLOBAL unsigned int Conn_InitListeners PARAMS(( void ));
90 GLOBAL void Conn_ExitListeners PARAMS(( void ));
91
92 GLOBAL void Conn_Handler PARAMS(( void ));
93
94 GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
95
96 GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
97
98 GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
99
100 GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i));
101 #endif
102
103 /* -eof- */