Commit Graph

18 Commits

Author SHA1 Message Date
João Valverde dafbcd0270 manuf: Minor cleanup when formatting output 2023-09-01 17:45:05 +00:00
João Valverde 17ef4b5802 manuf: Change struct ws_manuf block size
We only ever use 5 bytes at most so change the block size from
6 to 5.
2023-08-31 13:51:44 +00:00
João Valverde 76f29a9b79 manuf: Optimize iteration
Instead of copying 3 entries with each iteration loop, keep
the buffer in the iterator and copy just one entry with each
iteration loop.
2023-08-31 13:51:44 +00:00
João Valverde 395e3b6cb5 manuf: Small optimization for ws_manuf_lookup()
Our name resolution logic does not use the address block
of the lookup result. As a small optimization avoid a
memset/memcpy to return the result and just return
two const string pointers.
2023-08-30 23:40:13 +00:00
Peter Wu 17ca30f5c0 manuf: change ws_manuf_lookup return type to bool
The result was propagated through both the return value and the first
output parameter. Change the return type to indicate whether it matched.
2023-08-30 18:53:47 +02:00
Peter Wu 9b39d6880e manuf: simplify ws_manuf_iter_next API
* Remove an internal implementation from the public API. Now the result
  is propagated as second parameter while the return value indicates
  whether an entry was found.
* Change iteration function to avoid comparing string pointers, two
  different values may or may not point to the same underlying value
  depending on linker optimization.
2023-08-30 18:53:47 +02: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
João Valverde c3283d9d17 manuf: Fix unaligned memory access
Use the correct struct pointer cast.
2023-08-24 15:23:46 +01:00
João Valverde 369b1d0696 manuf: Print short name with tshark -G
Add the short name (used by Wireshark for MAC address name resolution)
to the output as another column. This matches the historical
format for this text file, before it was turned into static
binary data.

The use case for still parsing an optional external manuf text file
is to allow customization of the compiled in data, for any reason.

In that case it is useful to be able to run something like:

    tshark -G manuf | grep MyVendorName >> ~/.config/wireshark/manuf

And then edit the newly added short name entries to one's satisfaction.
2023-08-19 07:39:50 +00:00
João Valverde 3210bf4dcf manuf: Revert to the previous concise format for blocks 2023-08-10 10:39:25 +01:00
João Valverde a582dc8ae5 manuf: Add ws_manuf_count() 2023-07-28 21:07:44 +00:00
João Valverde 9179ba9667 manuf: More cleanups
Rename function to use the ws_manuf namespace.

Make all the interface functions public.
2023-07-28 21:07:44 +00:00
João Valverde 341c03713f manuf: Move private declarations out of header 2023-07-28 21:07:44 +00:00
João Valverde b3e09c65d3 manuf: Mask out broadcast flag 2023-07-27 17:46:03 +00:00
João Valverde 0ebe3bc0d4 manuf: Improve iteration logic
Fill the temporary buffer with existing entries only. Use
a for loop to iterate and select the smallest.
2023-07-27 17:46:03 +00:00
João Valverde 611bf80be3 manuf: Code cleanup
Make global_manuf_lookup() return a struct ws_manuf pointer.

Use a function to handle each switch case.
2023-07-27 17:46:03 +00:00
João Valverde dae58c9a69 manuf: Add table dump with tshark -G 2023-07-26 00:13:32 +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