network

package
v28.0.0-rc.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DNSRespAddr = "10.11.12.13"

Variables

This section is empty.

Functions

func CollectBcastARPs

func CollectBcastARPs(t *testing.T, ifname string) (stop func() []TimestampedPkt)

CollectBcastARPs collects broadcast ARPs from interface ifname. It returns a stop function, to stop collection and return a slice of collected packets (with timestamps added when they were received in userspace).

func CollectICMP6

func CollectICMP6(t *testing.T, ifname string) (stop func() []TimestampedPkt)

CollectICMP6 collects ICMP6 packets sent to the all nodes address. It returns a stop function, to stop collection and return a slice of collected packets (with timestamps added when they were received in userspace).

func Create

func Create(ctx context.Context, client client.APIClient, name string, ops ...func(*network.CreateOptions)) (string, error)

Create creates a network with the specified options

func CreateNoError

func CreateNoError(ctx context.Context, t *testing.T, client client.APIClient, name string, ops ...func(*network.CreateOptions)) string

CreateNoError creates a network with the specified options and verifies there were no errors

func GenResolvConf

func GenResolvConf(addr string) string

GenResolvConf generates a resolv.conf that only contains a single nameserver line, with address addr, and returns the file content.

func IsRemoved

func IsRemoved(ctx context.Context, client client.NetworkAPIClient, networkID string) func(log poll.LogT) poll.Result

IsRemoved verifies the network is removed.

func RemoveNoError

func RemoveNoError(ctx context.Context, t *testing.T, apiClient client.APIClient, name string)

func StartDaftDNS

func StartDaftDNS(t *testing.T, addr string)

StartDaftDNS starts and returns a really, really daft DNS server that only responds to type-A requests, and always with address dnsRespAddr. The DNS server will be stopped automatically by a t.Cleanup().

func UnpackUnsolARP

func UnpackUnsolARP(pkt TimestampedPkt) (sh net.HardwareAddr, sp netip.Addr, err error)

UnpackUnsolARP checks the packet is a valid Ethernet unsolicited/broadcast ARP request packet. It returns sender hardware and protocol addresses, and true if it is - else, an error.

func UnpackUnsolNA

func UnpackUnsolNA(pkt TimestampedPkt) (th net.HardwareAddr, tp netip.Addr, err error)

UnpackUnsolNA returns the hardware (MAC) and protocol (IP) addresses from the packet, if it is an unsolicited Neighbour Advertisement message with a link address option. Otherwise, it returns an error.

func WithAttachable

func WithAttachable() func(*network.CreateOptions)

WithAttachable sets Attachable flag on the create network request

func WithDriver

func WithDriver(driver string) func(*network.CreateOptions)

WithDriver sets the driver of the network

func WithIPAM

func WithIPAM(subnet, gateway string) func(*network.CreateOptions)

WithIPAM adds an IPAM with the specified Subnet and Gateway to the network

func WithIPAMRange

func WithIPAMRange(subnet, iprange, gateway string) func(*network.CreateOptions)

WithIPAM adds an IPAM with the specified Subnet, IPRange and Gateway to the network

func WithIPv4

func WithIPv4(enable bool) func(*network.CreateOptions)

WithIPv4 enables/disables IPv4 on the network

func WithIPv4Disabled

func WithIPv4Disabled() func(*network.CreateOptions)

WithIPv4Disabled makes sure IPv4 is disabled on the network.

func WithIPv6

func WithIPv6() func(*network.CreateOptions)

WithIPv6 Enables IPv6 on the network

func WithIPv6Disabled

func WithIPv6Disabled() func(*network.CreateOptions)

WithIPv6Disabled makes sure IPv6 is disabled on the network.

func WithIPvlan

func WithIPvlan(parent, mode string) func(*network.CreateOptions)

WithIPvlan sets the network as ipvlan with the specified parent and mode

func WithInternal

func WithInternal() func(*network.CreateOptions)

WithInternal enables Internal flag on the create network request

func WithMacvlan

func WithMacvlan(parent string) func(*network.CreateOptions)

WithMacvlan sets the network as macvlan with the specified parent

func WithMacvlanPassthru

func WithMacvlanPassthru(parent string) func(options *network.CreateOptions)

WithMacvlanPassthru sets the network as macvlan with the specified parent in passthru mode

func WithOption

func WithOption(key, value string) func(*network.CreateOptions)

WithOption adds the specified key/value pair to network's options

Types

type TimestampedPkt

type TimestampedPkt struct {
	ReceivedAt time.Time
	Data       []byte
}

TimestampedPkt has a Data slice representing a packet, ReceivedAt is a timestamp set after the packet was received in user-space.

Jump to

Keyboard shortcuts

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