]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/connection.h
94b657288b019d8e86d7f6bae323d01d3daf2dd8
[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.h>
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
24
25 class packet : public classbase
26 {
27  public:
28         long key;
29         short int id;
30         short int type;
31         char data[MAXBUF];
32
33         packet();
34         ~packet();
35 };
36
37
38 class connection : public classbase
39 {
40  public:
41         long key;
42         int fd;                 // file descriptor
43         char host[256];         // hostname
44         long ip;                // ipv4 address
45         char inbuf[MAXBUF];     // recvQ
46         long bytes_in;
47         long bytes_out;
48         long cmds_in;
49         long cmds_out;
50         bool haspassed;
51         int port;
52         int registered;
53         time_t lastping;
54         time_t signon;
55         time_t idle_lastmsg;
56         time_t nping;
57         
58         connection();
59         bool CreateListener(char* host, int port);
60         bool BeginLink(char* targethost, int port, char* password);
61         void TerminateLink(char* targethost);
62         bool SendPacket(char *message, char* host, int port);
63         bool RecvPacket(char *message, char* host, int &port);
64         bool SendSYN(char* host, int port);
65         bool SendACK(char* host, int port, int reply_id);
66         long GenKey();
67 };
68
69
70 #endif
71