| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "jingle/glue/utils.h" | 5 #include "jingle/glue/utils.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
| 13 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
| 14 #include "third_party/libjingle/source/talk/base/byteorder.h" | 14 #include "third_party/libjingle/source/talk/base/byteorder.h" |
| 15 #include "third_party/libjingle/source/talk/base/socketaddress.h" | 15 #include "third_party/libjingle/source/talk/base/socketaddress.h" |
| 16 #include "third_party/libjingle/source/talk/p2p/base/candidate.h" | 16 #include "third_party/libjingle/source/talk/p2p/base/candidate.h" |
| 17 | 17 |
| 18 namespace jingle_glue { | 18 namespace jingle_glue { |
| 19 | 19 |
| 20 bool IPEndPointToSocketAddress(const net::IPEndPoint& address_chrome, | 20 bool IPEndPointToSocketAddress(const net::IPEndPoint& address_chrome, |
| 21 talk_base::SocketAddress* address_lj) { | 21 talk_base::SocketAddress* address_lj) { |
| 22 if (address_chrome.GetFamily() != AF_INET) { | 22 if (address_chrome.GetFamily() != net::ADDRESS_FAMILY_IPV4) { |
| 23 LOG(ERROR) << "Only IPv4 addresses are supported."; | 23 LOG(ERROR) << "Only IPv4 addresses are supported."; |
| 24 return false; | 24 return false; |
| 25 } | 25 } |
| 26 uint32 ip_as_int = talk_base::NetworkToHost32( | 26 uint32 ip_as_int = talk_base::NetworkToHost32( |
| 27 *reinterpret_cast<const uint32*>(&address_chrome.address()[0])); | 27 *reinterpret_cast<const uint32*>(&address_chrome.address()[0])); |
| 28 *address_lj = talk_base::SocketAddress(ip_as_int, address_chrome.port()); | 28 *address_lj = talk_base::SocketAddress(ip_as_int, address_chrome.port()); |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool SocketAddressToIPEndPoint(const talk_base::SocketAddress& address_lj, | 32 bool SocketAddressToIPEndPoint(const talk_base::SocketAddress& address_lj, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 candidate->set_protocol(protocol); | 91 candidate->set_protocol(protocol); |
| 92 candidate->set_username(username); | 92 candidate->set_username(username); |
| 93 candidate->set_password(password); | 93 candidate->set_password(password); |
| 94 candidate->set_preference(static_cast<float>(preference)); | 94 candidate->set_preference(static_cast<float>(preference)); |
| 95 candidate->set_generation(generation); | 95 candidate->set_generation(generation); |
| 96 | 96 |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 } // namespace jingle_glue | 100 } // namespace jingle_glue |
| OLD | NEW |