forked from codyps/peerduct
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpeer.h
More file actions
66 lines (51 loc) · 1.34 KB
/
peer.h
File metadata and controls
66 lines (51 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef PEER_H_
#define PEER_H_
/* struct sockaddr_storage */
#include <netinet/in.h>
/* XXX: presently assumes that each 'peer' has a single method of reaching it.
* this is inaccurate */
enum peer_route_type {
PRT_DIRECT,
PRT_SYM_NAT, /* symetric */
PRT_FULL_CONE_NAT, /* full cone */
PRT_REST_CONE_NAT, /* restricted cone */
PRT_REST_PORT_NAT /* restricted port */
};
struct peer_id {
/* KAD id for now (128 bit) */
uint8_t id[16];
};
/* XXX: this is a copy of addrinfo with route_type added. I don't like the
* duplication, but it isn't clear how to avoid it. */
struct peer_addrinfo {
enum peer_route_type pai_route_type;
int pai_family;
int pai_socktype;
int pai_protocol;
size_t pai_addrlen;
struct sockaddr *pai_addr;
char *pai_canonname;
struct peer_addrinfo *pai_next;
};
enum peer_type {
PT_KAD,
PT_BT_DHT
};
struct peer {
enum peer_type type;
struct peer *next;
};
struct kad_peer {
struct peer peer;
uint8_t client_id[16];
uint8_t kad_udp_key[8];
struct sockaddr_in udp;
struct sockaddr_in tcp;
uint8_t verified; /* non-zero value indicates verified. */
uint8_t version; /* 0 = kad v1, non-zero indicates v2 and is a
featured bitmask */
};
#include "useful.h"
#define kad_peer_from_peer(p) container_of(p, struct kad_peer, peer)
void free_kad_peers(struct peer *peer);
#endif