-
Notifications
You must be signed in to change notification settings - Fork 114
/
bgpreflector_api.go
77 lines (63 loc) · 1.69 KB
/
bgpreflector_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
77
package bgpreflector
import (
"fmt"
"net"
controller "github.com/contiv/vpp/plugins/controller/api"
)
/*************************** BGP Route Update Event ***************************/
// BGPRouteUpdateType represents type of the BGP update.
type BGPRouteUpdateType int
const (
// RouteAdd represents addition of a new BGP route.
RouteAdd BGPRouteUpdateType = iota
// RouteDelete represents deletion of a BGP route.
RouteDelete
)
func (t BGPRouteUpdateType) String() string {
switch t {
case RouteAdd:
return "RouteAdd"
case RouteDelete:
return "RouteDelete"
default:
return fmt.Sprintf("%d", int(t))
}
}
// BGPRouteUpdate is triggered when a BGP route on the host changes.
type BGPRouteUpdate struct {
Type BGPRouteUpdateType
DstNetwork *net.IPNet
GwAddr net.IP
}
// GetName returns name of the BGPRouteUpdate event.
func (ev *BGPRouteUpdate) GetName() string {
return "BGP route Change"
}
// String describes BGPRouteUpdate event.
func (ev *BGPRouteUpdate) String() string {
return fmt.Sprintf("%s\n"+
"* Type: %s\n"+
"* DstNetwork: %s\n"+
"* GW: %s",
ev.GetName(), ev.Type.String(), ev.DstNetwork.String(), ev.GwAddr.String())
}
// Method is Update.
func (ev *BGPRouteUpdate) Method() controller.EventMethodType {
return controller.Update
}
// TransactionType is BestEffort.
func (ev *BGPRouteUpdate) TransactionType() controller.UpdateTransactionType {
return controller.BestEffort
}
// Direction is Forward.
func (ev *BGPRouteUpdate) Direction() controller.UpdateDirectionType {
return controller.Forward
}
// IsBlocking returns false.
func (ev *BGPRouteUpdate) IsBlocking() bool {
return false
}
// Done is NOOP.
func (ev *BGPRouteUpdate) Done(error) {
return
}