summaryrefslogtreecommitdiffhomepage
path: root/table/path.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-25 22:56:15 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-25 22:56:15 -0800
commitcf87cd2b465ca740a8c216131a44b5bda870a8d5 (patch)
tree218a93a93c2710ac008f28150eabd27a3338f603 /table/path.go
parent4490c9301e2b075994404ba93f7d68e4b283e837 (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>
Diffstat (limited to 'table/path.go')
-rw-r--r--table/path.go31
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),
})
}