macaddr

package
v0.0.0-...-67f8464 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: NIST-PD-fallback Imports: 5 Imported by: 3

Documentation

Overview

Package macaddr validates MAC-48 addresses.

Index

Constants

View Source
const (
	// MinVLAN is the minimum VLAN number.
	MinVLAN = 0x001

	// MaxVLAN is the maximum VLAN number.
	MaxVLAN = 0xFFE
)

Variables

View Source
var (
	ErrAddr      = errors.New("invalid MAC address")
	ErrUnicast   = errors.New("invalid unicast MAC address")
	ErrMulticast = errors.New("invalid multicast MAC address")
	ErrVLAN      = errors.New("invalid VLAN")
)

Error conditions.

Functions

func IsMulticast

func IsMulticast(a net.HardwareAddr) bool

IsMulticast determines whether the HardwareAddr is a multicast MAC-48 address.

func IsUnicast

func IsUnicast(a net.HardwareAddr) bool

IsUnicast determines whether the HardwareAddr is a non-zero unicast MAC-48 address.

func IsVLAN

func IsVLAN(vlan int) bool

IsVLAN determines whether an integer is a valid VLAN identifier.

func MakeRandomUnicast

func MakeRandomUnicast() (a net.HardwareAddr)

MakeRandomUnicast generates a random unicast MAC-48 address.

Types

type Flag

type Flag struct {
	net.HardwareAddr
}

Flag is a wrapper of net.HardwareAddr compatible with flag and json packages.

func (Flag) Empty

func (f Flag) Empty() bool

Empty returns true if the HardwareAddr is unset.

func (*Flag) Get

func (f *Flag) Get() any

Get implements flag.Getter.

func (Flag) MarshalText

func (f Flag) MarshalText() (text []byte, e error)

MarshalText implements encoding.TextMarshaler.

func (*Flag) Set

func (f *Flag) Set(s string) (e error)

Set implements flag.Value.

func (*Flag) UnmarshalText

func (f *Flag) UnmarshalText(text []byte) (e error)

UnmarshalText implements encoding.TextUnmarshaler.

Jump to

Keyboard shortcuts

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