Skip to content

Commit

Permalink
std: switch mgmt/nfd/status to time
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Jan 3, 2025
1 parent b198a0a commit 8ee8188
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 31 deletions.
4 changes: 2 additions & 2 deletions fw/mgmt/forwarder-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (f *ForwarderStatusModule) general(interest *spec.Interest, pitToken []byte
// Generate new dataset
status := &mgmt.GeneralStatus{
NfdVersion: core.Version,
StartTimestamp: uint64(core.StartTimestamp.UnixNano() / 1000 / 1000),
CurrentTimestamp: uint64(time.Now().UnixNano() / 1000 / 1000),
StartTimestamp: time.Duration(core.StartTimestamp.UnixNano()),
CurrentTimestamp: time.Duration(time.Now().UnixNano()),
NFibEntries: uint64(len(table.FibStrategyTable.GetAllFIBEntries())),
}
// Don't set NNameTreeEntries because we don't use a NameTree
Expand Down
10 changes: 6 additions & 4 deletions std/ndn/mgmt_2022/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
package mgmt_2022

import (
"time"

enc "github.com/named-data/ndnd/std/encoding"
)

Expand Down Expand Up @@ -139,10 +141,10 @@ type FaceEventNotification struct {
type GeneralStatus struct {
//+field:string
NfdVersion string `tlv:"0x80"`
//+field:natural
StartTimestamp uint64 `tlv:"0x81"`
//+field:natural
CurrentTimestamp uint64 `tlv:"0x82"`
//+field:time
StartTimestamp time.Duration `tlv:"0x81"`
//+field:time
CurrentTimestamp time.Duration `tlv:"0x82"`
//+field:natural
NNameTreeEntries uint64 `tlv:"0x83"`
//+field:natural
Expand Down
53 changes: 31 additions & 22 deletions std/ndn/mgmt_2022/zz_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tools/nfdc/nfdc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func (n *Nfdc) ExecStatusGeneral(args []string) {
fmt.Println("General NFD status:")
n.statusPadding = 24
n.printStatusLine("version", status.NfdVersion)
n.printStatusLine("startTime", time.UnixMilli(int64(status.StartTimestamp)))
n.printStatusLine("currentTime", time.UnixMilli(int64(status.CurrentTimestamp)))
n.printStatusLine("uptime", time.Duration(status.CurrentTimestamp-status.StartTimestamp)*time.Millisecond)
n.printStatusLine("startTime", time.Unix(0, int64(status.StartTimestamp)))
n.printStatusLine("currentTime", time.Unix(0, int64(status.CurrentTimestamp)))
n.printStatusLine("uptime", (status.CurrentTimestamp - status.StartTimestamp))
n.printStatusLine("nNameTreeEntries", status.NNameTreeEntries)
n.printStatusLine("nFibEntries", status.NFibEntries)
n.printStatusLine("nPitEntries", status.NCsEntries)
Expand Down

0 comments on commit 8ee8188

Please sign in to comment.