~ubuntu-branches/ubuntu/jaunty/transmission/jaunty-security

« back to all changes in this revision

Viewing changes to libtransmission/net.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2008-12-28 18:50:08 UTC
  • mfrom: (1.1.20 upstream)
  • Revision ID: james.westby@ubuntu.com-20081228185008-2u8ac12dbckrwn7c
Tags: 1.42-0ubuntu1
* New upstream version (LP: #311959):
  - All platforms:
    - Better peer management in large swarms
    - Support BitTorrent Enhancement Proposal (BEP) #21 "Extension for 
      Partial Seeds"
    - Partial support for BEP #6 "Fast Extension" (reject, have all/none)
    - Honor the peer's BEP #10 reqq key, when available
    - Fix 1.40 "Got HTTP Status Code: 0" error message
    - Fix 1.40 "lazy bitfield" error
    - Fix 1.40 "jumpy upload speed" bug
    - Fix handshake peer_id error
    - Corrrectly handle Windows-style newlines in Bluetack blocklists
    - More accurate bandwidth measurement
    - File selection & priority was reset when editing a torrent's 
      tracker list
    - Fix autoconf/automake build warnings
  - GTK+:
    - In the Details dialog's peer tabs, rows were sometimes duplicated
    - Minor bugfixes, usability changes, and locale improvements
    - Three new translations: Afrikaans, Asturian, Bosnian
    - Sixteen updated translations
  - Daemon:
    - Fix 1.40 bug in handling IP whitelist
    - Minor bugfixes and output cleanup
    - Windows portability
  - CLI:
    - Fix minor free-memory-read bug

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: net.c 6944 2008-10-22 13:57:30Z charles $
 
2
 * $Id: net.c 7455 2008-12-22 00:51:14Z charles $
3
3
 *
4
4
 * Copyright (c) 2005-2008 Transmission authors and contributors
5
5
 *
63
63
    }
64
64
}
65
65
 
 
66
tr_bool
 
67
tr_isAddress( const tr_address * a )
 
68
{
 
69
    return a != NULL; /* this is implemented better in 1.50 */
 
70
}
 
71
 
 
72
 
66
73
/***********************************************************************
67
74
 * DNS resolution
68
75
 *
122
129
    return makeSocketNonBlocking( tr_fdSocketCreate( type ) );
123
130
}
124
131
 
 
132
static void
 
133
setSndBuf( tr_session * session UNUSED, int fd UNUSED )
 
134
{
 
135
#if 0
 
136
    if( fd >= 0 )
 
137
    {
 
138
        const int sndbuf = session->so_sndbuf;
 
139
        const int rcvbuf = session->so_rcvbuf;
 
140
        setsockopt( fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof( sndbuf ) );
 
141
        setsockopt( fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof( rcvbuf ) );
 
142
    }
 
143
#endif
 
144
}
 
145
 
125
146
int
126
 
tr_netOpenTCP( const struct in_addr * addr,
127
 
               tr_port_t              port )
 
147
tr_netOpenTCP( tr_session            * session,
 
148
               const struct in_addr  * addr,
 
149
               tr_port_t               port )
128
150
{
129
151
    int                s;
130
152
    struct sockaddr_in sock;
133
155
    if( ( s = createSocket( type ) ) < 0 )
134
156
        return -1;
135
157
 
 
158
    setSndBuf( session, s );
 
159
 
136
160
    memset( &sock, 0, sizeof( sock ) );
137
161
    sock.sin_family      = AF_INET;
138
162
    sock.sin_addr.s_addr = addr->s_addr;
197
221
}
198
222
 
199
223
int
200
 
tr_netAccept( int              b,
201
 
              struct in_addr * addr,
202
 
              tr_port_t *      port )
 
224
tr_netAccept( tr_session      * session,
 
225
              int               b,
 
226
              struct in_addr  * addr,
 
227
              tr_port_t       * port )
203
228
{
204
 
    return makeSocketNonBlocking( tr_fdSocketAccept( b, addr, port ) );
 
229
    int fd = makeSocketNonBlocking( tr_fdSocketAccept( b, addr, port ) );
 
230
    setSndBuf( session, fd );
 
231
    return fd;
205
232
}
206
233
 
207
234
void
222
249
                 cast[0], cast[1], cast[2], cast[3] );
223
250
}
224
251
 
 
252
int
 
253
tr_compareAddresses( const struct in_addr * a, const struct in_addr * b )
 
254
{
 
255
    if( a->s_addr != b->s_addr )
 
256
        return a->s_addr < b->s_addr ? -1 : 1;
 
257
 
 
258
    return 0;
 
259
}