diff options
-rw-r--r-- | DEPS | 4 | ||||
-rw-r--r-- | content/renderer/p2p/ipc_network_manager.cc | 9 | ||||
-rw-r--r-- | jingle/glue/fake_network_manager.cc | 5 | ||||
-rw-r--r-- | jingle/notifier/communicator/xmpp_connection_generator.cc | 4 | ||||
-rw-r--r-- | remoting/jingle_glue/xmpp_socket_adapter.cc | 2 | ||||
-rw-r--r-- | remoting/protocol/content_description.cc | 8 | ||||
-rw-r--r-- | remoting/protocol/content_description.h | 4 | ||||
-rw-r--r-- | remoting/protocol/message_decoder.cc | 2 | ||||
-rw-r--r-- | remoting/protocol/rtp_utils.cc | 2 | ||||
-rw-r--r-- | remoting/protocol/util.cc | 2 | ||||
-rw-r--r-- | third_party/libjingle/README.chromium | 4 | ||||
-rw-r--r-- | third_party/libjingle/libjingle.gyp | 26 | ||||
-rw-r--r-- | third_party/libjingle/overrides/talk/base/byteorder.h | 21 | ||||
-rw-r--r-- | third_party/libjingle/overrides/talk/base/win32.cc | 468 | ||||
-rw-r--r-- | third_party/libjingle/overrides/talk/base/win32.h | 9 |
15 files changed, 68 insertions, 502 deletions
@@ -39,7 +39,7 @@ vars = { "nacl_toolchain_revision": "7898", "pnacl_toolchain_revision": "7898", - "libjingle_revision": "119", + "libjingle_revision": "124", "libphonenumber_revision": "425", "libvpx_revision": "125647", "lss_revision": "9", @@ -55,7 +55,7 @@ vars = { # the commit queue can handle CLs rolling Skia # and V8 without interference from each other. "v8_revision": "10875", - "webrtc_revision": "1538", + "webrtc_revision": "1888", "jsoncpp_revision": "248", "nss_revision": "126189", "rlz_revision": "72", diff --git a/content/renderer/p2p/ipc_network_manager.cc b/content/renderer/p2p/ipc_network_manager.cc index 0268a9e..2ddc397 100644 --- a/content/renderer/p2p/ipc_network_manager.cc +++ b/content/renderer/p2p/ipc_network_manager.cc @@ -52,10 +52,11 @@ void IpcNetworkManager::OnNetworkListChanged( if (it->address.size() != net::kIPv4AddressSize) continue; memcpy(&address, &it->address[0], sizeof(uint32)); - address = ntohl(address); - networks.push_back( - new talk_base::Network( - it->name, it->name, talk_base::IPAddress(address))); + address = talk_base::NetworkToHost32(address); + talk_base::Network* network = new talk_base::Network( + it->name, it->name, talk_base::IPAddress(address), 32); + network->AddIP(talk_base::IPAddress(address)); + networks.push_back(network); } bool changed = false; diff --git a/jingle/glue/fake_network_manager.cc b/jingle/glue/fake_network_manager.cc index 34d0c0b..7884301 100644 --- a/jingle/glue/fake_network_manager.cc +++ b/jingle/glue/fake_network_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -20,7 +20,8 @@ FakeNetworkManager::FakeNetworkManager(const net::IPAddressNumber& address) talk_base::SocketAddress socket_address; CHECK(IPEndPointToSocketAddress(endpoint, &socket_address)); network_.reset(new talk_base::Network("fake", "Fake Network", - socket_address.ipaddr())); + socket_address.ipaddr(), 32)); + network_->AddIP(socket_address.ipaddr()); } FakeNetworkManager::~FakeNetworkManager() { diff --git a/jingle/notifier/communicator/xmpp_connection_generator.cc b/jingle/notifier/communicator/xmpp_connection_generator.cc index 3a05d9c..d1a9404a 100644 --- a/jingle/notifier/communicator/xmpp_connection_generator.cc +++ b/jingle/notifier/communicator/xmpp_connection_generator.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -161,7 +161,7 @@ void XmppConnectionGenerator::HandleServerDNSResolved(int status) { addr != NULL; addr = addr->ai_next) { const sockaddr_in& sockaddr = *reinterpret_cast<const sockaddr_in*>(addr->ai_addr); - uint32 ip = ntohl(sockaddr.sin_addr.s_addr); + uint32 ip = talk_base::NetworkToHost32(sockaddr.sin_addr.s_addr); ip_list.push_back(ip); } successfully_resolved_dns_ = !ip_list.empty(); diff --git a/remoting/jingle_glue/xmpp_socket_adapter.cc b/remoting/jingle_glue/xmpp_socket_adapter.cc index e819736..611d70f 100644 --- a/remoting/jingle_glue/xmpp_socket_adapter.cc +++ b/remoting/jingle_glue/xmpp_socket_adapter.cc @@ -9,8 +9,8 @@ #include "base/logging.h" #include "remoting/jingle_glue/ssl_adapter.h" -#include "third_party/libjingle/overrides/talk/base/byteorder.h" #include "third_party/libjingle/overrides/talk/base/thread.h" +#include "third_party/libjingle/source/talk/base/byteorder.h" #include "third_party/libjingle/source/talk/base/common.h" #include "third_party/libjingle/source/talk/base/firewallsocketserver.h" #include "third_party/libjingle/source/talk/base/socketadapters.h" diff --git a/remoting/protocol/content_description.cc b/remoting/protocol/content_description.cc index e2e3a9e..06fd309 100644 --- a/remoting/protocol/content_description.cc +++ b/remoting/protocol/content_description.cc @@ -159,6 +159,14 @@ ContentDescription::ContentDescription( ContentDescription::~ContentDescription() { } +ContentDescription* ContentDescription::Copy() const { + if (!candidate_config_.get() || !authenticator_message_.get()) { + return NULL; + } + scoped_ptr<XmlElement> message(new XmlElement(*authenticator_message_)); + return new ContentDescription(candidate_config_->Clone(), message.Pass()); +} + // ToXml() creates content description for chromoting session. The // description looks as follows: // <description xmlns="google:remoting"> diff --git a/remoting/protocol/content_description.h b/remoting/protocol/content_description.h index cc66ac5..2eed505 100644 --- a/remoting/protocol/content_description.h +++ b/remoting/protocol/content_description.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -32,6 +32,8 @@ class ContentDescription : public cricket::ContentDescription { scoped_ptr<buzz::XmlElement> authenticator_message); virtual ~ContentDescription(); + virtual ContentDescription* Copy() const OVERRIDE; + const CandidateSessionConfig* config() const { return candidate_config_.get(); } diff --git a/remoting/protocol/message_decoder.cc b/remoting/protocol/message_decoder.cc index ba9c5c1..6a102a3 100644 --- a/remoting/protocol/message_decoder.cc +++ b/remoting/protocol/message_decoder.cc @@ -8,7 +8,7 @@ #include "net/base/io_buffer.h" #include "remoting/base/compound_buffer.h" #include "remoting/proto/internal.pb.h" -#include "third_party/libjingle/overrides/talk/base/byteorder.h" +#include "third_party/libjingle/source/talk/base/byteorder.h" namespace remoting { namespace protocol { diff --git a/remoting/protocol/rtp_utils.cc b/remoting/protocol/rtp_utils.cc index 8643827..92b6d67 100644 --- a/remoting/protocol/rtp_utils.cc +++ b/remoting/protocol/rtp_utils.cc @@ -5,7 +5,7 @@ #include "remoting/protocol/rtp_utils.h" #include "base/logging.h" -#include "third_party/libjingle/overrides/talk/base/byteorder.h" +#include "third_party/libjingle/source/talk/base/byteorder.h" using talk_base::GetBE16; using talk_base::GetBE32; diff --git a/remoting/protocol/util.cc b/remoting/protocol/util.cc index 95ec04f..7b2ffe1 100644 --- a/remoting/protocol/util.cc +++ b/remoting/protocol/util.cc @@ -8,7 +8,7 @@ #include "base/hash_tables.h" #include "base/logging.h" #include "net/base/io_buffer.h" -#include "third_party/libjingle/overrides/talk/base/byteorder.h" +#include "third_party/libjingle/source/talk/base/byteorder.h" namespace { diff --git a/third_party/libjingle/README.chromium b/third_party/libjingle/README.chromium index b60ceae..6a8005a 100644 --- a/third_party/libjingle/README.chromium +++ b/third_party/libjingle/README.chromium @@ -1,8 +1,8 @@ Name: Libjingle library. Used for p2p voice and video communication. Short Name: libjingle URL: http://code.google.com/p/libjingle/ -Version: 0.6.14 -Revision: 119 +Version: 0.6.16 +Revision: 124 License: BSD License File: source/COPYING Security Critical: yes diff --git a/third_party/libjingle/libjingle.gyp b/third_party/libjingle/libjingle.gyp index 1a33854..1bb70ae 100644 --- a/third_party/libjingle/libjingle.gyp +++ b/third_party/libjingle/libjingle.gyp @@ -177,7 +177,6 @@ # TODO(ronghuawu): Remove below overrides once below bug is fixed: # http://crbug.com/115702 - 'overrides/talk/base/byteorder.h', 'overrides/talk/base/messagequeue.cc', 'overrides/talk/base/messagequeue.h', 'overrides/talk/base/thread.cc', @@ -204,6 +203,7 @@ 'source/talk/base/basicpacketsocketfactory.h', 'source/talk/base/bytebuffer.cc', 'source/talk/base/bytebuffer.h', + 'source/talk/base/byteorder.h', 'source/talk/base/checks.cc', 'source/talk/base/checks.h', 'source/talk/base/common.cc', @@ -240,12 +240,15 @@ 'source/talk/base/linked_ptr.h', 'source/talk/base/md5.h', 'source/talk/base/md5c.c', + 'source/talk/base/messagedigest.cc', + 'source/talk/base/messagedigest.h', 'source/talk/base/messagehandler.cc', 'source/talk/base/messagehandler.h', 'source/talk/base/nethelpers.cc', 'source/talk/base/nethelpers.h', 'source/talk/base/network.cc', 'source/talk/base/network.h', + 'source/talk/base/nullsocketserver.h', 'source/talk/base/pathutils.cc', 'source/talk/base/pathutils.h', 'source/talk/base/physicalsocketserver.cc', @@ -257,6 +260,8 @@ 'source/talk/base/ratetracker.cc', 'source/talk/base/ratetracker.h', 'source/talk/base/sec_buffer.h', + 'source/talk/base/sha1.c', + 'source/talk/base/sha1.h', 'source/talk/base/signalthread.cc', 'source/talk/base/signalthread.h', 'source/talk/base/sigslot.h', @@ -280,8 +285,6 @@ 'source/talk/base/sslsocketfactory.h', 'source/talk/base/stream.cc', 'source/talk/base/stream.h', - 'source/talk/base/stringdigest.cc', - 'source/talk/base/stringdigest.h', 'source/talk/base/stringencode.cc', 'source/talk/base/stringencode.h', 'source/talk/base/stringutils.cc', @@ -352,10 +355,8 @@ 'overrides/talk/base/win32socketinit.cc', 'source/talk/base/schanneladapter.cc', 'source/talk/base/schanneladapter.h', - # TODO(ronghuawu): Remove below overrides once below bug is fixed: - # http://crbug.com/115702 - 'overrides/talk/base/win32.h', - 'overrides/talk/base/win32.cc', + 'source/talk/base/win32.cc', + 'source/talk/base/win32.h', 'source/talk/base/win32filesystem.cc', 'source/talk/base/win32filesystem.h', 'source/talk/base/win32window.h', @@ -369,6 +370,10 @@ }], ['os_posix == 1', { 'sources': [ + 'source/talk/base/openssladapter.cc', + 'source/talk/base/openssladapter.h', + 'source/talk/base/openssldigest.cc', + 'source/talk/base/openssldigest.h', 'source/talk/base/sslstreamadapter.cc', 'source/talk/base/sslstreamadapter.h', 'source/talk/base/unixfilesystem.cc', @@ -393,6 +398,9 @@ }], ['OS=="android"', { 'sources!': [ + # The openssl is not available in android build. + 'source/talk/base/openssldigest.cc', + 'source/talk/base/openssldigest.h', # These depend on jsoncpp which we don't load because we probably # don't actually need this code at all. 'source/talk/base/json.cc', @@ -544,9 +552,13 @@ 'source/talk/session/phone/channelmanager.h', 'source/talk/session/phone/codec.cc', 'source/talk/session/phone/codec.h', + 'source/talk/session/phone/constants.cc', + 'source/talk/session/phone/constants.h', 'source/talk/session/phone/cryptoparams.h', 'source/talk/session/phone/currentspeakermonitor.cc', 'source/talk/session/phone/currentspeakermonitor.h', + 'source/talk/session/phone/dataengine.cc', + 'source/talk/session/phone/dataengine.h', 'source/talk/session/phone/devicemanager.cc', 'source/talk/session/phone/devicemanager.h', 'source/talk/session/phone/dummydevicemanager.cc', diff --git a/third_party/libjingle/overrides/talk/base/byteorder.h b/third_party/libjingle/overrides/talk/base/byteorder.h index b1375b6..513a8c8 100644 --- a/third_party/libjingle/overrides/talk/base/byteorder.h +++ b/third_party/libjingle/overrides/talk/base/byteorder.h @@ -33,8 +33,8 @@ #endif #ifdef WIN32 +#include <stdlib.h> #include <winsock2.h> -#include "talk/base/win32.h" #endif #include "talk/base/basictypes.h" @@ -143,11 +143,22 @@ inline bool IsHostBigEndian() { } inline uint16 HostToNetwork16(uint16 n) { +#ifdef WIN32 + // This and below _byteswap_* are to remove the dependency to ws2_32.dll + // especially for chrome, where we don't load the ws2_32.dll in the render + // process. This is correct only on little-endian machines. + return _byteswap_ushort(n); +#else return htons(n); +#endif } inline uint32 HostToNetwork32(uint32 n) { +#ifdef WIN32 + return _byteswap_ulong(n); +#else return htonl(n); +#endif } inline uint64 HostToNetwork64(uint64 n) { @@ -156,11 +167,19 @@ inline uint64 HostToNetwork64(uint64 n) { } inline uint16 NetworkToHost16(uint16 n) { +#ifdef WIN32 + return _byteswap_ushort(n); +#else return ntohs(n); +#endif } inline uint32 NetworkToHost32(uint32 n) { +#ifdef WIN32 + return _byteswap_ulong(n); +#else return ntohl(n); +#endif } inline uint64 NetworkToHost64(uint64 n) { diff --git a/third_party/libjingle/overrides/talk/base/win32.cc b/third_party/libjingle/overrides/talk/base/win32.cc index cda3c0e..e69de29 100644 --- a/third_party/libjingle/overrides/talk/base/win32.cc +++ b/third_party/libjingle/overrides/talk/base/win32.cc @@ -1,468 +0,0 @@ -/* - * libjingle - * Copyright 2004--2005, Google Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "talk/base/win32.h" - -#include <winsock2.h> -#include <ws2tcpip.h> -#include <algorithm> - -#include "talk/base/basictypes.h" -#include "talk/base/common.h" -#include "talk/base/logging.h" - -namespace talk_base { - -// Helper function declarations for inet_ntop/inet_pton. -static const char* inet_ntop_v4(const void* src, char* dst, socklen_t size); -static const char* inet_ntop_v6(const void* src, char* dst, socklen_t size); -static int inet_pton_v4(const char* src, void* dst); -static int inet_pton_v6(const char* src, void* dst); - -// Implementation of inet_ntop (create a printable representation of an -// ip address). XP doesn't have its own inet_ntop, and -// WSAAddressToString requires both IPv6 to be installed and for Winsock -// to be initialized. -const char* win32_inet_ntop(int af, const void *src, - char* dst, socklen_t size) { - if (!src || !dst) { - return NULL; - } - switch (af) { - case AF_INET: { - return inet_ntop_v4(src, dst, size); - } - case AF_INET6: { - return inet_ntop_v6(src, dst, size); - } - } - return NULL; -} - -// As above, but for inet_pton. Implements inet_pton for v4 and v6. -// Note that our inet_ntop will output normal 'dotted' v4 addresses only. -int win32_inet_pton(int af, const char* src, void* dst) { - if (!src || !dst) { - return 0; - } - if (af == AF_INET) { - return inet_pton_v4(src, dst); - } else if (af == AF_INET6) { - return inet_pton_v6(src, dst); - } - return -1; -} - -// Helper function for inet_ntop for IPv4 addresses. -// Outputs "dotted-quad" decimal notation. -const char* inet_ntop_v4(const void* src, char* dst, socklen_t size) { - if (size < INET_ADDRSTRLEN) { - return NULL; - } - const struct in_addr* as_in_addr = - reinterpret_cast<const struct in_addr*>(src); - talk_base::sprintfn(dst, size, "%d.%d.%d.%d", - as_in_addr->S_un.S_un_b.s_b1, - as_in_addr->S_un.S_un_b.s_b2, - as_in_addr->S_un.S_un_b.s_b3, - as_in_addr->S_un.S_un_b.s_b4); - return dst; -} - -// Helper function for inet_ntop for IPv6 addresses. -const char* inet_ntop_v6(const void* src, char* dst, socklen_t size) { - if (size < INET6_ADDRSTRLEN) { - return NULL; - } - const uint16* as_shorts = - reinterpret_cast<const uint16*>(src); - int runpos[8]; - int current = 1; - int max = 1; - int maxpos = -1; - int run_array_size = ARRAY_SIZE(runpos); - // Run over the address marking runs of 0s. - for (int i = 0; i < run_array_size; ++i) { - if (as_shorts[i] == 0) { - runpos[i] = current; - if (current > max) { - maxpos = i; - max = current; - } - ++current; - } else { - runpos[i] = -1; - current =1; - } - } - - if (max > 1) { - int tmpmax = maxpos; - // Run back through, setting -1 for all but the longest run. - for (int i = run_array_size - 1; i >= 0; i--) { - if (i > tmpmax) { - runpos[i] = -1; - } else if (runpos[i] == -1) { - // We're less than maxpos, we hit a -1, so the 'good' run is done. - // Setting tmpmax -1 means all remaining positions get set to -1. - tmpmax = -1; - } - } - } - - char* cursor = dst; - // Print IPv4 compatible and IPv4 mapped addresses using the IPv4 helper. - // These addresses have an initial run of either eight zero-bytes followed - // by 0xFFFF, or an initial run of ten zero-bytes. - if (runpos[0] == 1 && (maxpos == 5 || - (maxpos == 4 && as_shorts[5] == 0xFFFF))) { - *cursor++ = ':'; - *cursor++ = ':'; - if (maxpos == 4) { - cursor += talk_base::sprintfn(cursor, INET6_ADDRSTRLEN - 2, "ffff:"); - } - const struct in_addr* as_v4 = - reinterpret_cast<const struct in_addr*>(&(as_shorts[6])); - inet_ntop_v4(as_v4, cursor, (INET6_ADDRSTRLEN - (cursor - dst))); - } else { - for (int i = 0; i < run_array_size; ++i) { - if (runpos[i] == -1) { - cursor += talk_base::sprintfn(cursor, - INET6_ADDRSTRLEN - (cursor - dst), - "%x", ntohs(as_shorts[i])); - if (i != 7 && runpos[i + 1] != 1) { - *cursor++ = ':'; - } - } else if (runpos[i] == 1) { - // Entered the run; print the colons and skip the run. - *cursor++ = ':'; - *cursor++ = ':'; - i += (max - 1); - } - } - } - return dst; -} - -// Helper function for inet_pton for IPv4 addresses. -// |src| points to a character string containing an IPv4 network address in -// dotted-decimal format, "ddd.ddd.ddd.ddd", where ddd is a decimal number -// of up to three digits in the range 0 to 255. -// The address is converted and copied to dst, -// which must be sizeof(struct in_addr) (4) bytes (32 bits) long. -int inet_pton_v4(const char* src, void* dst) { - const int kIpv4AddressSize = 4; - int num_dot = 0; - const char* src_pos = src; - unsigned char result[kIpv4AddressSize] = {0}; - - while (*src_pos != 0) { - // strtol won't treat whitespace characters in the begining as an error, - // so check to ensure this is started with digit before passing to strtol. - if (!isdigit(*src_pos)) { - return 0; - } - char* end_pos; - long int value = strtol(src_pos, &end_pos, 10); - if (value < 0 || value > 255 || src_pos == end_pos) { - return 0; - } - result[num_dot] = value; - if (*end_pos == 0) { - break; - } - src_pos = end_pos; - if (*src_pos == '.') { - ++num_dot; - if (num_dot > kIpv4AddressSize - 1) { - return 0; - } - } - ++src_pos; - } - if (num_dot != kIpv4AddressSize - 1) { - return 0; - } - memcpy(dst, result, sizeof(result)); - return 1; -} - -// Helper function for inet_pton for IPv6 addresses. -int inet_pton_v6(const char* src, void* dst) { - // sscanf will pick any other invalid chars up, but it parses 0xnnnn as hex. - // Check for literal x in the input string. - const char* readcursor = src; - char c = *readcursor++; - while (c) { - if (c == 'x') { - return 0; - } - c = *readcursor++; - } - readcursor = src; - - struct in6_addr an_addr; - memset(&an_addr, 0, sizeof(an_addr)); - - uint16* addr_cursor = reinterpret_cast<uint16*>(&an_addr.s6_addr[0]); - uint16* addr_end = reinterpret_cast<uint16*>(&an_addr.s6_addr[16]); - bool seencompressed = false; - - // Addresses that start with "::" (i.e., a run of initial zeros) or - // "::ffff:" can potentially be IPv4 mapped or compatibility addresses. - // These have dotted-style IPv4 addresses on the end (e.g. "::192.168.7.1"). - if (*readcursor == ':' && *(readcursor+1) == ':' && - *(readcursor + 2) != 0) { - // Check for periods, which we'll take as a sign of v4 addresses. - const char* addrstart = readcursor + 2; - if (talk_base::strchr(addrstart, ".")) { - const char* colon = talk_base::strchr(addrstart, "::"); - if (colon) { - uint16 a_short; - int bytesread = 0; - if (sscanf(addrstart, "%hx%n", &a_short, &bytesread) != 1 || - a_short != 0xFFFF || bytesread != 4) { - // Colons + periods means has to be ::ffff:a.b.c.d. But it wasn't. - return 0; - } else { - an_addr.s6_addr[10] = 0xFF; - an_addr.s6_addr[11] = 0xFF; - addrstart = colon + 1; - } - } - struct in_addr v4; - if (inet_pton_v4(addrstart, &v4.s_addr)) { - memcpy(&an_addr.s6_addr[12], &v4, sizeof(v4)); - memcpy(dst, &an_addr, sizeof(an_addr)); - return 1; - } else { - // Invalid v4 address. - return 0; - } - } - } - - // For addresses without a trailing IPv4 component ('normal' IPv6 addresses). - while (*readcursor != 0 && addr_cursor < addr_end) { - if (*readcursor == ':') { - if (*(readcursor + 1) == ':') { - if (seencompressed) { - // Can only have one compressed run of zeroes ("::") per address. - return 0; - } - // Hit a compressed run. Count colons to figure out how much of the - // address is skipped. - readcursor += 2; - const char* coloncounter = readcursor; - int coloncount = 0; - if (*coloncounter == 0) { - // Special case - trailing ::. - addr_cursor = addr_end; - } else { - while (*coloncounter) { - if (*coloncounter == ':') { - ++coloncount; - } - ++coloncounter; - } - // (coloncount + 1) is the number of shorts left in the address. - addr_cursor = addr_end - (coloncount + 1); - seencompressed = true; - } - } else { - ++readcursor; - } - } else { - uint16 word; - int bytesread = 0; - if (sscanf(readcursor, "%hx%n", &word, &bytesread) != 1) { - return 0; - } else { - *addr_cursor = htons(word); - ++addr_cursor; - readcursor += bytesread; - if (*readcursor != ':' && *readcursor != '\0') { - return 0; - } - } - } - } - - if (*readcursor != '\0' || addr_cursor < addr_end) { - // Catches addresses too short or too long. - return 0; - } - memcpy(dst, &an_addr, sizeof(an_addr)); - return 1; -} - -// -// Unix time is in seconds relative to 1/1/1970. So we compute the windows -// FILETIME of that time/date, then we add/subtract in appropriate units to -// convert to/from unix time. -// The units of FILETIME are 100ns intervals, so by multiplying by or dividing -// by 10000000, we can convert to/from seconds. -// -// FileTime = UnixTime*10000000 + FileTime(1970) -// UnixTime = (FileTime-FileTime(1970))/10000000 -// - -void FileTimeToUnixTime(const FILETIME& ft, time_t* ut) { - ASSERT(NULL != ut); - - // FILETIME has an earlier date base than time_t (1/1/1970), so subtract off - // the difference. - SYSTEMTIME base_st; - memset(&base_st, 0, sizeof(base_st)); - base_st.wDay = 1; - base_st.wMonth = 1; - base_st.wYear = 1970; - - FILETIME base_ft; - SystemTimeToFileTime(&base_st, &base_ft); - - ULARGE_INTEGER base_ul, current_ul; - memcpy(&base_ul, &base_ft, sizeof(FILETIME)); - memcpy(¤t_ul, &ft, sizeof(FILETIME)); - - // Divide by big number to convert to seconds, then subtract out the 1970 - // base date value. - const ULONGLONG RATIO = 10000000; - *ut = static_cast<time_t>((current_ul.QuadPart - base_ul.QuadPart) / RATIO); -} - -void UnixTimeToFileTime(const time_t& ut, FILETIME* ft) { - ASSERT(NULL != ft); - - // FILETIME has an earlier date base than time_t (1/1/1970), so add in - // the difference. - SYSTEMTIME base_st; - memset(&base_st, 0, sizeof(base_st)); - base_st.wDay = 1; - base_st.wMonth = 1; - base_st.wYear = 1970; - - FILETIME base_ft; - SystemTimeToFileTime(&base_st, &base_ft); - - ULARGE_INTEGER base_ul; - memcpy(&base_ul, &base_ft, sizeof(FILETIME)); - - // Multiply by big number to convert to 100ns units, then add in the 1970 - // base date value. - const ULONGLONG RATIO = 10000000; - ULARGE_INTEGER current_ul; - current_ul.QuadPart = base_ul.QuadPart + static_cast<int64>(ut) * RATIO; - memcpy(ft, ¤t_ul, sizeof(FILETIME)); -} - -bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename) { - // TODO: Integrate into fileutils.h - // TODO: Handle wide and non-wide cases via TCHAR? - // TODO: Skip \\?\ processing if the length is not > MAX_PATH? - // TODO: Write unittests - - // Convert to Utf16 - int wlen = ::MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), utf8.length() + 1, - NULL, 0); - if (0 == wlen) { - return false; - } - wchar_t* wfilename = STACK_ARRAY(wchar_t, wlen); - if (0 == ::MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), utf8.length() + 1, - wfilename, wlen)) { - return false; - } - // Replace forward slashes with backslashes - std::replace(wfilename, wfilename + wlen, L'/', L'\\'); - // Convert to complete filename - DWORD full_len = ::GetFullPathName(wfilename, 0, NULL, NULL); - if (0 == full_len) { - return false; - } - wchar_t* filepart = NULL; - wchar_t* full_filename = STACK_ARRAY(wchar_t, full_len + 6); - wchar_t* start = full_filename + 6; - if (0 == ::GetFullPathName(wfilename, full_len, start, &filepart)) { - return false; - } - // Add long-path prefix - const wchar_t kLongPathPrefix[] = L"\\\\?\\UNC"; - if ((start[0] != L'\\') || (start[1] != L'\\')) { - // Non-unc path: <pathname> - // Becomes: \\?\<pathname> - start -= 4; - ASSERT(start >= full_filename); - memcpy(start, kLongPathPrefix, 4 * sizeof(wchar_t)); - } else if (start[2] != L'?') { - // Unc path: \\<server>\<pathname> - // Becomes: \\?\UNC\<server>\<pathname> - start -= 6; - ASSERT(start >= full_filename); - memcpy(start, kLongPathPrefix, 7 * sizeof(wchar_t)); - } else { - // Already in long-path form. - } - filename->assign(start); - return true; -} - -bool GetOsVersion(int* major, int* minor, int* build) { - OSVERSIONINFO info = {0}; - info.dwOSVersionInfoSize = sizeof(info); - if (GetVersionEx(&info)) { - if (major) *major = info.dwMajorVersion; - if (minor) *minor = info.dwMinorVersion; - if (build) *build = info.dwBuildNumber; - return true; - } - return false; -} - -bool GetCurrentProcessIntegrityLevel(int* level) { - bool ret = false; - HANDLE process = ::GetCurrentProcess(), token; - if (OpenProcessToken(process, TOKEN_QUERY | TOKEN_QUERY_SOURCE, &token)) { - DWORD size; - if (!GetTokenInformation(token, TokenIntegrityLevel, NULL, 0, &size) && - GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - - char* buf = STACK_ARRAY(char, size); - TOKEN_MANDATORY_LABEL* til = - reinterpret_cast<TOKEN_MANDATORY_LABEL*>(buf); - if (GetTokenInformation(token, TokenIntegrityLevel, til, size, &size)) { - - DWORD count = *GetSidSubAuthorityCount(til->Label.Sid); - *level = *GetSidSubAuthority(til->Label.Sid, count - 1); - ret = true; - } - } - CloseHandle(token); - } - return ret; -} -} // namespace talk_base diff --git a/third_party/libjingle/overrides/talk/base/win32.h b/third_party/libjingle/overrides/talk/base/win32.h index 5cb8d9f..9c6ea3f 100644 --- a/third_party/libjingle/overrides/talk/base/win32.h +++ b/third_party/libjingle/overrides/talk/base/win32.h @@ -47,20 +47,11 @@ typedef struct _TOKEN_MANDATORY_LABEL { #undef SetPort -#include <stdlib.h> #include <string> #include "talk/base/stringutils.h" #include "talk/base/basictypes.h" -// This is to remove the dependency to ws2_32.dll especially for chrome, -// where we don't load the ws2_32.dll in the render process. -// This is correct only on little-endian machines. -#define ntohl(x) _byteswap_ulong(x) -#define ntohs(x) _byteswap_ushort(x) -#define htonl(x) _byteswap_ulong(x) -#define htons(x) _byteswap_ushort(x) - namespace talk_base { const char* win32_inet_ntop(int af, const void *src, char* dst, socklen_t size); |