]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/connection.h
Added '@' (WALLOPS) link token
[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 #include <vector>
17
18 #ifndef __CONNECTION_H__
19 #define __CONNECTION_H__
20
21 #define PT_SYN_ONLY 0
22 #define PT_ACK_ONLY 1
23 #define PT_SYN_WITH_DATA 2
24 #define PT_KEY_EXCHANGE 3
25
26
27 class packet : public classbase
28 {
29  public:
30         long key;
31         int id;
32         short int type;
33         char data[MAXBUF];
34
35         packet();
36         ~packet();
37 };
38
39 class packet_buf : public classbase
40 {
41  public:
42         packet p;
43         char host[128];
44         int port;
45 };
46
47
48
49 class connection : public classbase
50 {
51  public:
52         long key;
53         int fd;                 // file descriptor
54         char host[256];         // hostname
55         long ip;                // ipv4 address
56         char inbuf[MAXBUF];     // recvQ
57         long bytes_in;
58         long bytes_out;
59         long cmds_in;
60         long cmds_out;
61         bool haspassed;
62         int port;
63         int registered;
64         short int state;
65         time_t lastping;
66         time_t signon;
67         time_t idle_lastmsg;
68         time_t nping;
69         char internal_addr[1024];
70         int internal_port;
71         std::vector<packet_buf> buffer;
72         
73         connection();
74         bool CreateListener(char* host, int p);
75         bool BeginLink(char* targethost, int port, char* password);
76         void TerminateLink(char* targethost);
77         bool SendPacket(char *message, char* host, int port, long ourkey);
78         bool RecvPacket(char *message, char* host, int &prt, long &theirkey);
79         bool SendSYN(char* host, int port);
80         bool SendACK(char* host, int port, int reply_id);
81         long GenKey();
82 };
83
84
85 #endif
86