diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 22:56:15 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 22:56:15 -0800 |
commit | cf87cd2b465ca740a8c216131a44b5bda870a8d5 (patch) | |
tree | 218a93a93c2710ac008f28150eabd27a3338f603 | |
parent | 4490c9301e2b075994404ba93f7d68e4b283e837 (diff) |
table: update path struct JSON format
Print all path attributes in a path.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | table/path.go | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/table/path.go b/table/path.go index 4d4e0c44..66b2dc4a 100644 --- a/table/path.go +++ b/table/path.go @@ -83,20 +83,11 @@ func (pd *PathDefault) setBest(isBest bool) { } func (pd *PathDefault) MarshalJSON() ([]byte, error) { - med := uint32(0) - _, attr := pd.GetPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC) - if attr != nil { - med = attr.(*bgp.PathAttributeMultiExitDisc).Value - } - - aslist := make([]uint32, 0) - _, attr = pd.GetPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) - if attr != nil { - for _, p := range attr.(*bgp.PathAttributeAsPath).Value { - path := p.(*bgp.As4PathParam) - aslist = append(aslist, path.AS...) - } - } + // med := uint32(0) + // _, attr := pd.GetPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC) + // if attr != nil { + // med = attr.(*bgp.PathAttributeMultiExitDisc).Value + // } var prefix net.IP var prefixLen uint8 @@ -108,16 +99,16 @@ func (pd *PathDefault) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Network string - Nexthop string - AsPath []uint32 - Metric string + //Nexthop string + Attrs []bgp.PathAttributeInterface + //Metric string //origin string Best string }{ Network: prefix.String() + "/" + fmt.Sprint(prefixLen), - Nexthop: pd.nexthop.String(), - Metric: fmt.Sprint(med), - AsPath: aslist, + //Nexthop: pd.nexthop.String(), + //Metric: fmt.Sprint(med), + Attrs: pd.GetPathAttrs(), Best: fmt.Sprint(pd.isBest), }) } |