79 struct curl_sockaddr* address =
nullptr)
override;
83 void RunLoop(CURLM* multi, CURL* easy,
const curl::fuzzer::proto::Scenario& scenario)
override;
88 enum class TransferDirection {
101 const curl::fuzzer::proto::Connection* script =
nullptr;
108 bool transfer_started =
false;
112 std::string incoming_data;
117 void ResetForScenario(
const curl::fuzzer::proto::Scenario& scenario);
121 bool ServiceControlConnection();
123 bool ServiceDataConnections();
125 void HandleControlCommand(std::string_view command);
127 void StartNextTransfer(TransferDirection direction);
129 void PreloadDownload(DataChannel* channel);
131 bool UsesActiveMode()
const;
133 curl_socket_t OpenActiveListener(
struct curl_sockaddr* address);
135 void ConnectActiveDataChannel();
137 void CloseActiveDescriptors();
139 static bool WriteActiveBytes(
int fd,
const unsigned char* data, std::size_t size);
141 static bool ReadActiveBytes(
int fd, std::string* output);
143 void QueueTransferCompletion();
145 const std::string* NextControlReply();
147 bool WriteControlBytes(std::string_view bytes);
149 static std::string_view CommandVerb(std::string_view command);
151 static bool VerbEquals(std::string_view verb, std::string_view expected_uppercase);
153 static TransferDirection DirectionForVerb(std::string_view verb);
155 bool IsConfiguredCustomDownload(std::string_view verb)
const;
157 static int FirstReplyCode(std::string_view response);
159 static bool TailNeedsOnlyNewline(std::string_view response);
161 static void CapturePrefix(std::string_view source, std::size_t limit, std::string* destination);
163 void FinishConnections(
bool completed);
172 static constexpr std::size_t kMaxCapturedControlBytes = 64 * 1024;
176 const curl::fuzzer::proto::Scenario* scenario_;
180 std::unique_ptr<MockConnection> control_connection_;
182 std::array<DataChannel, kMaxDataChannels> data_channels_;
184 std::size_t next_data_script_;
187 int active_listener_fd_;
190 curl_socket_t active_listener_client_fd_;
192 std::size_t pending_active_channel_;
194 std::size_t control_reply_count_;
196 std::size_t next_control_reply_;
198 std::string pending_control_bytes_;
200 std::string control_transcript_;
202 std::string uploaded_data_;
204 std::size_t active_pollset_probe_count_;
206 bool control_opened_;