Example #1
0
 /// <summary>
 /// Call registerPrefix on the Face given to the constructor so that this
 /// MemoryContentCache will answer interests whose name has the prefix.
 /// Alternatively, if the Face's registerPrefix has already been called, then
 /// you can call this object's setInterestFilter.
 /// Do not call a callback if a data packet is not found in the cache.
 /// This uses the default WireFormat.getDefaultWireFormat().
 /// Use default ForwardingFlags.
 /// </summary>
 ///
 /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
 /// <param name="onRegisterFailed">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="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess 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>
 /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
 /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
 public void registerPrefix(Name prefix,
                            OnRegisterFailed onRegisterFailed,
                            OnRegisterSuccess onRegisterSuccess)
 {
     registerPrefix(prefix, onRegisterFailed, onRegisterSuccess, null,
                    new ForwardingFlags(), net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
 }
Example #2
0
 /// <summary>
 /// Call registerPrefix on the Face given to the constructor so that this
 /// MemoryContentCache will answer interests whose name has the prefix.
 /// Alternatively, if the Face's registerPrefix has already been called, then
 /// you can call this object's setInterestFilter.
 /// This uses the default WireFormat.getDefaultWireFormat().
 /// </summary>
 ///
 /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
 /// <param name="onRegisterFailed">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="onDataNotFound">onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter). Your callback can find the Data packet for the interest and call face.putData(data).  If your callback cannot find the Data packet, it can optionally call storePendingInterest(interest, face) to store the pending interest in this object to be satisfied by a later call to add(data). If you want to automatically store all pending interests, you can simply use getStorePendingInterest() for onDataNotFound. If onDataNotFound is null, this does not use it.</param>
 /// <param name="flags">See Face.registerPrefix.</param>
 /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
 /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
 public void registerPrefix(Name prefix,
                            OnRegisterFailed onRegisterFailed,
                            OnInterestCallback onDataNotFound, ForwardingFlags flags)
 {
     registerPrefix(prefix, onRegisterFailed, onDataNotFound, flags,
                    net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
 }
Example #3
0
        /// <summary>
        /// Submit a task to the thread pool to register prefix with the connected
        /// forwarder and call onInterest when a matching interest is received. To
        /// register a prefix with NFD, you must first call setCommandSigningInfo.
        /// </summary>
        ///
        /// <param name="prefix_0">A Name for the prefix to register. This copies the Name.</param>
        /// <param name="onInterest">onInterest.onInterest(prefix, interest, face, interestFilterId, filter). The onInterest callback should supply the Data with face.putData(). NOTE: You must not change the prefix or filter objects - if you need to change them then make a copy. If onInterest is null, it is ignored and you must call setInterestFilter. 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="onRegisterFailed">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="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess is null, this does not use it. (The onRegisterSuccess parameter comes after onRegisterFailed because it can be null or omitted, unlike onRegisterFailed.) 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="flags_1"></param>
        /// <param name="wireFormat_2">A WireFormat object used to encode the message.</param>
        /// <returns>The registered prefix ID which can be used with
        /// removeRegisteredPrefix.</returns>
        public override long registerPrefix(Name prefix_0,
                                            OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed,
                                            OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags_1,
                                            WireFormat wireFormat_2)
        {
            long registeredPrefixId_3 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnInterestCallback finalOnInterest_4  = onInterest;
            OnInterestCallback onInterestSubmit_5 = (onInterest == null) ? null
                                        : new ThreadPoolFace.Anonymous_C6(this, finalOnInterest_4);

            OnRegisterFailed finalOnRegisterFailed_6  = onRegisterFailed;
            OnRegisterFailed onRegisterFailedSubmit_7 = new ThreadPoolFace.Anonymous_C5(this, finalOnRegisterFailed_6);

            // Wrap callbacks to submit to the thread pool.
            OnRegisterSuccess finalOnRegisterSuccess_8  = onRegisterSuccess;
            OnRegisterSuccess onRegisterSuccessSubmit_9 = (onRegisterSuccess == null) ? null
                                        : new ThreadPoolFace.Anonymous_C4(this, finalOnRegisterSuccess_8);

            threadPool_.submit(new ThreadPoolFace.Anonymous_C3(this, wireFormat_2, onRegisterSuccessSubmit_9, prefix_0,
                                                               flags_1, onInterestSubmit_5, onRegisterFailedSubmit_7,
                                                               registeredPrefixId_3));

            return(registeredPrefixId_3);
        }
Example #4
0
 /// <summary>
 /// Call registerPrefix on the Face given to the constructor so that this
 /// MemoryContentCache will answer interests whose name has the prefix.
 /// Alternatively, if the Face's registerPrefix has already been called, then
 /// you can call this object's setInterestFilter.
 /// </summary>
 ///
 /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
 /// <param name="onRegisterFailed">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="onDataNotFound">onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter). Your callback can find the Data packet for the interest and call face.putData(data).  If your callback cannot find the Data packet, it can optionally call storePendingInterest(interest, face) to store the pending interest in this object to be satisfied by a later call to add(data). If you want to automatically store all pending interests, you can simply use getStorePendingInterest() for onDataNotFound. If onDataNotFound 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="flags">See Face.registerPrefix.</param>
 /// <param name="wireFormat">See Face.registerPrefix.</param>
 /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
 /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
 public void registerPrefix(Name prefix,
                            OnRegisterFailed onRegisterFailed,
                            OnInterestCallback onDataNotFound, ForwardingFlags flags,
                            WireFormat wireFormat)
 {
     registerPrefix(prefix, onRegisterFailed, null, onDataNotFound, flags,
                    wireFormat);
 }
Example #5
0
 /// <summary>
 /// Register prefix with the connected NDN hub and call onInterest when a
 /// matching interest is received. To register a prefix with NFD, you must
 /// first call setCommandSigningInfo.
 /// </summary>
 ///
 /// <param name="registeredPrefixId"></param>
 /// <param name="prefix">A Name for the prefix to register. This copies the Name.</param>
 /// <param name="onInterest">onInterest.onInterest(prefix, interest, face, interestFilterId, filter). If onInterest is null, it is ignored and you must call setInterestFilter.</param>
 /// <param name="onRegisterFailed">prefix.</param>
 /// <param name="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess is null, this does not use it.</param>
 /// <param name="flags"></param>
 /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
 /// <param name="commandKeyChain">The KeyChain object for signing interests.</param>
 /// <param name="commandCertificateName">The certificate name for signing interests.</param>
 /// <param name="face"></param>
 /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
 /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
 public void registerPrefix(long registeredPrefixId, Name prefix,
                            OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed,
                            OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags,
                            WireFormat wireFormat, KeyChain commandKeyChain,
                            Name commandCertificateName, Face face)
 {
     nfdRegisterPrefix(registeredPrefixId, new Name(prefix), onInterest,
                       onRegisterFailed, onRegisterSuccess, flags, commandKeyChain,
                       commandCertificateName, wireFormat, face);
 }
Example #6
0
 /// <param name="prefix"></param>
 /// <param name="onRegisterFailed"></param>
 /// <param name="onRegisterSuccess"></param>
 /// <param name="registeredPrefixId"></param>
 /// <param name="onInterest">The callback to add if register succeeds.</param>
 /// <param name="face_0"></param>
 public Info(Name prefix, OnRegisterFailed onRegisterFailed,
             OnRegisterSuccess onRegisterSuccess,
             long registeredPrefixId, OnInterestCallback onInterest,
             Face face_0)
 {
     prefix_             = prefix;
     onRegisterFailed_   = onRegisterFailed;
     onRegisterSuccess_  = onRegisterSuccess;
     registeredPrefixId_ = registeredPrefixId;
     onInterest_         = onInterest;
     face_ = face_0;
 }
        public override long registerPrefix(Name prefix, OnInterestCallback onInterest,
                                            OnRegisterFailed onRegisterFailed,
                                            OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags,
                                            WireFormat wireFormat)
        {
            interestFilterTable_.setInterestFilter(0, new InterestFilter(prefix),
                                                   onInterest, this);

            if (onRegisterSuccess != null)
            {
                onRegisterSuccess.onRegisterSuccess(prefix, 0);
            }
            return(0);
        }
Example #8
0
 public Anonymous_C3(ThreadPoolFace paramouter_ThreadPoolFace,
                     WireFormat wireFormat_0,
                     OnRegisterSuccess onRegisterSuccessSubmit_1, Name prefix_2,
                     ForwardingFlags flags_3, OnInterestCallback onInterestSubmit_4,
                     OnRegisterFailed onRegisterFailedSubmit_5, long registeredPrefixId_6)
 {
     this.wireFormat = wireFormat_0;
     this.onRegisterSuccessSubmit = onRegisterSuccessSubmit_1;
     this.prefix                 = prefix_2;
     this.flags                  = flags_3;
     this.onInterestSubmit       = onInterestSubmit_4;
     this.onRegisterFailedSubmit = onRegisterFailedSubmit_5;
     this.registeredPrefixId     = registeredPrefixId_6;
     this.outer_ThreadPoolFace   = paramouter_ThreadPoolFace;
 }
Example #9
0
        /// <summary>
        /// Call registerPrefix on the Face given to the constructor so that this
        /// MemoryContentCache will answer interests whose name has the prefix.
        /// Alternatively, if the Face's registerPrefix has already been called, then
        /// you can call this object's setInterestFilter.
        /// </summary>
        ///
        /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
        /// <param name="onRegisterFailed">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="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess 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="onDataNotFound">onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter). Your callback can find the Data packet for the interest and call face.putData(data).  If your callback cannot find the Data packet, it can optionally call storePendingInterest(interest, face) to store the pending interest in this object to be satisfied by a later call to add(data). If you want to automatically store all pending interests, you can simply use getStorePendingInterest() for onDataNotFound. If onDataNotFound 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="flags">See Face.registerPrefix.</param>
        /// <param name="wireFormat">See Face.registerPrefix.</param>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public void registerPrefix(Name prefix,
                                   OnRegisterFailed onRegisterFailed,
                                   OnRegisterSuccess onRegisterSuccess,
                                   OnInterestCallback onDataNotFound, ForwardingFlags flags,
                                   WireFormat wireFormat)
        {
            if (onDataNotFound != null)
            {
                ILOG.J2CsMapping.Collections.Collections.Put(onDataNotFoundForPrefix_, prefix.toUri(), onDataNotFound);
            }
            long registeredPrefixId = face_.registerPrefix(prefix, this,
                                                           onRegisterFailed, onRegisterSuccess, flags, wireFormat);

            ILOG.J2CsMapping.Collections.Collections.Add(registeredPrefixIdList_, registeredPrefixId);
        }
Example #10
0
            public Anonymous_C5(ThreadPoolFace paramouter_ThreadPoolFace,
						OnRegisterFailed finalOnRegisterFailed_0)
            {
                this.finalOnRegisterFailed = finalOnRegisterFailed_0;
                    this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
            }
Example #11
0
        /// <summary>
        /// Register prefix with the connected NDN hub and call onInterest when a
        /// matching interest is received. To register a prefix with NFD, you must
        /// first call setCommandSigningInfo.
        /// </summary>
        ///
        /// <param name="registeredPrefixId"></param>
        /// <param name="prefix">A Name for the prefix to register. This copies the Name.</param>
        /// <param name="onInterest">onInterest.onInterest(prefix, interest, face, interestFilterId, filter). If onInterest is null, it is ignored and you must call setInterestFilter.</param>
        /// <param name="onRegisterFailed">prefix.</param>
        /// <param name="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess is null, this does not use it.</param>
        /// <param name="flags"></param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="commandKeyChain">The KeyChain object for signing interests.</param>
        /// <param name="commandCertificateName">The certificate name for signing interests.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public void registerPrefix(long registeredPrefixId, Name prefix,
				OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed,
				OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags,
				WireFormat wireFormat, KeyChain commandKeyChain,
				Name commandCertificateName, Face face)
        {
            nfdRegisterPrefix(registeredPrefixId, new Name(prefix), onInterest,
                    onRegisterFailed, onRegisterSuccess, flags, commandKeyChain,
                    commandCertificateName, wireFormat, face);
        }
