Add ping rate tests, discover_peer helper, standardize prepend_buffer to 4096
This commit is contained in:
@@ -25,15 +25,17 @@ template <typename Buf>
|
||||
void prepend_echo_request(Buf& buf,
|
||||
eth::mac_addr src_mac, ipv4::ip4_addr src_ip,
|
||||
eth::mac_addr dst_mac, ipv4::ip4_addr dst_ip,
|
||||
uint16_t id, uint16_t seq) {
|
||||
uint16_t id, uint16_t seq,
|
||||
size_t payload_len = 0) {
|
||||
auto* e = buf.template prepend<echo>();
|
||||
e->type = 8;
|
||||
e->code = 0;
|
||||
e->checksum = 0;
|
||||
e->id = id;
|
||||
e->seq = seq;
|
||||
e->checksum = ipv4::checksum(e, sizeof(echo));
|
||||
ipv4::prepend(buf, dst_mac, src_mac, src_ip, dst_ip, 1, sizeof(echo));
|
||||
size_t icmp_len = sizeof(echo) + payload_len;
|
||||
e->checksum = ipv4::checksum(e, icmp_len);
|
||||
ipv4::prepend(buf, dst_mac, src_mac, src_ip, dst_ip, 1, icmp_len);
|
||||
}
|
||||
|
||||
bool parse_echo_reply(std::span<const uint8_t> frame, ipv4::ip4_addr& src_ip, uint16_t expected_id);
|
||||
|
||||
Reference in New Issue
Block a user