Documentation ¶
Index ¶
- func GarbageCollect(adapter, address string) (found bool, err error)
- func GenerateMac() (mac string)
- func GetDefaultGatewayInterface() (*net.Interface, error)
- func GetFullMask(address string) (string, error)
- func GetIPs(vip string) []string
- func IsIP(address string) bool
- func IsIPv4(address string) bool
- func IsIPv6(address string) bool
- func ListRoutes(table, protocol int) ([]netlink.Route, error)
- func ListRoutesByDst(table int, dst *net.IPNet) ([]netlink.Route, error)
- func LookupHost(dnsName, dnsMode string) ([]string, error)
- func MonitorDefaultInterface(ctx context.Context, defaultIF *net.Interface) error
- type DHCPClient
- type Network
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GarbageCollect ¶
func GenerateMac ¶
func GenerateMac() (mac string)
func GetDefaultGatewayInterface ¶
GetDefaultGatewayInterface return default gateway interface link
func GetFullMask ¶
GetFullMask returns /32 for an IPv4 address and /128 for an IPv6 address
func ListRoutes ¶
ListRoutes returns all routes from selected table with selected protocol
func ListRoutesByDst ¶
ListRoutesByDst returns all routes from selected table with selected destination IP
func LookupHost ¶
LookupHost resolves dnsName and return an IP or an error
Types ¶
type DHCPClient ¶
type DHCPClient struct {
// contains filtered or unexported fields
}
DHCPClient is responsible for maintaining ipv4 lease for one specified interface
func NewDHCPClient ¶
func NewDHCPClient(iface *net.Interface, initRebootFlag bool, requestedIP string) *DHCPClient
NewDHCPClient returns a new DHCP Client.
func (*DHCPClient) ErrorChannel ¶
func (c *DHCPClient) ErrorChannel() chan error
Gets the ErrorChannel for consumption
func (*DHCPClient) IPChannel ¶
func (c *DHCPClient) IPChannel() chan string
Gets the IPChannel for consumption
func (*DHCPClient) Start ¶
func (c *DHCPClient) Start()
Start state-transition process of dhcp client
-------- -------
| | +-------------------------->| |<-------------------+ | INIT- | | +-------------------->| INIT | | | REBOOT |DHCPNAK/ +---------->| |<---+ | | |Restart| | ------- | |
-------- | DHCPNAK/ | | | | Discard offer | -/Send DHCPDISCOVER |
-/Send DHCPREQUEST | | |
| | | DHCPACK v | | ----------- | (not accept.)/ ----------- | |
| | | Send DHCPDECLINE | | | | REBOOTING | | | | SELECTING |<----+ | | | | / | | |DHCPOFFER/ |
----------- | / ----------- | |Collect | | | / | | | replies |
DHCPACK/ | / +----------------+ +-------+ | Record lease, set| | v Select offer/ | timers T1, T2 ------------ send DHCPREQUEST | |
| +----->| | DHCPNAK, Lease expired/ | | | | REQUESTING | Halt network | DHCPOFFER/ | | | | Discard ------------ | | | | | | ----------- | | +--------+ DHCPACK/ | | | | Record lease, set -----| REBINDING | | | timers T1, T2 / | | | | | DHCPACK/ ----------- | | v Record lease, set ^ | +----------------> ------- /timers T1,T2 | | +----->| |<---+ | | | | BOUND |<---+ | | DHCPOFFER, DHCPACK, | | | T2 expires/ DHCPNAK/ DHCPNAK/Discard ------- | Broadcast Halt network | | | | DHCPREQUEST | +-------+ | DHCPACK/ | | T1 expires/ Record lease, set | | Send DHCPREQUEST timers T1, T2 | | to leasing server | | | | ---------- | | | | |------------+ | +->| RENEWING | | | |----------------------------+ ---------- Figure: State-transition diagram for DHCP clients
func (*DHCPClient) Stop ¶
func (c *DHCPClient) Stop()
Stop state-transition process and close dhcp client
func (*DHCPClient) WithHostName ¶
func (c *DHCPClient) WithHostName(hostname string) *DHCPClient
type Network ¶
type Network interface { AddIP() error AddRoute() error DeleteIP() error DeleteRoute() error UpdateRoutes() (bool, error) IsSet() (bool, error) IP() string PrepareRoute() *netlink.Route SetIP(ip string) error Interface() string IsDADFAIL() bool IsDNS() bool IsDDNS() bool DDNSHostName() string DNSName() string }
Network is an interface that enable managing operations for a given IP