| 1 |
/************************************************************************ |
| 2 |
* IRC - Internet Relay Chat, servlink/servlink.h |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 1, or (at your option) |
| 7 |
* any later version. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, write to the Free Software |
| 16 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 17 |
* |
| 18 |
* $Id$ |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef INCLUDED_servlink_servlink_h |
| 22 |
#define INCLUDED_servlink_servlink_h |
| 23 |
|
| 24 |
#include "config.h" |
| 25 |
|
| 26 |
#ifdef HAVE_LIBCRYPTO |
| 27 |
#include <openssl/evp.h> |
| 28 |
#endif |
| 29 |
#ifdef HAVE_LIBZ |
| 30 |
#include <zlib.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
/* do not use stdin/out/err, as it seems to break on solaris */ |
| 34 |
#define CONTROL_R fds[0] |
| 35 |
#define CONTROL_W fds[1] |
| 36 |
#define LOCAL_R fds[2] |
| 37 |
#define LOCAL_W fds[3] |
| 38 |
#define REMOTE_R fds[4] |
| 39 |
#define REMOTE_W REMOTE_R |
| 40 |
|
| 41 |
#undef SERVLINK_DEBUG |
| 42 |
|
| 43 |
#define READLEN 16384 |
| 44 |
|
| 45 |
#ifdef HAVE_LIBZ |
| 46 |
#define BUFLEN READLEN * 6 /* allow for decompression */ |
| 47 |
#else |
| 48 |
#define BUFLEN READLEN |
| 49 |
#endif |
| 50 |
|
| 51 |
|
| 52 |
#ifdef HAVE_LIBCRYPTO |
| 53 |
#define CIPHER_BF 1 |
| 54 |
#define CIPHER_CAST 2 |
| 55 |
#define CIPHER_DES 3 |
| 56 |
#define CIPHER_3DES 4 |
| 57 |
#define CIPHER_IDEA 5 |
| 58 |
#define CIPHER_RC5_8 6 |
| 59 |
#define CIPHER_RC5_12 7 |
| 60 |
#define CIPHER_RC5_16 8 |
| 61 |
|
| 62 |
struct crypt_state |
| 63 |
{ |
| 64 |
EVP_CIPHER_CTX ctx; |
| 65 |
const EVP_CIPHER *cipher; |
| 66 |
unsigned int keylen; /* bytes */ |
| 67 |
unsigned char *key; |
| 68 |
unsigned int ivlen; /* bytes */ |
| 69 |
unsigned char *iv; |
| 70 |
unsigned int rounds; /* rc5 only */ |
| 71 |
}; |
| 72 |
#endif |
| 73 |
|
| 74 |
#ifdef HAVE_LIBZ |
| 75 |
struct zip_state |
| 76 |
{ |
| 77 |
z_stream stream; |
| 78 |
int level; /* compression level */ |
| 79 |
}; |
| 80 |
#endif |
| 81 |
|
| 82 |
struct slink_state |
| 83 |
{ |
| 84 |
unsigned int crypt:1; |
| 85 |
unsigned int zip:1; |
| 86 |
unsigned int active:1; |
| 87 |
|
| 88 |
unsigned char buf[BUFLEN*2]; |
| 89 |
unsigned int ofs; |
| 90 |
unsigned int len; |
| 91 |
|
| 92 |
#ifdef HAVE_LIBCRYPTO |
| 93 |
struct crypt_state crypt_state; |
| 94 |
#endif |
| 95 |
#ifdef HAVE_LIBZ |
| 96 |
struct zip_state zip_state; |
| 97 |
#endif |
| 98 |
}; |
| 99 |
|
| 100 |
|
| 101 |
typedef void (io_callback)(void); |
| 102 |
|
| 103 |
struct fd_table |
| 104 |
{ |
| 105 |
int fd; |
| 106 |
io_callback *read_cb; |
| 107 |
io_callback *write_cb; |
| 108 |
}; |
| 109 |
|
| 110 |
extern struct slink_state in_state; |
| 111 |
extern struct slink_state out_state; |
| 112 |
extern struct fd_table fds[5]; |
| 113 |
|
| 114 |
#endif /* INCLUDED_servlink_servlink_h */ |