eui64

package module
v0.0.0-...-300b7bd Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2019 License: MIT Imports: 2 Imported by: 26

README

eui64 Build Status Coverage Status GoDoc

Package eui64 enables creation and parsing of Modified EUI-64 format interface identifiers, as described in RFC 4291, Section 2.5.1. MIT Licensed.

Documentation

Overview

Package eui64 enables creation and parsing of Modified EUI-64 format interface identifiers, as described in RFC 4291, Section 2.5.1.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseIP

func ParseIP(ip net.IP) (net.IP, net.HardwareAddr, error)

ParseIP parses an input IPv6 address to retrieve its IPv6 address prefix and EUI-48 or EUI-64 MAC address. ip must be an IPv6 address or an error is returned.

Example

ExampleParseIP demonstrates usage of ParseIP. This example parses an input IPv6 address into a IPv6 prefix and a MAC address.

// Example data taken from:
// http://packetlife.net/blog/2008/aug/4/eui-64-ipv6/
ip := net.ParseIP("fe80::212:7fff:feeb:6b40")

// Retrieve IPv6 prefix and MAC address from IPv6 address
prefix, mac, err := ParseIP(ip)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("    ip: %s\nprefix: %s\n   mac: %s", ip, prefix, mac)
Output:

    ip: fe80::212:7fff:feeb:6b40
prefix: fe80::
   mac: 00:12:7f:eb:6b:40

func ParseMAC

func ParseMAC(prefix net.IP, mac net.HardwareAddr) (net.IP, error)

ParseMAC parses an input IPv6 address prefix and EUI-48 or EUI-64 MAC address to retrieve an IPv6 address in EUI-64 modified form, with the designated prefix.

An error is returned if prefix is not an IPv6 address with only the first 64 bits or less set, or mac is not in EUI-48 or EUI-64 form.

Example

ExampleParseMAC demonstrates usage of ParseMAC. This example parses an input IPv6 address into a IPv6 prefix and a MAC address.

// Example data taken from:
// http://packetlife.net/blog/2008/aug/4/eui-64-ipv6/
prefix := net.ParseIP("fe80::")
mac, err := net.ParseMAC("00:12:7f:eb:6b:40")
if err != nil {
	log.Fatal(err)
}

// Retrieve IPv6 address from IPv6 prefix and MAC address
ip, err := ParseMAC(prefix, mac)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("prefix: %s\n   mac: %s\n    ip: %s", prefix, mac, ip)
Output:

prefix: fe80::
   mac: 00:12:7f:eb:6b:40
    ip: fe80::212:7fff:feeb:6b40

Types

This section is empty.

Directories

Path Synopsis
cmd
eui64
Command eui64 provides a simple utility to convert an IPv6 address to an IPv6 prefix and MAC address, or to convert an IPv6 prefix and MAC address to an IPv6 address.
Command eui64 provides a simple utility to convert an IPv6 address to an IPv6 prefix and MAC address, or to convert an IPv6 prefix and MAC address to an IPv6 address.

Jump to

Keyboard shortcuts

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