source: trunk/third-party/dht/dht.h @ 11663

Last change on this file since 11663 was 11663, checked in by jch, 11 years ago

Import dht-0.17.

File size: 2.4 KB
Line 
1/*
2Copyright (c) 2009-2011 by Juliusz Chroboczek
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE.
21*/
22
23typedef void
24dht_callback(void *closure, int event,
25             unsigned char *info_hash,
26             void *data, size_t data_len);
27
28#define DHT_EVENT_NONE 0
29#define DHT_EVENT_VALUES 1
30#define DHT_EVENT_VALUES6 2
31#define DHT_EVENT_SEARCH_DONE 3
32#define DHT_EVENT_SEARCH_DONE6 4
33
34extern FILE *dht_debug;
35
36int dht_init(int s, int s6, const unsigned char *id, const unsigned char *v);
37int dht_insert_node(const unsigned char *id, struct sockaddr *sa, int salen);
38int dht_ping_node(struct sockaddr *sa, int salen);
39int dht_periodic(const void *buf, size_t buflen,
40                 const struct sockaddr *from, int fromlen,
41                 time_t *tosleep, dht_callback *callback, void *closure);
42int dht_search(const unsigned char *id, int port, int af,
43               dht_callback *callback, void *closure);
44int dht_nodes(int af,
45              int *good_return, int *dubious_return, int *cached_return,
46              int *incoming_return);
47void dht_dump_tables(FILE *f);
48int dht_get_nodes(struct sockaddr_in *sin, int *num,
49                  struct sockaddr_in6 *sin6, int *num6);
50int dht_uninit(void);
51
52/* This must be provided by the user. */
53void dht_hash(void *hash_return, int hash_size,
54              const void *v1, int len1,
55              const void *v2, int len2,
56              const void *v3, int len3);
57int dht_random_bytes(void *buf, size_t size);
Note: See TracBrowser for help on using the repository browser.