diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-11-16 10:06:47 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-11-16 12:23:18 +0900 |
commit | c1bca2555919f9f2a7dd9d13dc3e14a4bf6a589a (patch) | |
tree | 3a19cc12f27f146df079e03a487acea492e8d595 /internal/pkg/apiutil/util.go | |
parent | 893dbd5c074c097f0c9921d3131a072011fb7e6a (diff) |
use google/protobuf/timestamp.proto
use google/protobuf/timestamp.proto instead of our own way to
represent time.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'internal/pkg/apiutil/util.go')
-rw-r--r-- | internal/pkg/apiutil/util.go | 7 |
1 files changed, 5 insertions, 2 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(), |