#!/usr/bin/env python # -*- coding: utf-8 -*- # # update-oui.py -- update netsniff-ng oui.conf from official IEEE OUI list # # Copyright (C) 2013 Tobias Klauser # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import os import sys import re import getopt try: from urllib2 import urlopen # Python 2.x except ImportError: from urllib.request import urlopen # Python 3.x DEFAULT_OUPUT_FILE = "oui.conf" DEFAULT_OUI_URL = "http://standards.ieee.org/develop/regauth/oui/oui.txt" OUI_PATTERN = re.compile(b"^\s*([a-fA-F0-9]{2})-([a-fA-F0-9]{2})-([a-fA-F0-9]{2})\s+\(hex\)\s+(.*)$") def usage(): print("""usage: {0} [OPTION...] available options: -f force overwrite of existing file -o set output file (default: {1}) -u set URL to fetch OUI list from (default: {2}) -h show this help and exit""".format(os.path.basename(sys.argv[0]), DEFAULT_OUPUT_FILE, DEFAULT_OUI_URL)) def main(): try: opts, args = getopt.getopt(sys.argv[1:], "fo:u:h") except getopt.GetoptError as err: print(str(err)) usage() sys.exit(-1) overwrite = False output_file = DEFAULT_OUPUT_FILE oui_url = DEFAULT_OUI_URL for o, a in opts: if o == '-f': overwrite = True elif o == '-o': output_file = a elif o == '-u': oui_url = a elif o == '-h': usage() sys.exit(0) else: assert False, "unhandled option" if not overwrite and os.path.exists(output_file): print("Error: output file {} already exists".format(output_file)) sys.exit(-1) print("Updating OUI information in {} from {}... ".format(output_file, oui_url)) fh_url = urlopen(oui_url) ouis = [] for line in fh_url: m = OUI_PATTERN.match(line) if m: oui = "0x{}{}{}".format(m.group(1), m.group(2), m.group(3)) vendor = m.group(4).rstrip() ouis.append((oui, vendor)) fh_file = open(output_file, 'w') for oui, vendor in sorted(ouis): fh_file.write("{}, {}\n".format(oui, vendor)) fh_url.close() fh_file.close() print("{} OUIs written to {}".format(len(ouis), output_file)) if __name__ == '__main__': main() nge'>range
path: root/tools/power/acpi/tools
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-06-03 23:13:20 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-06-03 23:13:20 +0200
commit057beb1de54d33ecfd3397ed219b1f4518e3b470 (patch)
tree7c67e9d8c88093a3d551111e56401826a964ffba /tools/power/acpi/tools
parent42a09284fab8abc15c8554f2e2aa2368161c77c6 (diff)
parent5ece2399181a5abaf42a4cb607463770686778e6 (diff)
Merge branch 'pm-cpufreq'
* pm-cpufreq: (28 commits) cpufreq: handle calls to ->target_index() in separate routine cpufreq: s5pv210: drop check for CONFIG_PM_VERBOSE cpufreq: intel_pstate: Remove unused member name of cpudata cpufreq: Break out early when frequency equals target_freq cpufreq: Tegra: drop wrapper around tegra_update_cpu_speed() cpufreq: imx6q: Remove unused include cpufreq: imx6q: Drop devm_clk/regulator_get usage cpufreq: powernow-k8: Suppress checkpatch warnings cpufreq: powernv: make local function static cpufreq: Enable big.LITTLE cpufreq driver on arm64 cpufreq: nforce2: remove DEFINE_PCI_DEVICE_TABLE macro intel_pstate: Add CPU IDs for Broadwell processors cpufreq: Fix build error on some platforms that use cpufreq_for_each_* PM / OPP: Move cpufreq specific OPP functions out of generic OPP library PM / OPP: Remove cpufreq wrapper dependency on internal data organization cpufreq: Catch double invocations of cpufreq_freq_transition_begin/end intel_pstate: Remove sample parameter in intel_pstate_calc_busy cpufreq: Kconfig: Fix spelling errors cpufreq: Make linux-pm@vger.kernel.org official mailing list cpufreq: exynos: Use dev_err/info function instead of pr_err/info ...
Diffstat (limited to 'tools/power/acpi/tools')