address

package
v0.9.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MPL-2.0 Imports: 15 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 DHCP4 added in v0.9.0

type DHCP4 struct {
	Offer       *dhcpv4.DHCPv4
	Ack         *dhcpv4.DHCPv4
	NetIf       *net.Interface
	DHCPOptions config.DHCPOptions
	Mtu         int
	RouteList   []config.Route
}

DHCP4 implements the Addressing interface.

func (*DHCP4) Address added in v0.9.0

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

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

func (*DHCP4) Discover added in v0.9.0

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

Discover handles the DHCP client exchange stores the DHCP Ack.

func (*DHCP4) Family added in v0.9.0

func (d *DHCP4) Family() int

Family qualifies the address as ipv4 or ipv6.

func (*DHCP4) Hostname added in v0.9.0

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

Hostname returns the hostname from the DHCP offer.

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

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

func (*DHCP4) MTU added in v0.9.0

func (d *DHCP4) MTU() uint32

MTU returs the MTU size from the DHCP offer.

func (*DHCP4) Mask added in v0.9.0

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

Mask returns the netmask from the DHCP offer.

func (*DHCP4) Name added in v0.9.0

func (d *DHCP4) Name() string

Name returns back the name of the address method.

func (*DHCP4) Resolvers added in v0.9.0

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

Resolvers returns the DNS resolvers from the DHCP offer.

func (*DHCP4) Routes added in v0.9.0

func (d *DHCP4) 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 (*DHCP4) Scope added in v0.9.0

func (d *DHCP4) Scope() uint8

Scope sets the address scope.

func (*DHCP4) TTL added in v0.9.0

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

TTL denotes how long a DHCP offer is valid for.

func (*DHCP4) Valid added in v0.9.0

func (d *DHCP4) Valid() bool

Valid denotes if this address method should be used.

type DHCP6 added in v0.9.0

type DHCP6 struct {
	Reply *dhcpv6.Message
	NetIf *net.Interface
	Mtu   int
}

DHCP6 implements the Addressing interface.

func (*DHCP6) Address added in v0.9.0

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

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

func (*DHCP6) Discover added in v0.9.0

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

Discover handles the DHCP client exchange stores the DHCP Ack.

func (*DHCP6) Family added in v0.9.0

func (d *DHCP6) Family() int

Family qualifies the address as ipv4 or ipv6.

func (*DHCP6) Hostname added in v0.9.0

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

Hostname returns the hostname from the DHCP offer.

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

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

func (*DHCP6) MTU added in v0.9.0

func (d *DHCP6) MTU() uint32

MTU returs the MTU size from the DHCP offer.

func (*DHCP6) Mask added in v0.9.0

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

Mask returns the netmask from the DHCP offer.

func (*DHCP6) Name added in v0.9.0

func (d *DHCP6) Name() string

Name returns back the name of the address method.

func (*DHCP6) Resolvers added in v0.9.0

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

Resolvers returns the DNS resolvers from the DHCP offer.

func (*DHCP6) Routes added in v0.9.0

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

Routes is not supported on IPv6.

func (*DHCP6) Scope added in v0.9.0

func (d *DHCP6) Scope() uint8

Scope sets the address scope.

func (*DHCP6) TTL added in v0.9.0

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

TTL denotes how long a DHCP offer is valid for.

func (*DHCP6) Valid added in v0.9.0

func (d *DHCP6) Valid() bool

Valid denotes if this address method should be used.

type Route

type Route struct {
	// Destination is the destination network this route provides.
	Destination *net.IPNet

	// Gateway is the router through which the destination may be reached.
	// This option is exclusive of Interface
	Gateway net.IP

	// Interface indicates the route is an interface route, and traffic destinted for the Gateway should be sent through the given network interface.
	// This option is exclusive of Gateway.
	Interface string

	// Metric indicates the "distance" to the destination through this route.
	// This is an integer which allows the control of priority in the case of multiple routes to the same destination.
	Metric uint32
}

Route is a representation of a network route.

type Static

type Static struct {
	CIDR        string
	Mtu         int
	FQDN        string
	RouteList   []config.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