rfc4193

package module
v0.0.0-...-737973e Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 8 Imported by: 0

README

rfc4193 builds.sr.ht status GoDoc Go Report Card

Package rfc4193 implements Unique Local IPv6 Unicast Address prefix generation, as described in RFC 4193. MIT Licensed.

Documentation

Overview

Package rfc4193 implements Unique Local IPv6 Unicast Address prefix generation, as described in RFC 4193.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prefix

type Prefix struct {
	// Local indicates if the prefix is locally assigned.
	Local bool

	// GlobalID stores an identifier for a globally unique prefix.
	GlobalID [5]byte

	// SubnetID identifies an individual /64 subnet within a Prefix.
	SubnetID uint16
	// contains filtered or unexported fields
}

A Prefix represents a Local IPv6 Unicast Address prefix, as described in RFC 4193, section 3.1.

func Generate

func Generate(mac net.HardwareAddr) (*Prefix, error)

Generate produces a /48 Prefix by using mac (typically the MAC address of a network interface) as a seed. It uses the algorithm specified in RFC 4193, section 3.2.2.

mac must either be nil or a 6-byte EUI-48 format MAC address. If mac is nil, cryptographically-secure random bytes will be used as a seed.

func Parse

func Parse(s string) (*Prefix, error)

Parse parses a /48 or /64 Prefix from a CIDR notation string. If s is not a /48 or /64 IPv6 Unique Local Address prefix, it returns an error.

func (*Prefix) IPNet

func (p *Prefix) IPNet() *net.IPNet

IPNet produces a *net.IPNet prefix value from a Prefix.

func (*Prefix) String

func (p *Prefix) String() string

String returns the CIDR notation string for a Prefix.

func (*Prefix) Subnet

func (p *Prefix) Subnet(id uint16) *Prefix

Subnet produces a /64 Prefix with the specified subnet ID.

If p is a /48 Prefix, the new /64 Prefix will be a child of that parent /48 Prefix.

If p is a /64 Prefix (typically produced through a previous call to Subnet), the new /64 Prefix will be a sibling /64 Prefix of the source /64 Prefix.

Directories

Path Synopsis
cmd
rfc4193
Command rfc4193 generates a Unique Local IPv6 Unicast Address prefix, as described in RFC4193.
Command rfc4193 generates a Unique Local IPv6 Unicast Address prefix, as described in RFC4193.

Jump to

Keyboard shortcuts

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