summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
Diffstat (limited to 'table')
-rw-r--r--table/destination.go1
-rw-r--r--table/table.go16
-rw-r--r--table/table_manager.go4
-rw-r--r--table/table_test.go35
-rw-r--r--table/temporary_structs.go10
5 files changed, 16 insertions, 50 deletions
diff --git a/table/destination.go b/table/destination.go
index 6bee6df3..16a71f54 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -62,7 +62,6 @@ type Destination interface {
type DestinationDefault struct {
ROUTE_FAMILY RouteFamily
- coreService CoreService
nlri bgp.AddrPrefixInterface
knownPathList []Path
withdrawList []Path
diff --git a/table/table.go b/table/table.go
index c3339a9f..87c92ddd 100644
--- a/table/table.go
+++ b/table/table.go
@@ -35,15 +35,13 @@ type Table interface {
type TableDefault struct {
ROUTE_FAMILY RouteFamily
destinations map[string]Destination
- coreService *CoreService
//need SignalBus
}
-func NewTableDefault(scope_id int, coreService *CoreService) *TableDefault {
+func NewTableDefault(scope_id int) *TableDefault {
table := &TableDefault{}
table.ROUTE_FAMILY = RF_IPv4_UC
table.destinations = make(map[string]Destination)
- table.coreService = coreService
return table
}
@@ -52,10 +50,6 @@ func (td *TableDefault) getRoutefamily() RouteFamily {
return td.ROUTE_FAMILY
}
-func (td *TableDefault) getCoreService() *CoreService {
- return td.coreService
-}
-
//Creates destination
//Implements interface
func (td *TableDefault) createDest(nlri *bgp.NLRInfo) Destination {
@@ -193,9 +187,9 @@ type IPv4Table struct {
//need structure
}
-func NewIPv4Table(scope_id int, coreService *CoreService) *IPv4Table {
+func NewIPv4Table(scope_id int) *IPv4Table {
ipv4Table := &IPv4Table{}
- ipv4Table.TableDefault = NewTableDefault(scope_id, coreService)
+ ipv4Table.TableDefault = NewTableDefault(scope_id)
ipv4Table.TableDefault.ROUTE_FAMILY = RF_IPv4_UC
//need Processing
return ipv4Table
@@ -227,9 +221,9 @@ type IPv6Table struct {
//need structure
}
-func NewIPv6Table(scope_id int, coreService *CoreService) *IPv6Table {
+func NewIPv6Table(scope_id int) *IPv6Table {
ipv6Table := &IPv6Table{}
- ipv6Table.TableDefault = NewTableDefault(scope_id, coreService)
+ ipv6Table.TableDefault = NewTableDefault(scope_id)
ipv6Table.TableDefault.ROUTE_FAMILY = RF_IPv6_UC
//need Processing
return ipv6Table
diff --git a/table/table_manager.go b/table/table_manager.go
index 081b19c4..63c4a60c 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -148,8 +148,8 @@ type ProcessMessage struct {
func NewTableManager() *TableManager {
t := &TableManager{}
t.Tables = make(map[RouteFamily]Table)
- t.Tables[RF_IPv4_UC] = NewIPv4Table(0, nil)
- t.Tables[RF_IPv6_UC] = NewIPv6Table(0, nil)
+ t.Tables[RF_IPv4_UC] = NewIPv4Table(0)
+ t.Tables[RF_IPv6_UC] = NewIPv6Table(0)
// initialize prefix counter
t.Counter = make(map[PeerCounterName]int)
t.Counter[RECV_PREFIXES] = 0
diff --git a/table/table_test.go b/table/table_test.go
index 715177dc..35eddea9 100644
--- a/table/table_test.go
+++ b/table/table_test.go
@@ -16,24 +16,20 @@
package table
import (
- //"fmt"
"github.com/osrg/gobgp/packet"
"github.com/stretchr/testify/assert"
- //"net"
"testing"
)
func TestTableCreateDestDefault(t *testing.T) {
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- td := NewTableDefault(0, coreService)
+ td := NewTableDefault(0)
nlri := bgp.NewNLRInfo(24, "13.2.3.1")
cd := td.createDest(nlri)
assert.Nil(t, cd)
}
func TestTableTableKeyDefault(t *testing.T) {
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- td := NewTableDefault(0, coreService)
+ td := NewTableDefault(0)
nlri := bgp.NewNLRInfo(24, "13.2.3.1")
tk := td.tableKey(nlri)
assert.Nil(t, tk)
@@ -43,8 +39,7 @@ func TestTableInsertSentRoute(t *testing.T) {
peerT := TableCreatePeer()
msgT := TableCreateMSG(peerT)
pathT := TableCreatePath(msgT)
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- ipv4t := NewIPv4Table(0, coreService)
+ ipv4t := NewIPv4Table(0)
for _, path := range pathT {
tableKey := ipv4t.tableKey(path.getNlri())
dest := ipv4t.createDest(path.getNlri())
@@ -62,8 +57,7 @@ func TestTableCleanupPathsForPeer(t *testing.T) {
peerT := TableCreatePeer()
msgT := TableCreateMSG(peerT)
pathT := TableCreatePath(msgT)
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- ipv4t := NewIPv4Table(0, coreService)
+ ipv4t := NewIPv4Table(0)
for _, path := range pathT {
tableKey := ipv4t.tableKey(path.getNlri())
dest := ipv4t.createDest(path.getNlri())
@@ -82,8 +76,7 @@ func TestTableDeleteDestByNlri(t *testing.T) {
peerT := TableCreatePeer()
msgT := TableCreateMSG(peerT)
pathT := TableCreatePath(msgT)
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- ipv4t := NewIPv4Table(0, coreService)
+ ipv4t := NewIPv4Table(0)
for _, path := range pathT {
tableKey := ipv4t.tableKey(path.getNlri())
dest := ipv4t.createDest(path.getNlri())
@@ -99,8 +92,7 @@ func TestTableDeleteDest(t *testing.T) {
peerT := TableCreatePeer()
msgT := TableCreateMSG(peerT)
pathT := TableCreatePath(msgT)
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- ipv4t := NewIPv4Table(0, coreService)
+ ipv4t := NewIPv4Table(0)
for _, path := range pathT {
tableKey := ipv4t.tableKey(path.getNlri())
dest := ipv4t.createDest(path.getNlri())
@@ -115,24 +107,16 @@ func TestTableDeleteDest(t *testing.T) {
}
func TestTableGetRouteFamily(t *testing.T) {
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- ipv4t := NewIPv4Table(0, coreService)
+ ipv4t := NewIPv4Table(0)
rf := ipv4t.getRoutefamily()
assert.Equal(t, rf, RF_IPv4_UC)
}
-func TestTableGetCoreService(t *testing.T) {
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- ipv4t := NewIPv4Table(0, coreService)
- cs := ipv4t.getCoreService()
- assert.Equal(t, cs, coreService)
-}
func TestTableSetDestinations(t *testing.T) {
peerT := TableCreatePeer()
msgT := TableCreateMSG(peerT)
pathT := TableCreatePath(msgT)
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- ipv4t := NewIPv4Table(0, coreService)
+ ipv4t := NewIPv4Table(0)
destinations := make(map[string]Destination)
for _, path := range pathT {
tableKey := ipv4t.tableKey(path.getNlri())
@@ -147,8 +131,7 @@ func TestTableGetDestinations(t *testing.T) {
peerT := DestCreatePeer()
msgT := DestCreateMSG(peerT)
pathT := DestCreatePath(msgT)
- coreService := &CoreService{CommonConf: &Commons{}, NeighborsConf: &Neighbors{}}
- ipv4t := NewIPv4Table(0, coreService)
+ ipv4t := NewIPv4Table(0)
destinations := make(map[string]Destination)
for _, path := range pathT {
tableKey := ipv4t.tableKey(path.getNlri())
diff --git a/table/temporary_structs.go b/table/temporary_structs.go
index 6350d2e7..a561aa72 100644
--- a/table/temporary_structs.go
+++ b/table/temporary_structs.go
@@ -6,16 +6,6 @@ import (
"net"
)
-type CoreService struct {
- CommonConf *Commons
- NeighborsConf *Neighbors
-}
-type Neighbors struct {
- //need to define a structure
-}
-type Commons struct {
- //need to define a structure
-}
type Peer struct {
//need to define a structure
RemoteAs uint32