mirror of
https://github.com/monero-project/monero.git
synced 2025-08-19 02:07:54 -04:00
epee: fix network packet header field endianness
This commit is contained in:
parent
ec1a62b50d
commit
9c923bad9b
5 changed files with 113 additions and 57 deletions
|
@ -80,10 +80,10 @@ int levin_client_impl::invoke(int command, const std::string& in_buff, std::stri
|
|||
return -1;
|
||||
|
||||
bucket_head head = {0};
|
||||
head.m_signature = LEVIN_SIGNATURE;
|
||||
head.m_cb = in_buff.size();
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = SWAP64LE(in_buff.size());
|
||||
head.m_have_to_return_data = true;
|
||||
head.m_command = command;
|
||||
head.m_command = SWAP32LE(command);
|
||||
if(!m_transport.send(&head, sizeof(head)))
|
||||
return -1;
|
||||
|
||||
|
@ -97,7 +97,7 @@ int levin_client_impl::invoke(int command, const std::string& in_buff, std::stri
|
|||
head = *(bucket_head*)local_buff.data();
|
||||
|
||||
|
||||
if(head.m_signature!=LEVIN_SIGNATURE)
|
||||
if(head.m_signature!=SWAP64LE(LEVIN_SIGNATURE))
|
||||
{
|
||||
LOG_PRINT_L1("Signature mismatch in response");
|
||||
return -1;
|
||||
|
@ -116,10 +116,10 @@ int levin_client_impl::notify(int command, const std::string& in_buff)
|
|||
return -1;
|
||||
|
||||
bucket_head head = {0};
|
||||
head.m_signature = LEVIN_SIGNATURE;
|
||||
head.m_cb = in_buff.size();
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = SWAP64LE(in_buff.size());
|
||||
head.m_have_to_return_data = false;
|
||||
head.m_command = command;
|
||||
head.m_command = SWAP32LE(command);
|
||||
|
||||
if(!m_transport.send((const char*)&head, sizeof(head)))
|
||||
return -1;
|
||||
|
@ -139,12 +139,13 @@ inline
|
|||
return -1;
|
||||
|
||||
bucket_head2 head = {0};
|
||||
head.m_signature = LEVIN_SIGNATURE;
|
||||
head.m_cb = in_buff.size();
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = SWAP64LE(in_buff.size());
|
||||
head.m_have_to_return_data = true;
|
||||
head.m_command = command;
|
||||
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
|
||||
head.m_flags = LEVIN_PACKET_REQUEST;
|
||||
head.m_command = SWAP32LE(command);
|
||||
head.m_return_code = SWAP32LE(0);
|
||||
head.m_flags = SWAP32LE(LEVIN_PACKET_REQUEST);
|
||||
head.m_protocol_version = SWAP32LE(LEVIN_PROTOCOL_VER_1);
|
||||
if(!m_transport.send(&head, sizeof(head)))
|
||||
return -1;
|
||||
|
||||
|
@ -157,14 +158,13 @@ inline
|
|||
|
||||
head = *(bucket_head2*)local_buff.data();
|
||||
|
||||
|
||||
if(head.m_signature!=LEVIN_SIGNATURE)
|
||||
if(head.m_signature != SWAP64LE(LEVIN_SIGNATURE))
|
||||
{
|
||||
LOG_PRINT_L1("Signature mismatch in response");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!m_transport.recv_n(buff_out, head.m_cb))
|
||||
if(!m_transport.recv_n(buff_out, SWAP64LE(head.m_cb)))
|
||||
return -1;
|
||||
|
||||
return head.m_return_code;
|
||||
|
@ -177,12 +177,13 @@ inline
|
|||
return -1;
|
||||
|
||||
bucket_head2 head = {0};
|
||||
head.m_signature = LEVIN_SIGNATURE;
|
||||
head.m_cb = in_buff.size();
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = SWAP64LE(in_buff.size());
|
||||
head.m_have_to_return_data = false;
|
||||
head.m_command = command;
|
||||
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
|
||||
head.m_flags = LEVIN_PACKET_REQUEST;
|
||||
head.m_command = SWAP32LE(command);
|
||||
head.m_return_code = SWAP32LE(0);
|
||||
head.m_flags = SWAP32LE(LEVIN_PACKET_REQUEST);
|
||||
head.m_protocol_version = SWAP32LE(LEVIN_PROTOCOL_VER_1);
|
||||
|
||||
if(!m_transport.send((const char*)&head, sizeof(head)))
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue