Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #64

Merged
merged 13 commits into from
Dec 11, 2024
2 changes: 1 addition & 1 deletion ndn_defn/link-type.go → defn/link-type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is licensed under the terms of the MIT License, as found in LICENSE.md.
*/

package ndn_defn
package defn

// LinkType indicates what type of link a face is.
type LinkType int
Expand Down
2 changes: 1 addition & 1 deletion ndn_defn/mtu.go → defn/mtu.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ndn_defn
package defn

// MaxNDNPacketSize is the maximum allowed NDN packet size
const MaxNDNPacketSize = 8800
15 changes: 9 additions & 6 deletions ndn_defn/pending-packet.go → defn/pkt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@
* This file is licensed under the terms of the MIT License, as found in LICENSE.md.
*/

package ndn_defn
package defn

import (
enc "github.com/zjkmxy/go-ndn/pkg/encoding"
spec "github.com/zjkmxy/go-ndn/pkg/ndn/spec_2022"
)

// PendingPacket represents a pending network-layer packet to be sent or recently received on the link, plus any associated metadata.
type PendingPacket struct {
// Pkt represents a pending packet to be sent or recently
// received on the link, plus any associated metadata.
type Pkt struct {
Name enc.Name
L3 *spec.Packet
Raw []byte

PitToken []byte
CongestionMark *uint64
IncomingFaceID *uint64
NextHopFaceID *uint64
CachePolicy *uint64
EncPacket *spec.Packet
RawBytes []byte
NameCache string
}
2 changes: 1 addition & 1 deletion ndn_defn/scope.go → defn/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is licensed under the terms of the MIT License, as found in LICENSE.md.
*/

package ndn_defn
package defn

// Scope indicates the scope of a face
type Scope int
Expand Down
2 changes: 1 addition & 1 deletion ndn_defn/state.go → defn/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is licensed under the terms of the MIT License, as found in LICENSE.md.
*/

package ndn_defn
package defn

// State indicates the state of a face
type State int
Expand Down
2 changes: 1 addition & 1 deletion ndn_defn/uri.go → defn/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is licensed under the terms of the MIT License, as found in LICENSE.md.
*/

package ndn_defn
package defn

import (
"net"
Expand Down
14 changes: 7 additions & 7 deletions dispatch/face.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package dispatch
import (
"sync"

"github.com/named-data/YaNFD/ndn_defn"
"github.com/named-data/YaNFD/defn"
)

// Face provides an interface that faces can satisfy (to avoid circular dependency between faces and forwarding)
Expand All @@ -19,15 +19,15 @@ type Face interface {
SetFaceID(faceID uint64)

FaceID() uint64
LocalURI() *ndn_defn.URI
RemoteURI() *ndn_defn.URI
Scope() ndn_defn.Scope
LinkType() ndn_defn.LinkType
LocalURI() *defn.URI
RemoteURI() *defn.URI
Scope() defn.Scope
LinkType() defn.LinkType
MTU() int

State() ndn_defn.State
State() defn.State

SendPacket(packet *ndn_defn.PendingPacket)
SendPacket(packet *defn.Pkt)
}

// FaceDispatch is used to allow forwarding to interact with faces without a circular dependency issue.
Expand Down
6 changes: 3 additions & 3 deletions dispatch/fw.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
package dispatch

import (
"github.com/named-data/YaNFD/ndn_defn"
"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 *ndn_defn.PendingPacket)
QueueInterest(packet *ndn_defn.PendingPacket)
QueueData(packet *defn.Pkt)
QueueInterest(packet *defn.Pkt)

GetNumPitEntries() int
GetNumCsEntries() int
Expand Down
10 changes: 5 additions & 5 deletions executor/yanfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"time"

"github.com/named-data/YaNFD/core"
"github.com/named-data/YaNFD/defn"
"github.com/named-data/YaNFD/dispatch"
"github.com/named-data/YaNFD/face"
"github.com/named-data/YaNFD/fw"
"github.com/named-data/YaNFD/mgmt"
"github.com/named-data/YaNFD/ndn_defn"
"github.com/named-data/YaNFD/table"
)

Expand Down Expand Up @@ -165,7 +165,7 @@ func (y *YaNFD) Start() {

if !addr.(*net.IPNet).IP.IsLoopback() {
multicastUDPTransport, err := face.MakeMulticastUDPTransport(
ndn_defn.MakeUDPFaceURI(ipVersion, path, face.UDPMulticastPort))
defn.MakeUDPFaceURI(ipVersion, path, face.UDPMulticastPort))
if err != nil {
core.LogError("Main", "Unable to create MulticastUDPTransport for ", path, " on ", iface.Name, ": ", err)
continue
Expand All @@ -177,7 +177,7 @@ func (y *YaNFD) Start() {
core.LogInfo("Main", "Created multicast UDP face for ", path, " on ", iface.Name)
}

udpListener, err := face.MakeUDPListener(ndn_defn.MakeUDPFaceURI(ipVersion, path, face.UDPUnicastPort))
udpListener, err := face.MakeUDPListener(defn.MakeUDPFaceURI(ipVersion, path, face.UDPUnicastPort))
if err != nil {
core.LogError("Main", "Unable to create UDP listener for ", path, " on ", iface.Name, ": ", err)
continue
Expand All @@ -187,7 +187,7 @@ func (y *YaNFD) Start() {
core.LogInfo("Main", "Created UDP listener for ", path, " on ", iface.Name)

if tcpEnabled {
tcpListener, err := face.MakeTCPListener(ndn_defn.MakeTCPFaceURI(ipVersion, path, tcpPort))
tcpListener, err := face.MakeTCPListener(defn.MakeTCPFaceURI(ipVersion, path, tcpPort))
if err != nil {
core.LogError("Main", "Unable to create TCP listener for ", path, " on ", iface.Name, ": ", err)
continue
Expand All @@ -201,7 +201,7 @@ func (y *YaNFD) Start() {
}
if core.GetConfigBoolDefault("faces.unix.enabled", true) && !y.config.DisableUnix {
// Set up Unix stream listener
y.unixListener, err = face.MakeUnixStreamListener(ndn_defn.MakeUnixFaceURI(face.UnixSocketPath))
y.unixListener, err = face.MakeUnixStreamListener(defn.MakeUnixFaceURI(face.UnixSocketPath))
if err != nil {
core.LogError("Main", "Unable to create Unix stream listener at ", face.UnixSocketPath, ": ", err)
} else {
Expand Down
25 changes: 14 additions & 11 deletions face/internal-transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strconv"

"github.com/named-data/YaNFD/core"
ndn_defn "github.com/named-data/YaNFD/ndn_defn"
defn "github.com/named-data/YaNFD/defn"
enc "github.com/zjkmxy/go-ndn/pkg/encoding"
spec "github.com/zjkmxy/go-ndn/pkg/ndn/spec_2022"
"github.com/zjkmxy/go-ndn/pkg/utils"
Expand All @@ -29,15 +29,15 @@ type InternalTransport struct {
func MakeInternalTransport() *InternalTransport {
t := new(InternalTransport)
t.makeTransportBase(
ndn_defn.MakeInternalFaceURI(),
ndn_defn.MakeInternalFaceURI(),
defn.MakeInternalFaceURI(),
defn.MakeInternalFaceURI(),
PersistencyPersistent,
ndn_defn.Local,
ndn_defn.PointToPoint,
ndn_defn.MaxNDNPacketSize)
defn.Local,
defn.PointToPoint,
defn.MaxNDNPacketSize)
t.recvQueue = make(chan []byte, faceQueueSize)
t.sendQueue = make(chan []byte, faceQueueSize)
t.changeState(ndn_defn.Up)
t.changeState(defn.Up)
return t
}

Expand Down Expand Up @@ -136,7 +136,10 @@ func (t *InternalTransport) sendFrame(frame []byte) {
t.nOutBytes += uint64(len(frame))

core.LogDebug(t, "Sending frame of size ", len(frame))
t.recvQueue <- frame

frameCopy := make([]byte, len(frame))
copy(frameCopy, frame)
t.recvQueue <- frameCopy
}

func (t *InternalTransport) runReceive() {
Expand All @@ -154,7 +157,7 @@ func (t *InternalTransport) runReceive() {
case frame := <-t.sendQueue:
core.LogTrace(t, "Component send of size ", len(frame))

if len(frame) > ndn_defn.MaxNDNPacketSize {
if len(frame) > defn.MaxNDNPacketSize {
core.LogWarn(t, "Component trying to send too much data - DROP")
continue
}
Expand All @@ -166,15 +169,15 @@ func (t *InternalTransport) runReceive() {
}
}

func (t *InternalTransport) changeState(new ndn_defn.State) {
func (t *InternalTransport) changeState(new defn.State) {
if t.state == new {
return
}

core.LogInfo(t, "state: ", t.state, " -> ", new)
t.state = new

if t.state != ndn_defn.Up {
if t.state != defn.Up {
// Stop link service
t.hasQuit <- true
t.hasQuit <- true // Send again to stop any pending receives
Expand Down
Loading
Loading