Changeset 14268


Ignore:
Timestamp:
May 5, 2014, 8:45:14 PM (8 years ago)
Author:
jordan
Message:

(trunk) #5671 'dht-0.22': update third-party/dht.c to Juliusz Chroboczek's upstream v0.22

Location:
trunk
Files:
5 edited

Legend:

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

    r14187 r14268  
    515515static void
    516516callback (void *ignore UNUSED, int event,
    517           unsigned char *info_hash, void *data, size_t data_len)
     517          const unsigned char *info_hash, const void *data, size_t data_len)
    518518{
    519519    if (event == DHT_EVENT_VALUES || event == DHT_EVENT_VALUES6) {
  • trunk/third-party/dht/CHANGES

    r12586 r14268  
     13 May 2014: dht-0.22
     2
     3  * INCOMPATIBLE CHANGE: the callback now takes const arguments.
     4  * Consult the local storage when performing a search, which should
     5    make bootstrapping of tiny DHTs easier.  Note that we're still not
     6    performing local stores, since that would require knowing our IP
     7    address.
     8  * Don't attempt to flush the debug stream if debugging is disabled.
     9    This appears to work around a bug in Transmission.
     10
    11125 July 2011: dht-0.21
    212
  • trunk/third-party/dht/dht-example.c

    r12586 r14268  
    8080callback(void *closure,
    8181         int event,
    82          unsigned char *info_hash,
    83          void *data, size_t data_len)
     82         const unsigned char *info_hash,
     83         const void *data, size_t data_len)
    8484{
    8585    if(event == DHT_EVENT_SEARCH_DONE)
  • trunk/third-party/dht/dht.c

    r14232 r14268  
    213213};
    214214
     215static struct storage * find_storage(const unsigned char *id);
    215216static void flush_search_node(struct search_node *n, struct search *sr);
    216217
     
    327328    va_list args;
    328329    va_start(args, format);
    329     if(dht_debug) {
     330    if(dht_debug)
    330331        vfprintf(dht_debug, format, args);
     332    va_end(args);
     333    if(dht_debug)
    331334        fflush(dht_debug);
    332     }
    333     va_end(args);
    334335}
    335336
     
    11941195{
    11951196    struct search *sr;
     1197    struct storage *st;
    11961198    struct bucket *b = find_bucket(id, af);
    11971199
     
    11991201        errno = EAFNOSUPPORT;
    12001202        return -1;
     1203    }
     1204
     1205    /* Try to answer this search locally.  In a fully grown DHT this
     1206       is very unlikely, but people are running modified versions of
     1207       this code in private DHTs with very few nodes.  What's wrong
     1208       with flooding? */
     1209    if(callback) {
     1210        st = find_storage(id);
     1211        if(st) {
     1212            unsigned short swapped;
     1213            unsigned char buf[18];
     1214            int i;
     1215
     1216            debugf("Found local data (%d peers).\n", st->numpeers);
     1217
     1218            for(i = 0; i < st->numpeers; i++) {
     1219                swapped = htons(st->peers[i].port);
     1220                if(st->peers[i].len == 4) {
     1221                    memcpy(buf, st->peers[i].ip, 4);
     1222                    memcpy(buf + 4, &swapped, 2);
     1223                    (*callback)(closure, DHT_EVENT_VALUES, id,
     1224                                (void*)buf, 6);
     1225                } else if(st->peers[i].len == 16) {
     1226                    memcpy(buf, st->peers[i].ip, 16);
     1227                    memcpy(buf + 16, &swapped, 2);
     1228                    (*callback)(closure, DHT_EVENT_VALUES6, id,
     1229                                (void*)buf, 18);
     1230                }
     1231            }
     1232        }
    12011233    }
    12021234
  • trunk/third-party/dht/dht.h

    r12586 r14268  
    2323typedef void
    2424dht_callback(void *closure, int event,
    25              unsigned char *info_hash,
    26              void *data, size_t data_len);
     25             const unsigned char *info_hash,
     26             const void *data, size_t data_len);
    2727
    2828#define DHT_EVENT_NONE 0
Note: See TracChangeset for help on using the changeset viewer.