Commit Graph

33 Commits

Author SHA1 Message Date
John Thacker 2f3f879f90 manuf: Remove curly quotes, double angle brackets
Remove curly quotes and double angle bracket punctuation too.
For some reason this has to be done in a different regex substitution
or Python handles it incorrectly.

Also add Chengdu to the list of Chinese locations
2023-11-29 09:27:33 -05:00
John Thacker 7234ce727b manuf: Update make-manuf for a few more Chinese names
Remove the contents of fullwidth parenthesis for the same reason as
parenthesis.

Special case 杭州德澜科技有限公司(HangZhou Delan Technology Co.,Ltd)
where the item in the parenthesis is the English name.

Add Guangdong to the list of city names to remove at the start.
2023-11-29 13:34:49 +00:00
John Thacker c3548e3005 manuf: Add back the special case for all zeroes
These words from Jörg Mayer are as true today as they were
21 years ago in 49a2f32336,
"I still have yet to see a case when a MAC address starting
with 0:0:0 actually means Xerox", but there are lots of cases
where all zero OUIs, MAC-48s, EUI-64s, etc are used to mean
null.

[skip ci]
2023-11-21 12:31:18 +00:00
Peter Wu a1c7e84f07 manuf: constify API, improve internal documentation
* None of the OUI tables are supposed to be written to, constify them.
* Use proper types in the bsearch parameters to avoid confusion.
* Move masking outside the bsearch function as tiny optimization.
* Document the MA-L/M/S macros.
2023-08-30 18:53:47 +02:00
Gerald Combs d437d4c5b9 manuf: Handle backslashes in company names
[skip ci]
2023-08-27 12:33:53 -07:00
João Valverde 159dc2c204 manuf: Remove parenthesis from short name 2023-08-20 16:59:39 +01:00
João Valverde 8985aa465f manuf: Add a special case 2023-08-20 16:59:39 +01:00
Markku Leiniö 90cc69536b Remove article 'a' from manuf data 2023-08-17 11:30:26 +03:00
João Valverde 341c03713f manuf: Move private declarations out of header 2023-07-28 21:07:44 +00:00
João Valverde b4a421cf82 Replace "manuf" files with static arrays
To reduce startup external file parsing replce the manuf file with
static arrays compiled into the binary.

Add 3 tables for MA-L, MA-M and MA-S. Add a fourth table to direct
a 24-bit MAC prefix (OUI) to one of these tables.

Adapt the make-manuf.py script to generate the static C data
instead of the text file.

The arrays are sorted and a binary search is performed to map
an OUI (24bit/28bit/36bit) to a short and long name.
2023-07-25 16:23:26 +00:00
João Valverde f588214a58 manuf: Improve name shortening heuristic
Add - and + to punctuation exclusion list.

Do not remove the first word as a general term. When an exclusion
term is used as the first word usually it is noa only legalese and
should not be rejected. The exception is "The".
2023-07-10 15:24:47 +01:00
João Valverde f44e088329 manuf: Skip some start words in short name
Skip some locations in company names that are just repeated low-value
information. Many different Chinese companies will short to the same
name (Shenzen for example).

This is a heuristic and not 100% reliable but in the vast majority of
cases it cuts down on noise and generates more informative names.
2023-07-10 15:23:23 +01:00
João Valverde ac57a25ed8 manuf: Increase truncation size to 12
The truncation size of 8 is too short to convey enough information
in many cases. Some experimentation suggests it can be safely
increased for better readability without any other ill effects.

Make a conservative size increase 12. Arguaby it could be larger.
2023-07-10 15:22:36 +01:00
João Valverde 641de5bd0d manuf: Fix indentation
Align the column indentation vertically.
2023-07-10 15:22:05 +01:00
João Valverde 0b5791b08d manuf: Drop Cavebear OUI list
The cavebear OUI list is hopelessly outdated (last updated 1999?)
and our template file mostly contains obsolete or poorly formatted
entries, compared to the official IEEE registry. We should rely on
the official registry, which is the best and most up-to-date source,
despite some minor inconsistencies and glitches.

