macaddr

package
v0.727.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package macaddr classifies an IEEE 802 MAC address (EUI-48) from its two administration bits — the I/G bit (individual vs group/multicast) and the U/L bit (universally vs locally administered). The U/L bit is the standard signal that an address is locally administered, which on a unicast address is the hallmark of a randomized / privacy MAC (modern iOS, Android, Windows and Linux randomize the client MAC, setting this bit). It is the offline analysis complement to the WiFi/BLE scan tooling, whose results are lists of MACs.

Wrap-vs-native judgement

Native. The classification is two bit tests on the first octet plus an all-ones broadcast check — the IEEE 802 address-format rules, fixed and unambiguous. There is nothing to wrap.

Verifiable / no confidently-wrong output

The I/G and U/L bits have exact, universally-agreed definitions, so the multicast / locally-administered / broadcast determinations are facts, not guesses. The "randomized MAC" reading is framed as an observation (a locally-administered unicast address is *commonly* a randomized/privacy MAC), not a verdict — a device can be locally administered for other reasons. The OUI (first three octets) is surfaced raw and only when the address is universally administered (a locally-administered address has no meaningful OUI); the full IEEE OUI-to-vendor registry is large and not embedded here, so a vendor name is not guessed at this layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MACToEUI64IID added in v0.424.0

func MACToEUI64IID(mac string) ([]byte, error)

MACToEUI64IID builds the Modified EUI-64 interface identifier (8 bytes) for a MAC — the forward transform RecoverMAC inverts. Exposed so callers (and the round-trip tests) can synthesise a SLAAC interface identifier from a MAC.

Types

type EUI64Result added in v0.424.0

type EUI64Result struct {
	IPv6         string   `json:"ipv6"`
	InterfaceID  string   `json:"interface_id"` // low 64 bits, hex
	EUI64Derived bool     `json:"eui64_derived"`
	RecoveredMAC string   `json:"recovered_mac,omitempty"`
	Notes        []string `json:"notes,omitempty"`
}

EUI64Result is the recovery of a MAC address from an IPv6 interface identifier (the low 64 bits of the address).

func RecoverMAC added in v0.424.0

func RecoverMAC(ipv6 string) (*EUI64Result, error)

RecoverMAC inspects an IPv6 address's interface identifier (low 64 bits) and, when it is a Modified EUI-64 — recognised by the FF:FE marker in the middle — recovers the embedded MAC by removing the FF:FE and flipping the U/L bit back. This deanonymises a host whose SLAAC address was derived from its MAC. A privacy-extension / RFC 7217 stable-private / random IID does not carry the marker (and matches it only ~1 in 65536 by chance), so the result is framed as an observation, not a certainty.

type Result

type Result struct {
	MAC                     string   `json:"mac"` // normalised AA:BB:CC:DD:EE:FF
	Unicast                 bool     `json:"unicast"`
	Multicast               bool     `json:"multicast"`
	Broadcast               bool     `json:"broadcast"`
	LocallyAdministered     bool     `json:"locally_administered"`
	UniversallyAdministered bool     `json:"universally_administered"`
	OUI                     string   `json:"oui,omitempty"` // first 3 octets, only when universally administered
	RandomizedLikely        bool     `json:"randomized_likely"`
	Notes                   []string `json:"notes,omitempty"`
}

Result is the structural classification of a MAC address.

func Classify

func Classify(raw string) (*Result, error)

Classify parses a MAC address (accepting ':' / '-' / '.' / no separators) and reports its IEEE 802 administration bits.

Jump to

Keyboard shortcuts

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