diff options
author | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2016-08-20 19:15:53 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-08-25 15:53:14 +0900 |
commit | 3235c0618cfc320c0ad751d83d850ec714fa1c49 (patch) | |
tree | 9bbc51cdb4e549dcb0567248d16c99dffd74e68d /table/table.go | |
parent | b3c874da2581eb71d8c137d956e792565193ec0e (diff) |
api/cli: kill cmd package custom path/destination structs
reuse table package
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/table.go')
-rw-r--r-- | table/table.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/table/table.go b/table/table.go index bad0e824..f89e8dff 100644 --- a/table/table.go +++ b/table/table.go @@ -50,10 +50,14 @@ type Table struct { destinations map[string]*Destination } -func NewTable(rf bgp.RouteFamily) *Table { +func NewTable(rf bgp.RouteFamily, dsts ...*Destination) *Table { + destinations := make(map[string]*Destination) + for _, dst := range dsts { + destinations[dst.GetNlri().String()] = dst + } return &Table{ routeFamily: rf, - destinations: make(map[string]*Destination), + destinations: destinations, } } @@ -229,15 +233,11 @@ func (t *Table) GetSortedDestinations() []*Destination { results = append(results, v.(*Destination)) return false }) - case bgp.RF_FS_IPv4_UC, bgp.RF_FS_IPv6_UC, bgp.RF_FS_IPv4_VPN, bgp.RF_FS_IPv6_VPN, bgp.RF_FS_L2_VPN: - for _, dst := range t.GetDestinations() { - results = append(results, dst) - } - sort.Sort(destinations(results)) default: for _, dst := range t.GetDestinations() { results = append(results, dst) } + sort.Sort(destinations(results)) } return results } |