/// <summary>
        /// Append a timestamp component and a random value component to interest's
        /// name. This ensures that the timestamp is greater than the timestamp used in
        /// the previous call. Then use keyChain to sign the interest which appends a
        /// SignatureInfo component and a component with the signature bits. If the
        /// interest lifetime is not set, this sets it.
        /// </summary>
        ///
        /// <param name="interest">The interest whose name is append with components.</param>
        /// <param name="keyChain">The KeyChain for calling sign.</param>
        /// <param name="certificateName">The certificate name of the key to use for signing.</param>
        /// <param name="wireFormat"></param>
        public void generate(Interest interest, KeyChain keyChain,
				Name certificateName, WireFormat wireFormat)
        {
            double timestamp;
             lock (lastTimestampLock_) {
                        timestamp = Math.Round(net.named_data.jndn.util.Common.getNowMilliseconds(),MidpointRounding.AwayFromZero);
                        while (timestamp <= lastTimestamp_)
                            timestamp += 1.0d;
                        // Update the timestamp now while it is locked. In the small chance that
                        //   signing fails, it just means that we have bumped the timestamp.
                        lastTimestamp_ = timestamp;
                    }

            // The timestamp is encoded as a TLV nonNegativeInteger.
            TlvEncoder encoder = new TlvEncoder(8);
            encoder.writeNonNegativeInteger((long) timestamp);
            interest.getName().append(new Blob(encoder.getOutput(), false));

            // The random value is a TLV nonNegativeInteger too, but we know it is 8 bytes,
            //   so we don't need to call the nonNegativeInteger encoder.
            ByteBuffer randomBuffer = ILOG.J2CsMapping.NIO.ByteBuffer.allocate(8);
            // Note: SecureRandom is thread safe.
            net.named_data.jndn.util.Common.getRandom().nextBytes(randomBuffer.array());
            interest.getName().append(new Blob(randomBuffer, false));

            keyChain.sign(interest, certificateName, wireFormat);

            if (interest.getInterestLifetimeMilliseconds() < 0)
                // The caller has not set the interest lifetime, so set it here.
                interest.setInterestLifetimeMilliseconds(1000.0d);
        }
