From 46e596b7b4cfc9b8f5d68c05b37e9d13d6474acd Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Mon, 11 May 2020 22:37:41 +0200 Subject: [PATCH] Add functions to AdjRIBIn/AdjRIBOut for RIS The funtions RegisterWithOptions(), LPPM(), Get() and GetLonger() need to be exposed by AdjRIBIn/AdjRIBOut. This makes these RIBs usable in much the same way as LocRIB for the RIS. --- routingtable/adjRIBIn/adj_rib_in.go | 20 ++++++++++++++++++++ routingtable/adjRIBOut/adj_rib_out.go | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/routingtable/adjRIBIn/adj_rib_in.go b/routingtable/adjRIBIn/adj_rib_in.go index c7868eea..376356ed 100644 --- a/routingtable/adjRIBIn/adj_rib_in.go +++ b/routingtable/adjRIBIn/adj_rib_in.go @@ -254,6 +254,11 @@ func (a *AdjRIBIn) Register(client routingtable.RouteTableClient) { a.clientManager.RegisterWithOptions(client, routingtable.ClientOptions{BestOnly: true}) } +// RegisterWithOptions registers a client for updates +func (a *AdjRIBIn) RegisterWithOptions(client routingtable.RouteTableClient, options routingtable.ClientOptions) { + a.clientManager.RegisterWithOptions(client, options) +} + // Unregister unregisters a client func (a *AdjRIBIn) Unregister(client routingtable.RouteTableClient) { if !a.clientManager.Unregister(client) { @@ -271,3 +276,18 @@ func (a *AdjRIBIn) Unregister(client routingtable.RouteTableClient) { func (a *AdjRIBIn) RefreshRoute(*net.Prefix, []*route.Path) { } + +// LPM performs a longest prefix match on the routing table +func (a *AdjRIBIn) LPM(pfx *net.Prefix) (res []*route.Route) { + return a.rt.LPM(pfx) +} + +// Get gets a route +func (a *AdjRIBIn) Get(pfx *net.Prefix) *route.Route { + return a.rt.Get(pfx) +} + +// GetLonger gets all more specifics +func (a *AdjRIBIn) GetLonger(pfx *net.Prefix) (res []*route.Route) { + return a.rt.GetLonger(pfx) +} diff --git a/routingtable/adjRIBOut/adj_rib_out.go b/routingtable/adjRIBOut/adj_rib_out.go index bec06450..4f470c72 100644 --- a/routingtable/adjRIBOut/adj_rib_out.go +++ b/routingtable/adjRIBOut/adj_rib_out.go @@ -275,6 +275,11 @@ func (a *AdjRIBOut) Register(client routingtable.RouteTableClient) { a.clientManager.RegisterWithOptions(client, routingtable.ClientOptions{BestOnly: true}) } +// RegisterWithOptions registers a client for updates +func (a *AdjRIBOut) RegisterWithOptions(client routingtable.RouteTableClient, options routingtable.ClientOptions) { + a.clientManager.RegisterWithOptions(client, options) +} + // Unregister unregisters a client func (a *AdjRIBOut) Unregister(client routingtable.RouteTableClient) { a.clientManager.Unregister(client) @@ -330,3 +335,18 @@ func (a *AdjRIBOut) RefreshRoute(pfx *net.Prefix, ribPaths []*route.Path) { } } + +// LPM performs a longest prefix match on the routing table +func (a *AdjRIBOut) LPM(pfx *net.Prefix) (res []*route.Route) { + return a.rt.LPM(pfx) +} + +// Get gets a route +func (a *AdjRIBOut) Get(pfx *net.Prefix) *route.Route { + return a.rt.Get(pfx) +} + +// GetLonger gets all more specifics +func (a *AdjRIBOut) GetLonger(pfx *net.Prefix) (res []*route.Route) { + return a.rt.GetLonger(pfx) +}