curl-fuzzer C++ reference
Loading...
Searching...
No Matches
h2_runtime.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3 *
4 * SPDX-License-Identifier: curl
5 */
6
9
10#ifndef PROTO_FUZZER_H2_RUNTIME_H_
11#define PROTO_FUZZER_H2_RUNTIME_H_
12
13#include <curl/curl.h>
14
15#include <cstddef>
16#include <cstdint>
17#include <functional>
18#include <string>
19
21
22struct curl_pushheaders;
23
24namespace proto_fuzzer {
25
26class MockConnection;
27class MockServer;
28
33class H2Runtime {
34 public:
36
37 H2Runtime(const H2Runtime&) = delete;
38 H2Runtime& operator=(const H2Runtime&) = delete;
39
40 void PrepareMulti(CURLM* multi, bool accept_push);
41
42 void AttachConnection(MockConnection* connection);
43
44 void ResetPlan(const curl::fuzzer::proto::Http2Plan& plan, std::string scheme, std::string authority = "tls.test");
45
46 void ResetPlan(curl::fuzzer::proto::Http2Plan&&, std::string, std::string = "tls.test") = delete;
47 void ResetPlan(const curl::fuzzer::proto::Http2Plan&&, std::string, std::string = "tls.test") = delete;
48
49 void DrivePlan(CURLM* multi, MockServer& server, int max_idle_iterations, int max_drive_iterations,
50 const std::function<void()>& after_perform);
51
52 void FinishTransfer(CURL* easy, MockConnection* connection);
53
54 std::size_t push_callback_count() const;
55 std::size_t push_header_count() const;
56 bool saw_push_path() const;
57 std::size_t accepted_push_count() const;
58 std::size_t pushed_body_bytes() const;
59 CURLcode upkeep_result() const;
60 std::size_t observed_request_count() const;
61 std::size_t observed_client_settings_count() const;
62 std::size_t observed_client_priority_count() const;
64 CURLcode stream_weight_setopt_result() const;
65 CURLcode stream_weight_egress_result() const;
66
67 void ApplyPostHeadersTransition(CURL* easy);
68
69 private:
70 static int PushCallback(CURL* parent, CURL* pushed, std::size_t header_count, struct curl_pushheaders* headers,
71 void* userdata);
72 static std::size_t PushedWriteCallback(char* contents, std::size_t size, std::size_t nmemb, void* userdata);
73
74 H2PlanDriver plan_driver_;
75 std::size_t push_callback_count_ = 0;
76 std::size_t push_header_count_ = 0;
77 bool saw_push_path_ = false;
78 bool accept_push_ = false;
79 std::size_t accepted_push_count_ = 0;
80 std::size_t pushed_body_bytes_ = 0;
81 CURLcode upkeep_result_ = CURLE_FAILED_INIT;
82 std::uint32_t stream_weight_after_headers_ = 0;
83 bool post_headers_transition_applied_ = false;
84 CURLcode stream_weight_setopt_result_ = CURLE_FAILED_INIT;
85 CURLcode stream_weight_egress_result_ = CURLE_FAILED_INIT;
86};
87
88} // namespace proto_fuzzer
89
90#endif // PROTO_FUZZER_H2_RUNTIME_H_
Converts Http2Plan actions to correlated wire frames while tracking the request streams observed from...
Definition h2_plan.h:30
bool post_headers_transition_applied() const
H2Runtime()
Construct detached protocol state without observing a connection.
std::size_t observed_request_count() const
void FinishTransfer(CURL *easy, MockConnection *connection)
Probe upkeep while curl's connection cache and the peer are still live.
std::size_t push_callback_count() const
void ResetPlan(const curl::fuzzer::proto::Http2Plan &plan, std::string scheme, std::string authority="tls.test")
Borrow a structured plan for the ensuing synchronous drive.
Definition h2_runtime.cc:60
std::size_t observed_client_priority_count() const
void AttachConnection(MockConnection *connection)
Observe application bytes after the carrier has decoded its transport.
Definition h2_runtime.cc:50
std::size_t accepted_push_count() const
CURLcode stream_weight_setopt_result() const
std::size_t observed_client_settings_count() const
void ApplyPostHeadersTransition(CURL *easy)
Apply the plan's one state transition only after a real request stream has been observed.
Definition h2_runtime.cc:72
CURLcode stream_weight_egress_result() const
CURLcode upkeep_result() const
void DrivePlan(CURLM *multi, MockServer &server, int max_idle_iterations, int max_drive_iterations, const std::function< void()> &after_perform)
Alternate curl and one bounded H2 plan boundary.
Definition h2_runtime.cc:95
std::size_t push_header_count() const
void PrepareMulti(CURLM *multi, bool accept_push)
Install the bounded push policy before curl emits its initial SETTINGS.
Definition h2_runtime.cc:38
std::size_t pushed_body_bytes() const
bool saw_push_path() const
Owns one half of a socketpair used to feed canned responses to libcurl.
Definition mock_server.h:29
Orchestrates a bounded sequence of mock HTTP exchanges: installs socket callbacks on an easy handle,...
Definition mock_server.h:72
Stateful serializer for structured HTTP/2 peer actions.