forked from contiv/vpp
/
ipv4net_api.go
76 lines (60 loc) · 2.33 KB
/
ipv4net_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package ipv4net
import (
"fmt"
"net"
controller "github.com/contiv/vpp/plugins/controller/api"
)
/********************************* Plugin API *********************************/
// API defines methods provided by IPv4Net plugin for use by other plugins to query
// IPv4 network-related information.
// Apart from GetPodByIf, these methods should not be accessed from outside of the
// main event loop!
type API interface {
// GetIfName looks up logical interface name that corresponds to the interface
// associated with the given pod.
GetIfName(podNamespace string, podName string) (name string, exists bool)
// GetPodByIf looks up podName and podNamespace that is associated with logical interface name.
// The method can be called from outside of the main event loop.
GetPodByIf(ifname string) (podNamespace string, podName string, exists bool)
// GetNodeIP returns the IP+network address of this node.
GetNodeIP() (ip net.IP, network *net.IPNet)
// GetHostIPs returns all IP addresses of this node present in the host network namespace (Linux).
GetHostIPs() []net.IP
// GetHostInterconnectIfName returns the name of the TAP/AF_PACKET interface
// interconnecting VPP with the host stack.
GetHostInterconnectIfName() string
// GetVxlanBVIIfName returns the name of an BVI interface facing towards VXLAN tunnels to other hosts.
// Returns an empty string if VXLAN is not used (in L2 interconnect mode).
GetVxlanBVIIfName() string
}
/*************************** Node IPv4 Change Event ***************************/
// NodeIPv4Change is triggered when DHCP-assigned IPv4 address of the node changes.
type NodeIPv4Change struct {
NodeIP net.IP
NodeIPNet *net.IPNet
DefaultGw net.IP
}
// GetName returns name of the NodeIPv4Change event.
func (ev *NodeIPv4Change) GetName() string {
return "Node IP(v4) Change"
}
// String describes NodeIPv4Change event.
func (ev *NodeIPv4Change) String() string {
return fmt.Sprintf("%s\n"+
"* IP: %s\n"+
"* IP-net: %s\n"+
"* GW: %s",
ev.GetName(), ev.NodeIP.String(), ev.NodeIPNet.String(), ev.DefaultGw.String())
}
// Method is UpstreamResync.
func (ev *NodeIPv4Change) Method() controller.EventMethodType {
return controller.UpstreamResync
}
// IsBlocking returns false.
func (ev *NodeIPv4Change) IsBlocking() bool {
return false
}
// Done is NOOP.
func (ev *NodeIPv4Change) Done(error) {
return
}