Skip to content

Script for updating "oui.c" #655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sgeto
Copy link
Contributor

@sgeto sgeto commented Nov 26, 2017

No description provided.

@sgeto
Copy link
Contributor Author

sgeto commented Nov 27, 2017

Almost there...

@fxlb
Copy link
Member

fxlb commented Nov 27, 2017

Hi,
Some remarks:

  • update-oui-database.sh is licensed under GPL, not sure we take it.
  • update-oui-database.sh is not executable.
  • Striped size of tcpdump increase by 66% (e.g. 1,2M->2.0M on Debian Jessie). Perhaps problem for embedded systems. Make update optional ?
  • After running update-oui-database.sh (I need to install gawk, my system has mawk by default), the oui.c file is only 3220 bytes.
  • Your branch is 2 commits behind the-tcpdump-group:master.

@infrastation
Copy link
Member

Also it would help to have one clean commit instead of many draft changes.

@sgeto
Copy link
Contributor Author

sgeto commented Nov 27, 2017

@fxlb

update-oui-database.sh is licensed under GPL

So is config.guess and config.sub. I believe that tcpdump's source is licensed under a BSD-style license, not so much the scripts to build it. And this script isn't even meant to be used by a developer or user. Only by tcpdump maintainers', and probably only once a year or so.

update-oui-database.sh is not executable

Sorry. You're right. I keep forgetting that. Executable bits aren't really a thing one my main OS. I will fix it that.

Make update optional ?

I guess there are cases where increases file size could be a problem. So this could be done. Although I also think that compiling these entries in should be the default.
My NanoStation Loco M2 from 2011 for example is barely complaining, and its total free space is 8 MiB (OpenWrt uses about 4 MiB of that).

Also, I noticed that prefixing every entry with 0x adds about 0.4 MiB to the total file size (stripped). Using a more efficient method of marking these as hex is probable in order too.

After running update-oui-database.sh (I need to install gawk, my system has mawk by default), the oui.c file is only 3220 bytes

