mirror of
https://github.com/esphome/esphome.git
synced 2026-10-21 21:36:14 +00:00
[packet_interface] Leave no room, instead of underflowing, on a small link
As in the other layers, addressing ports and fragmentation get no room when max_packet_size is smaller than their header, and fragmentation fails its setup instead of dividing by zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
592d1820ba
commit
13ec5f27e9
@@ -191,4 +191,13 @@ TEST_F(BasicFragmentationTest, OversizedSingleFragmentDropped) {
|
||||
EXPECT_EQ(received, std::vector<Packet>{Packet({1, 2, 3, 4})});
|
||||
}
|
||||
|
||||
TEST_F(BasicFragmentationTest, LinkTooSmallFailsSetup) {
|
||||
this->link_a.set_max_packet_size(BasicFragmentation::HEADER_SIZE);
|
||||
BasicFragmentation fragmentation(&this->link_a, 100);
|
||||
fragmentation.setup();
|
||||
EXPECT_TRUE(fragmentation.is_failed());
|
||||
Packet packet{1};
|
||||
EXPECT_FALSE(fragmentation.send_to_interface(PacketBuffer(packet), {}));
|
||||
}
|
||||
|
||||
} // namespace esphome::packet_interface::fragmentation_testing
|
||||
|
||||
Reference in New Issue
Block a user