1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
* Copyright 2006 Marijn Kruisselbrink and others *
* Copyright 2007 Uli Meis <a.sporto+bee@gmail.com> *
\********************************************************************/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License with
the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
if not, write to the Free Software Foundation, Inc., 59 Temple Place,
Suite 330, Boston, MA 02111-1307 USA
*/
/*
* DCC SEND
*
* Historically, DCC means send 1024 Bytes and wait for a 4 byte reply
* acknowledging all transferred data. This is ridiculous for two reasons. The
* first being that TCP is a stream oriented protocol that doesn't care much
* about your idea of a packet. The second reason being that TCP is a reliable
* transfer protocol with its own sophisticated ACK mechanism, making DCCs ACK
* mechanism look like a joke. For these reasons, DCCs requirements have
* (hopefully) been relaxed in most implementations and this implementation
* depends upon at least the following: The 1024 bytes need not be transferred
* at once, i.e. packets can be smaller. A second relaxation has apparently
* gotten the name "DCC SEND ahead" which basically means to not give a damn
* about those DCC ACKs and just send data as you please. This behaviour is
* enabled by default. Note that this also means that packets may be as large
* as the maximum segment size.
*/
#ifndef _DCC_H
#define _DCC_H
/* Send an ACK after receiving this amount of data */
#define DCC_PACKET_SIZE 1024
typedef struct dcc_file_transfer {
struct im_connection *ic;
/*
* Depending in the status of the file transfer, this is either the socket that is
* being listened on for connections, or the socket over which the file transfer is
* taking place.
*/
int fd;
/*
* IDs returned by b_input_add for watch_ing over the above socket.
*/
gint watch_in; /* readable */
gint watch_out; /* writable */
/*
* The total amount of bytes that have been sent to the irc client.
*/
size_t bytes_sent;
/* imc's handle */
file_transfer_t *ft;
/* if we're receiving, this is the sender's socket address */
struct sockaddr_storage saddr;
} dcc_file_transfer_t;
file_transfer_t *dccs_send_start( struct im_connection *ic, char *user_nick, char *file_name, size_t file_size );
void dcc_canceled( file_transfer_t *file, char *reason );
gboolean dccs_send_write( file_transfer_t *file, char *data, unsigned int data_size );
file_transfer_t *dcc_request( struct im_connection *ic, char *line );
#endif
|