| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_ | 5 #ifndef NET_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_ |
| 6 #define NET_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_ | 6 #define NET_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "net/base/ip_endpoint.h" | 11 #include "net/base/ip_endpoint.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 // Serializes and parses a socket address (IP address and port), to be used in | 16 // Serializes and parses a socket address (IP address and port), to be used in |
| 17 // the kCADR tag in the ServerHello handshake message and the Public Reset | 17 // the kCADR tag in the ServerHello handshake message and the Public Reset |
| 18 // packet. | 18 // packet. |
| 19 class NET_EXPORT_PRIVATE QuicSocketAddressCoder { | 19 class NET_EXPORT_PRIVATE QuicSocketAddressCoder { |
| 20 public: | 20 public: |
| 21 QuicSocketAddressCoder(); | 21 QuicSocketAddressCoder(); |
| 22 explicit QuicSocketAddressCoder(const IPEndPoint& address); | 22 explicit QuicSocketAddressCoder(const IPEndPoint& address); |
| 23 ~QuicSocketAddressCoder(); | 23 ~QuicSocketAddressCoder(); |
| 24 | 24 |
| 25 std::string Encode() const; | 25 std::string Encode() const; |
| 26 | 26 |
| 27 bool Decode(const char* data, size_t length); | 27 bool Decode(const char* data, size_t length); |
| 28 | 28 |
| 29 IPAddressNumber ip() const { | 29 IPAddressNumber ip() const { return address_.address(); } |
| 30 return address_.address(); | |
| 31 } | |
| 32 | 30 |
| 33 uint16 port() const { | 31 uint16 port() const { return address_.port(); } |
| 34 return address_.port(); | |
| 35 } | |
| 36 | 32 |
| 37 private: | 33 private: |
| 38 IPEndPoint address_; | 34 IPEndPoint address_; |
| 39 | 35 |
| 40 DISALLOW_COPY_AND_ASSIGN(QuicSocketAddressCoder); | 36 DISALLOW_COPY_AND_ASSIGN(QuicSocketAddressCoder); |
| 41 }; | 37 }; |
| 42 | 38 |
| 43 } // namespace net | 39 } // namespace net |
| 44 | 40 |
| 45 #endif // NET_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_ | 41 #endif // NET_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_ |
| OLD | NEW |