mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed sendnodes and updated readme.
This commit is contained in:
parent
c93858110b
commit
bd37e3ad68
|
@ -110,7 +110,7 @@ Proposal of a free as in freedom skype replacement:
|
||||||
|
|
||||||
Protocol:
|
Protocol:
|
||||||
|
|
||||||
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]
|
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]
|
||||||
|
|
||||||
Valid queries and Responses:
|
Valid queries and Responses:
|
||||||
|
|
||||||
|
@ -122,6 +122,6 @@ Proposal of a free as in freedom skype replacement:
|
||||||
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]
|
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]
|
||||||
Valid replies: a send_nodes packet
|
Valid replies: a send_nodes packet
|
||||||
|
|
||||||
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]
|
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]
|
||||||
ex: 03[Node][Node][Node]
|
ex: 03[Node][Node][Node]
|
||||||
|
|
||||||
|
|
|
@ -416,7 +416,7 @@ int sendnodes(IP_Port ip_port, char * client_id, uint32_t ping_id)
|
||||||
memcpy(data + 5, self_client_id, CLIENT_ID_SIZE);
|
memcpy(data + 5, self_client_id, CLIENT_ID_SIZE);
|
||||||
memcpy(data + 5 + CLIENT_ID_SIZE, nodes_list, num_nodes * (CLIENT_ID_SIZE + sizeof(IP_Port)));
|
memcpy(data + 5 + CLIENT_ID_SIZE, nodes_list, num_nodes * (CLIENT_ID_SIZE + sizeof(IP_Port)));
|
||||||
|
|
||||||
return sendpacket(ip_port, data, sizeof(data));
|
return sendpacket(ip_port, data, 5 + CLIENT_ID_SIZE + num_nodes * (CLIENT_ID_SIZE + sizeof(IP_Port)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -463,6 +463,8 @@ int handle_getnodes(char * packet, uint32_t length, IP_Port source)
|
||||||
memcpy(&ping_id, packet + 1, 4);
|
memcpy(&ping_id, packet + 1, 4);
|
||||||
sendnodes(source, packet + 5 + CLIENT_ID_SIZE, ping_id);
|
sendnodes(source, packet + 5 + CLIENT_ID_SIZE, ping_id);
|
||||||
|
|
||||||
|
pingreq(source);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ typedef struct
|
||||||
{
|
{
|
||||||
IP ip;
|
IP ip;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
|
//not used for anything right now
|
||||||
|
uint16_t padding;
|
||||||
}IP_Port;
|
}IP_Port;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user