diff options
Diffstat (limited to 'src/common.c')
| -rw-r--r-- | src/common.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/common.c b/src/common.c index 74515c1..0cc0240 100644 --- a/src/common.c +++ b/src/common.c @@ -21,6 +21,7 @@ typedef byte hash[ 32 ]; typedef byte public_key[ 32 ]; typedef byte private_key[ 32 ]; typedef byte signature[ 64 ]; +typedef byte recipient[ 64 ]; const uint16_t default_port = 8040; @@ -146,7 +147,7 @@ struct data_packet { public_key author; // message author public_key author_signing_pub; // message signing pubkey uint8_t recipient_count; // number of recipients. leave as 0 for public. - public_key recipients[ 32 ]; // up to 32 recipients for packet + recipient recipients[ 32 ]; // up to 32 recipients for packet byte data[ 65536 ]; // packet data signature signature; // data signature } contents; @@ -181,7 +182,7 @@ static inline void write_u16_le(byte *b, uint16_t v) { b[ 1 ] = (v >> 8) & 0xFF; } -const size_t CONTENTS_SIZE = 1 + 8 + 32 + 32 + 1 + (32 * MAX_RECIPIENTS) + 65536 + 64; +const size_t CONTENTS_SIZE = 1 + 8 + 32 + 32 + 1 + (64 * MAX_RECIPIENTS) + 65536 + 64; const size_t PACKET_SIZE = 4 + 32 + (CONTENTS_SIZE); struct relay_neighbor s2relay_neighbor(size_t len, byte *stream, bool *success) { @@ -251,7 +252,7 @@ struct relay_info s2relay_info(size_t len, byte *stream, bool *success) { *success = false; return (struct relay_info) { 0 }; } - off += 1 + 1 + 1 + 4 + 16; + off += 1 + 1 + 1 + 4 + 16 + 2; } *success = true; @@ -318,8 +319,8 @@ struct data_packet s2data_packet(size_t len, byte *stream, bool *success) { off += 32; out.contents.recipient_count = stream[ off++ ]; - memcpy(out.contents.recipients, stream + off, 32 * MAX_RECIPIENTS); - off += 32 * MAX_RECIPIENTS; + memcpy(out.contents.recipients, stream + off, 64 * MAX_RECIPIENTS); + off += 64 * MAX_RECIPIENTS; memcpy(out.contents.data, stream + off, 65536); off += 65536; @@ -355,8 +356,8 @@ bool data_packet2s(struct data_packet data, byte *stream) { off += 32; stream[ off++ ] = data.contents.recipient_count; - memcpy(stream + off, data.contents.recipients, 32 * MAX_RECIPIENTS); - off += 32 * MAX_RECIPIENTS; + memcpy(stream + off, data.contents.recipients, 64 * MAX_RECIPIENTS); + off += 64 * MAX_RECIPIENTS; memcpy(stream + off, data.contents.data, 65536); off += 65536; |