Example #12
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);
                }
            }
        }
Example #13
0
        /// <summary>
        /// Register prefix with the connected NDN hub and call onInterest when a
        /// matching interest is received. To register a prefix with NFD, you must
        /// first call setCommandSigningInfo.
        /// This uses the default WireFormat.getDefaultWireFormat().
        /// Use default ForwardingFlags.
        /// </summary>
        ///
        /// <param name="prefix">A Name for the prefix to register. This copies the Name.</param>
        /// <param name="onInterest">onInterest.onInterest(prefix, interest, face, interestFilterId, filter). The onInterest callback should supply the Data with face.putData(). NOTE: You must not change the prefix or filter objects - if you need to change them then make a copy. If onInterest is null, it is ignored and you must call setInterestFilter. 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="onRegisterFailed">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 registered prefix ID which can be used with
        /// removeRegisteredPrefix.</returns>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public long registerPrefix(Name prefix, OnInterestCallback onInterest,
				OnRegisterFailed onRegisterFailed)
        {
            return registerPrefix(prefix, onInterest, onRegisterFailed, null,
                    new ForwardingFlags(), net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
Example #14
0
        /// <summary>
        /// Register prefix with the connected NDN hub and call onInterest when a
        /// matching interest is received. To register a prefix with NFD, you must
        /// first call setCommandSigningInfo.
        /// Use default ForwardingFlags.
        /// </summary>
        ///
        /// <param name="prefix">A Name for the prefix to register. This copies the Name.</param>
        /// <param name="onInterest">onInterest.onInterest(prefix, interest, face, interestFilterId, filter). The onInterest callback should supply the Data with face.putData(). NOTE: You must not change the prefix or filter objects - if you need to change them then make a copy. If onInterest is null, it is ignored and you must call setInterestFilter. 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="onRegisterFailed">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 registered prefix ID which can be used with
        /// removeRegisteredPrefix.</returns>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public long registerPrefix(Name prefix, OnInterestCallback onInterest,
				OnRegisterFailed onRegisterFailed, WireFormat wireFormat)
        {
            return registerPrefix(prefix, onInterest, onRegisterFailed, null,
                    new ForwardingFlags(), wireFormat);
        }
Example #15
0
        public long registerPrefix(Name prefix, OnInterestCallback onInterest,
				OnRegisterSuccess onRegisterSuccess,
				OnRegisterFailed onRegisterFailed, ForwardingFlags flags)
        {
            return registerPrefix(prefix, onInterest, onRegisterFailed,
                    onRegisterSuccess, flags, net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
        /// <summary>
        /// Call registerPrefix on the Face given to the constructor so that this
        /// MemoryContentCache will answer interests whose name has the prefix.
        /// Alternatively, if the Face's registerPrefix has already been called, then
        /// you can call this object's setInterestFilter.
        /// </summary>
        ///
        /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
        /// <param name="onRegisterFailed">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="onDataNotFound">onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter). Your callback can find the Data packet for the interest and call face.putData(data).  If your callback cannot find the Data packet, it can optionally call storePendingInterest(interest, face) to store the pending interest in this object to be satisfied by a later call to add(data). If you want to automatically store all pending interests, you can simply use getStorePendingInterest() for onDataNotFound. If onDataNotFound 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="flags">See Face.registerPrefix.</param>
        /// <param name="wireFormat">See Face.registerPrefix.</param>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public void registerPrefix(Name prefix,
				OnRegisterFailed onRegisterFailed,
				OnInterestCallback onDataNotFound, ForwardingFlags flags,
				WireFormat wireFormat)
        {
            registerPrefix(prefix, onRegisterFailed, null, onDataNotFound, flags,
                    wireFormat);
        }
Example #17
0
        /// <summary>
        /// Register prefix with the connected NDN hub and call onInterest when a
        /// matching interest is received. To register a prefix with NFD, you must
        /// first call setCommandSigningInfo.
        /// </summary>
        ///
        /// <param name="prefix">A Name for the prefix to register. This copies the Name.</param>
        /// <param name="onInterest">onInterest.onInterest(prefix, interest, face, interestFilterId, filter). The onInterest callback should supply the Data with face.putData(). NOTE: You must not change the prefix or filter objects - if you need to change them then make a copy. If onInterest is null, it is ignored and you must call setInterestFilter. 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="onRegisterFailed">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="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess is null, this does not use it. (The onRegisterSuccess parameter comes after onRegisterFailed because it can be null or omitted, unlike onRegisterFailed.) 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="flags"></param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The registered prefix ID which can be used with
        /// removeRegisteredPrefix.</returns>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public virtual long registerPrefix(Name prefix, OnInterestCallback onInterest,
				OnRegisterFailed onRegisterFailed,
				OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags,
				WireFormat wireFormat)
        {
            // Get the registeredPrefixId now so we can return it to the caller.
            long registeredPrefixId = node_.getNextEntryId();

            node_.registerPrefix(registeredPrefixId, prefix, onInterest,
                    onRegisterFailed, onRegisterSuccess, flags, wireFormat,
                    commandKeyChain_, commandCertificateName_, this);

            return registeredPrefixId;
        }
Example #18
0
            public Anonymous_C3(ThreadPoolFace paramouter_ThreadPoolFace,
						OnRegisterSuccess onRegisterSuccessSubmit_0,
						OnRegisterFailed onRegisterFailedSubmit_1, Name prefix_2,
						OnInterestCallback onInterestSubmit_3, ForwardingFlags flags_4,
						WireFormat wireFormat_5, long registeredPrefixId_6)
            {
                this.onRegisterSuccessSubmit = onRegisterSuccessSubmit_0;
                    this.onRegisterFailedSubmit = onRegisterFailedSubmit_1;
                    this.prefix = prefix_2;
                    this.onInterestSubmit = onInterestSubmit_3;
                    this.flags = flags_4;
                    this.wireFormat = wireFormat_5;
                    this.registeredPrefixId = registeredPrefixId_6;
                    this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
            }
Example #19
0
                /// <param name="prefix"></param>
                /// <param name="onRegisterFailed"></param>
                /// <param name="onRegisterSuccess"></param>
                /// <param name="registeredPrefixId"></param>
                /// <param name="onInterest">The callback to add if register succeeds.</param>
                /// <param name="face_0"></param>
                public Info(Name prefix, OnRegisterFailed onRegisterFailed,
						OnRegisterSuccess onRegisterSuccess,
						long registeredPrefixId, OnInterestCallback onInterest,
						Face face_0)
                {
                    prefix_ = prefix;
                    onRegisterFailed_ = onRegisterFailed;
                    onRegisterSuccess_ = onRegisterSuccess;
                    registeredPrefixId_ = registeredPrefixId;
                    onInterest_ = onInterest;
                    face_ = face_0;
                }
        /// <summary>
        /// Call registerPrefix on the Face given to the constructor so that this
        /// MemoryContentCache will answer interests whose name matches the filter.
        /// Alternatively, if the Face's registerPrefix has already been called, then
        /// you can call this object's setInterestFilter.
        /// Do not call a callback if a data packet is not found in the cache.
        /// This uses the default WireFormat.getDefaultWireFormat().
        /// Use default ForwardingFlags.
        /// </summary>
        ///
        /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
        /// <param name="onRegisterFailed">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>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public void registerPrefix(Name prefix,
				OnRegisterFailed onRegisterFailed)
        {
            registerPrefix(prefix, onRegisterFailed, null, new ForwardingFlags(),
                    net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
        /// <summary>
        /// Call registerPrefix on the Face given to the constructor so that this
        /// MemoryContentCache will answer interests whose name has the prefix.
        /// Alternatively, if the Face's registerPrefix has already been called, then
        /// you can call this object's setInterestFilter.
        /// This uses the default WireFormat.getDefaultWireFormat().
        /// Use default ForwardingFlags.
        /// </summary>
        ///
        /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
        /// <param name="onRegisterFailed">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="onDataNotFound">onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter). Your callback can find the Data packet for the interest and call face.putData(data).  If your callback cannot find the Data packet, it can optionally call storePendingInterest(interest, face) to store the pending interest in this object to be satisfied by a later call to add(data). If you want to automatically store all pending interests, you can simply use getStorePendingInterest() for onDataNotFound. If onDataNotFound 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>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public void registerPrefix(Name prefix,
				OnRegisterFailed onRegisterFailed, OnInterestCallback onDataNotFound)
        {
            registerPrefix(prefix, onRegisterFailed, onDataNotFound,
                    new ForwardingFlags(), net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
Example #22
0
        public long registerPrefix(Name prefix, OnInterestCallback onInterest,
				OnRegisterSuccess onRegisterSuccess,
				OnRegisterFailed onRegisterFailed, ForwardingFlags flags,
				WireFormat wireFormat)
        {
            return registerPrefix(prefix, onInterest, onRegisterFailed,
                    onRegisterSuccess, flags, wireFormat);
        }
Example #23
0
 public Anonymous_C5(ThreadPoolFace paramouter_ThreadPoolFace,
                     OnRegisterFailed finalOnRegisterFailed_0)
 {
     this.finalOnRegisterFailed = finalOnRegisterFailed_0;
     this.outer_ThreadPoolFace  = paramouter_ThreadPoolFace;
 }
        /// <summary>
        /// Call registerPrefix on the Face given to the constructor so that this
        /// MemoryContentCache will answer interests whose name has the prefix.
        /// Alternatively, if the Face's registerPrefix has already been called, then
        /// you can call this object's setInterestFilter.
        /// </summary>
        ///
        /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
        /// <param name="onRegisterFailed">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="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess 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="onDataNotFound">onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter). Your callback can find the Data packet for the interest and call face.putData(data).  If your callback cannot find the Data packet, it can optionally call storePendingInterest(interest, face) to store the pending interest in this object to be satisfied by a later call to add(data). If you want to automatically store all pending interests, you can simply use getStorePendingInterest() for onDataNotFound. If onDataNotFound 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="flags">See Face.registerPrefix.</param>
        /// <param name="wireFormat">See Face.registerPrefix.</param>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public void registerPrefix(Name prefix,
				OnRegisterFailed onRegisterFailed,
				OnRegisterSuccess onRegisterSuccess,
				OnInterestCallback onDataNotFound, ForwardingFlags flags,
				WireFormat wireFormat)
        {
            if (onDataNotFound != null)
                ILOG.J2CsMapping.Collections.Collections.Put(onDataNotFoundForPrefix_,prefix.toUri(),onDataNotFound);
            long registeredPrefixId = face_.registerPrefix(prefix, this,
                    onRegisterFailed, onRegisterSuccess, flags, wireFormat);
            ILOG.J2CsMapping.Collections.Collections.Add(registeredPrefixIdList_,registeredPrefixId);
        }
Example #25
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);
                }
            }
        }
