From cc7ff372950afdcc1c9dbf39dcd13a15830410e2 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 13 Jan 2015 23:35:12 +0900 Subject: table: simplify path's MarshalJSON() Signed-off-by: FUJITA Tomonori --- table/path.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'table/path.go') diff --git a/table/path.go b/table/path.go index f2926cf3..276555ee 100644 --- a/table/path.go +++ b/table/path.go @@ -78,24 +78,13 @@ func (pd *PathDefault) setBest(isBest bool) { } func (pd *PathDefault) MarshalJSON() ([]byte, error) { - var prefix net.IP - var prefixLen uint8 - switch nlri := pd.nlri.(type) { - case *bgp.NLRInfo: - prefix = nlri.Prefix - prefixLen = nlri.Length - case *bgp.IPv6AddrPrefix: - prefix = nlri.Prefix - prefixLen = nlri.Length - } - return json.Marshal(struct { Network string Nexthop string Attrs []bgp.PathAttributeInterface Best string }{ - Network: prefix.String() + "/" + fmt.Sprint(prefixLen), + Network: pd.getPrefix(), Nexthop: pd.nexthop.String(), Attrs: pd.getPathAttrs(), Best: fmt.Sprint(pd.isBest), -- cgit v1.2.3