summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-13 23:35:12 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-13 23:35:12 +0900
commitcc7ff372950afdcc1c9dbf39dcd13a15830410e2 (patch)
tree71dfb41d3d6b3d8524f44a93fd3bf9d0df74e571 /table
parent529bec9f5c907bb9b93c6e5c7287b6985ff1ee03 (diff)
table: simplify path's MarshalJSON()
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/path.go13
1 files changed, 1 insertions, 12 deletions
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),