source: trunk/libtransmission/net.h @ 2343

Last change on this file since 2343 was 2343, checked in by joshe, 14 years ago

Change a couple functions to take an in_addr pointer instead of an in_addr.
Forward declare struct in_addr and include the relevant headers in the .c files where it's used.

  • Property svn:keywords set to Date Rev Author Id
File size: 3.0 KB
Line 
1/******************************************************************************
2 * $Id: net.h 2343 2007-07-14 16:29:21Z joshe $
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
25
26struct in_addr;
27struct sockaddr_in;
28
29/***********************************************************************
30 * DNS resolution
31 **********************************************************************/
32int tr_netResolve( const char *, struct in_addr * );
33
34typedef struct tr_resolve_s tr_resolve_t;
35void           tr_netResolveThreadInit();
36void           tr_netResolveThreadClose();
37tr_resolve_t * tr_netResolveInit( const char * );
38tr_tristate_t  tr_netResolvePulse( tr_resolve_t *, struct in_addr * );
39void           tr_netResolveClose( tr_resolve_t * );
40
41
42/***********************************************************************
43 * TCP and UDP sockets
44 **********************************************************************/
45#define tr_netOpenTCP( addr, port, priority ) \
46    tr_netOpen( (addr), (port), SOCK_STREAM, (priority) )
47#define tr_netOpenUDP( addr, port, priority ) \
48    tr_netOpen( (addr), (port), SOCK_DGRAM, (priority) )
49int  tr_netOpen    ( const struct in_addr * addr, in_port_t port, int type,
50                     int priority );
51int  tr_netMcastOpen( int port, const struct in_addr * addr );
52#define tr_netBindTCP( port ) tr_netBind( (port), SOCK_STREAM )
53#define tr_netBindUDP( port ) tr_netBind( (port), SOCK_DGRAM )
54int  tr_netBind    ( int port, int type );
55int  tr_netAccept  ( int s, struct in_addr *, in_port_t * );
56void tr_netClose   ( int s );
57
58#define TR_NET_BLOCK 0x80000000
59#define TR_NET_CLOSE 0x40000000
60int  tr_netSend    ( int s, const void * buf, int size );
61#define tr_netRecv( s, buf, size ) tr_netRecvFrom( (s), (buf), (size), NULL )
62int  tr_netRecvFrom( int s, uint8_t * buf, int size, struct sockaddr_in * );
63
64void tr_netNtop( const struct in_addr * addr, char * buf, int len );
65
66
67#define tr_addrcmp( aa, bb )    memcmp( ( void * )(aa), ( void * )(bb), 4)
Note: See TracBrowser for help on using the repository browser.