Ignore:
Timestamp:
Dec 5, 2012, 5:29:46 PM (8 years ago)
Author:
jordan
Message:

Follow more common whitespace style conventions in the C code (libtransmission, daemon, utils, cli, gtk).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/tr-lpd.c

    r12229 r13625  
    2424#include <errno.h>
    2525#include <stdio.h>
    26 #include <string.h> /* strlen(), strncpy(), strstr(), memset() */
     26#include <string.h> /* strlen (), strncpy (), strstr (), memset () */
    2727
    2828/* posix */
    2929#include <signal.h> /* sig_atomic_t */
    3030#include <sys/time.h>
    31 #include <unistd.h> /* close() */
    32 #include <ctype.h> /* toupper() */
     31#include <unistd.h> /* close () */
     32#include <ctype.h> /* toupper () */
    3333#ifdef WIN32
    3434  #include <w32api.h>
    35   #define WINDOWS  WindowsXP  /* freeaddrinfo(),getaddrinfo(),getnameinfo() */
     35  #define WINDOWS  WindowsXP  /* freeaddrinfo (),getaddrinfo (),getnameinfo () */
    3636  #include <inttypes.h>
    3737  #include <ws2tcpip.h>
     
    3939#else
    4040  #include <sys/types.h>
    41   #include <sys/socket.h> /* socket(), bind() */
     41  #include <sys/socket.h> /* socket (), bind () */
    4242  #include <netinet/in.h> /* sockaddr_in */
    4343#endif
     
    5050#include "transmission.h"
    5151#include "net.h"
    52 #include "peer-mgr.h" /* tr_peerMgrAddPex() */
     52#include "peer-mgr.h" /* tr_peerMgrAddPex () */
    5353#include "session.h"
    54 #include "torrent.h" /* tr_torrentFindFromHash() */
     54#include "torrent.h" /* tr_torrentFindFromHash () */
    5555#include "tr-lpd.h"
    5656#include "utils.h"
     
    6767*/
    6868
    69 static void event_callback( int, short, void* );
     69static void event_callback (int, short, void*);
    7070
    7171enum {
     
    160160* the lpd_protocolVersion structure.
    161161*/
    162 static const char* lpd_extractHeader( const char* s, struct lpd_protocolVersion* const ver )
     162static const char* lpd_extractHeader (const char* s, struct lpd_protocolVersion* const ver)
    163163{
    164164    int major = -1, minor = -1;
    165165    size_t len;
    166166
    167     assert( s != NULL );
    168     len = strlen( s );
     167    assert (s != NULL);
     168    len = strlen (s);
    169169
    170170    /* something might be rotten with this chunk of data */
    171     if( len == 0 || len > lpd_maxDatagramLength )
     171    if (len == 0 || len > lpd_maxDatagramLength)
    172172        return NULL;
    173173
    174174    /* now we can attempt to look up the BT-SEARCH header */
    175     if( sscanf( s, "BT-SEARCH * HTTP/%d.%d" CRLF, &major, &minor ) != 2 )
     175    if (sscanf (s, "BT-SEARCH * HTTP/%d.%d" CRLF, &major, &minor) != 2)
    176176        return NULL;
    177177
    178     if( major < 0 || minor < 0 )
     178    if (major < 0 || minor < 0)
    179179        return NULL;
    180180
     
    182182        /* a pair of blank lines at the end of the string, no place else */
    183183        const char* const two_blank = CRLF CRLF CRLF;
    184         const char* const end = strstr( s, two_blank );
    185 
    186         if( end == NULL || strlen( end ) > strlen( two_blank ) )
     184        const char* const end = strstr (s, two_blank);
     185
     186        if (end == NULL || strlen (end) > strlen (two_blank))
    187187            return NULL;
    188188    }
    189189
    190     if( ver != NULL )
     190    if (ver != NULL)
    191191    {
    192192        ver->major = major;
     
    195195
    196196    /* separate the header, begins with CRLF */
    197     return strstr( s, CRLF );
     197    return strstr (s, CRLF);
    198198}
    199199
     
    212212*   - copy back value from end to next "\r\n"
    213213*/
    214 static int lpd_extractParam( const char* const str, const char* const name, int n, char* const val )
     214static int lpd_extractParam (const char* const str, const char* const name, int n, char* const val)
    215215{
    216216    /* configure maximum length of search string here */
     
    219219    const char* pos;
    220220
    221     assert( str != NULL && name != NULL );
    222     assert( val != NULL );
    223 
    224     if( strlen( name ) > maxLength - strlen( CRLF ": " ) )
     221    assert (str != NULL && name != NULL);
     222    assert (val != NULL);
     223
     224    if (strlen (name) > maxLength - strlen (CRLF ": "))
    225225        return 0;
    226226
    227227    /* compose the string token to search for */
    228     snprintf( sstr, maxLength, CRLF "%s: ", name );
    229 
    230     pos = strstr( str, sstr );
    231     if( pos == NULL )
     228    snprintf (sstr, maxLength, CRLF "%s: ", name);
     229
     230    pos = strstr (str, sstr);
     231    if (pos == NULL)
    232232        return 0; /* search was not successful */
    233233
    234234    {
    235         const char* const beg = pos + strlen( sstr );
    236         const char* const new_line = strstr( beg, CRLF );
     235        const char* const beg = pos + strlen (sstr);
     236        const char* const new_line = strstr (beg, CRLF);
    237237
    238238        /* the value is delimited by the next CRLF */
     
    241241        /* if value string hits the length limit n,
    242242         * leave space for a trailing '\0' character */
    243         if( len < n-- )
     243        if (len < n--)
    244244            n = len;
    245245
    246         strncpy( val, beg, n );
     246        strncpy (val, beg, n);
    247247        val[n] = 0;
    248248    }
     
    255255* @} */
    256256
    257 static void on_upkeep_timer( int, short, void * );
     257static void on_upkeep_timer (int, short, void *);
    258258
    259259/**
     
    266266* IPv4 only for the time being.
    267267*/
    268 int tr_lpdInit( tr_session* ss, tr_address* tr_addr UNUSED )
     268int tr_lpdInit (tr_session* ss, tr_address* tr_addr UNUSED)
    269269{
    270270    struct ip_mreq mcastReq;
    271271    const int opt_on = 1, opt_off = 0;
    272272
    273     if( session ) /* already initialized */
     273    if (session) /* already initialized */
    274274        return -1;
    275275
    276     assert( lpd_announceInterval > 0 );
    277     assert( lpd_announceScope > 0 );
    278 
    279     lpd_port = tr_sessionGetPeerPort( ss );
    280     if( lpd_port <= 0 )
     276    assert (lpd_announceInterval > 0);
     277    assert (lpd_announceScope > 0);
     278
     279    lpd_port = tr_sessionGetPeerPort (ss);
     280    if (lpd_port <= 0)
    281281        return -1;
    282282
    283     tr_ndbg( "LPD", "Initialising Local Peer Discovery" );
     283    tr_ndbg ("LPD", "Initialising Local Peer Discovery");
    284284
    285285    /* setup datagram socket (receive) */
    286286    {
    287         lpd_socket = socket( PF_INET, SOCK_DGRAM, 0 );
    288         if( lpd_socket < 0 )
    289             goto fail;
    290 
    291         if( evutil_make_socket_nonblocking( lpd_socket ) < 0 )
    292             goto fail;
    293 
    294         if( setsockopt( lpd_socket, SOL_SOCKET, SO_REUSEADDR,
    295                 &opt_on, sizeof opt_on ) < 0 )
    296             goto fail;
    297 
    298         memset( &lpd_mcastAddr, 0, sizeof lpd_mcastAddr );
     287        lpd_socket = socket (PF_INET, SOCK_DGRAM, 0);
     288        if (lpd_socket < 0)
     289            goto fail;
     290
     291        if (evutil_make_socket_nonblocking (lpd_socket) < 0)
     292            goto fail;
     293
     294        if (setsockopt (lpd_socket, SOL_SOCKET, SO_REUSEADDR,
     295                &opt_on, sizeof opt_on) < 0)
     296            goto fail;
     297
     298        memset (&lpd_mcastAddr, 0, sizeof lpd_mcastAddr);
    299299        lpd_mcastAddr.sin_family = AF_INET;
    300         lpd_mcastAddr.sin_port = htons( lpd_mcastPort );
    301         if( evutil_inet_pton( lpd_mcastAddr.sin_family, lpd_mcastGroup,
    302                 &lpd_mcastAddr.sin_addr ) < 0 )
    303             goto fail;
    304 
    305         if( bind( lpd_socket, (struct sockaddr*) &lpd_mcastAddr,
    306                 sizeof lpd_mcastAddr ) < 0 )
     300        lpd_mcastAddr.sin_port = htons (lpd_mcastPort);
     301        if (evutil_inet_pton (lpd_mcastAddr.sin_family, lpd_mcastGroup,
     302                &lpd_mcastAddr.sin_addr) < 0)
     303            goto fail;
     304
     305        if (bind (lpd_socket, (struct sockaddr*) &lpd_mcastAddr,
     306                sizeof lpd_mcastAddr) < 0)
    307307            goto fail;
    308308
    309309        /* we want to join that LPD multicast group */
    310         memset( &mcastReq, 0, sizeof mcastReq );
     310        memset (&mcastReq, 0, sizeof mcastReq);
    311311        mcastReq.imr_multiaddr = lpd_mcastAddr.sin_addr;
    312         mcastReq.imr_interface.s_addr = htonl( INADDR_ANY );
    313         if( setsockopt( lpd_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
    314                 &mcastReq, sizeof mcastReq ) < 0 )
    315             goto fail;
    316 
    317         if( setsockopt( lpd_socket, IPPROTO_IP, IP_MULTICAST_LOOP,
    318                 &opt_off, sizeof opt_off ) < 0 )
     312        mcastReq.imr_interface.s_addr = htonl (INADDR_ANY);
     313        if (setsockopt (lpd_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
     314                &mcastReq, sizeof mcastReq) < 0)
     315            goto fail;
     316
     317        if (setsockopt (lpd_socket, IPPROTO_IP, IP_MULTICAST_LOOP,
     318                &opt_off, sizeof opt_off) < 0)
    319319            goto fail;
    320320    }
     
    324324        const unsigned char scope = lpd_announceScope;
    325325
    326         lpd_socket2 = socket( PF_INET, SOCK_DGRAM, 0 );
    327         if( lpd_socket2 < 0 )
    328             goto fail;
    329 
    330         if( evutil_make_socket_nonblocking( lpd_socket2 ) < 0 )
     326        lpd_socket2 = socket (PF_INET, SOCK_DGRAM, 0);
     327        if (lpd_socket2 < 0)
     328            goto fail;
     329
     330        if (evutil_make_socket_nonblocking (lpd_socket2) < 0)
    331331            goto fail;
    332332
    333333        /* configure outbound multicast TTL */
    334         if( setsockopt( lpd_socket2, IPPROTO_IP, IP_MULTICAST_TTL,
    335                 &scope, sizeof scope ) < 0 )
    336             goto fail;
    337 
    338         if( setsockopt( lpd_socket2, IPPROTO_IP, IP_MULTICAST_LOOP,
    339                 &opt_off, sizeof opt_off ) < 0 )
     334        if (setsockopt (lpd_socket2, IPPROTO_IP, IP_MULTICAST_TTL,
     335                &scope, sizeof scope) < 0)
     336            goto fail;
     337
     338        if (setsockopt (lpd_socket2, IPPROTO_IP, IP_MULTICAST_LOOP,
     339                &opt_off, sizeof opt_off) < 0)
    340340            goto fail;
    341341    }
     
    346346     * any announcement received during the initial interval will be discarded. */
    347347
    348     lpd_event = event_new( ss->event_base, lpd_socket, EV_READ | EV_PERSIST, event_callback, NULL );
    349     event_add( lpd_event, NULL );
    350 
    351     upkeep_timer = evtimer_new( ss->event_base, on_upkeep_timer, ss );
    352     tr_timerAdd( upkeep_timer, UPKEEP_INTERVAL_SECS, 0 );
    353 
    354     tr_ndbg( "LPD", "Local Peer Discovery initialised" );
     348    lpd_event = event_new (ss->event_base, lpd_socket, EV_READ | EV_PERSIST, event_callback, NULL);
     349    event_add (lpd_event, NULL);
     350
     351    upkeep_timer = evtimer_new (ss->event_base, on_upkeep_timer, ss);
     352    tr_timerAdd (upkeep_timer, UPKEEP_INTERVAL_SECS, 0);
     353
     354    tr_ndbg ("LPD", "Local Peer Discovery initialised");
    355355
    356356    return 1;
     
    359359    {
    360360        const int save = errno;
    361         close( lpd_socket );
    362         close( lpd_socket2 );
     361        close (lpd_socket);
     362        close (lpd_socket2);
    363363        lpd_socket = lpd_socket2 = -1;
    364364        session = NULL;
    365         tr_ndbg( "LPD", "LPD initialisation failed (errno = %d)", save );
     365        tr_ndbg ("LPD", "LPD initialisation failed (errno = %d)", save);
    366366        errno = save;
    367367    }
     
    371371}
    372372
    373 void tr_lpdUninit( tr_session* ss )
    374 {
    375     if( session != ss )
     373void tr_lpdUninit (tr_session* ss)
     374{
     375    if (session != ss)
    376376        return;
    377377
    378     tr_ndbg( "LPD", "Uninitialising Local Peer Discovery" );
    379 
    380     event_free( lpd_event );
     378    tr_ndbg ("LPD", "Uninitialising Local Peer Discovery");
     379
     380    event_free (lpd_event);
    381381    lpd_event = NULL;
    382382
    383     evtimer_del( upkeep_timer );
     383    evtimer_del (upkeep_timer);
    384384    upkeep_timer = NULL;
    385385
    386386    /* just shut down, we won't remember any former nodes */
    387     evutil_closesocket( lpd_socket );
    388     evutil_closesocket( lpd_socket2 );
    389     tr_ndbg( "LPD", "Done uninitialising Local Peer Discovery" );
     387    evutil_closesocket (lpd_socket);
     388    evutil_closesocket (lpd_socket2);
     389    tr_ndbg ("LPD", "Done uninitialising Local Peer Discovery");
    390390
    391391    session = NULL;
     
    393393
    394394bool
    395 tr_lpdEnabled( const tr_session* ss )
    396 {
    397     return ss && ( ss == session );
     395tr_lpdEnabled (const tr_session* ss)
     396{
     397    return ss && (ss == session);
    398398}
    399399
     
    405405* functions. In any other respect, lpd_consistencyCheck is an orphaned function.
    406406*/
    407 static inline void lpd_consistencyCheck( void )
     407static inline void lpd_consistencyCheck (void)
    408408{
    409409    /* if the following check fails, the definition of a hash string has changed
     
    411411     * and tr_lpdConsiderAnnounce. However, the code is designed to function as long
    412412     * as interfaces to the rest of the lib remain compatible with char* strings. */
    413     STATIC_ASSERT( sizeof(lpd_torStaticType->info.hashString[0]) == sizeof(char) );
     413    STATIC_ASSERT (sizeof (lpd_torStaticType->info.hashString[0]) == sizeof (char));
    414414}
    415415/**
     
    433433*/
    434434bool
    435 tr_lpdSendAnnounce( const tr_torrent* t )
     435tr_lpdSendAnnounce (const tr_torrent* t)
    436436{
    437437    size_t i;
     
    444444        CRLF;
    445445
    446     char hashString[lengthof( t->info.hashString )];
     446    char hashString[lengthof (t->info.hashString)];
    447447    char query[lpd_maxDatagramLength + 1] = { };
    448448
    449     if( t == NULL )
     449    if (t == NULL)
    450450        return false;
    451451
    452452    /* make sure the hash string is normalized, just in case */
    453     for( i = 0; i < sizeof hashString; i++ )
    454         hashString[i] = toupper( t->info.hashString[i] );
     453    for (i = 0; i < sizeof hashString; i++)
     454        hashString[i] = toupper (t->info.hashString[i]);
    455455
    456456    /* prepare a zero-terminated announce message */
    457     snprintf( query, lpd_maxDatagramLength + 1, fmt, 1, 1,
    458         lpd_mcastGroup, lpd_mcastPort, lpd_port, hashString );
     457    snprintf (query, lpd_maxDatagramLength + 1, fmt, 1, 1,
     458        lpd_mcastGroup, lpd_mcastPort, lpd_port, hashString);
    459459
    460460    /* actually send the query out using [lpd_socket2] */
    461461    {
    462         const int len = strlen( query );
    463 
    464         /* destination address info has already been set up in tr_lpdInit(),
     462        const int len = strlen (query);
     463
     464        /* destination address info has already been set up in tr_lpdInit (),
    465465         * so we refrain from preparing another sockaddr_in here */
    466         int res = sendto( lpd_socket2, query, len, 0,
    467             (const struct sockaddr*) &lpd_mcastAddr, sizeof lpd_mcastAddr );
    468 
    469         if( res != len )
     466        int res = sendto (lpd_socket2, query, len, 0,
     467          (const struct sockaddr*) &lpd_mcastAddr, sizeof lpd_mcastAddr);
     468
     469        if (res != len)
    470470            return false;
    471471    }
    472472
    473     tr_tordbg( t, "LPD announce message away" );
     473    tr_tordbg (t, "LPD announce message away");
    474474
    475475    return true;
     
    490490* return != 0, the caller may retrieve the value from the passed structure.
    491491*/
    492 static int tr_lpdConsiderAnnounce( tr_pex* peer, const char* const msg )
     492static int tr_lpdConsiderAnnounce (tr_pex* peer, const char* const msg)
    493493{
    494494    enum
    495495    {
    496496        maxValueLen = 25,
    497         maxHashLen = lengthof(lpd_torStaticType->info.hashString)
     497        maxHashLen = lengthof (lpd_torStaticType->info.hashString)
    498498    };
    499499
     
    503503    int res = 0, peerPort = 0;
    504504
    505     if( peer != NULL && msg != NULL )
     505    if (peer != NULL && msg != NULL)
    506506    {
    507507        tr_torrent* tor = NULL;
    508508
    509         const char* params = lpd_extractHeader( msg, &ver );
    510         if( params == NULL || ver.major != 1 ) /* allow messages of protocol v1 */
     509        const char* params = lpd_extractHeader (msg, &ver);
     510        if (params == NULL || ver.major != 1) /* allow messages of protocol v1 */
    511511            return 0;
    512512
    513513        /* save the effort to check Host, which seems to be optional anyway */
    514514
    515         if( lpd_extractParam( params, "Port", maxValueLen, value ) == 0 )
     515        if (lpd_extractParam (params, "Port", maxValueLen, value) == 0)
    516516            return 0;
    517517
    518518        /* determine announced peer port, refuse if value too large */
    519         if( sscanf( value, "%d", &peerPort ) != 1 || peerPort > (in_port_t)-1 )
     519        if (sscanf (value, "%d", &peerPort) != 1 || peerPort > (in_port_t)-1)
    520520            return 0;
    521521
    522         peer->port = htons( peerPort );
     522        peer->port = htons (peerPort);
    523523        res = -1; /* signal caller side-effect to peer->port via return != 0 */
    524524
    525         if( lpd_extractParam( params, "Infohash", maxHashLen, hashString ) == 0 )
     525        if (lpd_extractParam (params, "Infohash", maxHashLen, hashString) == 0)
    526526            return res;
    527527
    528         tor = tr_torrentFindFromHashString( session, hashString );
    529 
    530         if( tr_isTorrent( tor ) && tr_torrentAllowsLPD( tor ) )
     528        tor = tr_torrentFindFromHashString (session, hashString);
     529
     530        if (tr_isTorrent (tor) && tr_torrentAllowsLPD (tor))
    531531        {
    532532            /* we found a suitable peer, add it to the torrent */
    533             tr_peerMgrAddPex( tor, TR_PEER_FROM_LPD, peer, -1 );
    534             tr_tordbg( tor, "Learned %d local peer from LPD (%s:%u)",
    535                 1, tr_address_to_string( &peer->addr ), peerPort );
    536 
    537             /* periodic reconnectPulse() deals with the rest... */
     533            tr_peerMgrAddPex (tor, TR_PEER_FROM_LPD, peer, -1);
     534            tr_tordbg (tor, "Learned %d local peer from LPD (%s:%u)",
     535                1, tr_address_to_string (&peer->addr), peerPort);
     536
     537            /* periodic reconnectPulse () deals with the rest... */
    538538
    539539            return 1;
    540540        }
    541541        else
    542             tr_ndbg( "LPD", "Cannot serve torrent #%s", hashString );
     542            tr_ndbg ("LPD", "Cannot serve torrent #%s", hashString);
    543543    }
    544544
     
    560560*/
    561561static int
    562 tr_lpdAnnounceMore( const time_t now, const int interval )
     562tr_lpdAnnounceMore (const time_t now, const int interval)
    563563{
    564564    tr_torrent* tor = NULL;
    565565    int announcesSent = 0;
    566566
    567     if( !tr_isSession( session ) )
     567    if (!tr_isSession (session))
    568568        return -1;
    569569
    570     while(( tor = tr_torrentNext( session, tor ) )
    571           && tr_sessionAllowsLPD( session ) )
    572     {
    573         if( tr_isTorrent( tor ) )
     570    while ((tor = tr_torrentNext (session, tor))
     571          && tr_sessionAllowsLPD (session))
     572    {
     573        if (tr_isTorrent (tor))
    574574        {
    575575            int announcePrio = 0;
    576576
    577             if( !tr_torrentAllowsLPD( tor ) )
     577            if (!tr_torrentAllowsLPD (tor))
    578578                continue;
    579579
    580580            /* issue #3208: prioritize downloads before seeds */
    581             switch( tr_torrentGetActivity( tor ) )
     581            switch (tr_torrentGetActivity (tor))
    582582            {
    583583            case TR_STATUS_DOWNLOAD:
     
    591591            }
    592592
    593             if( announcePrio > 0 && tor->lpdAnnounceAt <= now )
     593            if (announcePrio > 0 && tor->lpdAnnounceAt <= now)
    594594            {
    595                 if( tr_lpdSendAnnounce( tor ) )
     595                if (tr_lpdSendAnnounce (tor))
    596596                    announcesSent++;
    597597
     
    608608        const int maxAnnounceCap = interval * lpd_announceCapFactor;
    609609
    610         if( lpd_unsolicitedMsgCounter < 0 )
    611             tr_ninf( "LPD", "Dropped %d announces in the last interval (max. %d "
    612                      "allowed)", -lpd_unsolicitedMsgCounter, maxAnnounceCap );
     610        if (lpd_unsolicitedMsgCounter < 0)
     611            tr_ninf ("LPD", "Dropped %d announces in the last interval (max. %d "
     612                     "allowed)", -lpd_unsolicitedMsgCounter, maxAnnounceCap);
    613613
    614614        lpd_unsolicitedMsgCounter = maxAnnounceCap;
     
    619619
    620620static void
    621 on_upkeep_timer( int foo UNUSED, short bar UNUSED, void * vsession UNUSED )
    622 {
    623     const time_t now = tr_time( );
    624     tr_lpdAnnounceMore( now, UPKEEP_INTERVAL_SECS );
    625     tr_timerAdd( upkeep_timer, UPKEEP_INTERVAL_SECS, 0 );
     621on_upkeep_timer (int foo UNUSED, short bar UNUSED, void * vsession UNUSED)
     622{
     623    const time_t now = tr_time ();
     624    tr_lpdAnnounceMore (now, UPKEEP_INTERVAL_SECS);
     625    tr_timerAdd (upkeep_timer, UPKEEP_INTERVAL_SECS, 0);
    626626}
    627627
     
    630630* @note maximum rate of read events is limited according to @a lpd_maxAnnounceCap
    631631* @see DoS */
    632 static void event_callback( int s UNUSED, short type, void* ignore UNUSED )
    633 {
    634     assert( tr_isSession( session ) );
     632static void event_callback (int s UNUSED, short type, void* ignore UNUSED)
     633{
     634    assert (tr_isSession (session));
    635635
    636636    /* do not allow announces to be processed if LPD is disabled */
    637     if( !tr_sessionAllowsLPD( session ) )
     637    if (!tr_sessionAllowsLPD (session))
    638638        return;
    639639
    640     if( ( type & EV_READ ) != 0 )
     640    if ((type & EV_READ) != 0)
    641641    {
    642642        struct sockaddr_in foreignAddr;
     
    647647
    648648        /* process local announcement from foreign peer */
    649         int res = recvfrom( lpd_socket, foreignMsg, lpd_maxDatagramLength,
    650             0, (struct sockaddr*) &foreignAddr, (socklen_t*) &addrLen );
     649        int res = recvfrom (lpd_socket, foreignMsg, lpd_maxDatagramLength,
     650            0, (struct sockaddr*) &foreignAddr, (socklen_t*) &addrLen);
    651651
    652652        /* besides, do we get flooded? then bail out! */
    653         if( --lpd_unsolicitedMsgCounter < 0 )
     653        if (--lpd_unsolicitedMsgCounter < 0)
    654654            return;
    655655
    656         if( res > 0 && res <= lpd_maxDatagramLength )
     656        if (res > 0 && res <= lpd_maxDatagramLength)
    657657        {
    658658            struct tr_pex foreignPeer =
     
    663663
    664664            foreignPeer.addr.addr.addr4 = foreignAddr.sin_addr;
    665             if( tr_lpdConsiderAnnounce( &foreignPeer, foreignMsg ) != 0 )
     665            if (tr_lpdConsiderAnnounce (&foreignPeer, foreignMsg) != 0)
    666666                return; /* OK so far, no log message */
    667667        }
    668668
    669         tr_ndbg( "LPD", "Discarded invalid multicast message" );
    670     }
    671 }
    672 
     669        tr_ndbg ("LPD", "Discarded invalid multicast message");
     670    }
     671}
     672
Note: See TracChangeset for help on using the changeset viewer.