00001
00002
00003
00004
00005 #include "inspircd_config.h"
00006 #include "base.h"
00007 #include <string>
00008 #include <map.h>
00009 #include <sys/socket.h>
00010 #include <sys/types.h>
00011 #include <netdb.h>
00012 #include <netinet/in.h>
00013 #include <unistd.h>
00014 #include <errno.h>
00015 #include <time.h>
00016
00017 #ifndef __CONNECTION_H__
00018 #define __CONNECTION_H__
00019
00020 #define PT_SYN_ONLY 0
00021 #define PT_ACK_ONLY 1
00022 #define PT_SYN_WITH_DATA 2
00023
00024
00025 class packet : public classbase
00026 {
00027 public:
00028 long key;
00029 short int id;
00030 short int type;
00031 char data[MAXBUF];
00032
00033 packet();
00034 ~packet();
00035 };
00036
00037
00038 class connection : public classbase
00039 {
00040 public:
00041 long key;
00042 int fd;
00043 char host[256];
00044 long ip;
00045 char inbuf[MAXBUF];
00046 long bytes_in;
00047 long bytes_out;
00048 long cmds_in;
00049 long cmds_out;
00050 bool haspassed;
00051 int port;
00052 int registered;
00053 time_t lastping;
00054 time_t signon;
00055 time_t idle_lastmsg;
00056 time_t nping;
00057
00058 connection();
00059 bool CreateListener(char* host, int p);
00060 bool BeginLink(char* targethost, int port, char* password);
00061 void TerminateLink(char* targethost);
00062 bool SendPacket(char *message, char* host, int port);
00063 bool RecvPacket(char *message, char* host, int &prt);
00064 bool SendSYN(char* host, int port);
00065 bool SendACK(char* host, int port, int reply_id);
00066 long GenKey();
00067 };
00068
00069
00070 #endif
00071