1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
4 * $Id: tcplink.h 2096 2001-07-31 01:00:39Z warmenhoven $
6 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
7 * Bill Soudan <soudan@kde.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 #include <sys/socket.h>
36 #include <netinet/in.h>
40 #include "icqpacket.h"
43 /* link mode bitfield values */
44 #define TCP_LINK_MODE_RAW 1
45 #define TCP_LINK_MODE_HELLOWAIT 2
46 #define TCP_LINK_MODE_LISTEN 4
47 #define TCP_LINK_MODE_CONNECTING 8
48 #define TCP_LINK_SOCKS_CONNECTING 16
49 #define TCP_LINK_SOCKS_AUTHORIZATION 32
50 #define TCP_LINK_SOCKS_AUTHSTATUS 64
51 #define TCP_LINK_SOCKS_NOAUTHSTATUS 128
52 #define TCP_LINK_SOCKS_CROSSCONNECT 256
53 #define TCP_LINK_SOCKS_CONNSTATUS 512
56 #define TCP_LINK_MESSAGE 1
57 #define TCP_LINK_CHAT 2
58 #define TCP_LINK_FILE 3
60 #define icq_TCPLinkBufferSize 4096
61 #define TCP_LINK_CONNECT_TIMEOUT 30
63 struct icq_TCPLink_s
{
65 /* icq_TCPLink ICQLINK, type, mode, and session */
72 /* socket parameters */
74 struct sockaddr_in socket_address
;
75 struct sockaddr_in remote_address
;
77 /* data buffer for receive calls */
78 char buffer
[icq_TCPLinkBufferSize
];
82 icq_List
*received_queue
;
85 /* icq specific data, initialized by hello packet */
87 unsigned long remote_version
;
88 unsigned long remote_uin
;
91 /* timeout for connect operation */
92 icq_Timeout
*connect_timeout
;
96 icq_TCPLink
*icq_TCPLinkNew(icq_Link
*icqlink
);
97 void icq_TCPLinkDelete(void *p
);
98 void icq_TCPLinkClose(icq_TCPLink
*p
);
99 void icq_TCPLinkNodeDelete(icq_ListNode
*p
);
101 int icq_TCPLinkConnect(icq_TCPLink
*plink
, DWORD uin
, int port
);
102 icq_TCPLink
*icq_TCPLinkAccept(icq_TCPLink
*plink
);
103 int icq_TCPLinkListen(icq_TCPLink
*plink
);
105 void icq_TCPLinkOnDataReceived(icq_TCPLink
*plink
);
106 void icq_TCPLinkOnPacketReceived(icq_TCPLink
*plink
, icq_Packet
*p
);
107 void icq_TCPLinkOnConnect(icq_TCPLink
*plink
);
108 void icq_TCPLinkOnConnectTimeout(icq_TCPLink
*plink
);
110 unsigned long icq_TCPLinkSendSeq(icq_TCPLink
*plink
, icq_Packet
*p
,
111 unsigned long sequence
);
112 void icq_TCPLinkSend(icq_TCPLink
*plink
, icq_Packet
*p
);
114 void icq_TCPLinkProcessReceived(icq_TCPLink
*plink
);
116 icq_TCPLink
*icq_FindTCPLink(icq_Link
*icqlink
, unsigned long uin
, int type
);
118 void icq_ChatRusConv_n(const char to
[4], char *t_in
, int t_len
);
120 #endif /* _TCP_LINK_H_ */