Example #1
0
def test_iab():
    eui = EUI('00-50-C2-05-C0-00')

    assert eui.is_iab()
    assert str(eui.oui) == '00-50-C2'
    assert str(eui.iab) == '00-50-C2-05-C0-00'
    assert eui.ei == '05-C0-00'
    assert int(eui.oui) == 0x0050c2
    assert int(eui.iab) == 0x0050c205c
Example #2
0
def test_iab():
    eui = EUI('00-50-C2-05-C0-00')

    assert eui.is_iab()
    assert str(eui.oui) == '00-50-C2'
    assert str(eui.iab) == '00-50-C2-05-C0-00'
    assert eui.ei == '05-C0-00'
    assert int(eui.oui) == 0x0050c2
    assert int(eui.iab) == 0x0050c205c
Example #3
0
def test_new_iab():
    eui = EUI('40-D8-55-13-10-00')

    assert eui.is_iab()
    assert str(eui.oui) == '40-D8-55'
    assert str(eui.iab) == '40-D8-55-13-10-00'
    assert eui.ei == '13-10-00'
    assert int(eui.oui) == 0x40d855
    assert int(eui.iab) == 0x40d855131

    assert IAB(eui.value) == eui.iab
Example #4
0
def test_eui_iab():
    mac = EUI('00-50-C2-00-0F-01')
    assert mac.is_iab()

    iab = mac.iab
    assert str(iab) == '00-50-C2-00-00-00'
    assert iab == IAB('00-50-C2-00-00-00')

    reg_info = iab.registration()

    assert reg_info.address == [
        '1241 Superieor Ave E',
        'Cleveland  OH  44114',
        'US',
    ]

    assert reg_info.iab == '00-50-C2-00-00-00'
    assert reg_info.org == 'T.L.S. Corp.'
Example #5
0
def test_eui_iab():
    mac = EUI('00-50-C2-00-0F-01')
    assert mac.is_iab()

    iab = mac.iab
    assert str(iab) == '00-50-C2-00-00-00'
    assert iab == IAB('00-50-C2-00-00-00')

    reg_info = iab.registration()

    assert reg_info.address == [
        '1241 Superieor Ave E',
        'Cleveland  OH  44114',
        'US',
    ]

    assert reg_info.iab == '00-50-C2-00-00-00'
    assert reg_info.org == 'T.L.S. Corp.'
Example #6
0
def mac_vendor(mac_addr):

    try:
        mac = EUI(mac_addr)
    except AddrFormatError:
        return "Invalid MAC"

    try:
        if mac.is_iab():
            oui = mac.iab
        else:
            oui = mac.oui
    except NotRegisteredError:
        # Words[0] attribute returns the first octet of a MAC address
        # in decimal:
        # https://netaddr.readthedocs.io/en/latest/api.html#netaddr.EUI.words
        # Bool() returns true if bitwise AND operation is not 0.
        if bool(mac.words[0] & 0b10):
            return "LA address"
        else:
            return "unknown vendor"

    return shorten(oui.registration().org)