#include "test/network/fake_network_socket_server.h"
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include "absl/algorithm/container.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "rtc_base/event.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread.h"
namespace webrtc {
namespace test {
namespace {
std::string ToString(const rtc::SocketAddress& addr) { … }
}
class FakeNetworkSocket : public rtc::Socket,
public EmulatedNetworkReceiverInterface { … };
FakeNetworkSocket::FakeNetworkSocket(FakeNetworkSocketServer* socket_server,
rtc::Thread* thread)
: … { … }
FakeNetworkSocket::~FakeNetworkSocket() { … }
void FakeNetworkSocket::OnPacketReceived(EmulatedIpPacket packet) { … }
rtc::SocketAddress FakeNetworkSocket::GetLocalAddress() const { … }
rtc::SocketAddress FakeNetworkSocket::GetRemoteAddress() const { … }
int FakeNetworkSocket::Bind(const rtc::SocketAddress& addr) { … }
int FakeNetworkSocket::Connect(const rtc::SocketAddress& addr) { … }
int FakeNetworkSocket::Send(const void* pv, size_t cb) { … }
int FakeNetworkSocket::SendTo(const void* pv,
size_t cb,
const rtc::SocketAddress& addr) { … }
int FakeNetworkSocket::Recv(void* pv, size_t cb, int64_t* timestamp) { … }
int FakeNetworkSocket::RecvFrom(void* pv,
size_t cb,
rtc::SocketAddress* paddr,
int64_t* timestamp) { … }
int FakeNetworkSocket::Listen(int backlog) { … }
rtc::Socket* FakeNetworkSocket::Accept(rtc::SocketAddress* ) { … }
int FakeNetworkSocket::Close() { … }
int FakeNetworkSocket::GetError() const { … }
void FakeNetworkSocket::SetError(int error) { … }
rtc::Socket::ConnState FakeNetworkSocket::GetState() const { … }
int FakeNetworkSocket::GetOption(Option opt, int* value) { … }
int FakeNetworkSocket::SetOption(Option opt, int value) { … }
FakeNetworkSocketServer::FakeNetworkSocketServer(
EndpointsContainer* endpoints_container)
: … { … }
FakeNetworkSocketServer::~FakeNetworkSocketServer() = default;
EmulatedEndpointImpl* FakeNetworkSocketServer::GetEndpointNode(
const rtc::IPAddress& ip) { … }
void FakeNetworkSocketServer::Unregister(FakeNetworkSocket* socket) { … }
rtc::Socket* FakeNetworkSocketServer::CreateSocket(int family, int type) { … }
void FakeNetworkSocketServer::SetMessageQueue(rtc::Thread* thread) { … }
bool FakeNetworkSocketServer::Wait(webrtc::TimeDelta max_wait_duration,
bool process_io) { … }
void FakeNetworkSocketServer::WakeUp() { … }
}
}