Пример #2
0
        public ValidationRequest checkVerificationPolicy(Interest interest,
				int stepCount, OnVerifiedInterest onVerified,
				OnInterestValidationFailed onValidationFailed)
        {
            return checkVerificationPolicy(interest, stepCount, onVerified,
                    onValidationFailed, net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
Пример #3
0
        /// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details.
        /// </summary>
        ///
        public override long expressInterest(Interest interest_0, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat_1)
        {
            long pendingInterestId_2 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_3 = onData;
            OnData onDataSubmit_4 = new ThreadPoolFace.Anonymous_C14 (this, finalOnData_3);

            OnTimeout finalOnTimeout_5 = onTimeout;
            OnTimeout onTimeoutSubmit_6 = (onTimeout == null) ? null
                    : new ThreadPoolFace.Anonymous_C13 (this, finalOnTimeout_5);

            OnNetworkNack finalOnNetworkNack_7 = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_8 = (onNetworkNack == null) ? null
                    : new ThreadPoolFace.Anonymous_C12 (this, finalOnNetworkNack_7);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_9 = new Interest(interest_0);
            threadPool_.submit(new ThreadPoolFace.Anonymous_C11 (this, onNetworkNackSubmit_8, onDataSubmit_4,
                    interestCopy_9, onTimeoutSubmit_6, pendingInterestId_2, wireFormat_1));

            return pendingInterestId_2;
        }
        public void testMaxNdnPacketSize()
        {
            // Construct an interest whose encoding is one byte larger than getMaxNdnPacketSize.
            int targetSize = net.named_data.jndn.Face.getMaxNdnPacketSize() + 1;
            // Start with an interest which is almost the right size.
            Interest interest = new Interest();
            interest.getName().append(new byte[targetSize]);
            int initialSize = interest.wireEncode().size();
            // Now replace the component with the desired size which trims off the extra encoding.
            interest.setName(new Name().append(new byte[targetSize
                    - (initialSize - targetSize)]));
            int interestSize = interest.wireEncode().size();
            AssertEquals("Wrong interest size for MaxNdnPacketSize", targetSize,
                    interestSize);

            CallbackCounter counter = new CallbackCounter();
            bool gotError = true;
            try {
                face.expressInterest(interest, counter, counter);
                gotError = false;
            } catch (Exception ex) {
            }
            if (!gotError)
                Fail("expressInterest didn't throw an exception when the interest size exceeds getMaxNdnPacketSize()");
        }
Пример #5
0
        public ValidationRequest(Interest interest, OnVerified onVerified,
				OnDataValidationFailed onValidationFailed, int retry, int stepCount)
        {
            interest_ = interest;
            onVerified_ = onVerified;
            onValidationFailed_ = onValidationFailed;
            retry_ = retry;
            stepCount_ = stepCount;
        }
Пример #6
0
        public void getMatchedFilters(Interest interest,
				ArrayList matchedFilters)
        {
            for (int i = 0; i < table_.Count; ++i) {
                InterestFilterTable.Entry  entry = table_[i];
                if (entry.getFilter().doesMatch(interest.getName()))
                    ILOG.J2CsMapping.Collections.Collections.Add(matchedFilters,entry);
            }
        }
Пример #7
0
 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;
     }
 }
        /// <summary>
        /// Override to call onVerified.onVerifiedInterest(interest) and to indicate no
        /// further verification step.
        /// </summary>
        ///
        /// <param name="interest">The interest with the signature (to ignore).</param>
        /// <param name="stepCount"></param>
        /// <param name="onVerified">better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onValidationFailed">Override to ignore this.</param>
        /// <returns>null for no further step.</returns>
        public override sealed ValidationRequest checkVerificationPolicy(Interest interest,
				int stepCount, OnVerifiedInterest onVerified,
				OnInterestValidationFailed onValidationFailed, WireFormat wireFormat)
        {
            try {
                onVerified.onVerifiedInterest(interest);
            } catch (Exception ex) {
                logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerifiedInterest", ex);
            }
            return null;
        }
        public PendingInterestTable.Entry add(long pendingInterestId,
				Interest interestCopy, OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack)
        {
            int removeRequestIndex = removeRequests_.indexOf(pendingInterestId);
            if (removeRequestIndex >= 0) {
                // removePendingInterest was called with the pendingInterestId returned by
                //   expressInterest before we got here, so don't add a PIT entry.
                ILOG.J2CsMapping.Collections.Collections.RemoveAt(removeRequests_,removeRequestIndex);
                return null;
            }

            PendingInterestTable.Entry  entry = new PendingInterestTable.Entry (pendingInterestId, interestCopy, onData,
                    onTimeout, onNetworkNack);
            ILOG.J2CsMapping.Collections.Collections.Add(table_,entry);
            return entry;
        }
Пример #10
0
        /// <summary>
        /// Do the work of expressInterest once we know we are connected. Add the entry
        /// to the PIT, encode and send the interest.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy"></param>
        /// <param name="onData"></param>
        /// <param name="onTimeout"></param>
        /// <param name="onNetworkNack"></param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        internal void expressInterestHelper(long pendingInterestId,
                                            Interest interestCopy, OnData onData, OnTimeout onTimeout,
                                            OnNetworkNack onNetworkNack, WireFormat wireFormat, Face face)
        {
            PendingInterestTable.Entry pendingInterest = pendingInterestTable_
                                                         .add(pendingInterestId, interestCopy, onData, onTimeout,
                                                              onNetworkNack);
            if (pendingInterest == null)
            {
                // removePendingInterest was already called with the pendingInterestId.
                return;
            }

            if (onTimeout != null ||
                interestCopy.getInterestLifetimeMilliseconds() >= 0.0d)
            {
                // Set up the timeout.
                double delayMilliseconds = interestCopy
                                           .getInterestLifetimeMilliseconds();
                if (delayMilliseconds < 0.0d)
                {
                    // Use a default timeout delay.
                    delayMilliseconds = 4000.0d;
                }

                face.callLater(delayMilliseconds, new Node.Anonymous_C0(this, pendingInterest));
            }

            // Special case: For timeoutPrefix_ we don't actually send the interest.
            if (!timeoutPrefix_.match(interestCopy.getName()))
            {
                Blob encoding = interestCopy.wireEncode(wireFormat);
                if (encoding.size() > getMaxNdnPacketSize())
                {
                    throw new Exception(
                              "The encoded interest size exceeds the maximum limit getMaxNdnPacketSize()");
                }
                transport_.send(encoding.buf());
            }
        }
Пример #11
0
        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();
                net.named_data.jndn.encoding.TlvWireFormat.get().decodeLpPacket(lpPacket, element);
                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 process 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.getName(), 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);
                    }
                }
            }
        }
Пример #12
0
 public void onData(Interest localInterest_0, Data data_1)
 {
     outer_ThreadPoolFace.threadPool_.submit(new net.named_data.jndn.ThreadPoolFace.Anonymous_C14.Anonymous_C24(this, localInterest_0, data_1));
 }
Пример #13
0
 public void onTimeout(Interest localInterest_0)
 {
     outer_ThreadPoolFace.threadPool_.submit(new net.named_data.jndn.ThreadPoolFace.Anonymous_C9.Anonymous_C20(this, localInterest_0));
 }
 /// <summary>
 /// Never skip verification.
 /// </summary>
 ///
 /// <param name="interest">The received interest.</param>
 /// <returns>false.</returns>
 public override bool skipVerifyAndTrust(Interest interest)
 {
     return false;
 }
        /// <summary>
        /// Use wireFormat.decodeSignatureInfoAndValue to decode the last two name
        /// components of the signed interest. Look in the IdentityStorage for the
        /// public key with the name in the KeyLocator (if available) and use it to
        /// verify the interest. If the public key can't be found, call onVerifyFailed.
        /// </summary>
        ///
        /// <param name="interest">The interest with the signature to check.</param>
        /// <param name="stepCount"></param>
        /// <param name="onVerified">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onValidationFailed">onValidationFailed.onInterestValidationFailed(interest, reason). NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>null for no further step for looking up a certificate chain.</returns>
        public override ValidationRequest checkVerificationPolicy(Interest interest,
				int stepCount, OnVerifiedInterest onVerified,
				OnInterestValidationFailed onValidationFailed, WireFormat wireFormat)
        {
            if (interest.getName().size() < 2) {
                try {
                    onValidationFailed.onInterestValidationFailed(interest,
                            "The signed interest has less than 2 components: "
                                    + interest.getName().toUri());
                } catch (Exception exception) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
                            "Error in onInterestValidationFailed", exception);
                }
                return null;
            }

            // Decode the last two name components of the signed interest
            Signature signature;
            try {
                signature = wireFormat.decodeSignatureInfoAndValue(interest
                        .getName().get(-2).getValue().buf(), interest.getName()
                        .get(-1).getValue().buf(), false);
            } catch (EncodingException ex) {
                logger_.log(
                        ILOG.J2CsMapping.Util.Logging.Level.INFO,
                        "Cannot decode the signed interest SignatureInfo and value",
                        ex);
                try {
                    onValidationFailed.onInterestValidationFailed(interest,
                            "Error decoding the signed interest signature: " + ex);
                } catch (Exception exception_0) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
                            "Error in onInterestValidationFailed", exception_0);
                }
                return null;
            }

            String[] failureReason = new String[] { "unknown" };
            // wireEncode returns the cached encoding if available.
            if (verify(signature, interest.wireEncode(wireFormat), failureReason)) {
                try {
                    onVerified.onVerifiedInterest(interest);
                } catch (Exception ex_1) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerifiedInterest", ex_1);
                }
            } else {
                try {
                    onValidationFailed.onInterestValidationFailed(interest,
                            failureReason[0]);
                } catch (Exception ex_2) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
                            "Error in onInterestValidationFailed", ex_2);
                }
            }

            // No more steps, so return a null ValidationRequest.
            return null;
        }
 public void onInterestValidationFailed(Interest interest, string reason)
 {
     Console.Out.WriteLine
       (prefix_ + " signature verification: FAILED. Reason: " + reason);
 }
 static void dumpInterest(Interest interest)
 {
     Console.Out.WriteLine("name: " + interest.getName().toUri());
       Console.Out.WriteLine("minSuffixComponents: " +
     (interest.getMinSuffixComponents() >= 0 ?
       "" + interest.getMinSuffixComponents() : "<none>"));
       Console.Out.WriteLine("maxSuffixComponents: " +
     (interest.getMaxSuffixComponents() >= 0 ?
       "" + interest.getMaxSuffixComponents() : "<none>"));
       Console.Out.Write("keyLocator: ");
       if (interest.getKeyLocator().getType() == KeyLocatorType.NONE)
     Console.Out.WriteLine("<none>");
       else if (interest.getKeyLocator().getType() ==KeyLocatorType.KEY_LOCATOR_DIGEST)
     Console.Out.WriteLine("KeyLocatorDigest: " + interest.getKeyLocator().getKeyData().toHex());
       else if (interest.getKeyLocator().getType() == KeyLocatorType.KEYNAME)
     Console.Out.WriteLine("KeyName: " + interest.getKeyLocator().getKeyName().toUri());
       else
     Console.Out.WriteLine("<unrecognized ndn_KeyLocatorType>");
       Console.Out.WriteLine
       ("exclude: " + (interest.getExclude().size() > 0 ?
     interest.getExclude().toUri() : "<none>"));
       Console.Out.WriteLine("lifetimeMilliseconds: " +
     (interest.getInterestLifetimeMilliseconds() >= 0 ?
       "" + interest.getInterestLifetimeMilliseconds() : "<none>"));
       Console.Out.WriteLine("childSelector: " +
     (interest.getChildSelector() >= 0 ?
       "" + interest.getChildSelector() : "<none>"));
       Console.Out.WriteLine("mustBeFresh: " + interest.getMustBeFresh());
       Console.Out.WriteLine("nonce: " +
     (interest.getNonce().size() > 0 ?
       "" + interest.getNonce().toHex() : "<none>"));
 }
Пример #18
0
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="interest">The Interest to send.  This copies the Interest.</param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public virtual long expressInterest(Interest interest, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat)
        {
            long pendingInterestId = node_.getNextEntryId();

            // This copies the interest as required by Node.expressInterest.
            node_.expressInterest(pendingInterestId, interest, onData, onTimeout,
                    onNetworkNack, wireFormat, this);

            return pendingInterestId;
        }
Пример #19
0
        /// <summary>
        /// Do the work of registerPrefix to register with NFD.
        /// </summary>
        ///
        /// <param name="registeredPrefixId">registeredPrefixTable_ (assuming it has already been done).</param>
        /// <param name="prefix"></param>
        /// <param name="onInterest"></param>
        /// <param name="onRegisterFailed"></param>
        /// <param name="onRegisterSuccess"></param>
        /// <param name="flags"></param>
        /// <param name="commandKeyChain"></param>
        /// <param name="commandCertificateName"></param>
        /// <param name="wireFormat_0"></param>
        /// <param name="face_1"></param>
        /// <exception cref="System.Security.SecurityException">If cannot find the private key for thecertificateName.</exception>
        private void nfdRegisterPrefix(long registeredPrefixId, Name prefix,
                                       OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed,
                                       OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags,
                                       KeyChain commandKeyChain, Name commandCertificateName,
                                       WireFormat wireFormat_0, Face face_1)
        {
            if (commandKeyChain == null)
            {
                throw new Exception(
                          "registerPrefix: The command KeyChain has not been set. You must call setCommandSigningInfo.");
            }
            if (commandCertificateName.size() == 0)
            {
                throw new Exception(
                          "registerPrefix: The command certificate name has not been set. You must call setCommandSigningInfo.");
            }

            ControlParameters controlParameters = new ControlParameters();

            controlParameters.setName(prefix);
            controlParameters.setForwardingFlags(flags);

            Interest commandInterest = new Interest();

            // Determine whether to use remote prefix registration.
            bool faceIsLocal;

            try {
                faceIsLocal = isLocal();
            } catch (IOException ex) {
                logger_.log(
                    ILOG.J2CsMapping.Util.Logging.Level.INFO,
                    "Register prefix failed: Error attempting to determine if the face is local: {0}",
                    ex);
                try {
                    onRegisterFailed.onRegisterFailed(prefix);
                } catch (Exception exception) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onRegisterFailed",
                                exception);
                }
                return;
            }

            if (faceIsLocal)
            {
                commandInterest.setName(new Name("/localhost/nfd/rib/register"));
                // The interest is answered by the local host, so set a short timeout.
                commandInterest.setInterestLifetimeMilliseconds(2000.0d);
            }
            else
            {
                commandInterest.setName(new Name("/localhop/nfd/rib/register"));
                // The host is remote, so set a longer timeout.
                commandInterest.setInterestLifetimeMilliseconds(4000.0d);
            }

            // NFD only accepts TlvWireFormat packets.
            commandInterest.getName().append(
                controlParameters.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get()));
            makeCommandInterest(commandInterest, commandKeyChain,
                                commandCertificateName, net.named_data.jndn.encoding.TlvWireFormat.get());

            // Send the registration interest.
            Node.RegisterResponse response = new Node.RegisterResponse(
                new RegisterResponse.Info(prefix, onRegisterFailed,
                                          onRegisterSuccess, registeredPrefixId, onInterest, face_1),
                this);
            try {
                expressInterest(getNextEntryId(), commandInterest, response,
                                response, null, wireFormat_0, face_1);
            } catch (IOException ex_2) {
                // Can't send the interest. Call onRegisterFailed.
                logger_.log(
                    ILOG.J2CsMapping.Util.Logging.Level.INFO,
                    "Register prefix failed: Error sending the register prefix interest to the forwarder: {0}",
                    ex_2);
                try {
                    onRegisterFailed.onRegisterFailed(prefix);
                } catch (Exception exception_3) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onRegisterFailed",
                                exception_3);
                }
            }
        }
Пример #20
0
            /// <summary>
            /// We received the response.
            /// </summary>
            ///
            /// <param name="interest"></param>
            /// <param name="responseData"></param>
            public virtual void onData(Interest interest, Data responseData)
            {
                // Decode responseData.getContent() and check for a success code.
                ControlResponse controlResponse = new ControlResponse();

                try {
                    controlResponse.wireDecode(responseData.getContent(),
                                               net.named_data.jndn.encoding.TlvWireFormat.get());
                } catch (EncodingException ex) {
                    net.named_data.jndn.Node.logger_.log(
                        ILOG.J2CsMapping.Util.Logging.Level.INFO,
                        "Register prefix failed: Error decoding the NFD response: {0}",
                        ex);
                    try {
                        info_.onRegisterFailed_.onRegisterFailed(info_.prefix_);
                    } catch (Exception exception) {
                        net.named_data.jndn.Node.logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onRegisterFailed",
                                                             exception);
                    }
                    return;
                }

                // Status code 200 is "OK".
                if (controlResponse.getStatusCode() != 200)
                {
                    net.named_data.jndn.Node.logger_.log(
                        ILOG.J2CsMapping.Util.Logging.Level.INFO,
                        "Register prefix failed: Expected NFD status code 200, got: {0}",
                        controlResponse.getStatusCode());
                    try {
                        info_.onRegisterFailed_.onRegisterFailed(info_.prefix_);
                    } catch (Exception ex_0) {
                        net.named_data.jndn.Node.logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onRegisterFailed", ex_0);
                    }
                    return;
                }

                // Success, so we can add to the registered prefix table.
                if (info_.registeredPrefixId_ != 0)
                {
                    long interestFilterId = 0;
                    if (info_.onInterest_ != null)
                    {
                        // registerPrefix was called with the "combined" form that includes the
                        // callback, so add an InterestFilterEntry.
                        interestFilterId = parent_.getNextEntryId();
                        parent_.setInterestFilter(interestFilterId,
                                                  new InterestFilter(info_.prefix_),
                                                  info_.onInterest_, info_.face_);
                    }

                    if (!parent_.registeredPrefixTable_.add(
                            info_.registeredPrefixId_, info_.prefix_,
                            interestFilterId))
                    {
                        // removeRegisteredPrefix was already called with the registeredPrefixId.
                        if (interestFilterId > 0)
                        {
                            // Remove the related interest filter we just added.
                            parent_.unsetInterestFilter(interestFilterId);
                        }

                        return;
                    }
                }

                net.named_data.jndn.Node.logger_.log(
                    ILOG.J2CsMapping.Util.Logging.Level.INFO,
                    "Register prefix succeeded with the NFD forwarder for prefix {0}",
                    info_.prefix_.toUri());
                if (info_.onRegisterSuccess_ != null)
                {
                    try {
                        info_.onRegisterSuccess_.onRegisterSuccess(info_.prefix_,
                                                                   info_.registeredPrefixId_);
                    } catch (Exception ex_1) {
                        net.named_data.jndn.Node.logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onRegisterSuccess", ex_1);
                    }
                }
            }
