We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / net / base / ip_endpoint.h
blobc1facda7bbe0c47a11865472a752fa64d24b22d4
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
3 // found in the LICENSE file.
5 #ifndef NET_BASE_IP_ENDPOINT_H_
6 #define NET_BASE_IP_ENDPOINT_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "net/base/address_family.h"
13 #include "net/base/net_export.h"
14 #include "net/base/net_util.h"
16 struct sockaddr;
18 namespace net {
20 // An IPEndPoint represents the address of a transport endpoint:
21 // * IP address (either v4 or v6)
22 // * Port
23 class NET_EXPORT IPEndPoint {
24 public:
25 IPEndPoint();
26 ~IPEndPoint();
27 IPEndPoint(const IPAddressNumber& address, uint16 port);
28 IPEndPoint(const IPEndPoint& endpoint);
30 const IPAddressNumber& address() const { return address_; }
31 uint16 port() const { return port_; }
33 // Returns AddressFamily of the address.
34 AddressFamily GetFamily() const;
36 // Returns the sockaddr family of the address, AF_INET or AF_INET6.
37 int GetSockAddrFamily() const;
39 // Convert to a provided sockaddr struct.
40 // |address| is the sockaddr to copy into. Should be at least
41 // sizeof(struct sockaddr_storage) bytes.
42 // |address_length| is an input/output parameter. On input, it is the
43 // size of data in |address| available. On output, it is the size of
44 // the address that was copied into |address|.
45 // Returns true on success, false on failure.
46 bool ToSockAddr(struct sockaddr* address, socklen_t* address_length) const
47 WARN_UNUSED_RESULT;
49 // Convert from a sockaddr struct.
50 // |address| is the address.
51 // |address_length| is the length of |address|.
52 // Returns true on success, false on failure.
53 bool FromSockAddr(const struct sockaddr* address, socklen_t address_length)
54 WARN_UNUSED_RESULT;
56 // Returns value as a string (e.g. "127.0.0.1:80"). The IP address must be
57 // valid.
58 std::string ToString() const;
60 // As above, but without port.
61 std::string ToStringWithoutPort() const;
63 bool operator<(const IPEndPoint& that) const;
64 bool operator==(const IPEndPoint& that) const;
66 private:
67 IPAddressNumber address_;
68 uint16 port_;
71 } // namespace net
73 #endif // NET_BASE_IP_ENDPOINT_H_