OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 import atexit | 5 import atexit |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import re | 8 import re |
9 import socket | 9 import socket |
10 import struct | 10 import struct |
(...skipping 10 matching lines...) Expand all Loading... |
21 class AndroidRndisForwarder(object): | 21 class AndroidRndisForwarder(object): |
22 """Forwards traffic using RNDIS. Assumes the device has root access.""" | 22 """Forwards traffic using RNDIS. Assumes the device has root access.""" |
23 | 23 |
24 def __init__(self, device, rndis_configurator): | 24 def __init__(self, device, rndis_configurator): |
25 self._device = device | 25 self._device = device |
26 self._rndis_configurator = rndis_configurator | 26 self._rndis_configurator = rndis_configurator |
27 self._device_iface = rndis_configurator.device_iface | 27 self._device_iface = rndis_configurator.device_iface |
28 self._host_ip = rndis_configurator.host_ip | 28 self._host_ip = rndis_configurator.host_ip |
29 self._original_dns = None, None, None | 29 self._original_dns = None, None, None |
30 self._RedirectPorts() | 30 self._RedirectPorts() |
31 self._OverrideDns() | 31 # The netd commands fail on Lollipop and newer releases, but aren't |
| 32 # necessary as DNS isn't used. |
| 33 # self._OverrideDns() |
32 self._OverrideDefaultGateway() | 34 self._OverrideDefaultGateway() |
33 # Need to override routing policy again since call to setifdns | 35 # Need to override routing policy again since call to setifdns |
34 # sometimes resets policy table | 36 # sometimes resets policy table |
35 self._rndis_configurator.OverrideRoutingPolicy() | 37 self._rndis_configurator.OverrideRoutingPolicy() |
36 atexit.register(self.Close) | 38 atexit.register(self.Close) |
37 # TODO(tonyg): Verify that each port can connect to host. | 39 # TODO(tonyg): Verify that each port can connect to host. |
38 | 40 |
39 @property | 41 @property |
40 def host_ip(self): | 42 def host_ip(self): |
41 return self._host_ip | 43 return self._host_ip |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 device_iface, host_iface = self._CheckEnableRndis(force) | 488 device_iface, host_iface = self._CheckEnableRndis(force) |
487 self._ConfigureNetwork(device_iface, host_iface) | 489 self._ConfigureNetwork(device_iface, host_iface) |
488 self.OverrideRoutingPolicy() | 490 self.OverrideRoutingPolicy() |
489 # Sometimes the first packet will wake up the connection. | 491 # Sometimes the first packet will wake up the connection. |
490 for _ in range(3): | 492 for _ in range(3): |
491 if self._TestConnectivity(): | 493 if self._TestConnectivity(): |
492 return | 494 return |
493 force = True | 495 force = True |
494 self.RestoreRoutingPolicy() | 496 self.RestoreRoutingPolicy() |
495 raise Exception('No connectivity, giving up.') | 497 raise Exception('No connectivity, giving up.') |
OLD | NEW |