~ubuntu-branches/ubuntu/hardy/transmission/hardy-updates

1 by Philipp Benner
Import upstream version 0.6.1.dfsg
1
/******************************************************************************
1.1.2 by Philipp Benner
Import upstream version 0.82.dfsg
2
 * $Id: net.h 2615 2007-08-04 01:34:00Z charles $
1 by Philipp Benner
Import upstream version 0.6.1.dfsg
3
 *
4
 * Copyright (c) 2005-2006 Transmission authors and contributors
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
23
 *****************************************************************************/
24
1.1.2 by Philipp Benner
Import upstream version 0.82.dfsg
25
#ifndef _TR_NET_H_
26
#define _TR_NET_H_
27
28
#ifdef WIN32
29
    #include <inttypes.h>
30
    #include <winsock2.h>
31
    typedef int socklen_t;
32
    typedef uint16_t tr_port_t;
33
#elif defined(__BEOS__)
34
    #include <sys/socket.h>
35
    #include <netinet/in.h>
36
    typedef unsigned short tr_port_t;
37
    typedef int socklen_t;
38
#else
39
    #include <sys/socket.h>
40
    #include <netinet/in.h>
41
    #include <arpa/inet.h>
42
    typedef in_port_t tr_port_t;
43
#endif
44
45
#ifdef WIN32
46
    #define ECONNREFUSED WSAECONNREFUSED
47
    #define ECONNRESET   WSAECONNRESET
48
    #define EHOSTUNREACH WSAEHOSTUNREACH
49
    #define EINPROGRESS  WSAEINPROGRESS
50
    #define ENOTCONN     WSAENOTCONN
51
    #define EWOULDBLOCK  WSAEWOULDBLOCK
52
    #define sockerrno WSAGetLastError( )
53
#else
54
    #include <errno.h>
55
    #define sockerrno errno
56
#endif
57
58
#ifndef INADDR_NONE
59
#define INADDR_NONE 0xffffffff
60
#endif
61
62
struct in_addr;
63
struct sockaddr_in;
1 by Philipp Benner
Import upstream version 0.6.1.dfsg
64
65
/***********************************************************************
66
 * DNS resolution
67
 **********************************************************************/
1.1.1 by Philipp Benner
Import upstream version 0.72.dfsg
68
int tr_netResolve( const char *, struct in_addr * );
1 by Philipp Benner
Import upstream version 0.6.1.dfsg
69
70
typedef struct tr_resolve_s tr_resolve_t;
1.1.2 by Philipp Benner
Import upstream version 0.82.dfsg
71
void           tr_netResolveThreadInit( void );
72
void           tr_netResolveThreadClose( void );
73
tr_resolve_t * tr_netResolveInit( const char * address );
1.1.1 by Philipp Benner
Import upstream version 0.72.dfsg
74
tr_tristate_t  tr_netResolvePulse( tr_resolve_t *, struct in_addr * );
1 by Philipp Benner
Import upstream version 0.6.1.dfsg
75
void           tr_netResolveClose( tr_resolve_t * );
76
77
78
/***********************************************************************
1.1.1 by Philipp Benner
Import upstream version 0.72.dfsg
79
 * TCP and UDP sockets
1 by Philipp Benner
Import upstream version 0.6.1.dfsg
80
 **********************************************************************/
1.1.2 by Philipp Benner
Import upstream version 0.82.dfsg
81
int  tr_netOpenTCP  ( const struct in_addr * addr, tr_port_t port, int priority );
82
int  tr_netOpenUDP  ( const struct in_addr * addr, tr_port_t port, int priority );
83
int  tr_netMcastOpen( int port, const struct in_addr * addr );
84
int  tr_netBindTCP  ( int port );
85
int  tr_netBindUDP  ( int port );
86
int  tr_netAccept   ( int s, struct in_addr *, tr_port_t * );
87
void tr_netClose    ( int s );
1 by Philipp Benner
Import upstream version 0.6.1.dfsg
88
89
#define TR_NET_BLOCK 0x80000000
90
#define TR_NET_CLOSE 0x40000000
1.1.2 by Philipp Benner
Import upstream version 0.82.dfsg
91
int  tr_netSend    ( int s, const void * buf, int size );
1.1.1 by Philipp Benner
Import upstream version 0.72.dfsg
92
#define tr_netRecv( s, buf, size ) tr_netRecvFrom( (s), (buf), (size), NULL )
93
int  tr_netRecvFrom( int s, uint8_t * buf, int size, struct sockaddr_in * );
94
95
void tr_netNtop( const struct in_addr * addr, char * buf, int len );
96
1.1.2 by Philipp Benner
Import upstream version 0.82.dfsg
97
void tr_netInit ( void );
98
1.1.1 by Philipp Benner
Import upstream version 0.72.dfsg
99
100
#define tr_addrcmp( aa, bb )    memcmp( ( void * )(aa), ( void * )(bb), 4)
1.1.2 by Philipp Benner
Import upstream version 0.82.dfsg
101
102
#endif /* _TR_NET_H_ */