netaddr / netaddr

A network address manipulation library for Python

Home Page:https://netaddr.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OUI lookups incorrect

JonathonReinhart opened this issue · comments

From /usr/share/ieee-data/oui.txt out of ieee-data 20210605.1 on Debian Bullseye:

F4-6D-04   (hex)        ASUSTek COMPUTER INC.
F46D04     (base 16)        ASUSTek COMPUTER INC.
                15,Li-Te Rd.,Peitou,
                Taipei    112    
                TW

Using netaddr 0.7.19 (from the Debian Bullseye python3-netaddr package version 0.7.19-5) I get completely incorrect / corrupt results:

>>> oui = OUI('F4-6D-04')
>>> oui
OUI('F4-6D-04')
>>> oui.re
oui.records        oui.reg_count      oui.registration(  
>>> oui.registration()
{'address': [')\t\tCisco Systems, Inc',
             '80 West Tasman Drive',
             'San Jose  CA  94568',
             'US'],
 'idx': 16018692,
 'offset': 821392,
 'org': 'eero inc.',
 'oui': 'F4-6D-04',
 'size': 141}

Virtualenv test

Using netaddr 0.7.19 (in a virtualenv install via pip) I get correct results:

>>> import netaddr
>>> netaddr.__version__
'0.7.19'
>>> from netaddr import *
>>> oui = OUI('F4-6D-04')
>>> oui
OUI('F4-6D-04')
>>> oui.registration()
{'address': ['15,Li-Te Rd.,Peitou,', 'Taipei    112', 'TW'],
 'idx': 16018692,
 'offset': 741741,
 'org': 'ASUSTek COMPUTER INC.',
 'oui': 'F4-6D-04',
 'size': 141}

So this appears to be a Debian bug.

virtualenv:

$ ls -l ~/virtualenvs/netaddrtest/lib/python3.9/site-packages/netaddr/eui/
total 6432
-rw-r--r-- 1 jreinhart jreinhart   95467 Jul 17 14:23 iab.idx
-rw-r--r-- 1 jreinhart jreinhart 2453271 Jul 17 14:23 iab.txt
-rw-r--r-- 1 jreinhart jreinhart    9500 Jul 17 14:23 ieee.py
-rw-r--r-- 1 jreinhart jreinhart   24990 Jul 17 14:23 __init__.py
-rw-r--r-- 1 jreinhart jreinhart  419098 Jul 17 14:23 oui.idx
-rw-r--r-- 1 jreinhart jreinhart 3566144 Jul 17 14:23 oui.txt
drwxr-xr-x 2 jreinhart jreinhart    4096 Jul 17 14:23 __pycache__

system:

$ ls -l /usr/lib/python3/dist-packages/netaddr/eui/
total 596
-rw-r--r-- 1 root root  95467 Mar 10  2021 iab.idx
lrwxrwxrwx 1 root root     26 Mar 10  2021 iab.txt -> /var/lib/ieee-data/iab.txt
-rw-r--r-- 1 root root   9500 Jan 12  2017 ieee.py
-rw-r--r-- 1 root root  24990 Jan 12  2017 __init__.py
-rw-r--r-- 1 root root 464869 Mar 10  2021 oui.idx
lrwxrwxrwx 1 root root     26 Mar 10  2021 oui.txt -> /var/lib/ieee-data/oui.txt
drwxr-xr-x 2 root root   4096 Jul 17 13:51 __pycache__

It appears that they are symlinking oui.txt to the oui.txt from ieee-data (which has correct data). I don't know how the oui.idx ("index"?) file works, but I'm assuming it's a shortcut into the text file.

My guess is that oui.idx matches the version of oui.txt that you ship, but does not match oui.txt from ieee-data. They need to also build the .idx file, I suppose.

I think I'm gonna close this issue. There's no support for replacing any of the data files the package includes.