diff options
author | irungentoo <irungentoo@gmail.com> | 2013-06-25 09:59:54 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-06-25 09:59:54 -0400 |
commit | bd37e3ad688a9739de1f82d76fde8b61fcd1e9fb (patch) | |
tree | 84b358504ff85a269d6ab66e08b669284988c983 | |
parent | c93858110bb17ce35143bae7ba9aa68fac93f46b (diff) |
Fixed sendnodes and updated readme.
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | core/DHT.c | 4 | ||||
-rw-r--r-- | core/DHT.h | 3 |
3 files changed, 7 insertions, 4 deletions
@@ -110,7 +110,7 @@ Proposal of a free as in freedom skype replacement: | |||
110 | 110 | ||
111 | Protocol: | 111 | Protocol: |
112 | 112 | ||
113 | Node format: [char array (node_id), length=32 bytes][ip (in network byte order), length=4 bytes][port (in network byte order), length=2 bytes] | 113 | Node format: [char array (node_id), length=32 bytes][ip (in network byte order), length=4 bytes][port (in network byte order), length=2 bytes][Padding , length=2 bytes] |
114 | 114 | ||
115 | Valid queries and Responses: | 115 | Valid queries and Responses: |
116 | 116 | ||
@@ -122,6 +122,6 @@ Proposal of a free as in freedom skype replacement: | |||
122 | Packet contents: [byte with value: 02][random 4 byte (ping_id)][char array (client node_id), length=32 bytes][char array: requested_node_id (node_id of which we want the ip), length=32 bytes] | 122 | Packet contents: [byte with value: 02][random 4 byte (ping_id)][char array (client node_id), length=32 bytes][char array: requested_node_id (node_id of which we want the ip), length=32 bytes] |
123 | Valid replies: a send_nodes packet | 123 | Valid replies: a send_nodes packet |
124 | 124 | ||
125 | Send_nodes (response): [byte with value: 03][random 4 byte (ping_id)][char array (client node_id), length=32 bytes][Nodes in node format, length=38 * (number of nodes (maximum of 8 nodes)) bytes] | 125 | Send_nodes (response): [byte with value: 03][random 4 byte (ping_id)][char array (client node_id), length=32 bytes][Nodes in node format, length=40 * (number of nodes (maximum of 8 nodes)) bytes] |
126 | ex: 03[Node][Node][Node] | 126 | ex: 03[Node][Node][Node] |
127 | 127 | ||
@@ -416,7 +416,7 @@ int sendnodes(IP_Port ip_port, char * client_id, uint32_t ping_id) | |||
416 | memcpy(data + 5, self_client_id, CLIENT_ID_SIZE); | 416 | memcpy(data + 5, self_client_id, CLIENT_ID_SIZE); |
417 | memcpy(data + 5 + CLIENT_ID_SIZE, nodes_list, num_nodes * (CLIENT_ID_SIZE + sizeof(IP_Port))); | 417 | memcpy(data + 5 + CLIENT_ID_SIZE, nodes_list, num_nodes * (CLIENT_ID_SIZE + sizeof(IP_Port))); |
418 | 418 | ||
419 | return sendpacket(ip_port, data, sizeof(data)); | 419 | return sendpacket(ip_port, data, 5 + CLIENT_ID_SIZE + num_nodes * (CLIENT_ID_SIZE + sizeof(IP_Port))); |
420 | } | 420 | } |
421 | 421 | ||
422 | 422 | ||
@@ -463,6 +463,8 @@ int handle_getnodes(char * packet, uint32_t length, IP_Port source) | |||
463 | memcpy(&ping_id, packet + 1, 4); | 463 | memcpy(&ping_id, packet + 1, 4); |
464 | sendnodes(source, packet + 5 + CLIENT_ID_SIZE, ping_id); | 464 | sendnodes(source, packet + 5 + CLIENT_ID_SIZE, ping_id); |
465 | 465 | ||
466 | pingreq(source); | ||
467 | |||
466 | return 0; | 468 | return 0; |
467 | } | 469 | } |
468 | 470 | ||
@@ -40,7 +40,8 @@ typedef struct | |||
40 | { | 40 | { |
41 | IP ip; | 41 | IP ip; |
42 | uint16_t port; | 42 | uint16_t port; |
43 | 43 | //not used for anything right now | |
44 | uint16_t padding; | ||
44 | }IP_Port; | 45 | }IP_Port; |
45 | 46 | ||
46 | 47 | ||