This matches how real UDP works and avoids 16 bit integer overflow.
}
// Ensure reassembled packet are not larger than 64 kiB
}
// Ensure reassembled packet are not larger than 64 kiB
- if(hdr->wnd >= MAX_UNRELIABLE_SIZE || hdr->wnd + len > MAX_UNRELIABLE_SIZE) {
+ if(hdr->wnd > MAX_UNRELIABLE_SIZE || hdr->wnd + len > MAX_UNRELIABLE_SIZE) {
#define DEFAULT_RCVBUFSIZE 0
#define DEFAULT_MAXRCVBUFSIZE 131072
#define DEFAULT_RCVBUFSIZE 0
#define DEFAULT_MAXRCVBUFSIZE 131072
-#define MAX_UNRELIABLE_SIZE 65536
+#define MAX_UNRELIABLE_SIZE 65535
#define DEFAULT_MTU 1000
#define USEC_PER_SEC 1000000L
#define DEFAULT_MTU 1000
#define USEC_PER_SEC 1000000L
// We expect always the same amount of data from the server.
assert(mesh->priv);
struct client *client = mesh->priv;
// We expect always the same amount of data from the server.
assert(mesh->priv);
struct client *client = mesh->priv;
- assert(len == 512 || len == 65536);
+ assert(len == 512 || len == 65535);
client->got_large_packet = true;
}
}
client->got_large_packet = true;
}
}
// Check that we can send up to 65535 bytes without errors
// Check that we can send up to 65535 bytes without errors
- char large_data[65536] = "";
+ char large_data[65535] = "";
for(int i = 0; i < 3; i++) {
for(int i = 0; i < 3; i++) {
- assert(meshlink_channel_send(server, channels[i], large_data, sizeof(large_data) + 1) == -1);
assert(meshlink_channel_send(server, channels[i], large_data, sizeof(large_data)) == sizeof(large_data));
}
assert(meshlink_channel_send(server, channels[i], large_data, sizeof(large_data)) == sizeof(large_data));
}
- // Assert that packets larger than 64 kiB are not allowed
+ // Assert that any larger packets are not allowed
- assert(meshlink_channel_send(server, channels[0], large_data, 65537) == -1);
+ assert(meshlink_channel_send(server, channels[0], large_data, 65536) == -1);
// Stream packets from server to clients for 5 seconds at 40 Mbps (1 kB * 500 Hz)
// Stream packets from server to clients for 5 seconds at 40 Mbps (1 kB * 500 Hz)