oui

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Updated version of https://github.com/dutchcoders/go-ouitools Package go-oui provides functions to work with MAC and OUI's

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidMACAddress = errors.New("invalid MAC address")

Functions

func CIDRMask

func CIDRMask(ones, bits int) []byte

Types

type AddressBlock

type AddressBlock struct {
	Oui          HardwareAddr
	Mask         int
	Organization string
}

oui, mask, organization

func (*AddressBlock) Contains

func (b *AddressBlock) Contains(address HardwareAddr) bool

Contains reports whether the mac address belongs to the OUI

type HardwareAddr

type HardwareAddr net.HardwareAddr

func ParseOUI

func ParseOUI(s string, size int) (hw HardwareAddr, err error)

ParseMAC parses s as an IEEE 802 MAC-48, EUI-48, or EUI-64 using one of the following formats:

01:23:45:67:89:ab
01:23:45:67:89:ab:cd:ef
01-23-45-67-89-ab
01-23-45-67-89-ab-cd-ef
0123.4567.89ab
0123.4567.89ab.cdef

func (HardwareAddr) Mask

func (address HardwareAddr) Mask(mask []byte) []byte

Mask returns the result of masking the address with mask.

type OuiDb

type OuiDb struct {
	Blocks []AddressBlock
}

func New

func New(reader io.Reader) *OuiDb

New returns a new OUI database loaded from the specified file.

func (*OuiDb) Load

func (m *OuiDb) Load(file io.Reader) error

func (*OuiDb) Lookup

func (m *OuiDb) Lookup(address HardwareAddr) *AddressBlock

Lookup finds the OUI the address belongs to

func (*OuiDb) LookupString

func (m *OuiDb) LookupString(s string) (*AddressBlock, error)

VendorLookup obtains the vendor organization name from the MAC address s.

func (*OuiDb) VendorLookup

func (m *OuiDb) VendorLookup(s string) (string, error)

VendorLookup obtains the vendor organization name from the MAC address s.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL