当前位置: 首页>>代码示例>>C#>>正文


C# Interest.wireDecode方法代码示例

本文整理汇总了C#中net.named_data.jndn.Interest.wireDecode方法的典型用法代码示例。如果您正苦于以下问题:C# Interest.wireDecode方法的具体用法?C# Interest.wireDecode怎么用?C# Interest.wireDecode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.named_data.jndn.Interest的用法示例。


在下文中一共展示了Interest.wireDecode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: setUp

 public void setUp()
 {
     referenceInterest = new Interest();
     try {
         referenceInterest.wireDecode(new Blob(codedInterest, false));
     } catch (EncodingException ex) {
         // We don't expect this to happen.
         referenceInterest = null;
     }
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:10,代码来源:TestInterestMethods.cs

示例2: Main

        static void Main(string[] args)
        {
            var interest = new Interest();
              interest.wireDecode(new Blob(TlvInterest));
              Console.Out.WriteLine("Interest:");
              dumpInterest(interest);

              // Set the name again to clear the cached encoding so we encode again.
              interest.setName(interest.getName());
              var encoding = interest.wireEncode();
              Console.Out.WriteLine("");
              Console.Out.WriteLine("Re-encoded interest " + encoding.toHex());

              var reDecodedInterest = new Interest();
              reDecodedInterest.wireDecode(encoding);
              Console.Out.WriteLine("");
              Console.Out.WriteLine("Re-decoded Interest:");
              dumpInterest(reDecodedInterest);

              var freshInterest = new Interest(new Name("/ndn/abc"));
              freshInterest.setMinSuffixComponents(4);
              freshInterest.setMaxSuffixComponents(6);
              freshInterest.setInterestLifetimeMilliseconds(30000);
              freshInterest.setChildSelector(1);
              freshInterest.setMustBeFresh(true);
              freshInterest.getKeyLocator().setType(KeyLocatorType.KEY_LOCATOR_DIGEST);
              freshInterest.getKeyLocator().setKeyData
            (new Blob(new byte[] {
              0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
              0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }));
              freshInterest.getExclude().appendComponent(new Name("abc").get(0)).appendAny();

              var identityStorage = new MemoryIdentityStorage();
              var privateKeyStorage = new MemoryPrivateKeyStorage();
              var keyChain = new KeyChain
            (new IdentityManager(identityStorage, privateKeyStorage),
              new SelfVerifyPolicyManager(identityStorage));

              // Initialize the storage.
              var keyName = new Name("/testname/DSK-123");
              var certificateName = keyName.getSubName(0, keyName.size() - 1).append
            ("KEY").append(keyName.get(-1)).append("ID-CERT").append("0");
              identityStorage.addKey(keyName, KeyType.RSA, new Blob(DEFAULT_RSA_PUBLIC_KEY_DER));
              privateKeyStorage.setKeyPairForKeyName
            (keyName, KeyType.RSA, new ByteBuffer(DEFAULT_RSA_PUBLIC_KEY_DER),
             new ByteBuffer(DEFAULT_RSA_PRIVATE_KEY_DER));

              // Make a Face just so that we can sign the interest.
              var face = new Face("localhost");
              face.setCommandSigningInfo(keyChain, certificateName);
              face.makeCommandInterest(freshInterest);

              Interest reDecodedFreshInterest = new Interest();
              reDecodedFreshInterest.wireDecode(freshInterest.wireEncode());
              Console.Out.WriteLine("");
              Console.Out.WriteLine("Re-decoded fresh Interest:");
              dumpInterest(reDecodedFreshInterest);

              VerifyCallbacks callbacks = new VerifyCallbacks("Freshly-signed Interest");
              keyChain.verifyInterest(reDecodedFreshInterest, callbacks, callbacks);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:61,代码来源:test-encode-decode-interest.cs

示例3: testSelectedDelegationIsNotNonNegativeInteger

        public void testSelectedDelegationIsNotNonNegativeInteger()
        {
            Interest interest = new Interest();

            try {
                interest.wireDecode(new Blob(
                        InterestWithLinkNotNonIntegerSelectedDelegation, false));
                Assert.Fail("Expected error decoding an interest with selected delegation not a non-negative integer");
            } catch (Exception ex) {
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:11,代码来源:TestLink.cs

示例4: testInterestLinkObjectWrongContentType

        public void testInterestLinkObjectWrongContentType()
        {
            Interest interest = new Interest();

            try {
                interest.wireDecode(new Blob(InterestWithLinkWrongContentType,
                        false));
            } catch (Exception ex) {
                Assert.Fail("Decoding InterestWithLinkWrongContentType: "
                        + ex.Message);
            }

            try {
                interest.getLink();
                Assert.Fail("Expected error decoding a link with the wrong content type");
            } catch (Exception ex_0) {
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:18,代码来源:TestLink.cs

示例5: testInterestLinkObjectNoMetaInfo

        public void testInterestLinkObjectNoMetaInfo()
        {
            Interest interest = new Interest();

            try {
                interest.wireDecode(new Blob(InterestWithLinkNoMetaInfo, false));
            } catch (Exception ex) {
                Assert.Fail("Decoding InterestWithLinkNoMetaInfo: " + ex.Message);
            }

            try {
                interest.getLink();
                Assert.Fail("Expected error decoding a link with no meta info");
            } catch (Exception ex_0) {
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:16,代码来源:TestLink.cs

示例6: testInterestContainingSelectedDelegationButNoLink

        public void testInterestContainingSelectedDelegationButNoLink()
        {
            Interest interest = new Interest();

            try {
                interest.wireDecode(new Blob(
                        InterestWithSelectedDelegationButNoLink, false));
                Assert.Fail("Expected error decoding an interest with a selected delegation but no link");
            } catch (Exception ex) {
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:11,代码来源:TestLink.cs

示例7: testEncodeDecodeInterestWithLink

        public void testEncodeDecodeInterestWithLink()
        {
            Link link1 = new Link();
            link1.setName(new Name("test"));
            link1.addDelegation(10, new Name("/test1"));
            link1.addDelegation(20, new Name("/test2"));
            link1.addDelegation(100, new Name("/test3"));

            try {
                keyChain.sign(link1, certificateName);
            } catch (SecurityException ex) {
                Assert.Fail(ex.Message);
            }

            Interest interestA = new Interest();
            interestA.setName(new Name("/Test/Encode/Decode/With/Link"));
            interestA.setChildSelector(1);
            interestA.setInterestLifetimeMilliseconds(10000);
            interestA.setLinkWireEncoding(link1.wireEncode());

            Blob interestEncoding = interestA.wireEncode();
            Interest interestB = new Interest();
            try {
                interestB.wireDecode(interestEncoding);
            } catch (EncodingException ex_0) {
                Assert.Fail(ex_0.Message);
            }

            Assert.AssertEquals(interestA.getName(), interestB.getName());

            Link link2 = null;
            try {
                link2 = interestB.getLink();
            } catch (Exception ex_1) {
                Assert.Fail("interestB.getLink(): " + ex_1.Message);
            }

            Assert.AssertTrue("Interest link object not specified", link2 != null);
            DelegationSet delegations = link2.getDelegations();
            for (int i = 0; i < delegations.size(); ++i) {
                if (i == 0) {
                    Assert.AssertEquals(10, delegations.get(i).getPreference());
                    Assert.AssertEquals(new Name("/test1"), delegations.get(i).getName());
                }
                if (i == 1) {
                    Assert.AssertEquals(20, delegations.get(i).getPreference());
                    Assert.AssertEquals(new Name("/test2"), delegations.get(i).getName());
                }
                if (i == 2) {
                    Assert.AssertEquals(100, delegations.get(i).getPreference());
                    Assert.AssertEquals(new Name("/test3"), delegations.get(i).getName());
                }
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:54,代码来源:TestLink.cs

示例8: testDecodeInterestWithLinkNonDecreasingOrder

        public void testDecodeInterestWithLinkNonDecreasingOrder()
        {
            Interest interest = new Interest();

            Link link = null;
            try {
                interest.wireDecode(new Blob(InterestWithLinkNonDecreasingOrder,
                        false));
                link = interest.getLink();
            } catch (Exception ex) {
                Assert.Fail("Decoding InterestWithLinkNonDecreasingOrder: "
                        + ex.Message);
            }
            Assert.AssertTrue(interest.getSelectedDelegationIndex() >= 0);
            Assert.AssertEquals(new Name("ndn"),
                    link.getDelegations()
                            .get(interest.getSelectedDelegationIndex()).getName());
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:18,代码来源:TestLink.cs

示例9: testDecodeInterestWithLink

        public void testDecodeInterestWithLink()
        {
            Interest interest = new Interest();
            Link link = null;
            try {
                interest.wireDecode(new Blob(InterestWithLink, false));
                link = interest.getLink();
            } catch (Exception ex) {
                Assert.Fail("Decoding InterestWithLink: " + ex.Message);
            }

            Assert.AssertTrue("Interest link object not specified", link != null);
            Assert.AssertEquals(new Name("/local/ndn/prefix"), link.getName());

            DelegationSet delegations = link.getDelegations();
            for (int i = 0; i < delegations.size(); ++i) {
                if (i == 0) {
                    Assert.AssertEquals(10, delegations.get(i).getPreference());
                    Assert.AssertEquals(new Name("local"), delegations.get(i).getName());
                }
                if (i == 1) {
                    Assert.AssertEquals(20, delegations.get(i).getPreference());
                    Assert.AssertEquals(new Name("ndn"), delegations.get(i).getName());
                }
            }

            Assert.AssertTrue("Interest selected delegation not specified",
                    interest.getSelectedDelegationIndex() >= 0);
            Assert.AssertEquals(new Name("local"),
                    delegations.get(interest.getSelectedDelegationIndex())
                            .getName());
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:32,代码来源:TestLink.cs

示例10: onReceivedElement

        public void onReceivedElement(ByteBuffer element)
        {
            LpPacket lpPacket = null;
            if (element.get(0) == net.named_data.jndn.encoding.tlv.Tlv.LpPacket_LpPacket) {
                // Decode the LpPacket and replace element with the fragment.
                lpPacket = new LpPacket();
                // Set copy false so that the fragment is a slice which will be copied below.
                // The header fields are all integers and don't need to be copied.
                net.named_data.jndn.encoding.TlvWireFormat.get().decodeLpPacket(lpPacket, element, false);
                element = lpPacket.getFragmentWireEncoding().buf();
            }

            // First, decode as Interest or Data.
            Interest interest = null;
            Data data = null;
            if (element.get(0) == net.named_data.jndn.encoding.tlv.Tlv.Interest || element.get(0) == net.named_data.jndn.encoding.tlv.Tlv.Data) {
                TlvDecoder decoder = new TlvDecoder(element);
                if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Interest, element.remaining())) {
                    interest = new Interest();
                    interest.wireDecode(element, net.named_data.jndn.encoding.TlvWireFormat.get());

                    if (lpPacket != null)
                        interest.setLpPacket(lpPacket);
                } else if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Data, element.remaining())) {
                    data = new Data();
                    data.wireDecode(element, net.named_data.jndn.encoding.TlvWireFormat.get());

                    if (lpPacket != null)
                        data.setLpPacket(lpPacket);
                }
            }

            if (lpPacket != null) {
                // We have decoded the fragment, so remove the wire encoding to save memory.
                lpPacket.setFragmentWireEncoding(new Blob());

                NetworkNack networkNack = net.named_data.jndn.NetworkNack.getFirstHeader(lpPacket);
                if (networkNack != null) {
                    if (interest == null)
                        // We got a Nack but not for an Interest, so drop the packet.
                        return;

                    ArrayList<PendingInterestTable.Entry> pitEntries = new ArrayList<PendingInterestTable.Entry>();
                    pendingInterestTable_.extractEntriesForNackInterest(interest,
                            pitEntries);
                    for (int i = 0; i < pitEntries.Count; ++i) {
                        PendingInterestTable.Entry pendingInterest = pitEntries[i];
                        try {
                            pendingInterest.getOnNetworkNack().onNetworkNack(
                                    pendingInterest.getInterest(), networkNack);
                        } catch (Exception ex) {
                            logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onNack", ex);
                        }
                    }

                    // We have processed the network Nack packet.
                    return;
                }
            }

            // Now process as Interest or Data.
            if (interest != null) {
                // Quickly lock and get all interest filter callbacks which match.
                ArrayList matchedFilters = new ArrayList();
                interestFilterTable_.getMatchedFilters(interest, matchedFilters);

                // The lock on interestFilterTable_ is released, so call the callbacks.
                for (int i_0 = 0; i_0 < matchedFilters.Count; ++i_0) {
                    InterestFilterTable.Entry entry = (InterestFilterTable.Entry) matchedFilters[i_0];
                    try {
                        entry.getOnInterest().onInterest(
                                entry.getFilter().getPrefix(), interest,
                                entry.getFace(), entry.getInterestFilterId(),
                                entry.getFilter());
                    } catch (Exception ex_1) {
                        logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onInterest", ex_1);
                    }
                }
            } else if (data != null) {
                ArrayList<PendingInterestTable.Entry> pitEntries_2 = new ArrayList<PendingInterestTable.Entry>();
                pendingInterestTable_.extractEntriesForExpressedInterest(data,
                        pitEntries_2);
                for (int i_3 = 0; i_3 < pitEntries_2.Count; ++i_3) {
                    PendingInterestTable.Entry pendingInterest_4 = pitEntries_2[i_3];
                    try {
                        pendingInterest_4.getOnData().onData(
                                pendingInterest_4.getInterest(), data);
                    } catch (Exception ex_5) {
                        logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onData", ex_5);
                    }
                }
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:93,代码来源:Node.cs

示例11: testRedecodeImplicitDigestExclude

        public void testRedecodeImplicitDigestExclude()
        {
            // Check that we encode and decode correctly with an implicit digest exclude.
            Interest interest = new Interest(new Name("/A"));
            interest.getExclude()
                    .appendComponent(
                            new Name(
                                    "/sha256digest="
                                            + "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
                                    .get(0));
            ArrayList dump = dumpInterest(interest);

            Blob encoding = interest.wireEncode();
            Interest reDecodedInterest = new Interest();
            try {
                reDecodedInterest.wireDecode(encoding);
            } catch (EncodingException ex) {
                Assert.Fail("Can't decode reDecodedInterest");
            }
            ArrayList redecodedDump = dumpInterest(reDecodedInterest);
            Assert.AssertTrue("Re-decoded interest does not match original",
                    interestDumpsEqual(dump, redecodedDump));
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:23,代码来源:TestInterestMethods.cs

示例12: testRedecode

 public void testRedecode()
 {
     // check that we encode and decode correctly
     Blob encoding = referenceInterest.wireEncode();
     Interest reDecodedInterest = new Interest();
     try {
         reDecodedInterest.wireDecode(encoding);
     } catch (EncodingException ex) {
         Assert.Fail("Can't decode reDecodedInterest");
     }
     ArrayList redecodedDump = dumpInterest(reDecodedInterest);
     Assert.AssertArrayEquals("Re-decoded interest does not match original",
             ILOG.J2CsMapping.Collections.Collections.ToArray(initialDump), ILOG.J2CsMapping.Collections.Collections.ToArray(redecodedDump));
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:14,代码来源:TestInterestMethods.cs

示例13: testCreateFresh

        public void testCreateFresh()
        {
            Interest freshInterest = createFreshInterest();
            ArrayList freshDump = dumpInterest(freshInterest);
            Assert.AssertTrue("Fresh interest does not match original",
                    interestDumpsEqual(initialDump, freshDump));

            Interest reDecodedFreshInterest = new Interest();
            try {
                reDecodedFreshInterest.wireDecode(freshInterest.wireEncode());
            } catch (EncodingException ex) {
                Assert.Fail("Can't decode reDecodedFreshInterest");
            }
            ArrayList reDecodedFreshDump = dumpInterest(reDecodedFreshInterest);

            Assert.AssertTrue("Redecoded fresh interest does not match original",
                    interestDumpsEqual(freshDump, reDecodedFreshDump));
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:18,代码来源:TestInterestMethods.cs


注:本文中的net.named_data.jndn.Interest.wireDecode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。