summaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/pkg/apiutil/util.go7
-rw-r--r--internal/pkg/config/util.go19
2 files changed, 20 insertions, 6 deletions
diff --git a/internal/pkg/apiutil/util.go b/internal/pkg/apiutil/util.go
index 4c18b752..7c4aabc3 100644
--- a/internal/pkg/apiutil/util.go
+++ b/internal/pkg/apiutil/util.go
@@ -20,6 +20,7 @@ import (
"net"
"time"
+ "github.com/golang/protobuf/ptypes"
api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/pkg/packet/bgp"
)
@@ -49,9 +50,10 @@ func NewDestination(dst *api.Destination) *Destination {
for _, p := range dst.Paths {
nlri, _ := GetNativeNlri(p)
attrs, _ := GetNativePathAttributes(p)
+ t, _ := ptypes.Timestamp(p.Age)
l = append(l, &Path{
Nlri: nlri,
- Age: p.Age,
+ Age: t.Unix(),
Best: p.Best,
Attrs: attrs,
Stale: p.Stale,
@@ -64,10 +66,11 @@ func NewDestination(dst *api.Destination) *Destination {
}
func NewPath(nlri bgp.AddrPrefixInterface, isWithdraw bool, attrs []bgp.PathAttributeInterface, age time.Time) *api.Path {
+ t, _ := ptypes.TimestampProto(age)
return &api.Path{
AnyNlri: MarshalNLRI(nlri),
AnyPattrs: MarshalPathAttributes(attrs),
- Age: age.Unix(),
+ Age: t,
IsWithdraw: isWithdraw,
Family: ToApiFamily(nlri.AFI(), nlri.SAFI()),
Identifier: nlri.PathIdentifier(),
diff --git a/internal/pkg/config/util.go b/internal/pkg/config/util.go
index 70fc8cd9..1a65e2ed 100644
--- a/internal/pkg/config/util.go
+++ b/internal/pkg/config/util.go
@@ -22,7 +22,10 @@ import (
"regexp"
"strconv"
"strings"
+ "time"
+ "github.com/golang/protobuf/ptypes"
+ "github.com/golang/protobuf/ptypes/timestamp"
api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/internal/pkg/apiutil"
"github.com/osrg/gobgp/pkg/packet/bgp"
@@ -408,6 +411,14 @@ func newAfiSafiFromConfigStruct(c *AfiSafi) *api.AfiSafi {
}
}
+func ProtoTimestamp(secs int64) *timestamp.Timestamp {
+ if secs == 0 {
+ return nil
+ }
+ t, _ := ptypes.TimestampProto(time.Unix(secs, 0))
+ return t
+}
+
func NewPeerFromConfigStruct(pconf *Neighbor) *api.Peer {
afiSafis := make([]*api.AfiSafi, 0, len(pconf.AfiSafis))
for _, f := range pconf.AfiSafis {
@@ -502,8 +513,8 @@ func NewPeerFromConfigStruct(pconf *Neighbor) *api.Peer {
State: &api.TimersState{
KeepaliveInterval: uint64(timer.State.KeepaliveInterval),
NegotiatedHoldTime: uint64(timer.State.NegotiatedHoldTime),
- Uptime: uint64(timer.State.Uptime),
- Downtime: uint64(timer.State.Downtime),
+ Uptime: ProtoTimestamp(timer.State.Uptime),
+ Downtime: ProtoTimestamp(timer.State.Downtime),
},
},
RouteReflector: &api.RouteReflector{
@@ -568,8 +579,8 @@ func NewPeerGroupFromConfigStruct(pconf *PeerGroup) *api.PeerGroup {
State: &api.TimersState{
KeepaliveInterval: uint64(timer.State.KeepaliveInterval),
NegotiatedHoldTime: uint64(timer.State.NegotiatedHoldTime),
- Uptime: uint64(timer.State.Uptime),
- Downtime: uint64(timer.State.Downtime),
+ Uptime: ProtoTimestamp(timer.State.Uptime),
+ Downtime: ProtoTimestamp(timer.State.Downtime),
},
},
RouteReflector: &api.RouteReflector{