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