From patchwork Fri Dec 4 17:55:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5850 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:311b:b0:11b:d6c:f273 with SMTP id e27csp1925135laa; Fri, 4 Dec 2026 09:55:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGJqz3yEbJ4nlb+inBS2t6TnG9cLm8fcAhCflq26sVqN2KRlWqWKKHHOUchL2hVM4KusLn2H5vniZc=@openvpn.net X-Received: by 2002:a05:701b:4542:10b0:1b3:a8fc:6306 with SMTP id a92af1059eb24-1b5ced52ac2mr4582735c88.6.1796406949401; Fri, 04 Dec 2026 09:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796406949; cv=none; d=google.com; s=arc-20260327; b=ESJCZO30gQ0k02Q6igo6Yl1qTquDgk0ucOmAPqydwnunrd3gUh91HHbQigGvnp9Gay DfzXnxVzXpbCi3JmSLpPbYcopNSWoegl7zT31QWap5V6EIyLQc7bz2ZT05vFG4CmXb54 L0iYx/HwcD/hbYfgjbW6V0LU907tAqamiBWTqsABPN6QUqFBpGnZ+1ky2wiX1+vswbTi JumOJ2rvjY0RxFrPmBFaDb8K7uagYCuqEqE/p/tXQ4YXx072EIfHUQYXsxWk/uSpBqI6 k8EjT9ZEUa6DUCU7Pw0sNuLs2eSasNitPP6cSKcXe617dV91ce5rUdL2SwCZhT2RfBEU eT9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=bPmo654fnMTx7UHcCarntQ7mMwrxy+3xDWDSebCXHlI=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=c98rhucG225BcCxG6p+n/nnuNZcTrjlcs1z/DhluY8YALeEMxSYpHJJCDmb3YIhIBC L/D9dqMHAsnu7ihQ3GtsyJJdQOb6OL8IIHm0MU/5+9HHnj4RkPFvWl+m5/TPCoEhalcJ pumiY3FrhuV8hNAGhQpcK02t47PhQgYCk9VgzPoqgPfyGlMaycMgGSsLQccoBM9wsBVa OZoHIxGdLLRI/4QWfEryV2SpJUaCFxU1lvHzQGv0B4tChlBUymDIc214M6Zc0l0Nvxjx V9iHBZXJ+1ly//iW5VVOvO+eGEFI9mGGelLnph/U8krNnBuvzbr4v/tgsTLzMDAXpRBN Ybpw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=P8rwQir0; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=WJjjRhSu; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=gvlYSbgF; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id a92af1059eb24-1b5d6430404si13343509c88.39.2026.12.04.09.55.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Dec 2026 09:55:49 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=P8rwQir0; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=WJjjRhSu; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=gvlYSbgF; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=bPmo654fnMTx7UHcCarntQ7mMwrxy+3xDWDSebCXHlI=; b=P8rwQir0zaGhG/ DG7Oa1T5yTPHmrM78fMRkOb33W9jiX1Bev3AsF5nOdQiypB3p5uJpTq4CEXTCmClzEiHrOQQt0qmM JWgsaux7S7EW567ThDARUYXic9Lfej/hNmco+wZgpmWnIms4lC6VMLvbmGV+Kn9I5/gZl9KkOCU42 5VE=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xZXVc-000000003L9-1yA8; Fri, 04 Dec 2026 17:55:48 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xZXVa-000000003L3-3DlL for openvpn-devel@lists.sourceforge.net; Fri, 04 Dec 2026 17:55:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oI4jVSH2dgoPbuJVwBCM6X5k7jpIPbw4YT/m3SwoZC8=; b=WJjjRhSusBetShVL82Wz+wnRlq /g+ZHYXEqR8Eegfkg4PofdWXi7GUidw0lUf0/F2+wcR1VZSW/N7czJaFqDOpnQnfRDBd89HHyUl2k n+b8xB8lOzDqXP0fekNvAb7SoUXlIJCr5ca0A4nHmlODDTcZPTvnI2wWRM2PnW/b+kL0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=oI4jVSH2dgoPbuJVwBCM6X5k7jpIPbw4YT/m3SwoZC8=; b=gvlYSbgFsnUrGhARyUgnVn5ygw T1cYCryw0X7p0GGzYsVOkTxKuDVmtO0gpOTxUKi+iMhwEwKMRZWvkpGsXFIoUth20Q7UKwhmXDO8Q HdXc0thiYajXY6La8BJmYkjdrETRVlAuBeCYKADek7slegMgEjQ5jXBMdPSi1EEoXSIQ=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xZXVY-000000007wH-3rzw for openvpn-devel@lists.sourceforge.net; Fri, 04 Dec 2026 17:55:46 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6B4Htcdf000716 for ; Fri, 4 Dec 2026 18:55:38 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6B4HtcGd000715 for openvpn-devel@lists.sourceforge.net; Fri, 4 Dec 2026 18:55:38 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 4 Dec 2026 18:55:33 +0100 Message-ID: <20261204175538.690-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Lev Stipakov Add the message-level helpers a server needs before it can answer a probe: probe_request_find() picks the probe request TLV out of the payload of a received P_CONTROL_V2 message, probe_timestamp_in_wi [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xZXVY-000000007wH-3rzw Subject: [Openvpn-devel] [PATCH v30] probe: Add probe request lookup and the probe-reply decision X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1883669213663960976 X-GMAIL-MSGID: 1883669213663960976 From: Lev Stipakov Add the message-level helpers a server needs before it can answer a probe: probe_request_find() picks the probe request TLV out of the payload of a received P_CONTROL_V2 message, probe_timestamp_in_window() checks its timestamp against the window the wire protocol describes, and probe_request_check() combines the two and classifies the message as invalid, stale or OK. The request itself is handed back, because the reply has to echo its request_id, which is how a client tells which of its probes a reply answers. A stale request, one whose timestamp is outside the window, is reported apart from an invalid one rather than dropped here. The timestamp is what bounds how long a captured request can be replayed against the server, but a client with an unsynchronised clock sends something that looks just like a replay, so what to do about it is the caller's decision: a follow-up answers a few of them per period. The width of the window is the caller's too. These are pure functions, covered by unit tests. The server packet path uses them in a follow-up, which also builds and sends the reply. Change-Id: Iafa9efc1c156974ad9f5752e9de810a8c2f68c30 Signed-off-by: Lev Stipakov Acked-by: Steffan Karger Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1742 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1742 This mail reflects revision 30 of this Change. Acked-by according to Gerrit (reflected above): Steffan Karger diff --git a/src/openvpn/control_msg.h b/src/openvpn/control_msg.h index 8ad5530..bf3525f 100644 --- a/src/openvpn/control_msg.h +++ b/src/openvpn/control_msg.h @@ -117,6 +117,10 @@ * whole sequence is walked even once the wanted TLV has been found. A message * carrying several mandatory TLVs walks them with ctrl_msg_tlv_next() instead. * + * The optional flag is consulted only for the types the caller did not ask + * for: it says whether a TLV may be ignored when its type is not understood, + * so it carries nothing for wanted_type, which is matched on the type alone. + * * On success value covers exactly the found TLV's value bytes; as in * ctrl_msg_tlv_next(), a header claiming more bytes than payload holds is * rejected rather than reported as found. payload is consumed as it is read. diff --git a/src/openvpn/probe.c b/src/openvpn/probe.c index 2497b07..b59c654 100644 --- a/src/openvpn/probe.c +++ b/src/openvpn/probe.c @@ -92,3 +92,31 @@ } return true; } + +bool +probe_request_find(struct buffer *payload, struct probe_request *req) +{ + struct buffer value; + return ctrl_msg_find_tlv(payload, TLV_TYPE_PROBE_REQUEST, &value) + && probe_request_read(&value, req); +} + +bool +probe_timestamp_in_window(uint64_t probe_ts, uint64_t now, uint64_t window_secs) +{ + /* both clocks are unsigned and either may be ahead, so subtract the + * smaller from the larger rather than letting the difference wrap */ + uint64_t diff = (now > probe_ts) ? (now - probe_ts) : (probe_ts - now); + return diff <= window_secs; +} + +enum probe_verdict +probe_request_check(struct buffer *payload, uint64_t now, uint64_t window_secs, + struct probe_request *req) +{ + if (!probe_request_find(payload, req)) + { + return PROBE_INVALID; + } + return probe_timestamp_in_window(req->timestamp, now, window_secs) ? PROBE_OK : PROBE_STALE; +} diff --git a/src/openvpn/probe.h b/src/openvpn/probe.h index 6001774..f836416 100644 --- a/src/openvpn/probe.h +++ b/src/openvpn/probe.h @@ -138,4 +138,61 @@ */ bool probe_reply_read(struct buffer *buf, struct probe_reply *r); +/** + * Find the probe request TLV in the payload of a received P_CONTROL_V2 + * message and parse it. + * + * A TLV of another type is skipped if it is marked optional and rejects the + * whole message if it is not, as ctrl_msg_find_tlv() defines. payload is + * consumed as it is read. + * + * @param payload the message payload, positioned at the first TLV + * @param req filled with the probe request on success + * @return true if the payload holds exactly one well-formed probe request + */ +bool probe_request_find(struct buffer *payload, struct probe_request *req); + +/** + * Is the timestamp of a probe request close enough to our own clock? + * + * This is how a server bounds the age of the requests it answers, and with it + * for how long a captured request can be replayed against it. The window is + * the caller's to choose: it has to be wide enough for a client that has no + * proper clock synchronisation, so it cannot be tight. + * + * @param probe_ts the timestamp from the probe request, UNIX seconds + * @param now the current time, UNIX seconds + * @param window_secs the largest difference allowed, in either direction + * @return true if probe_ts and now are no more than window_secs apart + */ +bool probe_timestamp_in_window(uint64_t probe_ts, uint64_t now, uint64_t window_secs); + +/** what probe_request_check() made of a received message */ +enum probe_verdict +{ + PROBE_INVALID, /**< it holds no probe request, so there is nothing to answer */ + PROBE_STALE, /**< a probe request, but its timestamp is outside the window */ + PROBE_OK, /**< a probe request whose timestamp is inside the window */ +}; + +/** + * Classify the payload of a received P_CONTROL_V2 message: probe_request_find() + * followed by probe_timestamp_in_window(). + * + * A stale request is reported apart from an invalid one rather than folded + * into it, because the two deserve different treatment. A replayed request and + * one from a client with an unsynchronised clock are indistinguishable here, so + * a server that dropped every stale request would lock that client out. What to + * do instead is left to the caller, which also builds the reply. + * + * @param payload the message payload, consumed as it is read + * @param now the current time, UNIX seconds + * @param window_secs the largest difference allowed, in either direction + * @param req filled with the probe request unless the verdict is + * PROBE_INVALID, so that a reply can echo its request_id + * @return what the payload turned out to be + */ +enum probe_verdict probe_request_check(struct buffer *payload, uint64_t now, uint64_t window_secs, + struct probe_request *req); + #endif /* ifndef PROBE_H */ diff --git a/tests/unit_tests/openvpn/test_pkt.c b/tests/unit_tests/openvpn/test_pkt.c index 5609c67..8aa3e1f 100644 --- a/tests/unit_tests/openvpn/test_pkt.c +++ b/tests/unit_tests/openvpn/test_pkt.c @@ -856,7 +856,16 @@ cmocka_unit_test(test_find_tlv_skips_optional_after_wanted), cmocka_unit_test(test_find_tlv_rejects_unknown_mandatory), cmocka_unit_test(test_find_tlv_rejects_duplicate), - cmocka_unit_test(test_find_tlv_empty_payload) + cmocka_unit_test(test_find_tlv_empty_payload), + cmocka_unit_test(test_probe_request_find), + cmocka_unit_test(test_probe_request_find_skips_unknown), + cmocka_unit_test(test_probe_request_find_rejects_unknown_mandatory), + cmocka_unit_test(test_probe_request_find_missing), + cmocka_unit_test(test_probe_request_find_reply_tlv), + cmocka_unit_test(test_probe_timestamp_in_window), + cmocka_unit_test(test_probe_request_check_valid), + cmocka_unit_test(test_probe_request_check_stale), + cmocka_unit_test(test_probe_request_check_no_request) }; return cmocka_run_group_tests_name("pkt tests", tests, NULL, NULL); diff --git a/tests/unit_tests/openvpn/test_probe.c b/tests/unit_tests/openvpn/test_probe.c index 967252c..1c6d2c1 100644 --- a/tests/unit_tests/openvpn/test_probe.c +++ b/tests/unit_tests/openvpn/test_probe.c @@ -423,3 +423,179 @@ gc_free(&gc); } + +/* A payload of nothing but a probe request is found, fields and all. */ +void +test_probe_request_find(void **state) +{ + struct gc_arena gc = gc_new(); + struct buffer buf = alloc_buf_gc(128, &gc); + + const struct probe_request in = { + .request_id = 0xdeadbeefcafef00dULL, + .timestamp = 0x1122334455667788ULL, + .flags = PROBE_REQUEST_FLAG_PROBE_ONLY, + }; + assert_true(probe_request_write(&buf, &in)); + + struct probe_request out = { 0 }; + assert_true(probe_request_find(&buf, &out)); + assert_true(out.request_id == in.request_id); + assert_true(out.timestamp == in.timestamp); + assert_int_equal(out.flags, in.flags); + + gc_free(&gc); +} + +/* A TLV of another type that is marked optional is skipped, so the request is + * still found behind one. */ +void +test_probe_request_find_skips_unknown(void **state) +{ + struct gc_arena gc = gc_new(); + struct buffer buf = alloc_buf_gc(128, &gc); + + assert_true(ctrl_msg_tlv_write_header(&buf, 0x7ff, true, 4)); + assert_true(buf_write_u32(&buf, 0xcafef00d)); + const struct probe_request in = { .timestamp = 42 }; + assert_true(probe_request_write(&buf, &in)); + + struct probe_request out = { 0 }; + assert_true(probe_request_find(&buf, &out)); + assert_true(out.timestamp == 42); + + gc_free(&gc); +} + +/* A TLV we do not know that is not marked optional carries something its + * sender requires us to act on, so the message is rejected whether that TLV + * comes before or after the request. */ +void +test_probe_request_find_rejects_unknown_mandatory(void **state) +{ + struct gc_arena gc = gc_new(); + const struct probe_request in = { .timestamp = 42 }; + + struct buffer before = alloc_buf_gc(128, &gc); + assert_true(ctrl_msg_tlv_write_header(&before, 0x7ff, false, 4)); + assert_true(buf_write_u32(&before, 0xcafef00d)); + assert_true(probe_request_write(&before, &in)); + + struct buffer after = alloc_buf_gc(128, &gc); + assert_true(probe_request_write(&after, &in)); + assert_true(ctrl_msg_tlv_write_header(&after, 0x7ff, false, 4)); + assert_true(buf_write_u32(&after, 0xcafef00d)); + + struct probe_request out = { 0 }; + assert_false(probe_request_find(&before, &out)); + assert_false(probe_request_find(&after, &out)); + + gc_free(&gc); +} + +/* A payload that holds no probe request at all. */ +void +test_probe_request_find_missing(void **state) +{ + struct gc_arena gc = gc_new(); + struct buffer buf = alloc_buf_gc(128, &gc); + + assert_true(ctrl_msg_tlv_write_header(&buf, 0x7ff, true, 4)); + assert_true(buf_write_u32(&buf, 0)); + + struct probe_request out = { 0 }; + assert_false(probe_request_find(&buf, &out)); + + gc_free(&gc); +} + +/* A probe reply is not a probe request: a server handed one must not answer + * it. The reply TLV is mandatory, so it rejects the message rather than + * being skipped. */ +void +test_probe_request_find_reply_tlv(void **state) +{ + struct gc_arena gc = gc_new(); + struct buffer buf = alloc_buf_gc(128, &gc); + + const struct probe_reply in = { .request_id = 42 }; + assert_true(probe_reply_write(&buf, &in)); + + struct probe_request out = { 0 }; + assert_false(probe_request_find(&buf, &out)); + + gc_free(&gc); +} + +/* The window is inclusive and symmetric: a client clock that is behind is + * treated like one that is ahead. */ +void +test_probe_timestamp_in_window(void **state) +{ + const uint64_t now = 1000000; + const uint64_t window = 30; + + assert_true(probe_timestamp_in_window(now, now, window)); + assert_true(probe_timestamp_in_window(now - window, now, window)); + assert_true(probe_timestamp_in_window(now + window, now, window)); + assert_false(probe_timestamp_in_window(now - window - 1, now, window)); + assert_false(probe_timestamp_in_window(now + window + 1, now, window)); + + /* a timestamp of 0, and one near the end of the range, must not wrap into + * the window */ + assert_false(probe_timestamp_in_window(0, now, window)); + assert_false(probe_timestamp_in_window(UINT64_MAX, now, window)); +} + +/* A well-formed request with a timestamp inside the window. */ +void +test_probe_request_check_valid(void **state) +{ + struct gc_arena gc = gc_new(); + struct buffer buf = alloc_buf_gc(128, &gc); + + const uint64_t now = 1000000; + const struct probe_request in = { .request_id = 1, .timestamp = now }; + assert_true(probe_request_write(&buf, &in)); + + struct probe_request req = { 0 }; + assert_int_equal(probe_request_check(&buf, now, 30, &req), PROBE_OK); + assert_true(req.request_id == 1); + + gc_free(&gc); +} + +/* One whose timestamp is outside it is stale rather than invalid, and is + * still handed back so that the caller can answer it if it decides to. */ +void +test_probe_request_check_stale(void **state) +{ + struct gc_arena gc = gc_new(); + struct buffer buf = alloc_buf_gc(128, &gc); + + const uint64_t now = 1000000; + const struct probe_request in = { .request_id = 7, .timestamp = now - 1000 }; + assert_true(probe_request_write(&buf, &in)); + + struct probe_request req = { 0 }; + assert_int_equal(probe_request_check(&buf, now, 30, &req), PROBE_STALE); + assert_true(req.request_id == 7); + + gc_free(&gc); +} + +/* A payload with no request in it has nothing to answer. */ +void +test_probe_request_check_no_request(void **state) +{ + struct gc_arena gc = gc_new(); + struct buffer buf = alloc_buf_gc(128, &gc); + + assert_true(ctrl_msg_tlv_write_header(&buf, 0x7ff, true, 4)); + assert_true(buf_write_u32(&buf, 0)); + + struct probe_request req; + assert_int_equal(probe_request_check(&buf, 1000000, 30, &req), PROBE_INVALID); + + gc_free(&gc); +} diff --git a/tests/unit_tests/openvpn/test_probe.h b/tests/unit_tests/openvpn/test_probe.h index 9c4137d..941bf99 100644 --- a/tests/unit_tests/openvpn/test_probe.h +++ b/tests/unit_tests/openvpn/test_probe.h @@ -51,4 +51,22 @@ void test_find_tlv_empty_payload(void **state); +void test_probe_request_find(void **state); + +void test_probe_request_find_skips_unknown(void **state); + +void test_probe_request_find_rejects_unknown_mandatory(void **state); + +void test_probe_request_find_missing(void **state); + +void test_probe_request_find_reply_tlv(void **state); + +void test_probe_timestamp_in_window(void **state); + +void test_probe_request_check_valid(void **state); + +void test_probe_request_check_stale(void **state); + +void test_probe_request_check_no_request(void **state); + #endif