diff --git a/dv/config/config.go b/dv/config/config.go index 69ea9a7c..027eac99 100644 --- a/dv/config/config.go +++ b/dv/config/config.go @@ -12,11 +12,10 @@ import ( const CostInfinity = uint64(16) const NlsrOrigin = uint64(mgmt.RouteOriginNLSR) -var MulticastStrategy = enc.LOCALHOST.Append( - enc.NewGenericComponent("nfd"), - enc.NewGenericComponent("strategy"), - enc.NewGenericComponent("multicast"), -) +var MulticastStrategy = enc.LOCALHOST. + Append(enc.NewGenericComponent("nfd")). + Append(enc.NewGenericComponent("strategy")). + Append(enc.NewGenericComponent("multicast")) //go:embed schema.tlv var SchemaBytes []byte @@ -136,40 +135,34 @@ func (c *Config) Parse() (err error) { } // Advertisement sync and data prefixes - c.advSyncPfxN = enc.LOCALHOP.Append(c.networkNameN.Append( - enc.NewKeywordComponent("DV"), - enc.NewKeywordComponent("ADS"), - )...) - c.advSyncActivePfxN = c.advSyncPfxN.Append( - enc.NewKeywordComponent("ACT"), - ) - c.advSyncPassivePfxN = c.advSyncPfxN.Append( - enc.NewKeywordComponent("PSV"), - ) - c.advDataPfxN = enc.LOCALHOP.Append(c.routerNameN.Append( - enc.NewKeywordComponent("DV"), - enc.NewKeywordComponent("ADV"), - )...) + c.advSyncPfxN = enc.LOCALHOP. + Append(c.networkNameN...). + Append(enc.NewKeywordComponent("DV")). + Append(enc.NewKeywordComponent("ADS")) + c.advSyncActivePfxN = c.advSyncPfxN. + Append(enc.NewKeywordComponent("ACT")) + c.advSyncPassivePfxN = c.advSyncPfxN. + Append(enc.NewKeywordComponent("PSV")) + c.advDataPfxN = enc.LOCALHOP. + Append(c.routerNameN...). + Append(enc.NewKeywordComponent("DV")). + Append(enc.NewKeywordComponent("ADV")) // Prefix table sync prefix - c.pfxSyncPfxN = c.networkNameN.Append( - enc.NewKeywordComponent("DV"), - enc.NewKeywordComponent("PFS"), - ) + c.pfxSyncPfxN = c.networkNameN. + Append(enc.NewKeywordComponent("DV")). + Append(enc.NewKeywordComponent("PFS")) // Router data prefix including prefix data and certificates - c.routerDataPfxN = c.routerNameN.Append( - enc.NewKeywordComponent("DV"), - ) - c.pfxDataPfxN = c.routerNameN.Append( - enc.NewKeywordComponent("DV"), - enc.NewKeywordComponent("PFX"), - ) + c.routerDataPfxN = c.routerNameN. + Append(enc.NewKeywordComponent("DV")) + c.pfxDataPfxN = c.routerNameN. + Append(enc.NewKeywordComponent("DV")). + Append(enc.NewKeywordComponent("PFX")) // Local prefixes to NFD - c.mgmtPrefix = enc.LOCALHOST.Append( - enc.NewGenericComponent("nlsr"), - ) + c.mgmtPrefix = enc.LOCALHOST. + Append(enc.NewGenericComponent("nlsr")) return nil } diff --git a/dv/dv/advert_data.go b/dv/dv/advert_data.go index b0f6bf87..c7b4c05a 100644 --- a/dv/dv/advert_data.go +++ b/dv/dv/advert_data.go @@ -44,13 +44,14 @@ func (a *advertModule) dataFetch(nName enc.Name, bootTime uint64, seqNo uint64) } // Fetch the advertisement - advName := enc.LOCALHOP.Append(nName.Append( - enc.NewKeywordComponent("DV"), - enc.NewKeywordComponent("ADV"), - enc.NewTimestampComponent(bootTime), - )...) + advName := enc.LOCALHOP. + Append(nName...). + Append(enc.NewKeywordComponent("DV")). + Append(enc.NewKeywordComponent("ADV")). + Append(enc.NewTimestampComponent(bootTime)). + WithVersion(seqNo) - a.dv.client.Consume(advName.WithVersion(seqNo), func(state ndn.ConsumeState) { + a.dv.client.Consume(advName, func(state ndn.ConsumeState) { if !state.IsComplete() { return } diff --git a/dv/table/neighbor_table.go b/dv/table/neighbor_table.go index 6df5576f..1192e71a 100644 --- a/dv/table/neighbor_table.go +++ b/dv/table/neighbor_table.go @@ -137,16 +137,15 @@ func (ns *NeighborState) delete() { } func (ns *NeighborState) localRoute() enc.Name { - return enc.LOCALHOP.Append(ns.Name.Append( - enc.NewKeywordComponent("DV"), - )...) + return enc.LOCALHOP. + Append(ns.Name...). + Append(enc.NewKeywordComponent("DV")) } func (ns *NeighborState) certRoute() enc.Name { - return ns.Name.Append( - enc.NewKeywordComponent("DV"), - enc.NewGenericComponent("KEY"), - ) + return ns.Name. + Append(enc.NewKeywordComponent("DV")). + Append(enc.NewGenericComponent("KEY")) } // Register route to this neighbor diff --git a/dv/table/prefix_table.go b/dv/table/prefix_table.go index df353312..9781388f 100644 --- a/dv/table/prefix_table.go +++ b/dv/table/prefix_table.go @@ -168,18 +168,17 @@ func (pt *PrefixTable) Apply(ops *tlv.PrefixOpList) (dirty bool) { func (r *PrefixTableRouter) GetNextDataName() enc.Name { // //32=DV/32=PFX/t=/32=SNAP/v= // //32=DV/32=PFX/t=/seq=/v=0 - name := r.Name.Append( - enc.NewKeywordComponent("DV"), - enc.NewKeywordComponent("PFX"), - enc.NewTimestampComponent(r.BootTime), - ) + prefix := r.Name. + Append(enc.NewKeywordComponent("DV")). + Append(enc.NewKeywordComponent("PFX")). + Append(enc.NewTimestampComponent(r.BootTime)) if r.Latest-r.Known > PrefixSnapThreshold { - return name. + return prefix. Append(enc.NewKeywordComponent(PrefixSnapKeyword)) } - return name. + return prefix. Append(enc.NewSequenceNumComponent(r.Known + 1)). WithVersion(enc.VersionImmutable) } diff --git a/fw/defn/name.go b/fw/defn/name.go index 89f4d1f3..e16eea95 100644 --- a/fw/defn/name.go +++ b/fw/defn/name.go @@ -12,6 +12,6 @@ var NON_LOCAL_PREFIX = enc.Name{enc.LOCALHOP, enc.NewGenericComponent("nfd")} var STRATEGY_PREFIX = LOCAL_PREFIX.Append(enc.NewGenericComponent("strategy")) // Default forwarding strategy name -var DEFAULT_STRATEGY = STRATEGY_PREFIX.Append( - enc.NewGenericComponent("best-route"), - enc.NewVersionComponent(1)) +var DEFAULT_STRATEGY = STRATEGY_PREFIX. + Append(enc.NewGenericComponent("best-route")). + Append(enc.NewVersionComponent(1)) diff --git a/fw/fw/strategy.go b/fw/fw/strategy.go index b90d3223..9c1e0f0d 100644 --- a/fw/fw/strategy.go +++ b/fw/fw/strategy.go @@ -56,10 +56,9 @@ func (s *StrategyBase) NewStrategyBase( ) { s.thread = fwThread s.threadID = s.thread.threadID - s.name = defn.STRATEGY_PREFIX.Append( - enc.NewGenericComponent(name), - enc.NewVersionComponent(version), - ) + s.name = defn.STRATEGY_PREFIX. + Append(enc.NewGenericComponent(name)). + Append(enc.NewVersionComponent(version)) s.version = version s.logName = name } diff --git a/fw/mgmt/cs.go b/fw/mgmt/cs.go index 46f9e920..780bb757 100644 --- a/fw/mgmt/cs.go +++ b/fw/mgmt/cs.go @@ -122,10 +122,9 @@ func (c *ContentStoreModule) info(interest *Interest) { status.CsInfo.NCsEntries += uint64(thread.GetNumCsEntries()) } - name := LOCAL_PREFIX.Append( - enc.NewGenericComponent("cs"), - enc.NewGenericComponent("info"), - ) + name := LOCAL_PREFIX. + Append(enc.NewGenericComponent("cs")). + Append(enc.NewGenericComponent("info")) c.manager.sendStatusDataset(interest, name, status.Encode()) } diff --git a/fw/mgmt/face.go b/fw/mgmt/face.go index 5bc618c2..39ec6ad0 100644 --- a/fw/mgmt/face.go +++ b/fw/mgmt/face.go @@ -472,10 +472,9 @@ func (f *FaceModule) list(interest *Interest) { dataset.Vals = append(dataset.Vals, f.createDataset(faces[pos])) } - name := LOCAL_PREFIX.Append( - enc.NewGenericComponent("faces"), - enc.NewGenericComponent("list"), - ) + name := LOCAL_PREFIX. + Append(enc.NewGenericComponent("faces")). + Append(enc.NewGenericComponent("list")) f.manager.sendStatusDataset(interest, name, dataset.Encode()) } diff --git a/fw/mgmt/fib.go b/fw/mgmt/fib.go index 1113adad..e3c22da8 100644 --- a/fw/mgmt/fib.go +++ b/fw/mgmt/fib.go @@ -153,9 +153,8 @@ func (f *FIBModule) list(interest *Interest) { dataset.Entries = append(dataset.Entries, fibEntry) } - name := LOCAL_PREFIX.Append( - enc.NewGenericComponent("fib"), - enc.NewGenericComponent("list"), - ) + name := LOCAL_PREFIX. + Append(enc.NewGenericComponent("fib")). + Append(enc.NewGenericComponent("list")) f.manager.sendStatusDataset(interest, name, dataset.Encode()) } diff --git a/fw/mgmt/forwarder-status.go b/fw/mgmt/forwarder-status.go index a01ed24f..45279ae5 100644 --- a/fw/mgmt/forwarder-status.go +++ b/fw/mgmt/forwarder-status.go @@ -80,9 +80,8 @@ func (f *ForwarderStatusModule) general(interest *Interest) { status.NUnsatisfiedInterests += thread.(*fw.Thread).NUnsatisfiedInterests } - name := LOCAL_PREFIX.Append( - enc.NewGenericComponent("status"), - enc.NewGenericComponent("general"), - ) + name := LOCAL_PREFIX. + Append(enc.NewGenericComponent("status")). + Append(enc.NewGenericComponent("general")) f.manager.sendStatusDataset(interest, name, status.Encode()) } diff --git a/fw/mgmt/rib.go b/fw/mgmt/rib.go index c6ae0e6a..267052cb 100644 --- a/fw/mgmt/rib.go +++ b/fw/mgmt/rib.go @@ -218,9 +218,8 @@ func (r *RIBModule) list(interest *Interest) { dataset.Entries = append(dataset.Entries, ribEntry) } - name := interest.Name()[:len(LOCAL_PREFIX)].Append( - enc.NewGenericComponent("rib"), - enc.NewGenericComponent("list"), - ) + name := interest.Name()[:len(LOCAL_PREFIX)]. + Append(enc.NewGenericComponent("rib")). + Append(enc.NewGenericComponent("list")) r.manager.sendStatusDataset(interest, name, dataset.Encode()) } diff --git a/fw/mgmt/strategy-choice.go b/fw/mgmt/strategy-choice.go index b6404537..2fb572a6 100644 --- a/fw/mgmt/strategy-choice.go +++ b/fw/mgmt/strategy-choice.go @@ -123,7 +123,8 @@ func (s *StrategyChoiceModule) set(interest *Interest) { } } else { // Add missing version information to strategy name - params.Strategy.Name = params.Strategy.Name.Append(enc.NewVersionComponent(strategyVersion)) + params.Strategy.Name = params.Strategy.Name. + Append(enc.NewVersionComponent(strategyVersion)) } table.FibStrategyTable.SetStrategyEnc(params.Name, params.Strategy.Name) diff --git a/std/object/client_produce.go b/std/object/client_produce.go index e8b6ec37..179f8c76 100644 --- a/std/object/client_produce.go +++ b/std/object/client_produce.go @@ -88,11 +88,10 @@ func Produce(args ndn.ProduceArgs, store ndn.Store, signer ndn.Signer) (enc.Name if !args.NoMetadata { // write metadata packet - name := args.Name.Prefix(-1).Append( - enc.NewKeywordComponent(rdr.MetadataKeyword), - enc.NewVersionComponent(version), - enc.NewSegmentComponent(0), - ) + name := args.Name.Prefix(-1). + Append(enc.NewKeywordComponent(rdr.MetadataKeyword)). + Append(enc.NewVersionComponent(version)). + Append(enc.NewSegmentComponent(0)) content := rdr.MetaData{ Name: args.Name, FinalBlockID: cfg.FinalBlockID.Bytes(), diff --git a/std/security/name_convention.go b/std/security/name_convention.go index 1879ccf5..44e8aaeb 100644 --- a/std/security/name_convention.go +++ b/std/security/name_convention.go @@ -12,10 +12,9 @@ func MakeKeyName(name enc.Name) enc.Name { keyId := make([]byte, 8) rand.Read(keyId) - return name.Append( - enc.NewGenericComponent("KEY"), - enc.NewGenericBytesComponent(keyId), - ) + return name. + Append(enc.NewGenericComponent("KEY")). + Append(enc.NewGenericBytesComponent(keyId)) } // GetIdentityFromKeyName extracts the identity name from a key name. diff --git a/std/security/ndncert/client_protocol.go b/std/security/ndncert/client_protocol.go index 54f36c8f..dca0be93 100644 --- a/std/security/ndncert/client_protocol.go +++ b/std/security/ndncert/client_protocol.go @@ -19,10 +19,10 @@ import ( func (c *Client) FetchProfile() (*tlv.CaProfile, error) { // TODO: validate packets received by the client using the cert. ch := make(chan ndn.ConsumeState) - c.client.Consume(c.caPrefix.Append( - enc.NewGenericComponent("CA"), - enc.NewGenericComponent("INFO"), - ), func(status ndn.ConsumeState) { + name := c.caPrefix. + Append(enc.NewGenericComponent("CA")). + Append(enc.NewGenericComponent("INFO")) + c.client.Consume(name, func(status ndn.ConsumeState) { if status.IsComplete() { ch <- status } diff --git a/tools/dvc/dvc_link.go b/tools/dvc/dvc_link.go index 8656d792..c9baef78 100644 --- a/tools/dvc/dvc_link.go +++ b/tools/dvc/dvc_link.go @@ -21,11 +21,11 @@ func (t *Tool) RunDvLinkCreate(cmd *cobra.Command, args []string) { } // /localhop//32=DV/32=ADS/32=ACT - name := enc.LOCALHOP.Append(status.NetworkName.Name.Append( - enc.NewKeywordComponent("DV"), - enc.NewKeywordComponent("ADS"), - enc.NewKeywordComponent("ACT"), - )...) + name := enc.LOCALHOP. + Append(status.NetworkName.Name...). + Append(enc.NewKeywordComponent("DV")). + Append(enc.NewKeywordComponent("ADS")). + Append(enc.NewKeywordComponent("ACT")) new(nfdc.Tool).ExecCmd(cmd, "rib", "register", []string{ "persistency=permanent",