mac

package
v1.15.8 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 49

Documentation

Index

Constants

View Source
const EthHdrLen = 14

Untagged ethernet (IEEE 802.3) frame header len

Variables

This section is empty.

Functions

func CArrayString added in v0.15.7

func CArrayString(m net.HardwareAddr) string

CArrayString returns a string which can be used for assigning the given MAC addr to "union macaddr" in C.

func HasMacAddr added in v0.15.7

func HasMacAddr(iface string) bool

HasMacAddr returns true if the given network interface has L2 addr.

func HaveMACAddrs added in v0.15.7

func HaveMACAddrs(ifaces []string) bool

HaveMACAddrs returns true if all given network interfaces have L2 addr.

func LinkHasMacAddr added in v0.15.7

func LinkHasMacAddr(link netlink.Link) bool

LinkHasMacAddr returns true if the given network interface has L2 addr.

Types

type MAC

type MAC net.HardwareAddr

MAC address is an net.HardwareAddr encapsulation to force cilium to only use MAC-48.

func GenerateRandMAC added in v0.15.7

func GenerateRandMAC() (MAC, error)

GenerateRandMAC generates a random unicast and locally administered MAC address.

func ParseMAC

func ParseMAC(s string) (MAC, error)

ParseMAC parses s only as an IEEE 802 MAC-48.

func (MAC) MarshalIndentJSON

func (m MAC) MarshalIndentJSON(prefix, indent string) ([]byte, error)

func (MAC) MarshalJSON

func (m MAC) MarshalJSON() ([]byte, error)

func (MAC) String

func (m MAC) String() string

String returns the string representation of m.

func (MAC) Uint64

func (m MAC) Uint64() (Uint64MAC, error)

Uint64 returns the MAC in uint64 format. The MAC is represented as little-endian in the returned value. Example:

m := MAC([]{0x11, 0x12, 0x23, 0x34, 0x45, 0x56})
v, err := m.Uint64()
fmt.Printf("0x%X", v) // 0x564534231211

func (*MAC) UnmarshalJSON

func (m *MAC) UnmarshalJSON(data []byte) error

type Uint64MAC added in v0.15.7

type Uint64MAC uint64

Uint64MAC is the __u64 representation of a MAC address. It corresponds to the C mac_t type used in bpf/.

func (Uint64MAC) String added in v0.15.7

func (m Uint64MAC) String() string

Jump to

Keyboard shortcuts

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