-
Notifications
You must be signed in to change notification settings - Fork 10
/
fib-strategy.go
65 lines (55 loc) · 1.83 KB
/
fib-strategy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* YaNFD - Yet another NDN Forwarding Daemon
*
* Copyright (C) 2020-2021 Eric Newberry.
*
* This file is licensed under the terms of the MIT License, as found in LICENSE.md.
*/
package table
import (
enc "github.com/zjkmxy/go-ndn/pkg/encoding"
)
// FibStrategyEntry represents an entry in the FIB-Strategy table.
type FibStrategyEntry interface {
Name() enc.Name
GetStrategy() enc.Name
GetNextHops() []*FibNextHopEntry
}
// baseFibStrategyEntry represents information that all
// FibStrategyEntry implementations should include.
type baseFibStrategyEntry struct {
component enc.Component
name enc.Name
nexthops []*FibNextHopEntry
strategy enc.Name
}
// FibNextHopEntry represents a nexthop in a FIB entry.
type FibNextHopEntry struct {
Nexthop uint64
Cost uint64
}
// FibStrategy represents the functionality that a FIB-strategy table should implement.
type FibStrategy interface {
FindNextHopsEnc(name enc.Name) []*FibNextHopEntry
FindStrategyEnc(name enc.Name) enc.Name
InsertNextHopEnc(name enc.Name, nextHop uint64, cost uint64)
ClearNextHopsEnc(name enc.Name)
RemoveNextHopEnc(name enc.Name, nextHop uint64)
GetAllFIBEntries() []FibStrategyEntry
SetStrategyEnc(name enc.Name, strategy enc.Name)
UnSetStrategyEnc(name enc.Name)
GetAllForwardingStrategies() []FibStrategyEntry
}
// FibStrategy is a table containing FIB and Strategy entries for given prefixes.
var FibStrategyTable FibStrategy
// Name returns the name associated with the baseFibStrategyEntry.
func (e *baseFibStrategyEntry) Name() enc.Name {
return e.name
}
// GetStrategy returns the strategy associated with the baseFibStrategyEntry.
func (e *baseFibStrategyEntry) GetStrategy() enc.Name {
return e.strategy
}
// GetNexthops gets the nexthops of the specified entry.
func (e *baseFibStrategyEntry) GetNextHops() []*FibNextHopEntry {
return e.nexthops
}