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

Side by Side 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: fix a sizeof 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 unified diff | Download patch
« no previous file with comments | « jingle/glue/utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 bool SocketAddressToIPEndPoint(const rtc::SocketAddress& address, 28 bool SocketAddressToIPEndPoint(const rtc::SocketAddress& address,
29 net::IPEndPoint* ip_endpoint) { 29 net::IPEndPoint* ip_endpoint) {
30 sockaddr_storage addr; 30 sockaddr_storage addr;
31 int size = address.ToSockAddrStorage(&addr); 31 int size = address.ToSockAddrStorage(&addr);
32 return (size > 0) && 32 return (size > 0) &&
33 ip_endpoint->FromSockAddr(reinterpret_cast<sockaddr*>(&addr), size); 33 ip_endpoint->FromSockAddr(reinterpret_cast<sockaddr*>(&addr), size);
34 } 34 }
35 35
36 rtc::IPAddress IPAddressNumberToIPAddress(
37 const net::IPAddressNumber& ip_address_number) {
38 if (ip_address_number.size() == net::kIPv4AddressSize) {
39 uint32_t address;
40 memcpy(&address, &ip_address_number[0], sizeof(uint32_t));
41 address = rtc::NetworkToHost32(address);
42 return rtc::IPAddress(address);
43 }
44 if (ip_address_number.size() == net::kIPv6AddressSize) {
45 in6_addr address;
46 memcpy(&address, &ip_address_number[0], sizeof(in6_addr));
47 return rtc::IPAddress(address);
48 }
49 return rtc::IPAddress();
50 }
51
36 std::string SerializeP2PCandidate(const cricket::Candidate& candidate) { 52 std::string SerializeP2PCandidate(const cricket::Candidate& candidate) {
37 // TODO(sergeyu): Use SDP to format candidates? 53 // TODO(sergeyu): Use SDP to format candidates?
38 base::DictionaryValue value; 54 base::DictionaryValue value;
39 value.SetString("ip", candidate.address().ipaddr().ToString()); 55 value.SetString("ip", candidate.address().ipaddr().ToString());
40 value.SetInteger("port", candidate.address().port()); 56 value.SetInteger("port", candidate.address().port());
41 value.SetString("type", candidate.type()); 57 value.SetString("type", candidate.type());
42 value.SetString("protocol", candidate.protocol()); 58 value.SetString("protocol", candidate.protocol());
43 value.SetString("username", candidate.username()); 59 value.SetString("username", candidate.username());
44 value.SetString("password", candidate.password()); 60 value.SetString("password", candidate.password());
45 value.SetDouble("preference", candidate.preference()); 61 value.SetDouble("preference", candidate.preference());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 candidate->set_protocol(protocol); 102 candidate->set_protocol(protocol);
87 candidate->set_username(username); 103 candidate->set_username(username);
88 candidate->set_password(password); 104 candidate->set_password(password);
89 candidate->set_preference(static_cast<float>(preference)); 105 candidate->set_preference(static_cast<float>(preference));
90 candidate->set_generation(generation); 106 candidate->set_generation(generation);
91 107
92 return true; 108 return true;
93 } 109 }
94 110
95 } // namespace jingle_glue 111 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « jingle/glue/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698