Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: jingle/glue/utils.cc

Issue 1405963021: Add support for default local address in IpcNetworkManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IPAddressNumberToIPAddress. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« content/renderer/p2p/ipc_network_manager.cc ('K') | « jingle/glue/utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jingle/glue/utils.cc
diff --git a/jingle/glue/utils.cc b/jingle/glue/utils.cc
index 4c9f4b681029ab9c8cc4df2bd18e834335eb3107..0872d31748ccf960e5bc114e6664b4e3e0c3c629 100644
--- a/jingle/glue/utils.cc
+++ b/jingle/glue/utils.cc
@@ -12,6 +12,7 @@
#include "net/base/ip_endpoint.h"
#include "net/base/net_util.h"
#include "third_party/webrtc/base/byteorder.h"
+#include "third_party/webrtc/base/ipaddress.h"
#include "third_party/webrtc/base/socketaddress.h"
#include "third_party/webrtc/p2p/base/candidate.h"
@@ -33,6 +34,24 @@ bool SocketAddressToIPEndPoint(const rtc::SocketAddress& address,
ip_endpoint->FromSockAddr(reinterpret_cast<sockaddr*>(&addr), size);
}
+bool IPAddressNumberToIPAddress(const net::IPAddressNumber& ip_address_number,
Sergey Ulanov 2015/11/11 21:10:02 Don't really need to return bool here. rtc::IPAddr
+ rtc::IPAddress* ip_address) {
+ if (ip_address_number.size() == net::kIPv4AddressSize) {
+ uint32 address;
Sergey Ulanov 2015/11/11 21:10:02 Please change this to uint32_t
+ memcpy(&address, &ip_address_number[0], sizeof(uint32));
+ address = rtc::NetworkToHost32(address);
+ *ip_address = rtc::IPAddress(address);
+ return true;
+ }
+ if (ip_address_number.size() == net::kIPv6AddressSize) {
+ in6_addr address;
+ memcpy(&address, &ip_address_number[0], sizeof(in6_addr));
+ *ip_address = rtc::IPAddress(address);
+ return true;
+ }
+ return false;
+}
+
std::string SerializeP2PCandidate(const cricket::Candidate& candidate) {
// TODO(sergeyu): Use SDP to format candidates?
base::DictionaryValue value;
« content/renderer/p2p/ipc_network_manager.cc ('K') | « jingle/glue/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698