Пример #21
0
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy">to use.</param>
        /// <param name="onData">expressInterest and data is the received Data object.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public void expressInterest(long pendingInterestId,
                                    Interest interestCopy, OnData onData,
                                    OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                    WireFormat wireFormat, Face face)
        {
            // Set the nonce in our copy of the Interest so it is saved in the PIT.
            interestCopy.setNonce(nonceTemplate_);
            interestCopy.refreshNonce();

            if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE)
            {
                // We are connected. Simply send the interest without synchronizing.
                expressInterestHelper(pendingInterestId, interestCopy, onData,
                                      onTimeout, onNetworkNack, wireFormat, face);
                return;
            }

            lock (onConnectedCallbacks_) {
                // TODO: Properly check if we are already connected to the expected host.
                if (!transport_.isAsync())
                {
                    // The simple case: Just do a blocking connect and express.
                    transport_.connect(connectionInfo_, this, null);
                    expressInterestHelper(pendingInterestId, interestCopy, onData,
                                          onTimeout, onNetworkNack, wireFormat, face);
                    // Make future calls to expressInterest send directly to the Transport.
                    connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE;

                    return;
                }

                // Handle the async case.
                if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.UNCONNECTED)
                {
                    connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED;

                    // expressInterestHelper will be called by onConnected.
                    ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_, new Node.Anonymous_C3(this, interestCopy, onData, wireFormat,
                                                                                                              onTimeout, pendingInterestId, face, onNetworkNack));

                    IRunnable onConnected = new Node.Anonymous_C2(this);
                    transport_.connect(connectionInfo_, this, onConnected);
                }
                else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED)
                {
                    // Still connecting. add to the interests to express by onConnected.
                    ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_, new Node.Anonymous_C1(this, onData, pendingInterestId, wireFormat,
                                                                                                              face, onNetworkNack, interestCopy, onTimeout));
                }
                else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE)
                {
                    // We have to repeat this check for CONNECT_COMPLETE in case the
                    // onConnected callback was called while we were waiting to enter this
                    // synchronized block.
                    expressInterestHelper(pendingInterestId, interestCopy, onData,
                                          onTimeout, onNetworkNack, wireFormat, face);
                }
                else
                {
                    // Don't expect this to happen.
                    throw new Exception("Node: Unrecognized _connectStatus "
                                        + connectStatus_);
                }
            }
        }
Пример #22
0
        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)
            {
                dispatchInterest(interest);
            }
            else if (data != null)
            {
                satisfyPendingInterests(data);
            }
        }
Пример #23
0
 /// <summary>
 /// Append a timestamp component and a random value component to interest's
 /// name. Then use the keyChain and certificateName to sign the interest. If
 /// the interest lifetime is not set, this sets it.
 /// </summary>
 ///
 /// <param name="interest">The interest whose name is append with components.</param>
 /// <param name="keyChain">The KeyChain object for signing interests.</param>
 /// <param name="certificateName">The certificate name for signing interests.</param>
 /// <param name="wireFormat"></param>
 /// <exception cref="System.Security.SecurityException">If cannot find the private key for thecertificateName.</exception>
 internal void makeCommandInterest(Interest interest, KeyChain keyChain,
                                   Name certificateName, WireFormat wireFormat)
 {
     commandInterestGenerator_.generate(interest, keyChain, certificateName,
                                        wireFormat);
 }
