diff options
Diffstat (limited to 'table/adj.go')
-rw-r--r-- | table/adj.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/table/adj.go b/table/adj.go index b38e02b8..ea7b4151 100644 --- a/table/adj.go +++ b/table/adj.go @@ -16,6 +16,7 @@ package table import ( + "fmt" "github.com/osrg/gobgp/packet/bgp" ) @@ -188,3 +189,16 @@ func (adj *AdjRib) Select(family bgp.RouteFamily, accepted bool, option ...Table option = append(option, TableSelectOption{adj: true}) return tbl.Select(option...) } + +func (adj *AdjRib) TableInfo(family bgp.RouteFamily) (*TableInfo, error) { + if _, ok := adj.table[family]; !ok { + return nil, fmt.Errorf("%s unsupported") + } + c := adj.Count([]bgp.RouteFamily{family}) + a := adj.Accepted([]bgp.RouteFamily{family}) + return &TableInfo{ + NumDestination: c, + NumPath: c, + NumAccepted: a, + }, nil +} |