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