forked from named-data/ndnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfw.go
41 lines (33 loc) · 1.03 KB
/
fw.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
/* 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 dispatch
import (
"github.com/named-data/YaNFD/defn"
)
// FWThread provides an interface that forwarding threads can satisfy
// (to avoid circular dependency between faces and forwarding)
type FWThread interface {
String() string
QueueData(packet *defn.Pkt)
QueueInterest(packet *defn.Pkt)
GetNumPitEntries() int
GetNumCsEntries() int
}
// FWDispatch is used to allow faces to interact with forwarding without a circular dependency issue.
var FWDispatch []FWThread
// InitializeFWThreads sets up the forwarding thread dispatch slice.
func InitializeFWThreads(faces []FWThread) {
FWDispatch = make([]FWThread, len(faces))
copy(FWDispatch, faces)
}
// GetFWThread returns the specified forwarding thread or nil if it does not exist.
func GetFWThread(id int) FWThread {
if id < 0 || id > len(FWDispatch) {
return nil
}
return FWDispatch[id]
}