Documentation ¶
Overview ¶
Package net implements some network-related functions for recovery. These include enabling interfaces and acquiring addresses via DHCP, and downloading files.
Index ¶
- func AdjustDupDefaultRoutes(plat common.PlatInfoer, MetricForDuplicates uint64)
- func AssignIP(device string, addr net.IPNet)
- func EnableNetworkingAny() bool
- func EnableNetworkingSkipDIAG(diags []int, allowedPrefixes [][]byte) (success bool)
- func EnableNic(nic string) (success bool)
- func HasIpv4(netif *net.Interface) bool
- func WaitForIpv4(wait time.Duration, ifaces []nic.Nic) (success bool)
- func WanDevice(plat common.PlatInfoer) *nic.Nic
- type IPNet
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustDupDefaultRoutes ¶
func AdjustDupDefaultRoutes(plat common.PlatInfoer, MetricForDuplicates uint64)
Remove duplicate routes if MetricForDuplicates is 0, else give them different priority by changing the metric. (high metric -> low prio)
func AssignIP ¶
Assign the given IP to the given device. Call multiple times to assign multiple addresses.
func EnableNetworkingAny ¶
func EnableNetworkingAny() bool
Enable any network interface, even DIAG if not hidden
func EnableNetworkingSkipDIAG ¶
Enable any network interface except DIAG (only use if DIAG port(s) are not already hidden - if they are, usable ports will be skipped)
func WaitForIpv4 ¶
WaitForIpv4 waits until at least one of the given interfaces to gain an ipv4 address, or until the wait time has expired.
Types ¶
type IPNet ¶
IPNet is a wrapper around net.IPNet allowing us to extend the functionality.
func IPNetFromCIDR ¶
IPNetFromCIDR converts an address string in CIDR notation into an IPNet. If you use net.ParseCIDR directly, the returned IPNet contains the subnet and mask, not the ip and mask.
func IPNetsFromIface ¶
func (*IPNet) MarshalJSON ¶
func (*IPNet) UnmarshalJSON ¶
type Route ¶
type Route struct { Iface string `json:",omitempty"` Gw net.IP `json:",omitempty"` Proto int `json:",omitempty"` Metric uint64 `json:",omitempty"` Src net.IP `json:",omitempty"` Dest IPNet `json:",omitempty"` Scope netlink.Scope `json:",omitempty"` }
Route represents an IP route.
func GetRouteThroughIface ¶
GetRouteThroughIface gets a route to destip through iface.