Remove the template file and use the IEEE registry exclusively.
2023-07-10 15:17:55 +01:00
Gerald Combs 4819716f14 Tools: Switch make-manuf.py URLs to HTTPS.
standards-oui.ieee.org is now served over HTTPS.
2022-09-05 17:55:33 +00:00
Jim Young 371f98aec4 make-manuf.py: Remove HTML double quote entities 2022-02-14 23:12:56 +00:00
Gerald Combs f9d0f35363 Tools: Fix a make-manuf error and some Pylint warnings. 2021-10-31 16:04:00 -07:00
Gerald Combs 99ef1b2643 make-manuf updates.
Strip A.S. and oü, similar to other business types. Strip forward
slashes as well, including A/S.

Change-Id: Icf436f8663dc9cddf220642913eea7a60285ebc1
2021-02-17 14:21:41 -08:00
Gerald Combs 894a70d079 Remove a bunch of duplicate manuf.tmpl entries.
Update make-manuf.py to print "Skipping duplicate IEEE ..." when the
organization names are the same. Remove duplicates by running

    tools/make-manuf.py | awk '/Skipping duplicate IEEE/ {printf "^%s\t\n", $1 }' > /tmp/duplicates.pat
    grep -v -f /tmp/duplicates.pat manuf.tmpl > manuf.tmpl.new ; mv manuf.tmpl.new manuf.tmpl
2021-01-01 10:27:35 +00:00
Gerald Combs 30c392f166 Tools+test: Call python3 explicitly.
PEP 394[1] says,

"In cases where the script is expected to be executed outside virtual
 environments, developers will need to be aware of the following
 discrepancies across platforms and installation methods:

  * Older Linux distributions will provide a python command that refers
    to Python 2, and will likely not provide a python2 command.

  * Some newer Linux distributions will provide a python command that
    refers to Python 3.

  * Some Linux distributions will not provide a python command at all by
    default, but will provide a python3 command by default."

Debian has forced the issue by choosing the third option[2]:

"NOTE: Debian testing (bullseye) has removed the "python" package and
 the '/usr/bin/python' symlink due to the deprecation of Python 2."

Switch our shebang from "#!/usr/bin/env python" to "#!/usr/bin/env
python3" in some places. Remove some 2/3 version checks if we know we're
running under Python 3. Remove the "coding: utf-8" in a bunch of places
since that's the default in Python 3.

[1]https://www.python.org/dev/peps/pep-0394/#for-python-script-publishers
[2]https://wiki.debian.org/Python
2020-11-05 06:46:35 +00:00
Jeff Widman 8d7ebc732e Fix issues discovered by common python linters
Fix some issues discovered by common python linters including:
* switch `None` comparisons to use `is` rather than `==`. Identity !=
equality, and I've spent 40+ hours before tracking down a subtle bug
caused by exactly this issue. Note that this may introduce a problem if
one of the scripts is depending on this behavior, in which case the
comparison should be changed to `True`/`False` rather than `None`.
* Use `except Exception:` as bare `except:` statements have been
discouraged for years. Ideally for some of these we'd examine if there
were specific exceptions that should be caught, but for now I simply
caught all. Again, this could introduce very subtle behavioral changes
under Python 2, but IIUC, that was all fixed in Python 3, so safe to
move to `except Exception:`.
* Use more idiomatic `if not x in y`--> `if x not in y`
* Use more idiomatic 2 blank lines. I only did this at the beginning,
until I realized how overwhelming this was going to be to apply, then I
stopped.
* Add a TODO where an undefined function name is called, so will fail
whenever that code is run.
* Add more idiomatic spacing around `:`. This is also only partially
cleaned up, as I gave up when I saw how `asn2wrs.py` was clearly
infatuated with the construct.
* Various other small cleanups, removed some trailing whitespace and
improper indentation that wasn't a multiple of 4, etc.

There is still _much_ to do, but I haven't been heavily involved with
this project before, so thought this was a sufficient amount to put up
and see what the feedback is.

Linters that I have enabled which highlighted some of these issues
include:
* `pylint`
* `flake8`
* `pycodestyle`
2020-09-26 04:38:18 +00:00
Gerald Combs 4d67f06108 make-manuf.py: Add "of" to the general terms list.
Add "of" to the list of general terms to remove when shortening.

