mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
increase lossy custom packet size in ngc to the toxcore common max of 1373
This commit is contained in:
parent
9b3c1089f1
commit
01e7950c67
|
@ -1 +1 @@
|
||||||
6468ae67bae96ca47fec38e3aff22809ea8a865df294c8a41cdb681b58a00830 /usr/local/bin/tox-bootstrapd
|
5aac1df4d6c1de289e8e9f646d06099c84fd4d9b80d19f45e3254eec3ece2bff /usr/local/bin/tox-bootstrapd
|
||||||
|
|
|
@ -182,7 +182,7 @@ static void kill_group_friend_connection(const GC_Session *c, const GC_Chat *cha
|
||||||
|
|
||||||
uint16_t gc_get_wrapped_packet_size(uint16_t length, Net_Packet_Type packet_type)
|
uint16_t gc_get_wrapped_packet_size(uint16_t length, Net_Packet_Type packet_type)
|
||||||
{
|
{
|
||||||
assert(length <= MAX_GC_PACKET_CHUNK_SIZE);
|
assert(length <= (packet_type == NET_PACKET_GC_LOSSY ? MAX_GC_CUSTOM_LOSSY_PACKET_SIZE : MAX_GC_PACKET_CHUNK_SIZE));
|
||||||
|
|
||||||
const uint16_t min_header_size = packet_type == NET_PACKET_GC_LOSSY
|
const uint16_t min_header_size = packet_type == NET_PACKET_GC_LOSSY
|
||||||
? GC_MIN_LOSSY_PAYLOAD_SIZE
|
? GC_MIN_LOSSY_PAYLOAD_SIZE
|
||||||
|
@ -226,10 +226,20 @@ GC_Connection *get_gc_connection(const GC_Chat *chat, int peer_number)
|
||||||
return &peer->gconn;
|
return &peer->gconn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the amount of empty padding a packet of designated length should have. */
|
/** Returns the max packet size, not wrapped */
|
||||||
static uint16_t group_packet_padding_length(uint16_t length)
|
static uint16_t group_packet_max_packet_size(Net_Packet_Type net_packet_type)
|
||||||
{
|
{
|
||||||
return (MAX_GC_PACKET_CHUNK_SIZE - length) % GC_MAX_PACKET_PADDING;
|
if (net_packet_type == NET_PACKET_GC_LOSSY) {
|
||||||
|
return MAX_GC_CUSTOM_LOSSY_PACKET_SIZE;
|
||||||
|
} else {
|
||||||
|
return MAX_GC_PACKET_CHUNK_SIZE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the amount of empty padding a packet of designated length should have. */
|
||||||
|
static uint16_t group_packet_padding_length(uint16_t length, uint16_t max_length)
|
||||||
|
{
|
||||||
|
return (max_length - length) % GC_MAX_PACKET_PADDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gc_get_self_nick(const GC_Chat *chat, uint8_t *nick)
|
void gc_get_self_nick(const GC_Chat *chat, uint8_t *nick)
|
||||||
|
@ -1483,9 +1493,10 @@ static int group_packet_unwrap(const Logger *log, const GC_Connection *gconn, ui
|
||||||
int group_packet_wrap(
|
int group_packet_wrap(
|
||||||
const Logger *log, const Random *rng, const uint8_t *self_pk, const uint8_t *shared_key, uint8_t *packet,
|
const Logger *log, const Random *rng, const uint8_t *self_pk, const uint8_t *shared_key, uint8_t *packet,
|
||||||
uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id,
|
uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id,
|
||||||
uint8_t gp_packet_type, uint8_t net_packet_type)
|
uint8_t gp_packet_type, Net_Packet_Type net_packet_type)
|
||||||
{
|
{
|
||||||
const uint16_t padding_len = group_packet_padding_length(length);
|
const uint16_t max_packet_size = group_packet_max_packet_size(net_packet_type);
|
||||||
|
const uint16_t padding_len = group_packet_padding_length(length, max_packet_size);
|
||||||
const uint16_t min_packet_size = net_packet_type == NET_PACKET_GC_LOSSLESS
|
const uint16_t min_packet_size = net_packet_type == NET_PACKET_GC_LOSSLESS
|
||||||
? length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + GC_MESSAGE_ID_BYTES + 1
|
? length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + GC_MESSAGE_ID_BYTES + 1
|
||||||
: length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + 1;
|
: length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + 1;
|
||||||
|
@ -1495,8 +1506,8 @@ int group_packet_wrap(
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > MAX_GC_PACKET_CHUNK_SIZE) {
|
if (length > max_packet_size) {
|
||||||
LOGGER_ERROR(log, "Packet payload size (%u) exceeds maximum (%u)", length, MAX_GC_PACKET_CHUNK_SIZE);
|
LOGGER_ERROR(log, "Packet payload size (%u) exceeds maximum (%u)", length, max_packet_size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1563,7 +1574,7 @@ non_null()
|
||||||
static bool send_lossy_group_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint8_t *data,
|
static bool send_lossy_group_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint8_t *data,
|
||||||
uint16_t length, uint8_t packet_type)
|
uint16_t length, uint8_t packet_type)
|
||||||
{
|
{
|
||||||
assert(length <= MAX_GC_PACKET_CHUNK_SIZE);
|
assert(length <= MAX_GC_CUSTOM_LOSSY_PACKET_SIZE);
|
||||||
|
|
||||||
if (!gconn->handshaked || gconn->pending_delete) {
|
if (!gconn->handshaked || gconn->pending_delete) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -142,7 +142,7 @@ non_null(1, 2, 3, 4, 5) nullable(7)
|
||||||
int group_packet_wrap(
|
int group_packet_wrap(
|
||||||
const Logger *log, const Random *rng, const uint8_t *self_pk, const uint8_t *shared_key, uint8_t *packet,
|
const Logger *log, const Random *rng, const uint8_t *self_pk, const uint8_t *shared_key, uint8_t *packet,
|
||||||
uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id,
|
uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id,
|
||||||
uint8_t gp_packet_type, uint8_t net_packet_type);
|
uint8_t gp_packet_type, Net_Packet_Type net_packet_type);
|
||||||
|
|
||||||
/** @brief Returns the size of a wrapped/encrypted packet with a plain size of `length`.
|
/** @brief Returns the size of a wrapped/encrypted packet with a plain size of `length`.
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH
|
#define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH
|
||||||
#define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE)
|
#define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE)
|
||||||
#define MAX_GC_CUSTOM_LOSSLESS_PACKET_SIZE 1373
|
#define MAX_GC_CUSTOM_LOSSLESS_PACKET_SIZE 1373
|
||||||
#define MAX_GC_CUSTOM_LOSSY_PACKET_SIZE MAX_GC_PACKET_CHUNK_SIZE
|
#define MAX_GC_CUSTOM_LOSSY_PACKET_SIZE 1373
|
||||||
#define MAX_GC_PASSWORD_SIZE 32
|
#define MAX_GC_PASSWORD_SIZE 32
|
||||||
#define MAX_GC_SAVED_INVITES 10
|
#define MAX_GC_SAVED_INVITES 10
|
||||||
#define MAX_GC_PEERS_DEFAULT 100
|
#define MAX_GC_PEERS_DEFAULT 100
|
||||||
|
|
|
@ -3307,7 +3307,7 @@ uint32_t tox_group_max_message_length(void);
|
||||||
/**
|
/**
|
||||||
* Maximum length of a group custom lossy packet.
|
* Maximum length of a group custom lossy packet.
|
||||||
*/
|
*/
|
||||||
#define TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH 500
|
#define TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH 1373
|
||||||
|
|
||||||
uint32_t tox_group_max_custom_lossy_packet_length(void);
|
uint32_t tox_group_max_custom_lossy_packet_length(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user