Example #26
0
        /// <summary>
        /// Submit a task to the thread pool to register prefix with the connected
        /// forwarder and call onInterest when a matching interest is received. To
        /// register a prefix with NFD, you must first call setCommandSigningInfo.
        /// </summary>
        ///
        /// <param name="prefix_0">A Name for the prefix to register. This copies the Name.</param>
        /// <param name="onInterest">onInterest.onInterest(prefix, interest, face, interestFilterId, filter). The onInterest callback should supply the Data with face.putData(). NOTE: You must not change the prefix or filter objects - if you need to change them then make a copy. If onInterest is null, it is ignored and you must call setInterestFilter. 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="onRegisterFailed">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="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess is null, this does not use it. (The onRegisterSuccess parameter comes after onRegisterFailed because it can be null or omitted, unlike onRegisterFailed.) 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="flags_1"></param>
        /// <param name="wireFormat_2">A WireFormat object used to encode the message.</param>
        /// <returns>The registered prefix ID which can be used with
        /// removeRegisteredPrefix.</returns>
        public override long registerPrefix(Name prefix_0,
				OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed,
				OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags_1,
				WireFormat wireFormat_2)
        {
            long registeredPrefixId_3 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnInterestCallback finalOnInterest_4 = onInterest;
            OnInterestCallback onInterestSubmit_5 = (onInterest == null) ? null
                    : new ThreadPoolFace.Anonymous_C6 (this, finalOnInterest_4);

            OnRegisterFailed finalOnRegisterFailed_6 = onRegisterFailed;
            OnRegisterFailed onRegisterFailedSubmit_7 = new ThreadPoolFace.Anonymous_C5 (this, finalOnRegisterFailed_6);

            // Wrap callbacks to submit to the thread pool.
            OnRegisterSuccess finalOnRegisterSuccess_8 = onRegisterSuccess;
            OnRegisterSuccess onRegisterSuccessSubmit_9 = (onRegisterSuccess == null) ? null
                    : new ThreadPoolFace.Anonymous_C4 (this, finalOnRegisterSuccess_8);

            threadPool_.submit(new ThreadPoolFace.Anonymous_C3 (this, onRegisterSuccessSubmit_9, onRegisterFailedSubmit_7,
                    prefix_0, onInterestSubmit_5, flags_1, wireFormat_2, registeredPrefixId_3));

            return registeredPrefixId_3;
        }