address

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addressing

type Addressing interface {
	Address() *net.IPNet
	Discover(context.Context, *net.Interface) error
	Family() int
	Hostname() string
	Link() *net.Interface
	MTU() uint32
	Mask() net.IPMask
	Name() string
	Resolvers() []net.IP
	Routes() []*Route
	Scope() uint8
	TTL() time.Duration
	Valid() bool
}

Addressing provides an interface for abstracting the underlying network addressing configuration. Currently dhcp(v4) and static methods are supported.

type DHCP

type DHCP struct {
	Ack   *dhcpv4.DHCPv4
	NetIf *net.Interface
}

DHCP implements the Addressing interface

func (*DHCP) Address

func (d *DHCP) Address() *net.IPNet

Address returns back the IP address from the received DHCP offer.

func (*DHCP) Discover

func (d *DHCP) Discover(ctx context.Context, link *net.Interface) error

Discover handles the DHCP client exchange stores the DHCP Ack.

func (*DHCP) Family

func (d *DHCP) Family() int

Family qualifies the address as ipv4 or ipv6

func (*DHCP) Hostname

func (d *DHCP) Hostname() (hostname string)

Hostname returns the hostname from the DHCP offer.

func (d *DHCP) Link() *net.Interface

Link returns the underlying net.Interface that this address method is configured for

func (*DHCP) MTU

func (d *DHCP) MTU() uint32

MTU returs the MTU size from the DHCP offer.

func (*DHCP) Mask

func (d *DHCP) Mask() net.IPMask

Mask returns the netmask from the DHCP offer.

func (*DHCP) Name

func (d *DHCP) Name() string

Name returns back the name of the address method.

func (*DHCP) Resolvers

func (d *DHCP) Resolvers() []net.IP

Resolvers returns the DNS resolvers from the DHCP offer.

func (*DHCP) Routes

func (d *DHCP) Routes() (routes []*Route)

Routes aggregates all Routers and ClasslessStaticRoutes retrieved from the DHCP offer. rfc3442:

If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.

func (*DHCP) Scope

func (d *DHCP) Scope() uint8

Scope sets the address scope

func (*DHCP) TTL

func (d *DHCP) TTL() time.Duration

TTL denotes how long a DHCP offer is valid for.

func (*DHCP) Valid

func (d *DHCP) Valid() bool

Valid denotes if this address method should be used.

type Route

type Route = dhcpv4.Route

Route is a representation of a network route

type Static

type Static struct {
	CIDR        string
	Mtu         int
	FQDN        string
	RouteList   []machine.Route
	NetIf       *net.Interface
	NameServers []net.IP
}

Static implements the Addressing interface

func (*Static) Address

func (s *Static) Address() *net.IPNet

Address returns the IP address

func (*Static) Discover

func (s *Static) Discover(ctx context.Context, link *net.Interface) error

Discover doesnt do anything in the static configuration since all the necessary configuration data is supplied via config.

func (*Static) Family

func (s *Static) Family() int

Family qualifies the address as ipv4 or ipv6

func (*Static) Hostname

func (s *Static) Hostname() string

Hostname returns the hostname

func (s Static) Link() *net.Interface

Link returns the underlying net.Interface that this address method is configured for

func (*Static) MTU

func (s *Static) MTU() uint32

MTU returns the specified MTU.

func (*Static) Mask

func (s *Static) Mask() net.IPMask

Mask returns the netmask.

func (*Static) Name

func (s *Static) Name() string

Name returns back the name of the address method.

func (*Static) Resolvers

func (s *Static) Resolvers() []net.IP

Resolvers returns the DNS resolvers

func (*Static) Routes

func (s *Static) Routes() (routes []*Route)

Routes aggregates the specified routes for a given device configuration TODO: do we need to be explicit on route vs gateway?

func (*Static) Scope

func (s *Static) Scope() uint8

Scope sets the address scope

func (*Static) TTL

func (s *Static) TTL() time.Duration

TTL returns the address lifetime. Since this is static, there is no TTL (0).

func (*Static) Valid

func (s *Static) Valid() bool

Valid denotes if this address method should be used.

Jump to

Keyboard shortcuts

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