summaryrefslogtreecommitdiffstats
path: root/net/curvecp/curvecp_client_socket.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/curvecp/curvecp_client_socket.cc')
-rw-r--r--net/curvecp/curvecp_client_socket.cc111
1 files changed, 111 insertions, 0 deletions
diff --git a/net/curvecp/curvecp_client_socket.cc b/net/curvecp/curvecp_client_socket.cc
new file mode 100644
index 0000000..f28e839
--- /dev/null
+++ b/net/curvecp/curvecp_client_socket.cc
@@ -0,0 +1,111 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/ip_endpoint.h"
+#include "net/base/net_errors.h"
+#include "net/base/sys_addrinfo.h"
+#include "net/curvecp/curvecp_client_socket.h"
+#include "net/curvecp/messenger.h"
+
+namespace net {
+
+CurveCPClientSocket::CurveCPClientSocket(const AddressList& addresses,
+ net::NetLog* net_log,
+ const net::NetLog::Source& source)
+ : addresses_(addresses),
+ net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)),
+ messenger_(&packetizer_) {
+}
+
+CurveCPClientSocket::~CurveCPClientSocket() {
+}
+
+int CurveCPClientSocket::Connect(CompletionCallback* callback) {
+ return packetizer_.Connect(addresses_, &messenger_, callback);
+}
+
+void CurveCPClientSocket::Disconnect() {
+ // TODO(mbelshe): DCHECK that we're connected.
+ // Record the ConnectionKey so that we can disconnect it properly.
+ // Do we need a close() on the messenger?
+ // packetizer_.Close();
+}
+
+bool CurveCPClientSocket::IsConnected() const {
+ // TODO(mbelshe): return packetizer_.IsConnected();
+ return false;
+}
+
+bool CurveCPClientSocket::IsConnectedAndIdle() const {
+ // TODO(mbelshe): return packetizer_.IsConnectedAndIdle();
+ return false;
+}
+
+int CurveCPClientSocket::GetPeerAddress(AddressList* address) const {
+ IPEndPoint endpoint;
+ int rv = packetizer_.GetPeerAddress(&endpoint);
+ if (rv < 0)
+ return rv;
+ struct sockaddr_storage sockaddr;
+ size_t sockaddr_length = sizeof(sockaddr);
+ bool success = endpoint.ToSockAddr(
+ reinterpret_cast<struct sockaddr*>(&sockaddr), &sockaddr_length);
+ if (!success)
+ return ERR_FAILED;
+ struct addrinfo ai;
+ memset(&ai, 0, sizeof(ai));
+ memcpy(&ai.ai_addr, &sockaddr, sockaddr_length);
+ ai.ai_addrlen = sockaddr_length;
+ *address = AddressList::CreateByCopying(&ai);
+ return OK;
+}
+
+int CurveCPClientSocket::GetLocalAddress(IPEndPoint* address) const {
+ NOTIMPLEMENTED();
+ return ERR_FAILED;
+}
+
+const BoundNetLog& CurveCPClientSocket::NetLog() const {
+ return net_log_;
+}
+
+void CurveCPClientSocket::SetSubresourceSpeculation() {
+ // This is ridiculous.
+}
+
+void CurveCPClientSocket::SetOmniboxSpeculation() {
+ // This is ridiculous.
+}
+
+bool CurveCPClientSocket::WasEverUsed() const {
+ // This is ridiculous.
+ return true;
+}
+
+bool CurveCPClientSocket::UsingTCPFastOpen() const {
+ // This is ridiculous.
+ return false;
+}
+
+int CurveCPClientSocket::Read(IOBuffer* buf,
+ int buf_len,
+ CompletionCallback* callback) {
+ return messenger_.Read(buf, buf_len, callback);
+}
+
+int CurveCPClientSocket::Write(IOBuffer* buf,
+ int buf_len,
+ CompletionCallback* callback) {
+ return messenger_.Write(buf, buf_len, callback);
+}
+
+bool CurveCPClientSocket::SetReceiveBufferSize(int32 size) {
+ return true;
+}
+
+bool CurveCPClientSocket::SetSendBufferSize(int32 size) {
+ return true;
+}
+
+} // namespace net