|
curl-fuzzer C++ reference
|
Real, nonblocking UDP peer for curl's TFTP state machine. More...
#include <tftp_mock_server.h>
Public Member Functions | |
| TftpMockServer () | |
| Start without live descriptors or borrowed scenario storage. | |
| ~TftpMockServer () override | |
| Close the two server endpoints after the base drive has removed curl's separately-owned client descriptor from its multi handle. | |
| void | ObserveState () override |
| Retain protocol outcomes in coverage and introspector builds. | |
| const std::vector< TftpReceivedDatagram > & | received_datagrams () const |
| Return bounded observations from the most recent run rather than parsing them in the peer. | |
| std::uint16_t | request_port () const |
| Expose the kernel-selected request endpoint for transfer-ID assertions, not for routing. | |
| std::uint16_t | transfer_port () const |
| Expose the kernel-selected response endpoint for transfer-ID assertions, not for routing. | |
| Public Member Functions inherited from proto_fuzzer::MockServerBase | |
| virtual | ~MockServerBase () |
| Out-of-line destructor so MockConnection can stay forward-declared in the base header (its complete type is only needed where unique_ptr is instantiated for destruction). | |
| virtual void | Install (CURL *easy) |
| Install the common OPENSOCKETFUNCTION / OPENSOCKETDATA / SOCKOPTFUNCTION callbacks on 'easy'. | |
| virtual void | ConfigureRequestData (ScenarioRequestData *request_data) |
| Bind protocol-specific work to the request-data callbacks after their per-scenario state has been constructed. | |
| CURLcode | DriveScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario) |
| Run 'scenario' to completion on 'easy': allocate a multi, attach 'easy', delegate protocol-specific work to RunLoop, consume its completion message, and clean up. | |
| virtual CURLcode | DriveEasyScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario, bool use_events=false) |
| Run through the public easy entrypoint when a protocol mock can preload all peer work before curl takes control. | |
| virtual ConnectOnlyRunStats | DriveConnectOnlyScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario) |
| Establish a CONNECT_ONLY transport, then perform bounded direct I/O. | |
| void | SetMultiObserver (MultiObserver observer) |
| Register an observer invoked with the live multi handle after 'easy' is attached and before the drive loop starts. | |
| MockConnection * | connection () |
Protected Member Functions | |
| curl_socket_t | HandleOpenSocket (curlsocktype purpose, struct curl_sockaddr *address) override |
| Create both server transfer IDs before returning curl's client socket. | |
| SocketSetupDisposition | GetSocketSetupDisposition (curl_socket_t curlfd, curlsocktype purpose) const override |
| TFTP returns an unconnected IPv4 datagram descriptor, so curl must still bind/configure it before the first sendto. | |
| void | RunLoop (CURLM *multi, CURL *easy, const curl::fuzzer::proto::Scenario &scenario) override |
| Give curl one nonblocking state-machine turn, retain all client packets that turn produced, then release at most one peer packet. | |
| Protected Member Functions inherited from proto_fuzzer::MockServerBase | |
| MockServerBase (MultiDrivePolicy drive_policy=MultiDrivePolicy::kPerform) | |
| Construct an empty base instance with a fixed multi-drive policy. | |
| virtual void | HandleDetachedMulti (CurlMultiPtr multi) |
| Dispose of or retain the multi after its easy handle has been removed. | |
| MultiSocketDriver * | multi_socket_driver () |
| Expose the callback state installed for the current socket-action drive. | |
| std::size_t | additional_handle_cleanup_count () const |
| void | ResumeResponseIfRequested (CURL *easy) |
| Resume receive-side callback output at one bounded drive boundary when the dedicated API plan requested it. | |
| void | ApplyPendingBackpressure () |
| Apply the BackpressureConfig cached by DriveScenario to the new connection_. | |
Additional Inherited Members | |
| Public Types inherited from proto_fuzzer::MockServerBase | |
| using | MultiObserver = std::function<void(CURLM*)> |
| Callback type used to publish the driving multi handle to observers. | |
| Static Protected Member Functions inherited from proto_fuzzer::MockServerBase | |
| static int | WaitOnMultiFdset (CURLM *multi, CURLMcode *rc) |
| Wait on curl's fdset with a short timeout. | |
| static void | ProbeMultiPollset (CURLM *multi) |
| Ask curl to construct and inspect its connection-filter pollset without waiting. | |
| static bool | MultiPollsetWantsWrite (CURLM *multi, curl_socket_t socket) |
| Inspect one socket's current writable interest through curl's public multi fdset API. | |
| static bool | UsesTimedDrive (const curl::fuzzer::proto::Scenario &scenario) |
| Treat a non-default BackpressureConfig as an explicit request for the slower, timed drive policy. | |
| Protected Attributes inherited from proto_fuzzer::MockServerBase | |
| std::unique_ptr< MockConnection > | connection_ |
| The per-scenario MockConnection, lazily created by HandleOpenSocket(). | |
| int | pending_recv_buf_bytes_ |
| Cached SO_RCVBUF/SO_SNDBUF setting in bytes. | |
| std::size_t | pending_drain_limit_ |
| Cached per-call DrainIncoming byte budget. | |
| MultiSocketDriver * | multi_socket_driver_ |
| Non-owning pointer into DriveScenario's stack. | |
| std::size_t | additional_handle_cleanup_count_ |
| Number of application-created handles, excluding the caller's parent, successfully removed from the current multi and cleaned up. | |
| bool | resume_response_ |
| True only for an API-plan multi drive with its one-shot write callback. | |
| MultiObserver | multi_observer_ |
| Observer receiving the live multi handle at the start of a drive. | |
| Static Protected Attributes inherited from proto_fuzzer::MockServerBase | |
| static constexpr int | kMaxDriveIterations = 512 |
| Hard operation budget for one scenario. | |
| static constexpr int | kMaxIdleIterations = 8 |
| Consecutive no-progress budget for ordinary scenarios. | |
| static constexpr int | kMaxTimedIdleIterations = 256 |
| Explicit backpressure scenarios get a larger idle budget and may use the short timed wait above. | |
Real, nonblocking UDP peer for curl's TFTP state machine.
An AF_UNIX socketpair cannot model TFTP: curl binds the returned descriptor as an IP datagram socket and uses sendto/recvfrom with a mutable transfer address. This peer binds two ephemeral loopback endpoints. The request endpoint receives RRQ/WRQ, while every response originates at the transfer endpoint so curl exercises the RFC transfer-ID pinning path.
Connection.initial_response, when nonempty, is the first response datagram. Each retained Connection.on_readable value is one subsequent datagram, including an explicitly empty value. A single datagram is released after each curl state-machine turn, which preserves packet boundaries and permits duplicates, unexpected blocks, and malformed packets without a thread or wall-clock wait.
Definition at line 60 of file tftp_mock_server.h.
| proto_fuzzer::TftpMockServer::TftpMockServer | ( | ) |
Start without live descriptors or borrowed scenario storage.
RunLoop builds both immediately before the first curl_multi_perform that can observe them.
Definition at line 26 of file tftp_mock_server.cc.
|
overrideprotectedvirtual |
TFTP returns an unconnected IPv4 datagram descriptor, so curl must still bind/configure it before the first sendto.
| curlfd | Descriptor returned by HandleOpenSocket. |
| purpose | Role curl assigned to the descriptor. |
Reimplemented from proto_fuzzer::MockServerBase.
Definition at line 66 of file tftp_mock_server.cc.
|
overrideprotectedvirtual |
Create both server transfer IDs before returning curl's client socket.
The first response deliberately comes from a port different from the rewritten request destination, matching real TFTP and making curl's address-pinning transition observable through where its next ACK/DATA arrives. Curl owns the client descriptor after a successful return.
| purpose | Socket purpose supplied by curl's open-socket callback. |
| address | Mutable destination storage supplied by curl. |
Implements proto_fuzzer::MockServerBase.
Definition at line 196 of file tftp_mock_server.cc.
| const std::vector< TftpReceivedDatagram > & proto_fuzzer::TftpMockServer::received_datagrams | ( | ) | const |
Return bounded observations from the most recent run rather than parsing them in the peer.
Tests can assert exact RRQ/WRQ/DATA/ACK bytes while production fuzz iterations pay only the bounded copies needed for those observations.
Definition at line 49 of file tftp_mock_server.cc.
| std::uint16_t proto_fuzzer::TftpMockServer::request_port | ( | ) | const |
Expose the kernel-selected request endpoint for transfer-ID assertions, not for routing.
Definition at line 54 of file tftp_mock_server.cc.
|
overrideprotectedvirtual |
Give curl one nonblocking state-machine turn, retain all client packets that turn produced, then release at most one peer packet.
Completion gets one final drain so the terminal ACK remains observable. Incomplete scripts stop after a small idle prefix rather than waiting for TFTP's one-second retry clock, keeping mutation throughput independent of wall time.
| multi | Multi handle containing the scenario's easy handle. |
| easy | Easy handle being driven; all work is reached through multi. |
| scenario | Scenario whose primary Connection supplies UDP packets. |
Implements proto_fuzzer::MockServerBase.
Definition at line 311 of file tftp_mock_server.cc.
| std::uint16_t proto_fuzzer::TftpMockServer::transfer_port | ( | ) | const |
Expose the kernel-selected response endpoint for transfer-ID assertions, not for routing.
Definition at line 59 of file tftp_mock_server.cc.