summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
Diffstat (limited to 'table')
-rw-r--r--table/destination.go11
-rw-r--r--table/path.go15
2 files changed, 17 insertions, 9 deletions
diff --git a/table/destination.go b/table/destination.go
index 2954c699..f6ee4030 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -855,3 +855,14 @@ func (ipv6d *IPv6Destination) getPrefix() net.IP {
}
return ip
}
+
+func (ipv6d *IPv6Destination) MarshalJSON() ([]byte, error) {
+ prefix := ipv6d.getNlri().(*bgp.IPv6AddrPrefix).Prefix
+ return json.Marshal(struct {
+ Prefix string
+ Paths []Path
+ }{
+ Prefix: prefix.String(),
+ Paths: ipv6d.knownPathList,
+ })
+}
diff --git a/table/path.go b/table/path.go
index 80969ab1..2e8bd839 100644
--- a/table/path.go
+++ b/table/path.go
@@ -79,30 +79,27 @@ 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
- // }
-
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
+ Nexthop string
+ Attrs []bgp.PathAttributeInterface
//Metric string
//origin string
Best string
}{
Network: prefix.String() + "/" + fmt.Sprint(prefixLen),
- //Nexthop: pd.nexthop.String(),
+ Nexthop: pd.nexthop.String(),
//Metric: fmt.Sprint(med),
Attrs: pd.getPathAttrs(),
Best: fmt.Sprint(pd.isBest),