Check ACK receiver point diagnostics at buffer boundaries
This commit is contained in:
1 parent
c35252c0df
commit
cad275ddce
2 files changed
+26
-1
No files matched your search
@@ -53,7 +53,7 @@ void etcp_dump_pkt_sections(struct ETCP_DGRAM* pkt, struct ETCP_LINK* link, int
|
||||
ack_count, len-offset, section_len);
|
||||
offset = len; break;
|
||||
}
|
||||
if (ack_count) {
|
||||
if (ack_count && pos < (int)sizeof(buf) - 1) {
|
||||
const uint8_t* point = data + offset + ETCP_ACK_BASE_SIZE + ack_count * ETCP_ACK_ENTRY_SIZE;
|
||||
uint64_t bytes = 0, time = 0;
|
||||
for (unsigned i = 0; i < 8; i++) { bytes |= (uint64_t)point[i] << (8*i); time |= (uint64_t)point[i+8] << (8*i); }
|
||||
|
||||
@@ -95,6 +95,31 @@ static void debug_sequence_boundaries(void) {
|
||||
else CHECK(dump_count == 0 && dump_warnings == 0);
|
||||
}
|
||||
}
|
||||
// Положительный ACK: footer полностью проверяется до чтения, следующая секция не теряется.
|
||||
u_free(pkt);
|
||||
unsigned ack_size = etcp_ack_section_size(1);
|
||||
pkt = u_calloc(1, sizeof(*pkt) + 10 * ack_size); CHECK(pkt);
|
||||
pkt->data[0] = ETCP_SECTION_ACK; pkt->data[1] = 1;
|
||||
memset(pkt->data + ETCP_ACK_BASE_SIZE + ETCP_ACK_ENTRY_SIZE, 255, ETCP_ACK_RX_POINT_SIZE);
|
||||
debug_set_category_level(DEBUG_CATEGORY_DUMP, DEBUG_LEVEL_DEBUG);
|
||||
for (unsigned len = ETCP_ACK_BASE_SIZE; len < ack_size; len++) {
|
||||
pkt->data_len = len; dump_count = dump_warnings = 0; dump_message[0] = 0;
|
||||
etcp_dump_pkt_sections(pkt, NULL, 0);
|
||||
CHECK(dump_count == 1 && dump_warnings == 1 && !strstr(dump_message, " rx="));
|
||||
}
|
||||
pkt->data[ack_size] = ETCP_SECTION_TIMESTAMP;
|
||||
pkt->data[ack_size+5] = ETCP_SECTION_PAYLOAD;
|
||||
pkt->data[ack_size+6] = 42; pkt->data[ack_size+10] = 99;
|
||||
pkt->data_len = ack_size + 5 + ETCP_PAYLOAD_HEADER_SIZE + 1;
|
||||
dump_count = dump_warnings = 0; dump_message[0] = 0;
|
||||
etcp_dump_pkt_sections(pkt, NULL, 0);
|
||||
CHECK(dump_count == 1 && !dump_warnings && strstr(dump_message, " rx=18446744073709551615/18446744073709551615us"));
|
||||
CHECK(strstr(dump_message, " ch_ts=0/0") && strstr(dump_message, " payload=1(seq=42 attempt=99)"));
|
||||
for (unsigned i = 1; i < 10; i++) memcpy(pkt->data + i*ack_size, pkt->data, ack_size);
|
||||
pkt->data_len = 10 * ack_size;
|
||||
dump_count = dump_warnings = 0; dump_message[0] = 0;
|
||||
etcp_dump_pkt_sections(pkt, NULL, 1);
|
||||
CHECK(dump_count == 1 && dump_warnings == 1 && strstr(dump_message, " [truncated]"));
|
||||
debug_set_log_hook(NULL);
|
||||
debug_enable_console(console);
|
||||
debug_set_category_level(DEBUG_CATEGORY_DUMP, saved);
|
||||
|
||||
Reference in new issue
Block a user