1152
|
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2 #ifndef _TCP_LINK_H_
|
|
3 #define _TCP_LINK_H_
|
|
4
|
|
5 #ifdef HAVE_CONFIG_H
|
|
6 #include <config.h>
|
|
7 #endif
|
|
8
|
|
9 #ifdef _WIN32
|
|
10 #include <winsock.h>
|
|
11 #else
|
|
12 #include <netinet/in.h>
|
|
13 #endif
|
|
14
|
|
15 #include <time.h>
|
|
16
|
|
17 #include "icq.h"
|
|
18 #include "icqpacket.h"
|
|
19 #include "list.h"
|
|
20
|
|
21 /* link mode bitfield values */
|
|
22 #define TCP_LINK_MODE_RAW 1
|
|
23 #define TCP_LINK_MODE_HELLOWAIT 2
|
|
24 #define TCP_LINK_MODE_LISTEN 4
|
|
25 #define TCP_LINK_MODE_CONNECTING 8
|
|
26 #define TCP_LINK_SOCKS_CONNECTING 16
|
|
27 #define TCP_LINK_SOCKS_AUTHORIZATION 32
|
|
28 #define TCP_LINK_SOCKS_AUTHSTATUS 64
|
|
29 #define TCP_LINK_SOCKS_NOAUTHSTATUS 128
|
|
30 #define TCP_LINK_SOCKS_CROSSCONNECT 256
|
|
31 #define TCP_LINK_SOCKS_CONNSTATUS 512
|
|
32
|
|
33 /* link types */
|
|
34 #define TCP_LINK_MESSAGE 1
|
|
35 #define TCP_LINK_CHAT 2
|
|
36 #define TCP_LINK_FILE 3
|
|
37
|
|
38 #define icq_TCPLinkBufferSize 4096
|
|
39 #define TCP_LINK_CONNECT_TIMEOUT 30
|
|
40
|
|
41 typedef struct icq_TCPLink_s
|
|
42 {
|
|
43 /* icq_TCPLink ICQLINK, type, mode, and session */
|
|
44 ICQLINK *icqlink;
|
|
45 int type;
|
|
46 int mode;
|
|
47 int proxy_status;
|
|
48 void *session;
|
|
49
|
|
50 /* socket parameters */
|
|
51 int socket;
|
|
52 struct sockaddr_in socket_address;
|
|
53 struct sockaddr_in remote_address;
|
|
54
|
|
55 /* data buffer for receive calls */
|
|
56 char buffer[icq_TCPLinkBufferSize];
|
|
57 int buffer_count;
|
|
58
|
|
59 /* packet queues */
|
|
60 list *received_queue;
|
|
61 list *send_queue;
|
|
62
|
|
63 /* icq specific data, initialized by hello packet */
|
|
64 unsigned long id;
|
|
65 unsigned long remote_version;
|
|
66 unsigned long remote_uin;
|
|
67 char flags;
|
|
68
|
|
69 /* connect timer */
|
|
70 time_t connect_time;
|
|
71
|
|
72 } icq_TCPLink;
|
|
73
|
|
74 icq_TCPLink *icq_TCPLinkNew(ICQLINK *link);
|
|
75 void icq_TCPLinkDelete(void *p);
|
|
76 void icq_TCPLinkClose(icq_TCPLink *p);
|
|
77 void icq_TCPLinkNodeDelete(list_node *p);
|
|
78
|
|
79 int icq_TCPLinkConnect(icq_TCPLink *plink, DWORD uin, int port);
|
|
80 icq_TCPLink *icq_TCPLinkAccept(icq_TCPLink *plink);
|
|
81 int icq_TCPLinkListen(icq_TCPLink *plink);
|
|
82
|
|
83 int icq_TCPLinkOnDataReceived(icq_TCPLink *plink);
|
|
84 void icq_TCPLinkOnPacketReceived(icq_TCPLink *plink, icq_Packet *p);
|
|
85 void icq_TCPLinkOnConnect(icq_TCPLink *plink);
|
|
86
|
|
87 unsigned long icq_TCPLinkSendSeq(icq_TCPLink *plink, icq_Packet *p,
|
|
88 unsigned long sequence);
|
|
89 void icq_TCPLinkSend(icq_TCPLink *plink, icq_Packet *p);
|
|
90
|
|
91 void icq_TCPLinkProcessReceived(icq_TCPLink *plink);
|
|
92
|
|
93 icq_TCPLink *icq_FindTCPLink(ICQLINK *link, unsigned long uin, int type);
|
|
94
|
|
95 void icq_ChatRusConv_n(const char to[4], char *t_in, int t_len);
|
|
96
|
|
97 #endif /* _TCP_LINK_H_ */
|