|
OpenVPN
|
Encoding and decoding of the server probe TLVs. More...


Go to the source code of this file.
Data Structures | |
| struct | probe_request |
| probe request TLV, sent by a client to probe a server More... | |
| struct | probe_reply |
| probe reply TLV, a server's answer to a probe request More... | |
Macros | |
| #define | PROBE_REQUEST_FLAG_PROBE_ONLY 0x00000001 |
| probe request flags. | |
| #define | PROBE_REPLY_FLAG_RESEND_WKC 0x0001 |
| complete the handshake with P_CONTROL_WKC_V1 rather than P_CONTROL_V1 | |
| #define | PROBE_REPLY_FLAG_ADDRS_EQUAL 0x0002 |
| the other addresses of this remote are the same server, no need to probe them | |
| #define | PROBE_REPLY_FLAG_LIFETIME_SHARED 0x0004 |
| the connect_lifetime holds against those other addresses too, so a reply from one of them can skip the handshake with another. | |
| #define | PROBE_REPLY_FLAG_PROBE_MORE 0x0008 |
| the other addresses of this remote are distinct servers, so probe them too | |
| #define | PROBE_REQUEST_LEN ((uint16_t)(2 * sizeof(uint64_t) + sizeof(uint32_t))) |
| request_id (u64), timestamp (u64), flags (u32) | |
| #define | PROBE_REPLY_LEN ((uint16_t)(sizeof(uint64_t) + 5 * sizeof(uint16_t))) |
| request_id (u64), then priority, weight, max_latency_diff, connect_lifetime and flags (u16 each) | |
Functions | |
| bool | probe_request_write (struct buffer *buf, const struct probe_request *r) |
| Write a complete probe request TLV, header and value, to buf. | |
| bool | probe_request_read (struct buffer *buf, struct probe_request *r) |
| Read a probe request TLV value from buf. | |
| bool | probe_reply_write (struct buffer *buf, const struct probe_reply *r) |
| Write a complete probe reply TLV, header and value, to buf. | |
| bool | probe_reply_read (struct buffer *buf, struct probe_reply *r) |
| Read a probe reply TLV value from buf. | |
Encoding and decoding of the server probe TLVs.
A client probes a server by sending a P_CONTROL_V2 message whose payload carries a probe request TLV, and the server answers with a P_CONTROL_V2 message carrying a probe reply TLV. The reply tells the client how the server wants to be ranked against the other remotes, and can also serve as the second packet of the three-way handshake.
The TLV framing and the TLV type space are shared with the other TLV-based control messages and live in control_msg.h; this file holds the two probe TLVs and what their fields mean.
Definition in file probe.h.
| #define PROBE_REPLY_FLAG_ADDRS_EQUAL 0x0002 |
the other addresses of this remote are the same server, no need to probe them
Definition at line 52 of file probe.h.
Referenced by probe_reply_read(), and test_probe_reply_flags_contradict().
| #define PROBE_REPLY_FLAG_LIFETIME_SHARED 0x0004 |
the connect_lifetime holds against those other addresses too, so a reply from one of them can skip the handshake with another.
Only meaningful together with ADDRS_EQUAL, which is what names those addresses.
Definition at line 56 of file probe.h.
Referenced by probe_reply_read(), and test_probe_reply_flags_contradict().
| #define PROBE_REPLY_FLAG_PROBE_MORE 0x0008 |
the other addresses of this remote are distinct servers, so probe them too
Definition at line 58 of file probe.h.
Referenced by probe_reply_read(), and test_probe_reply_flags_contradict().
| #define PROBE_REPLY_FLAG_RESEND_WKC 0x0001 |
complete the handshake with P_CONTROL_WKC_V1 rather than P_CONTROL_V1
Definition at line 50 of file probe.h.
Referenced by test_probe_reply_roundtrip(), and test_probe_reply_wire_format().
| #define PROBE_REPLY_LEN ((uint16_t)(sizeof(uint64_t) + 5 * sizeof(uint16_t))) |
request_id (u64), then priority, weight, max_latency_diff, connect_lifetime and flags (u16 each)
Definition at line 98 of file probe.h.
Referenced by probe_reply_read(), probe_reply_write(), and test_probe_reply_roundtrip().
| #define PROBE_REQUEST_FLAG_PROBE_ONLY 0x00000001 |
probe request flags.
The client is only probing: it does not want to continue into a handshake, and the server may forget it right away.
Definition at line 46 of file probe.h.
Referenced by test_probe_request_roundtrip().
| #define PROBE_REQUEST_LEN ((uint16_t)(2 * sizeof(uint64_t) + sizeof(uint32_t))) |
request_id (u64), timestamp (u64), flags (u32)
Definition at line 94 of file probe.h.
Referenced by probe_request_read(), probe_request_write(), test_find_tlv_skips_optional_after_wanted(), test_find_tlv_value_truncated(), test_probe_request_forward_compat(), and test_probe_request_roundtrip().
| bool probe_reply_read | ( | struct buffer * | buf, |
| struct probe_reply * | r ) |
Read a probe reply TLV value from buf.
The calling convention is that of probe_request_read().
The two flag combinations the protocol rules out are rejected here, since neither can be acted on: a reply must not call the other addresses of the remote both the same server and distinct ones, and it must not extend the connect_lifetime to those addresses without first calling them the same server.
Definition at line 67 of file probe.c.
References buf_len(), buf_read_u16(), buf_read_u64(), probe_reply::connect_lifetime, probe_reply::flags, probe_reply::max_latency_diff, probe_reply::priority, PROBE_REPLY_FLAG_ADDRS_EQUAL, PROBE_REPLY_FLAG_LIFETIME_SHARED, PROBE_REPLY_FLAG_PROBE_MORE, PROBE_REPLY_LEN, probe_reply::request_id, and probe_reply::weight.
Referenced by test_probe_reply_flags_contradict(), test_probe_reply_roundtrip(), and test_probe_reply_too_short().
| bool probe_reply_write | ( | struct buffer * | buf, |
| const struct probe_reply * | r ) |
Write a complete probe reply TLV, header and value, to buf.
Definition at line 58 of file probe.c.
References buf_write_u16(), buf_write_u64(), probe_reply::connect_lifetime, ctrl_msg_tlv_write_header(), probe_reply::flags, probe_reply::max_latency_diff, probe_reply::priority, PROBE_REPLY_LEN, probe_reply::request_id, TLV_TYPE_PROBE_REPLY, and probe_reply::weight.
Referenced by test_probe_reply_flags_contradict(), test_probe_reply_roundtrip(), and test_probe_reply_wire_format().
| bool probe_request_read | ( | struct buffer * | buf, |
| struct probe_request * | r ) |
Read a probe request TLV value from buf.
buf must cover exactly the TLV's value, as ctrl_msg_find_tlv() returns it. Bytes beyond the fields understood here are ignored, so a longer value from a future version still parses. Flag bits that are not known are kept in flags rather than rejected, for the same reason.
Definition at line 41 of file probe.c.
References buf_len(), buf_read_u32(), buf_read_u64(), probe_request::flags, PROBE_REQUEST_LEN, probe_request::request_id, and probe_request::timestamp.
Referenced by test_find_tlv_skips_optional_after_wanted(), test_probe_request_forward_compat(), test_probe_request_roundtrip(), and test_probe_request_too_short().
| bool probe_request_write | ( | struct buffer * | buf, |
| const struct probe_request * | r ) |
Write a complete probe request TLV, header and value, to buf.
Definition at line 33 of file probe.c.
References buf_write_u32(), buf_write_u64(), ctrl_msg_tlv_write_header(), probe_request::flags, PROBE_REQUEST_LEN, probe_request::request_id, probe_request::timestamp, and TLV_TYPE_PROBE_REQUEST.
Referenced by test_find_tlv_rejects_duplicate(), test_find_tlv_rejects_unknown_mandatory(), test_find_tlv_skips_optional_after_wanted(), test_find_tlv_trailing_bytes(), test_probe_request_roundtrip(), and test_probe_request_wire_format().