33TEST(oob_probe, server_probe_roundtrip)
42 EXPECT_EQ(
out->timestamp, in.timestamp);
43 EXPECT_EQ(
out->flags, in.flags);
47TEST(oob_probe, probe_reply_roundtrip)
53 .max_latency_diff = 25,
54 .connect_lifetime = 60,
62 EXPECT_TRUE(
out->peer_session_id.match(in.peer_session_id));
63 EXPECT_EQ(
out->priority, in.priority);
64 EXPECT_EQ(
out->weight, in.weight);
65 EXPECT_EQ(
out->connect_lifetime, in.connect_lifetime);
66 EXPECT_EQ(
out->flags, in.flags);
67 EXPECT_EQ(
out->max_latency_diff, in.max_latency_diff);
71TEST(oob_probe, server_probe_wire_format)
104TEST(oob_probe, probe_reply_wire_format)
110 .max_latency_diff = 25,
111 .connect_lifetime = 60,
150TEST(oob_probe, skips_unknown_optional_tlv)
156 ASSERT_TRUE(oob::write_u16(buf, 0xdead));
160 ASSERT_TRUE(in.write(buf));
164 EXPECT_EQ(
out->timestamp, 42u);
169TEST(oob_probe, rejects_unknown_mandatory_tlv)
174 ASSERT_TRUE(oob::write_u16(buf, 0xdead));
177 ASSERT_TRUE(in.write(buf));
183TEST(oob_probe, tolerates_longer_tlv_value)
189 ASSERT_TRUE(oob::write_u64(buf, 7));
190 ASSERT_TRUE(oob::write_u32(buf, 0));
191 ASSERT_TRUE(oob::write_u32(buf, 0xffffffff));
195 EXPECT_EQ(
out->timestamp, 7u);
199TEST(oob_probe, truncated_input_fails)
207 for (
size_t n = 0; n < full.
size(); ++n)
216TEST(oob_probe, oversized_tlv_length_fails)
221 ASSERT_TRUE(oob::write_u64(buf, 1));
227TEST(oob_probe, wrong_message_type_fails)
const T * c_data() const
Returns a const pointer to the start of the buffer.
void push_back(const T &value)
Append a T object to the end of the array, resizing the array if necessary.
size_t size() const
Returns the size of the buffer in T objects.
void write(const T *data, const size_t size)
Write data to the buffer.
bool server_probe_write(Buffer &buf, const ProbeParameter ¶m)
Write a complete SERVER_PROBE (message header + probe_parameter TLV). Client.
bool client_reply_write(Buffer &buf, const ProbeReply &reply)
Write a complete PROBE_REPLY (message header + probe_reply TLV). Server.
std::optional< ProbeReply > client_reply_read(Buffer &buf)
std::optional< ProbeParameter > server_probe_read(Buffer &buf)
bool msg_write_header(Buffer &buf, std::uint16_t msg_type)
Write an OOB message-type header (the 16-bit type preceding the TLVs).
bool tlv_write_header(Buffer &buf, std::uint16_t type, bool optional, std::uint16_t value_len)
Write a TLV header (type + optional flag + value length) to buf.
probe parameter TLV (sent by the client in a SERVER_PROBE).
static constexpr std::size_t WIRE_LEN
std::uint64_t timestamp
client clock as a UNIX timestamp
probe reply TLV (sent by the server in a PROBE_REPLY).
ProtoSessionID peer_session_id
echoes the session id of the request
TEST(oob_probe, server_probe_roundtrip)
static std::stringstream out