Пример #24
0
 /// <summary>
 /// Append a timestamp component and a random value component to interest's
 /// name. Then use the keyChain and certificateName from setCommandSigningInfo
 /// to sign the interest. If the interest lifetime is not set, this sets it.
 /// Use the default WireFormat to encode the SignatureInfo and to encode the
 /// interest name for signing.
 /// </summary>
 ///
 /// <param name="interest">The interest whose name is appended with components.</param>
 /// <exception cref="System.Security.SecurityException">If cannot find the private key for thecertificateName.</exception>
 /// @note This method is an experimental feature. See the API docs for more detail at
 /// http://named-data.net/doc/ndn-ccl-api/face.html#face-makecommandinterest-method .
 public void makeCommandInterest(Interest interest)
 {
     makeCommandInterest(interest, net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
 }
Пример #25
0
        /// <summary>
        /// Do the work of expressInterest to make an Interest based on name and
        /// interestTemplate.
        /// </summary>
        ///
        /// <param name="name">A Name for the interest.  This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <returns>The Interest, suitable for Node.expressInterest.</returns>
        protected internal static Interest getInterestCopy(Name name,
				Interest interestTemplate)
        {
            if (interestTemplate != null) {
                // Copy the interestTemplate.
                Interest interestCopy = new Interest(interestTemplate);
                interestCopy.setName(name);
                return interestCopy;
            } else {
                Interest interestCopy_0 = new Interest(name);
                interestCopy_0.setInterestLifetimeMilliseconds(4000.0d);
                return interestCopy_0;
            }
        }
Пример #26
0
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData as described below.
        /// Ignore if the interest times out.
        /// </summary>
        ///
        /// <param name="interest">The Interest to send.  This copies the Interest.</param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Interest interest, OnData onData,
				WireFormat wireFormat)
        {
            return expressInterest(interest, onData, null, wireFormat);
        }
        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);
        }
