]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/connection.h
c996e0abd4540a4e0ffb8164a90a68835cd7bce4
[user/henk/code/inspircd.git] / include / connection.h
1 /*
2
3 */
4
5 #include "inspircd_config.h"
6 #include "base.h"
7 #include <string>
8 #include <map>
9 #include <sys/socket.h>
10 #include <sys/types.h>
11 #include <netdb.h>
12 #include <netinet/in.h>
13 #include <unistd.h>
14 #include <errno.h>
15 #include <time.h>
16
17 #ifndef __CONNECTION_H__
18 #define __CONNECTION_H__
19
20 #define PT_SYN_ONLY 0
21 #define PT_ACK_ONLY 1
22 #define PT_SYN_WITH_DATA 2
23 #define PT_KEY_EXCHANGE 3
24
25
26 class packet : public classbase
27 {
28  public:
29         long key;
30         int id;
31         short int type;
32         char data[MAXBUF];
33
34         packet();
35         ~packet();
36 };
37
38
39 class connection : public classbase
40 {
41  public:
42         long key;
43         int fd;                 // file descriptor
44         char host[256];         // hostname
45         long ip;                // ipv4 address
46         char inbuf[MAXBUF];     // recvQ
47         long bytes_in;
48         long bytes_out;
49         long cmds_in;
50         long cmds_out;
51         bool haspassed;
52         int port;
53         int registered;
54         short int state;
55         time_t lastping;
56         time_t signon;
57         time_t idle_lastmsg;
58         time_t nping;
59         char internal_addr[1024];
60         int internal_port;
61         
62         connection();
63         bool CreateListener(char* host, int p);
64         bool BeginLink(char* targethost, int port, char* password);
65         void TerminateLink(char* targethost);
66         bool SendPacket(char *message, char* host, int port, long ourkey);
67         bool RecvPacket(char *message, char* host, int &prt, long &theirkey);
68         bool SendSYN(char* host, int port);
69         bool SendACK(char* host, int port, int reply_id);
70         long GenKey();
71 };
72
73
74 #endif
75