def get_ip_range(ifname): for line in wifi.shell_execute('ip route').splitlines(): if 'dev %s' % ifname in line: match = RE_IP_RANGE.search(line) if match: return match.group(0) return None
def get_default_gateway(ifname): for line in wifi.shell_execute('/data/data/fq.router/busybox ip route').splitlines(): if 'dev %s' % ifname not in line: continue match = RE_DEFAULT_GATEWAY.search(line) if match: return match.group(1) return None
def check_wifi_repeater_supported(): try: api_version = wifi.shell_execute('getprop ro.build.version.sdk').strip() if api_version: return int(api_version) >= 14 else: return True except: LOGGER.exception('failed to get api version') return True
def get_ip_and_mac(ifname): output = wifi.shell_execute('/data/data/fq.router/busybox ifconfig %s' % ifname).lower() match = RE_MAC_ADDRESS.search(output) if match: mac = match.group(0) else: mac = None match = RE_IFCONFIG_IP.search(output) if match: ip = match.group(1) else: ip = None return ip, mac
def get_default_gateway(ifname): global previous_default_gateway for line in wifi.shell_execute('/data/data/fq.router/busybox ip route').splitlines(): if 'dev %s' % ifname not in line: continue match = RE_DEFAULT_GATEWAY.search(line) if match: previous_default_gateway = match.group(1) return previous_default_gateway if previous_default_gateway: return previous_default_gateway else: raise Exception('failed to find default gateway: %s' % ifname)