24 typedef int socklen_t;
28 #include <sys/socket.h> 51 struct sockaddr_storage
addr;
65 unsigned char sig[64];
97 const struct sockaddr *dest, socklen_t
addrlen,
117 unsigned char ip[18];
128 struct timeval heat_start;
141 unsigned char id[20];
146 struct search *first;
147 struct search **tail;
152 unsigned char secret[16];
219 const struct sockaddr *src, socklen_t addrlen);
297 dht_search_t *handle);
342 int implied_port,
int port);
359 const struct bvalue *val);
381 const unsigned char k[32],
382 const unsigned char signature[64],
383 const unsigned char *salt,
size_t salt_len,
External IP counter entry.
Definition: node.h:116
struct sockaddr_storage addr
Node address.
Definition: node.h:51
unsigned int count
Number of times seen.
Definition: node.h:119
struct peer_list * peer_storage
Peer list storage.
Definition: node.h:153
struct ip_counter_entry * entries
External IP address entries.
Definition: node.h:129
void(* node_output_t)(const unsigned char *data, size_t len, const struct sockaddr *dest, socklen_t addrlen, void *opaque)
Node output callback.
Definition: node.h:96
struct ip_counter_entry * next
Next entry.
Definition: node.h:120
DHT node object.
Definition: node.h:140
Search node.
Definition: node.h:49
unsigned int total
Total external IP address count.
Definition: node.h:127
struct bucket * buckets
Bucket list.
Definition: node.h:144
void * bootstrap_priv
Bootstrap callback user data.
Definition: node.h:157
void dht_node_dump_buckets(struct dht_node *n)
Dump the node's routing table.
Provides routines for parsing and formating bencoded data.
void dht_node_ping(struct dht_node *n, struct sockaddr *dest, socklen_t addrlen)
Ping remote node.
unsigned char sig[64]
signature of stored value
Definition: node.h:65
void(* search_complete_t)(struct dht_node *n, const struct search_node *nodes, void *opaque)
Search complete callback.
Definition: node.h:81
size_t peer_count
Number of entries in peers array.
Definition: node.h:62
size_t token_len
Length of token string.
Definition: node.h:57
int dht_node_restore(const struct bvalue *dict, struct dht_node *n)
Restore node state.
void(* bootstrap_status_t)(int ready, void *opaque)
Bootstrap status notification callback.
Definition: node.h:111
int seq
v's sequence number
Definition: node.h:61
bootstrap_status_t bootstrap_cb
Bootstrap status callback.
Definition: node.h:156
uint16_t tid
Transaction ID generation counter.
Definition: node.h:149
struct search_node * next
Next node in the list.
Definition: node.h:58
bencoding value.
Definition: bencode.h:32
int dht_node_start(struct dht_node *n)
Start DHT node.
void dht_node_announce(struct dht_node *n, const unsigned char *info_hash, const struct search_node *nodes, int implied_port, int port)
Send announce queries for an infohash.
struct search * dht_search_t
Search handle.
Definition: node.h:165
int error
Error code if node query failed.
Definition: node.h:63
void dht_node_put_mutable(struct dht_node *n, const struct search_node *nodes, const unsigned char k[32], const unsigned char signature[64], const unsigned char *salt, size_t salt_len, int seq, const struct bvalue *val)
Store mutable data in the DHT.
void dht_node_set_bootstrap_callback(struct dht_node *n, bootstrap_status_t callback, void *opaque)
Set bootstrap status notification callback.
struct timeval next_query
When to send next query.
Definition: node.h:54
int dht_node_search(struct dht_node *n, const unsigned char id[20], int search_type, search_complete_t callback, void *opaque, dht_search_t *handle)
Start a search on the DHT.
struct sockaddr_storage * peers
Array of peer addresses.
Definition: node.h:59
External IP counter.
Definition: node.h:126
node_output_t output
Datagram output function.
Definition: node.h:142
socklen_t addrlen
Length of addr field.
Definition: node.h:52
struct put_item * put_storage
Put data storage.
Definition: node.h:154
void dht_node_cancel(struct dht_node *n, dht_search_t handle)
Cancel a pending DHT search.
unsigned char k[32]
ed25519 public key of stored value
Definition: node.h:64
void dht_node_timeout(struct dht_node *n, struct timeval *tv)
Get node timeout.
struct bvalue * dht_node_save(const struct dht_node *n)
Save node state.
int dht_node_init(struct dht_node *n, const unsigned char *id, node_output_t output, void *opaque)
Initialize DHT node.
void dht_node_work(struct dht_node *n)
Service the node.
void dht_node_input(struct dht_node *n, const unsigned char *data, size_t len, const struct sockaddr *src, socklen_t addrlen)
Input a received UDP datagram.
size_t len
Length of ip field.
Definition: node.h:118
void dht_node_put_immutable(struct dht_node *n, const struct search_node *nodes, const struct bvalue *val)
Store immutable data in the DHT.
struct bvalue * v
value received in reply to get query
Definition: node.h:60
struct timeval reply_time
Query reply time.
Definition: node.h:53
struct search * bootstrap
Bootstrap search handle.
Definition: node.h:155
dht_search_type
Type of DHT search.
Definition: node.h:36
void * opaque
Output callback user data.
Definition: node.h:143
unsigned char * token
Storage token.
Definition: node.h:56
int queried
Number of queries sent with no reply.
Definition: node.h:55
void dht_node_cleanup(struct dht_node *n)
Cleanup DHT node.