Changeset 2343


Ignore:
Timestamp:
Jul 14, 2007, 4:29:21 PM (15 years ago)
Author:
joshe
Message:

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.

Location:
trunk/libtransmission
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r2339 r2343  
    2323 *****************************************************************************/
    2424
    25 #include <fcntl.h>
    2625#include <sys/types.h>
    2726#include <sys/stat.h>
     27#include <sys/socket.h>
     28#include <netinet/in.h>
     29#include <arpa/inet.h>
    2830#include <unistd.h>
     31#include <fcntl.h>
     32
    2933#include "transmission.h"
    3034
  • trunk/libtransmission/http.c

    r2334 r2343  
    2323 *****************************************************************************/
    2424
     25#include <sys/types.h>
     26#include <sys/socket.h>
     27#include <netinet/in.h>
     28#include <arpa/inet.h>
    2529#include <stdarg.h>
     30
    2631#include "transmission.h"
    2732#include "http.h"
     
    563568            if( !tr_netResolve( http->host, &addr ) )
    564569            {
    565                 http->sock = tr_netOpenTCP( addr, htons( http->port ), 1 );
     570                http->sock = tr_netOpenTCP( &addr, htons( http->port ), 1 );
    566571                http->state = HTTP_STATE_CONNECT;
    567572                break;
     
    585590                    tr_netResolveClose( http->resolve );
    586591                    http->resolve = NULL;
    587                     http->sock = tr_netOpenTCP( addr, htons( http->port ), 1 );
     592                    http->sock = tr_netOpenTCP( &addr, htons( http->port ), 1 );
    588593                    http->state = HTTP_STATE_CONNECT;
    589594            }
  • trunk/libtransmission/internal.h

    r2341 r2343  
    4545#include <sys/resource.h>
    4646#endif
    47 #include <sys/types.h>
    48 #include <sys/socket.h>
    49 #include <netinet/in.h>
    5047#include <assert.h>
    5148#ifdef SYS_BEOS
  • trunk/libtransmission/natpmp.c

    r2311 r2343  
    2222 * DEALINGS IN THE SOFTWARE.
    2323 *****************************************************************************/
     24
     25#include <sys/types.h>
     26#include <sys/socket.h>
     27#include <netinet/in.h>
     28#include <arpa/inet.h>
    2429
    2530#include "transmission.h"
     
    511516    }
    512517
    513     ret->fd = tr_netOpenUDP( addr, htons( PMP_PORT ), 1 );
     518    ret->fd = tr_netOpenUDP( &addr, htons( PMP_PORT ), 1 );
    514519    if( 0 > ret->fd )
    515520    {
     
    667672
    668673    addr.s_addr = inet_addr( PMP_MCAST_ADDR );
    669     fd = tr_netMcastOpen( PMP_PORT, addr );
     674    fd = tr_netMcastOpen( PMP_PORT, &addr );
    670675    if( 0 > fd )
    671676    {
  • trunk/libtransmission/net.c

    r2334 r2343  
    2323 *****************************************************************************/
    2424
    25 #include <netdb.h>
     25#include <sys/types.h>
    2626#include <sys/socket.h>
    2727#include <netinet/in.h>
     28#include <arpa/inet.h>
     29#include <netdb.h>
    2830#include <fcntl.h>
     31
    2932#include "transmission.h"
    3033#include "fdlimit.h"
     
    265268}
    266269
    267 int tr_netOpen( struct in_addr addr, in_port_t port, int type, int priority )
     270int tr_netOpen( const struct in_addr * addr, in_port_t port,
     271                int type, int priority )
    268272{
    269273    int s;
     
    277281    memset( &sock, 0, sizeof( sock ) );
    278282    sock.sin_family      = AF_INET;
    279     sock.sin_addr.s_addr = addr.s_addr;
     283    sock.sin_addr.s_addr = addr->s_addr;
    280284    sock.sin_port        = port;
    281285
     
    293297
    294298#ifdef IP_ADD_MEMBERSHIP
    295 int tr_netMcastOpen( int port, struct in_addr addr )
     299int tr_netMcastOpen( int port, const struct in_addr * addr )
    296300{
    297301    int fd;
     
    305309
    306310    memset( &req, 0, sizeof( req ) );
    307     req.imr_multiaddr.s_addr = addr.s_addr;
     311    req.imr_multiaddr.s_addr = addr->s_addr;
    308312    req.imr_interface.s_addr = htonl( INADDR_ANY );
    309313    if( setsockopt( fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &req, sizeof ( req ) ) )
     
    317321}
    318322#else /* IP_ADD_MEMBERSHIP */
    319 int tr_netMcastOpen( int port UNUSED, struct in_addr addr UNUSED )
     323int tr_netMcastOpen( int port UNUSED, const struct in_addr * addr UNUSED )
    320324{
    321325    return -1;
  • trunk/libtransmission/net.h

    r2334 r2343  
    2424
    2525
     26struct in_addr;
     27struct sockaddr_in;
     28
    2629/***********************************************************************
    2730 * DNS resolution
     
    4447#define tr_netOpenUDP( addr, port, priority ) \
    4548    tr_netOpen( (addr), (port), SOCK_DGRAM, (priority) )
    46 int  tr_netOpen    ( struct in_addr addr, in_port_t port, int type,
     49int  tr_netOpen    ( const struct in_addr * addr, in_port_t port, int type,
    4750                     int priority );
    48 int  tr_netMcastOpen( int port, struct in_addr addr );
     51int  tr_netMcastOpen( int port, const struct in_addr * addr );
    4952#define tr_netBindTCP( port ) tr_netBind( (port), SOCK_STREAM )
    5053#define tr_netBindUDP( port ) tr_netBind( (port), SOCK_DGRAM )
  • trunk/libtransmission/peer.c

    r2339 r2343  
    2323 *****************************************************************************/
    2424
     25#include <sys/types.h>
     26#include <sys/socket.h>
     27#include <netinet/in.h>
     28#include <arpa/inet.h>
    2529#include <stdarg.h>
     30
    2631#include "transmission.h"
    2732#include "bencode.h"
     
    233238 * Initializes a new peer.
    234239 **********************************************************************/
    235 tr_peer_t * tr_peerInit( struct in_addr addr, in_port_t port, int s, int from )
     240tr_peer_t * tr_peerInit( const struct in_addr * addr, in_port_t port,
     241                         int s, int from )
    236242{
    237243    tr_peer_t * peer;
     
    252258
    253259    peer->socket = s;
    254     peer->addr = addr;
     260    peer->addr = *addr;
    255261    peer->port = port;
    256262    peer->from = from;
     
    464470    if( PEER_STATUS_IDLE == peer->status )
    465471    {
    466         peer->socket = tr_netOpenTCP( peer->addr, peer->port, 0 );
     472        peer->socket = tr_netOpenTCP( &peer->addr, peer->port, 0 );
    467473        if( peer->socket < 0 )
    468474        {
  • trunk/libtransmission/peer.h

    r2339 r2343  
    2828#include "transmission.h"
    2929
     30struct in_addr;
    3031typedef struct tr_peer_s tr_peer_t;
    3132
    32 tr_peer_t * tr_peerInit            ( struct in_addr, in_port_t, int sock, int );
     33tr_peer_t * tr_peerInit            ( const struct in_addr *, in_port_t, int sock, int );
    3334void        tr_peerDestroy         ( tr_peer_t * );
    3435const char *tr_peerClient          ( tr_peer_t * );
  • trunk/libtransmission/platform.c

    r2328 r2343  
    384384#if defined( BSD )
    385385
     386#include <sys/types.h>
     387#include <sys/socket.h>
     388#include <netinet/in.h>
     389#include <arpa/inet.h>
    386390#include <sys/sysctl.h>
    387391#include <net/route.h>
  • trunk/libtransmission/shared.c

    r2311 r2343  
    2222 * DEALINGS IN THE SOFTWARE.
    2323 *****************************************************************************/
     24
     25#include <sys/types.h>
     26#include <sys/socket.h>
     27#include <netinet/in.h>
     28#include <arpa/inet.h>
    2429
    2530#include "transmission.h"
     
    355360            break;
    356361        }
    357         s->peers[s->peerCount++] = tr_peerInit( addr, 0, socket,
     362        s->peers[s->peerCount++] = tr_peerInit( &addr, 0, socket,
    358363                                                TR_PEER_FROM_INCOMING );
    359364    }
  • trunk/libtransmission/torrent.c

    r2339 r2343  
    2222 * DEALINGS IN THE SOFTWARE.
    2323 *****************************************************************************/
     24
     25#include <sys/types.h>
     26#include <sys/socket.h>
     27#include <netinet/in.h>
     28#include <arpa/inet.h>
    2429
    2530#include "transmission.h"
     
    865870        memcpy( &port, buf, 2 ); buf += 2;
    866871
    867         peer = tr_peerInit( addr, port, -1, from );
     872        peer = tr_peerInit( &addr, port, -1, from );
    868873        added += tr_torrentAttachPeer( tor, peer );
    869874    }
  • trunk/libtransmission/tracker.c

    r2334 r2343  
    2222 * DEALINGS IN THE SOFTWARE.
    2323 *****************************************************************************/
     24
     25#include <sys/types.h>
     26#include <sys/socket.h>
     27#include <netinet/in.h>
     28#include <arpa/inet.h>
    2429
    2530#include "transmission.h"
  • trunk/libtransmission/upnp.c

    r2328 r2343  
    2323 *****************************************************************************/
    2424
     25#include <sys/types.h>
     26#include <sys/socket.h>
     27#include <netinet/in.h>
     28#include <arpa/inet.h>
    2529#include <stdarg.h>
     30
    2631#include "transmission.h"
    2732#include "http.h"
     
    408413
    409414    addr.s_addr = inet_addr( SSDP_ADDR );
    410     fd = tr_netMcastOpen( SSDP_PORT, addr );
     415    fd = tr_netMcastOpen( SSDP_PORT, &addr );
    411416    if( 0 > fd )
    412417    {
Note: See TracChangeset for help on using the changeset viewer.