Blame


1 5fefe1a3 2001-12-12 alex /*
2 5fefe1a3 2001-12-12 alex * ngIRCd -- The Next Generation IRC Daemon
3 03d971d9 2002-01-02 alex * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4 5fefe1a3 2001-12-12 alex *
5 c7f07523 2002-12-12 alex * This program is free software; you can redistribute it and/or modify
6 c7f07523 2002-12-12 alex * it under the terms of the GNU General Public License as published by
7 c7f07523 2002-12-12 alex * the Free Software Foundation; either version 2 of the License, or
8 c7f07523 2002-12-12 alex * (at your option) any later version.
9 c7f07523 2002-12-12 alex * Please read the file COPYING, README and AUTHORS for more information.
10 5fefe1a3 2001-12-12 alex *
11 b77dae34 2002-12-30 alex * $Id: conn.h,v 1.29 2002/12/30 17:14:59 alex Exp $
12 5fefe1a3 2001-12-12 alex *
13 c7f07523 2002-12-12 alex * Connection management (header)
14 5fefe1a3 2001-12-12 alex */
15 5fefe1a3 2001-12-12 alex
16 5fefe1a3 2001-12-12 alex
17 5fefe1a3 2001-12-12 alex #ifndef __conn_h__
18 5fefe1a3 2001-12-12 alex #define __conn_h__
19 5fefe1a3 2001-12-12 alex
20 5fefe1a3 2001-12-12 alex
21 ecde730e 2002-11-26 alex #include <time.h> /* wg. time_t, s.u. */
22 8465653c 2002-02-23 alex
23 8465653c 2002-02-23 alex
24 ecde730e 2002-11-26 alex #ifdef USE_ZLIB
25 ecde730e 2002-11-26 alex #define CONN_ZIP 4 /* Kompression mit zlib */
26 ecde730e 2002-11-26 alex #endif
27 ecde730e 2002-11-26 alex
28 ecde730e 2002-11-26 alex
29 933e62fb 2001-12-14 alex typedef INT CONN_ID;
30 933e62fb 2001-12-14 alex
31 933e62fb 2001-12-14 alex
32 b77dae34 2002-12-30 alex #ifdef CONN_MODULE
33 e68cdf30 2002-12-30 alex
34 e68cdf30 2002-12-30 alex #include "defines.h"
35 e68cdf30 2002-12-30 alex #include "resolve.h"
36 e68cdf30 2002-12-30 alex
37 e68cdf30 2002-12-30 alex #ifdef USE_ZLIB
38 e68cdf30 2002-12-30 alex #include <zlib.h>
39 e68cdf30 2002-12-30 alex typedef struct _ZipData
40 e68cdf30 2002-12-30 alex {
41 e68cdf30 2002-12-30 alex z_stream in; /* "Handle" for input stream */
42 e68cdf30 2002-12-30 alex z_stream out; /* "Handle" for output stream */
43 e68cdf30 2002-12-30 alex CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
44 e68cdf30 2002-12-30 alex INT rdatalen; /* Length of data in read buffer (compressed) */
45 e68cdf30 2002-12-30 alex CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
46 e68cdf30 2002-12-30 alex INT wdatalen; /* Length of data in write buffer (uncompressed) */
47 e68cdf30 2002-12-30 alex LONG bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
48 e68cdf30 2002-12-30 alex } ZIPDATA;
49 e68cdf30 2002-12-30 alex #endif /* USE_ZLIB */
50 e68cdf30 2002-12-30 alex
51 e68cdf30 2002-12-30 alex typedef struct _Connection
52 e68cdf30 2002-12-30 alex {
53 e68cdf30 2002-12-30 alex INT sock; /* Socket handle */
54 e68cdf30 2002-12-30 alex struct sockaddr_in addr; /* Client address */
55 e68cdf30 2002-12-30 alex RES_STAT *res_stat; /* Status of resolver process, if any */
56 e68cdf30 2002-12-30 alex CHAR host[HOST_LEN]; /* Hostname */
57 e68cdf30 2002-12-30 alex CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
58 e68cdf30 2002-12-30 alex INT rdatalen; /* Length of data in read buffer */
59 e68cdf30 2002-12-30 alex CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
60 e68cdf30 2002-12-30 alex INT wdatalen; /* Length of data in write buffer */
61 e68cdf30 2002-12-30 alex time_t starttime; /* Start time of link */
62 e68cdf30 2002-12-30 alex time_t lastdata; /* Last activity */
63 e68cdf30 2002-12-30 alex time_t lastping; /* Last PING */
64 e68cdf30 2002-12-30 alex time_t lastprivmsg; /* Last PRIVMSG */
65 e68cdf30 2002-12-30 alex time_t delaytime; /* Ignore link ("penalty") */
66 e68cdf30 2002-12-30 alex LONG bytes_in, bytes_out; /* Received and sent bytes */
67 e68cdf30 2002-12-30 alex LONG msg_in, msg_out; /* Received and sent IRC messages */
68 e68cdf30 2002-12-30 alex INT flag; /* Flag (see "irc-write" module) */
69 e68cdf30 2002-12-30 alex INT options; /* Link options */
70 e68cdf30 2002-12-30 alex #ifdef USE_ZLIB
71 e68cdf30 2002-12-30 alex ZIPDATA zip; /* Compression information */
72 e68cdf30 2002-12-30 alex #endif /* USE_ZLIB */
73 e68cdf30 2002-12-30 alex } CONNECTION;
74 e68cdf30 2002-12-30 alex
75 e68cdf30 2002-12-30 alex GLOBAL CONNECTION *My_Connections;
76 e68cdf30 2002-12-30 alex GLOBAL CONN_ID Pool_Size;
77 b77dae34 2002-12-30 alex GLOBAL LONG WCounter;
78 e68cdf30 2002-12-30 alex
79 b77dae34 2002-12-30 alex #endif /* CONN_MODULE */
80 e68cdf30 2002-12-30 alex
81 e68cdf30 2002-12-30 alex
82 c2f60abe 2002-05-27 alex GLOBAL VOID Conn_Init PARAMS((VOID ));
83 c2f60abe 2002-05-27 alex GLOBAL VOID Conn_Exit PARAMS(( VOID ));
84 03d971d9 2002-01-02 alex
85 a0c032b2 2002-11-22 alex GLOBAL INT Conn_InitListeners PARAMS(( VOID ));
86 a0c032b2 2002-11-22 alex GLOBAL VOID Conn_ExitListeners PARAMS(( VOID ));
87 a0c032b2 2002-11-22 alex
88 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN Conn_NewListener PARAMS(( CONST UINT Port ));
89 5fefe1a3 2001-12-12 alex
90 b966b210 2002-06-02 alex GLOBAL VOID Conn_Handler PARAMS(( VOID ));
91 5fefe1a3 2001-12-12 alex
92 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN Conn_Write PARAMS(( CONN_ID Idx, CHAR *Data, INT Len ));
93 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN Conn_WriteStr PARAMS(( CONN_ID Idx, CHAR *Format, ... ));
94 5fefe1a3 2001-12-12 alex
95 c2f60abe 2002-05-27 alex GLOBAL VOID Conn_Close PARAMS(( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ));
96 5fefe1a3 2001-12-12 alex
97 41d3107c 2001-12-15 alex
98 c2f60abe 2002-05-27 alex GLOBAL INT Conn_MaxFD;
99 804b1ec4 2001-12-31 alex
100 c2f60abe 2002-05-27 alex
101 5fefe1a3 2001-12-12 alex #endif
102 5fefe1a3 2001-12-12 alex
103 5fefe1a3 2001-12-12 alex
104 5fefe1a3 2001-12-12 alex /* -eof- */