Пример #28
0
 /// <summary>
 /// Send the Interest through the transport, read the entire response and call
 /// onData as described below.
 /// Ignore if the interest times out.
 /// This uses the default WireFormat.getDefaultWireFormat().
 /// </summary>
 ///
 /// <param name="interest">The Interest to send.  This copies the Interest.</param>
 /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
 /// <returns>The pending interest ID which can be used with
 /// removePendingInterest.</returns>
 /// <exception cref="IOException">For I/O error in sending the interest.</exception>
 /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
 public long expressInterest(Interest interest, OnData onData)
 {
     return expressInterest(interest, onData, null,
             net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
 }
 public void onVerifiedInterest(Interest interest)
 {
     Console.Out.WriteLine(prefix_ + " signature verification: VERIFIED");
 }
Пример #30
0
        /// <summary>
        /// Encode name as an Interest. If interestTemplate is not null, use its
        /// interest selectors.
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public virtual long expressInterest(Name name, Interest interestTemplate,
				OnData onData, OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat)
        {
            long pendingInterestId = node_.getNextEntryId();

            // This copies the name object as required by Node.expressInterest.
            node_.expressInterest(pendingInterestId,
                    getInterestCopy(name, interestTemplate), onData, onTimeout,
                    onNetworkNack, wireFormat, this);

            return pendingInterestId;
        }
 /// <summary>
 /// Always return true to use the self-verification rule for the received interest.
 /// </summary>
 ///
 /// <param name="interest">The received interest.</param>
 /// <returns>true.</returns>
 public override bool requireVerify(Interest interest)
 {
     return true;
 }
Пример #32
0
        /// <summary>
        /// Encode name as an Interest. If interestTemplate is not null, use its
        /// interest selectors.
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// This uses the default WireFormat.getDefaultWireFormat().
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Name name, Interest interestTemplate,
				OnData onData, OnTimeout onTimeout, OnNetworkNack onNetworkNack)
        {
            return expressInterest(name, interestTemplate, onData, onTimeout,
                    onNetworkNack, net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
Пример #33
0
 public Anonymous_C20(ThreadPoolFace.Anonymous_C9 paramouter_Anonymous_C9,
                      Interest localInterest_0)
 {
     this.localInterest      = localInterest_0;
     this.outer_Anonymous_C9 = paramouter_Anonymous_C9;
 }
 public virtual void onData(Interest interest, Data data)
 {
     interest_ = interest;
     data_ = data;
     ++onDataCallCount_;
 }
Пример #35
0
 public void onNetworkNack(Interest localInterest_0,
                           NetworkNack networkNack_1)
 {
     outer_ThreadPoolFace.threadPool_.submit(new net.named_data.jndn.ThreadPoolFace.Anonymous_C8.Anonymous_C19(this, localInterest_0, networkNack_1));
 }
 public virtual void onTimeout(Interest interest)
 {
     interest_ = interest;
     ++onTimeoutCallCount_;
 }
Пример #37
0
 public Anonymous_C23(ThreadPoolFace.Anonymous_C13 paramouter_Anonymous_C13,
                      Interest localInterest_0)
 {
     this.localInterest       = localInterest_0;
     this.outer_Anonymous_C13 = paramouter_Anonymous_C13;
 }
        /// <summary>
        /// Append a timestamp component and a random value component to interest's
        /// name. This ensures that the timestamp is greater than the timestamp used in
        /// the previous call. Then use keyChain to sign the interest which appends a
        /// SignatureInfo component and a component with the signature bits. If the
        /// interest lifetime is not set, this sets it. Use the default WireFormat to
        /// encode the SignatureInfo and to encode interest name for signing.
        /// </summary>
        ///
        /// <param name="interest">The interest whose name is append with components.</param>
        /// <param name="keyChain">The KeyChain for calling sign.</param>
        /// <param name="certificateName">The certificate name of the key to use for signing.</param>
        public void generate(Interest interest, KeyChain keyChain,
				Name certificateName)
        {
            generate(interest, keyChain, certificateName,
                    net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
 public virtual void onNetworkNack(Interest interest, NetworkNack networkNack)
 {
     networkNack_ = networkNack;
     ++onNetworkNackCallCount_;
 }
Пример #40
0
        /// <summary>
        /// Encode name as an Interest. If interestTemplate is not null, use its
        /// interest selectors.
        /// Send the Interest through the transport, read the entire response and call
        /// onData as described below.
        /// Ignore if the interest times out.
        /// This uses the default WireFormat.getDefaultWireFormat().
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Name name, Interest interestTemplate,
				OnData onData)
        {
            return expressInterest(name, interestTemplate, onData, null,
                    net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
Пример #41
0
        /// <summary>
        /// Encode name as an Interest. If interestTemplate is not null, use its
        /// interest selectors.
        /// Send the Interest through the transport, read the entire response and call
        /// onData as described below.
        /// Ignore if the interest times out.
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Name name, Interest interestTemplate,
				OnData onData, WireFormat wireFormat)
        {
            return expressInterest(name, interestTemplate, onData, null, wireFormat);
        }
Пример #42
0
 /// <summary>
 /// Append a timestamp component and a random value component to interest's
 /// name. Then use the keyChain and certificateName from setCommandSigningInfo
 /// to sign the interest. If the interest lifetime is not set, this sets it.
 /// </summary>
 ///
 /// <param name="interest">The interest whose name is appended with components.</param>
 /// <param name="wireFormat"></param>
 /// <exception cref="System.Security.SecurityException">If cannot find the private key for thecertificateName.</exception>
 /// @note This method is an experimental feature. See the API docs for more detail at
 /// http://named-data.net/doc/ndn-ccl-api/face.html#face-makecommandinterest-method .
 public void makeCommandInterest(Interest interest, WireFormat wireFormat)
 {
     node_.makeCommandInterest(interest, commandKeyChain_,
             commandCertificateName_, wireFormat);
 }