oui.txt (from http://standards-oui.ieee.org/oui.txt) has Windows line endings by default. 😆 😆
I didn't notice that. As convenient as as that may be for me, it wasn't their smartest move.
You need to convert them (i.e the script should probably do that for you). I'm on it.
And then try it mawk. Maybe it works.

@infrastation

Also it would help to have one clean commit instead of many draft changes.

I will squash them into a single commit once I come after some of the points mentioned.

@gvanem
Python and I aren't on out best terms. The dry-run option is great though 👍

@mcr
Copy link
Member

mcr commented Nov 27, 2017

if you are talking about the 0x in the oui_values table in oui.c, then the size of the .c file has no relationship to the resulting object file.

@mcr
Copy link
Member

mcr commented Nov 27, 2017

There is also the PEN table in oui.c, which would be nice to update.
It might be that a better policy would be to install a file into /usr/share that has the list. I hate to parse that file each time tcpdump runs, so it should at least be on demand... maybe we can mmap() it read only. At least that eliminates the hit for small systems (just don't ship the file). Or maybe compile it has as now, with #ifdef SMALL or something.

@sgeto
Copy link
Contributor Author

sgeto commented Nov 28, 2017

I agree, an #ifdef SMALL or something in oui.c and a note somewhere should be enough.
There could also be an option for that in the configure script.

There is also the PEN table in oui.c, which would be nice to update.

The OUI database is significantly smaller than the PEN table. This would add 51000+ entries.

@gvanem
Copy link
Contributor

gvanem commented Nov 28, 2017

@sgeto Python and I aren't on out best terms. The dry-run option is great though

I deleted that comment since you d/l it since it failed in Python3 (it still have some Unicode issue).
But here it is again with a cached tweak:
make-oui.py.txt

I.e. it doesn't download again if oui.txt is in curr-dir. (drop the .txt extension again and run python2 make-oui.py)

@sgeto
Copy link
Contributor Author

sgeto commented Nov 28, 2017

@gvanem
whoa the script is fast! (It took around a second)

This is clever
f.write (" { 0xFFFFFF, NULL } /* Since XEROX CORPORATION has value 0, use this */\n };\n")

but the script adds only "netdissect.h" when oui.c needs

#include <netdissect-stdinc.h>
#include "netdissect.h"
#include "oui.h"

It also seems to overrides already existing content in oui.c (PEN table, copyright notice, includes etc).
I spend quite some time on mine to make sure it never does.

@gvanem
Copy link
Contributor

gvanem commented Nov 29, 2017

What is PEN table?
Okay, it's trivial to add the other headers (I've not actually built tcpdump with this oui.c).

@sgeto
Copy link
Contributor Author

sgeto commented Nov 29, 2017

What is PEN table?

the other structure in oui,c that begins with

/*
 * SMI Network Management Private Enterprise Codes for organizations.
 *
 * XXX - these also appear in FreeRadius dictionary files, with items such
 * as
 *
 *	VENDOR          Cisco           9
 *
 * List taken from Ethereal's epan/sminmpec.c.
 */

@sgeto
Copy link
Contributor Author

sgeto commented Nov 29, 2017

I'm pretty happy with how the PR is right now. So what would it take to get this baby on the road?
If you have suggestions or really want me to squeeze these commits on one, let me know.

@gvanem
Copy link
Contributor

gvanem commented Dec 6, 2017

I'm still tinkering with my make-oui.py script. But have some problems understanding how all the
oui.h entries (like #define OUI_IANA) should be used/generated. Are they not?

Having all these OUI_xx in oui.h is IMHO ugly. Should we rather make some generated:

oui_val_to_name()
oui_name_to_val()

functions? (ref. pcap_datalink_val_to_name).

Edit: I've updated my .py script for a smi_values[] array too: https://gist.github.com/gvanem/1643c946fb2395b6c8a05c3ec8904e13

Compiles okay with gcc/clang-cl now. But MSVC says:

oui-generated.c : fatal error C1128: number of sections exceeded object file format limit: 
compile with /bigobj

Besides the size of windump.exe jumped from 1.522.688 to 3.819.008 bytes!

@infrastation
Copy link
Member

As a matter of style, for a change of this scope 1 commit would be better than 12 commits trying to amend one another.

Remove old OUI list:
Except for some defines in oui.h needed by print-llc.c
Generate new OUI list


Brought some needed defines back:
needed by print-llc.c and print-openflow-1.0.c
Add update-oui-database.sh as dist target

Adjusted tests

Added executable permission to update-oui-database.sh

Merge branch 'master' into oui

Convert DOS newlines (CR/LF) to Unix format

Allow skipping full OUI database by defining NOOUIDB

Add an --disable-oui-database option to the configure script

The last entry in should be 0xFFFFFF
shout-out to @gvanem

Updated OUI database again
@sgeto
Copy link
Contributor Author

sgeto commented Dec 10, 2017

@infrastation
done

@sgeto
Copy link
Contributor Author

sgeto commented Dec 10, 2017

@gvanem

But have some problems understanding how all the
oui.h entries (like #define OUI_IANA) should be used/generated. Are they not?

Will this change, these definitions are only around for print-lldp.c and print-llc.c.

Having all these OUI_xx in oui.h is IMHO ugly.

I agree but just leave them there. Another option would be to replace these macros in print-lldp.c and print-llc.c with with their actual value since they will probably stay the same forever anyways.

oui-generated.c : fatal error C1128: number of sections exceeded object file format limit:
compile with /bigobj

Have not build this branch with MSVC yet.
If MSVC knows that the resulting object file is exceeding the object file format limit (the have a term for everything, don't they?), why wouldn't the compiler add that flag by itself? That's just backwards.
Does the error go away when you add /bigobj?

Besides the size of windump.exe jumped from 1.522.688 to 3.819.008 bytes!

oui.txt is a big list. An alternative would be to make the list optional or to make tcpdump read a plain oui.txt at runtime. See @mcr 's comment on that. The latter will require quite some coding.
Whether this feature should be around is a more important question than the increasing filesize. And because it's 2017, that question should also be a rhetorical one.

@fxlb
Copy link
Member

fxlb commented May 26, 2020

Need to study memory and size before/after adding a complete oui file.
I think we need to keep tcpdump small.
Make this optional?

@mcr
Copy link
Member

mcr commented May 26, 2020

Alternatively, I have the OUIs as a reverse DNS lookup:

tilapia-[/etc/domain/sandelman.ca] mcr 10007 %dig +short 1.0.0.5.c.b.1.0.0.ethermap.sandelman.ca. txt
"OpenRB.com, Direct SIA"

I don't really want to put this in my zone. It could go into tcpdump.net if desired.

@infrastation
Copy link
Member

@fxlb, did you have a chance to see what effect this change would have on performance and memory footprint?

@fxlb
Copy link
Member

fxlb commented Oct 10, 2021

did you have a chance to see what effect this change would have on performance and memory footprint?

Stripped size of tcpdump increases from 1.6M -> 2.2M on Debian Bullseye. No time for other studies.

(This PR updates 107 files : problem!)

@infrastation
Copy link
Member

Most of the changes are not related to OUI printing, possibly a git rebase went wrong at some point. The proposed change would need to be extracted into a small commit before it can be considered again.

@infrastation
Copy link
Member

infrastation commented Nov 25, 2021

The changes that belong to the commit are:

  • update-oui-database.sh (a new file)
  • Makefile.in (one line added for the above)
  • oui.h (some lines removed)
  • oui.c (many lines added)
  • configure (support for --disable-oui-database to define NOOUIDB)

The original changes to configure.ac seem to be lost and would need to be recovered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants