00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef INCLUDED_servlink_servlink_h
00022 #define INCLUDED_servlink_servlink_h
00023
00024 #include "setup.h"
00025
00026 #ifdef HAVE_LIBCRYPTO
00027 #include <openssl/evp.h>
00028 #endif
00029 #ifdef HAVE_LIBZ
00030 #include <zlib.h>
00031 #endif
00032
00033
00034 #define CONTROL_R fds[0]
00035 #define CONTROL_W fds[1]
00036 #define LOCAL_R fds[2]
00037 #define LOCAL_W fds[3]
00038 #define REMOTE_R fds[4]
00039 #define REMOTE_W REMOTE_R
00040
00041 #undef SERVLINK_DEBUG
00042
00043 #define READLEN 16384
00044
00045 #ifdef HAVE_LIBZ
00046 #define BUFLEN READLEN * 6
00047 #else
00048 #define BUFLEN READLEN
00049 #endif
00050
00051
00052 #ifdef HAVE_LIBCRYPTO
00053 #define CIPHER_BF 1
00054 #define CIPHER_CAST 2
00055 #define CIPHER_DES 3
00056 #define CIPHER_3DES 4
00057 #define CIPHER_IDEA 5
00058 #define CIPHER_RC5_8 6
00059 #define CIPHER_RC5_12 7
00060 #define CIPHER_RC5_16 8
00061
00062 struct crypt_state
00063 {
00064 EVP_CIPHER_CTX ctx;
00065 const EVP_CIPHER *cipher;
00066 unsigned int keylen;
00067 unsigned char *key;
00068 unsigned int ivlen;
00069 unsigned char *iv;
00070 unsigned int rounds;
00071 };
00072 #endif
00073
00074 #ifdef HAVE_LIBZ
00075 struct zip_state
00076 {
00077 z_stream stream;
00078 int level;
00079 };
00080 #endif
00081
00082 struct slink_state
00083 {
00084 unsigned int crypt:1;
00085 unsigned int zip:1;
00086 unsigned int active:1;
00087
00088 unsigned char buf[BUFLEN*2];
00089 unsigned int ofs;
00090 unsigned int len;
00091
00092 #ifdef HAVE_LIBCRYPTO
00093 struct crypt_state crypt_state;
00094 #endif
00095 #ifdef HAVE_LIBZ
00096 struct zip_state zip_state;
00097 #endif
00098 };
00099
00100
00101 typedef void (io_callback)(void);
00102
00103 struct fd_table
00104 {
00105 int fd;
00106 io_callback *read_cb;
00107 io_callback *write_cb;
00108 };
00109
00110 extern struct slink_state in_state;
00111 extern struct slink_state out_state;
00112 extern struct fd_table fds[5];
00113
00114 #endif