Change-Id: Idbfea2d502a89d668ba2f170bf3450cfcbb91fe5
Reviewed-on: https://code.wireshark.org/review/35627
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2020-01-02 22:57:32 +00:00
Gerald Combs 12550ef794 make-manuf.py: Fix a shortening error.
Handle cases where we might shorten a name (e.g. "ZAO") down to
nothing.

Change-Id: I5ecb9592d2ecd8225d0ed459ef16885214af5da4
Reviewed-on: https://code.wireshark.org/review/35584
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-12-29 18:30:16 +00:00
Gerald Combs f8808b8bd0 make-manuf.py: Handle more business types and other fixes.
Move our business types and general terms to a list and add more. Only
convert all upper case names to title case. Remove double quotes when
shortening names.

Change-Id: I31e9799986542270350b8c2436929f293de4e36c
Reviewed-on: https://code.wireshark.org/review/35577
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-12-29 02:42:06 +00:00
Gerald Combs 6f57aa72a8 Make a couple of scripts Python 3 only.
Remove Python 2 support from tools/make-manuf.py and tools/make-usb.py.

Don't double-escape UTF-8 sequences in make-usb.py so that we generate

    { 0x045e000e, "SideWinder\xc2\xae Freestyle Pro" },

instead of

    { 0x045e000e, "SideWinder\\xc2\\xae Freestyle Pro" },

Change-Id: I918f854ccba868a122fd7b138c1654b2c7615f94
Reviewed-on: https://code.wireshark.org/review/32839
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-04-12 20:12:10 +00:00
Gerald Combs 6501231a3c make-manuf.py: Add response headers.
Add comments containing the resonse headers for the URLs we fetch.
standards-oui.ieee.org currently returns inconsistent results depending
on which host you happen to resolve.

Change-Id: I4adba7e51628d0350ba8e091523807ec85009700
Reviewed-on: https://code.wireshark.org/review/29729
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-19 00:34:50 +00:00
Gerald Combs 7b65208ef3 make-manuf.py: Add back our user agent.
Change-Id: I39c54fa38c791f3244075b03a0045babc4f249ec
Reviewed-on: https://code.wireshark.org/review/29706
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-17 18:30:27 +00:00
Gerald Combs 56a30766ef make-manuf.py: Improve truncation.
If the PyICU module is available, use it to truncate manufacturer
names by grapheme clusters.

Change-Id: Ib7dcbb126809df496a534f44a47871a1b28dc539
Reviewed-on: https://code.wireshark.org/review/29660
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-14 18:01:49 +00:00
Gerald Combs bc600962e2 Manuf fixups.
Remove some entries from manuf.tmpl that are either redundant or less
informative that their corresponding IEEE entries. Add a missing '"' to
make-manuf.py.

Change-Id: Ia69f4529c5fa1b39f1662b94d072c65bd2d969ea
Reviewed-on: https://code.wireshark.org/review/29568
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-10 17:38:03 +00:00
Gerald Combs cba7dfb40b make-manuf.py: Expand a comment.
Change-Id: I545a63bb4a045ba93d1ad1ee82315315bdbb3c9e
Reviewed-on: https://code.wireshark.org/review/29508
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-09-10 04:07:08 +00:00
Gerald Combs aba5c65f4d make-manuf.py: Skip the title row of each .csv file.
Change-Id: I88a4b3da6b75d4891dc3b3e5b8ceb1233e038932
Reviewed-on: https://code.wireshark.org/review/29470
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-07 17:23:53 +00:00
Gerald Combs a1fac65d8e Migrate make-manuf to Python+CSV.
The download links offered by the IEEE at
https://standards.ieee.org/products-services/regauth/ are CSV files.
Updating the Perl version to support CSV would have required rewriting a
significant portion of the script along with either adding a dependency
on Text::CSV or writing our own CSV parser.

Migrate it to Python, which has a built-in CSV module.

Change-Id: I39ba0ec873145f44374ab9f751e8bde51535ca4d
Reviewed-on: https://code.wireshark.org/review/29442
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-09-07 04:01:44 +00:00