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 c40592d2 2003-12-26 alex * $Id: conn.h,v 1.32 2003/12/26 15:55:07 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 2a3f8cc5 2003-02-21 alex #include <time.h> /* fro time_t, see below */
22 8465653c 2002-02-23 alex
23 8465653c 2002-02-23 alex
24 2a3f8cc5 2003-02-21 alex #define CONN_ISCLOSING 1 /* Conn_Close() already called */
25 2a3f8cc5 2003-02-21 alex
26 c40592d2 2003-12-26 alex #ifdef ZLIB
27 2a3f8cc5 2003-02-21 alex #define CONN_ZIP 2 /* zlib compressed link */
28 ecde730e 2002-11-26 alex #endif
29 ecde730e 2002-11-26 alex
30 ecde730e 2002-11-26 alex
31 933e62fb 2001-12-14 alex typedef INT CONN_ID;
32 933e62fb 2001-12-14 alex
33 933e62fb 2001-12-14 alex
34 b77dae34 2002-12-30 alex #ifdef CONN_MODULE
35 e68cdf30 2002-12-30 alex
36 e68cdf30 2002-12-30 alex #include "defines.h"
37 e68cdf30 2002-12-30 alex #include "resolve.h"
38 e68cdf30 2002-12-30 alex
39 c40592d2 2003-12-26 alex #ifdef ZLIB
40 e68cdf30 2002-12-30 alex #include <zlib.h>
41 e68cdf30 2002-12-30 alex typedef struct _ZipData
42 e68cdf30 2002-12-30 alex {
43 e68cdf30 2002-12-30 alex z_stream in; /* "Handle" for input stream */
44 e68cdf30 2002-12-30 alex z_stream out; /* "Handle" for output stream */
45 e68cdf30 2002-12-30 alex CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
46 e68cdf30 2002-12-30 alex INT rdatalen; /* Length of data in read buffer (compressed) */
47 e68cdf30 2002-12-30 alex CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
48 e68cdf30 2002-12-30 alex INT wdatalen; /* Length of data in write buffer (uncompressed) */
49 e68cdf30 2002-12-30 alex LONG bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
50 e68cdf30 2002-12-30 alex } ZIPDATA;
51 c40592d2 2003-12-26 alex #endif /* ZLIB */
52 e68cdf30 2002-12-30 alex
53 e68cdf30 2002-12-30 alex typedef struct _Connection
54 e68cdf30 2002-12-30 alex {
55 e68cdf30 2002-12-30 alex INT sock; /* Socket handle */
56 e68cdf30 2002-12-30 alex struct sockaddr_in addr; /* Client address */
57 e68cdf30 2002-12-30 alex RES_STAT *res_stat; /* Status of resolver process, if any */
58 e68cdf30 2002-12-30 alex CHAR host[HOST_LEN]; /* Hostname */
59 e68cdf30 2002-12-30 alex CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
60 e68cdf30 2002-12-30 alex INT rdatalen; /* Length of data in read buffer */
61 e68cdf30 2002-12-30 alex CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
62 e68cdf30 2002-12-30 alex INT wdatalen; /* Length of data in write buffer */
63 e68cdf30 2002-12-30 alex time_t starttime; /* Start time of link */
64 e68cdf30 2002-12-30 alex time_t lastdata; /* Last activity */
65 e68cdf30 2002-12-30 alex time_t lastping; /* Last PING */
66 e68cdf30 2002-12-30 alex time_t lastprivmsg; /* Last PRIVMSG */
67 e68cdf30 2002-12-30 alex time_t delaytime; /* Ignore link ("penalty") */
68 e68cdf30 2002-12-30 alex LONG bytes_in, bytes_out; /* Received and sent bytes */
69 e68cdf30 2002-12-30 alex LONG msg_in, msg_out; /* Received and sent IRC messages */
70 e68cdf30 2002-12-30 alex INT flag; /* Flag (see "irc-write" module) */
71 e68cdf30 2002-12-30 alex INT options; /* Link options */
72 c40592d2 2003-12-26 alex #ifdef ZLIB
73 e68cdf30 2002-12-30 alex ZIPDATA zip; /* Compression information */
74 c40592d2 2003-12-26 alex #endif /* ZLIB */
75 e68cdf30 2002-12-30 alex } CONNECTION;
76 e68cdf30 2002-12-30 alex
77 e68cdf30 2002-12-30 alex GLOBAL CONNECTION *My_Connections;
78 e68cdf30 2002-12-30 alex GLOBAL CONN_ID Pool_Size;
79 b77dae34 2002-12-30 alex GLOBAL LONG WCounter;
80 e68cdf30 2002-12-30 alex
81 b77dae34 2002-12-30 alex #endif /* CONN_MODULE */
82 e68cdf30 2002-12-30 alex
83 e68cdf30 2002-12-30 alex
84 c2f60abe 2002-05-27 alex GLOBAL VOID Conn_Init PARAMS((VOID ));
85 c2f60abe 2002-05-27 alex GLOBAL VOID Conn_Exit PARAMS(( VOID ));
86 03d971d9 2002-01-02 alex
87 a0c032b2 2002-11-22 alex GLOBAL INT Conn_InitListeners PARAMS(( VOID ));
88 a0c032b2 2002-11-22 alex GLOBAL VOID Conn_ExitListeners PARAMS(( VOID ));
89 a0c032b2 2002-11-22 alex
90 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN Conn_NewListener PARAMS(( CONST UINT Port ));
91 5fefe1a3 2001-12-12 alex
92 b966b210 2002-06-02 alex GLOBAL VOID Conn_Handler PARAMS(( VOID ));
93 5fefe1a3 2001-12-12 alex
94 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN Conn_Write PARAMS(( CONN_ID Idx, CHAR *Data, INT Len ));
95 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN Conn_WriteStr PARAMS(( CONN_ID Idx, CHAR *Format, ... ));
96 5fefe1a3 2001-12-12 alex
97 c2f60abe 2002-05-27 alex GLOBAL VOID Conn_Close PARAMS(( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ));
98 5fefe1a3 2001-12-12 alex
99 59a0fb8c 2003-03-27 alex GLOBAL VOID Conn_SyncServerStruct PARAMS(( VOID ));
100 41d3107c 2001-12-15 alex
101 c2f60abe 2002-05-27 alex GLOBAL INT Conn_MaxFD;
102 804b1ec4 2001-12-31 alex
103 c2f60abe 2002-05-27 alex
104 5fefe1a3 2001-12-12 alex #endif
105 5fefe1a3 2001-12-12 alex
106 5fefe1a3 2001-12-12 alex
107 5fefe1a3 2001-12-12 alex /* -eof- */