netboot

package
v0.0.0-...-bbc9ce3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

This file implements the Zircon loglistener protocol.

Package netboot implements the Zircon netboot protocol.

Index

Constants

View Source
const NodenameWildcard = "*"

NodenameWildcard is the wildcard for discovering all nodes.

Variables

This section is empty.

Functions

func UDPConnWithReusablePort

func UDPConnWithReusablePort(port int, zone string, reusable bool) (*net.UDPConn, error)

UDPConnWithReusablePort creates a new connection that binds to the specified port while allowing it to be reused.

Types

type Advertisement struct {
	Nodename          string
	BootloaderVersion string
}

Advertisement represents the information in an advertisement sent from a device.

type Client

type Client struct {
	ServerPort int
	AdvertPort int
	Cookie     uint32
	Timeout    time.Duration
	Wait       bool
}

Client implements the netboot protocol.

func NewClient

func NewClient(timeout time.Duration) *Client

NewClient creates a new Client instance.

func (*Client) Beacon

func (n *Client) Beacon() (*net.UDPAddr, error)

Beacon receives the beacon packet, returning the address of the sender.

func (*Client) BeaconForDevice

func (n *Client) BeaconForDevice(ctx context.Context, nodename string, ipv6Addr *net.UDPAddr, reusable bool) (*net.UDPAddr, *Advertisement, func(), error)

BeaconForDevice receives the beacon packet for a particular device with the given nodename or ipv6 address.

func (*Client) BeaconOnInterface

func (n *Client) BeaconOnInterface(networkInterface string) (*net.UDPAddr, error)

BeaconOnInterface receives the beacon packet on a particular interface.

func (*Client) Boot

func (n *Client) Boot(addr *net.UDPAddr) error

Boot sends a boot packet to the address.

func (*Client) Discover

func (n *Client) Discover(ctx context.Context, nodename string) (*net.UDPAddr, error)

Discover returns the netsvc address of nodename.

func (*Client) DiscoverAll

func (n *Client) DiscoverAll(ctx context.Context) ([]*Target, error)

DiscoverAll returns all netsvc addresses on the local network.

If no devices are found, returns a nil array.

func (*Client) Reboot

func (n *Client) Reboot(addr *net.UDPAddr) error

Reboot sends a reboot packet the address.

func (*Client) StartDiscover

func (n *Client) StartDiscover(ctx context.Context, t chan<- *Target, nodename string) (func() error, error)

StartDiscover takes a channel and returns every Target as it is found. Returns a cleanup function for closing the discovery connection or an error if there is a failure.

Errors within discovery will be propagated up the channel via the Target.Error field.

The Timeout field is not used with this function, and as such it is the caller's responsibility to handle timeouts when using this function.

Example:

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
cleanup, err := c.StartDiscover(ctx, t, true)
if err != nil {
	return err
}
defer cleanup()
for {
	select {
		case target := <-t:
			// Do something with the target.
		case <-ctx.Done():
			// Do something now that the parent context is
			// completed.
	}
}

type LogListener

type LogListener struct {
	// contains filtered or unexported fields
}

LogListener is Zircon's debug log listener.

func NewLogListener

func NewLogListener(nodename string) (*LogListener, error)

NewLogListener creates and connects a new instance of debug log listener.

func (*LogListener) Close

func (l *LogListener) Close() error

Close shuts down the log listener underlying connection.

func (*LogListener) Listen

func (l *LogListener) Listen() (string, error)

Listen receive a single debug log packet.

type Target

type Target struct {
	// Nodename is target's nodename: thumb-set-human-neon is an example.
	// This is derived from the NIC mac address.
	Nodename string

	// TargetAddress is the address of the target from the host.
	TargetAddress net.IP

	// HostAddress is the "local" address, i.e. the one to which the target
	// is responding. This would be the address the target would send to in
	// order to communicate with the host.
	HostAddress net.IP

	// Interface is the index of the "local" interface connecting to
	// the Fuchsia device. nil if this does not apply.
	Interface *net.Interface

	// Error is the error associated with the device when returned via
	// the StartDiscover function.
	Error error
}

Target defines a netboot protocol target, which includes information about how to find said target on the network: the target's nodename, its address, the address from the target back to the host, and the interface used to connect from the host to the target.

Jump to

Keyboard shortcuts

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