| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
| 6 #define NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 6 #define NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 8 #include <stdint.h> | 9 #include <stdint.h> |
| 9 | 10 |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/basictypes.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "net/base/address_list.h" | 16 #include "net/base/address_list.h" |
| 16 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/dns/host_resolver.h" | 19 #include "net/dns/host_resolver.h" |
| 19 #include "net/log/net_log.h" | 20 #include "net/log/net_log.h" |
| 20 #include "net/socket/stream_socket.h" | 21 #include "net/socket/stream_socket.h" |
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 22 | 23 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 int64_t GetTotalReceivedBytes() const override; | 63 int64_t GetTotalReceivedBytes() const override; |
| 63 | 64 |
| 64 // Socket implementation. | 65 // Socket implementation. |
| 65 int Read(IOBuffer* buf, | 66 int Read(IOBuffer* buf, |
| 66 int buf_len, | 67 int buf_len, |
| 67 const CompletionCallback& callback) override; | 68 const CompletionCallback& callback) override; |
| 68 int Write(IOBuffer* buf, | 69 int Write(IOBuffer* buf, |
| 69 int buf_len, | 70 int buf_len, |
| 70 const CompletionCallback& callback) override; | 71 const CompletionCallback& callback) override; |
| 71 | 72 |
| 72 int SetReceiveBufferSize(int32 size) override; | 73 int SetReceiveBufferSize(int32_t size) override; |
| 73 int SetSendBufferSize(int32 size) override; | 74 int SetSendBufferSize(int32_t size) override; |
| 74 | 75 |
| 75 int GetPeerAddress(IPEndPoint* address) const override; | 76 int GetPeerAddress(IPEndPoint* address) const override; |
| 76 int GetLocalAddress(IPEndPoint* address) const override; | 77 int GetLocalAddress(IPEndPoint* address) const override; |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 enum State { | 80 enum State { |
| 80 STATE_GREET_WRITE, | 81 STATE_GREET_WRITE, |
| 81 STATE_GREET_WRITE_COMPLETE, | 82 STATE_GREET_WRITE_COMPLETE, |
| 82 STATE_GREET_READ, | 83 STATE_GREET_READ, |
| 83 STATE_GREET_READ_COMPLETE, | 84 STATE_GREET_READ_COMPLETE, |
| 84 STATE_HANDSHAKE_WRITE, | 85 STATE_HANDSHAKE_WRITE, |
| 85 STATE_HANDSHAKE_WRITE_COMPLETE, | 86 STATE_HANDSHAKE_WRITE_COMPLETE, |
| 86 STATE_HANDSHAKE_READ, | 87 STATE_HANDSHAKE_READ, |
| 87 STATE_HANDSHAKE_READ_COMPLETE, | 88 STATE_HANDSHAKE_READ_COMPLETE, |
| 88 STATE_NONE, | 89 STATE_NONE, |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 // Addressing type that can be specified in requests or responses. | 92 // Addressing type that can be specified in requests or responses. |
| 92 enum SocksEndPointAddressType { | 93 enum SocksEndPointAddressType { |
| 93 kEndPointDomain = 0x03, | 94 kEndPointDomain = 0x03, |
| 94 kEndPointResolvedIPv4 = 0x01, | 95 kEndPointResolvedIPv4 = 0x01, |
| 95 kEndPointResolvedIPv6 = 0x04, | 96 kEndPointResolvedIPv6 = 0x04, |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 static const unsigned int kGreetReadHeaderSize; | 99 static const unsigned int kGreetReadHeaderSize; |
| 99 static const unsigned int kWriteHeaderSize; | 100 static const unsigned int kWriteHeaderSize; |
| 100 static const unsigned int kReadHeaderSize; | 101 static const unsigned int kReadHeaderSize; |
| 101 static const uint8 kSOCKS5Version; | 102 static const uint8_t kSOCKS5Version; |
| 102 static const uint8 kTunnelCommand; | 103 static const uint8_t kTunnelCommand; |
| 103 static const uint8 kNullByte; | 104 static const uint8_t kNullByte; |
| 104 | 105 |
| 105 void DoCallback(int result); | 106 void DoCallback(int result); |
| 106 void OnIOComplete(int result); | 107 void OnIOComplete(int result); |
| 107 void OnReadWriteComplete(const CompletionCallback& callback, int result); | 108 void OnReadWriteComplete(const CompletionCallback& callback, int result); |
| 108 | 109 |
| 109 int DoLoop(int last_io_result); | 110 int DoLoop(int last_io_result); |
| 110 int DoHandshakeRead(); | 111 int DoHandshakeRead(); |
| 111 int DoHandshakeReadComplete(int result); | 112 int DoHandshakeReadComplete(int result); |
| 112 int DoHandshakeWrite(); | 113 int DoHandshakeWrite(); |
| 113 int DoHandshakeWriteComplete(int result); | 114 int DoHandshakeWriteComplete(int result); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 HostResolver::RequestInfo host_request_info_; | 155 HostResolver::RequestInfo host_request_info_; |
| 155 | 156 |
| 156 BoundNetLog net_log_; | 157 BoundNetLog net_log_; |
| 157 | 158 |
| 158 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); | 159 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 } // namespace net | 162 } // namespace net |
| 162 | 163 |
| 163 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 164 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
| OLD | NEW |