Пример #1
0
 /// <summary>
 /// Create a new ForwardingFlags as a copy of the given value.
 /// </summary>
 ///
 /// <param name="forwardingFlags">The ForwardingFlags to copy.</param>
 public ForwardingFlags(ForwardingFlags forwardingFlags)
 {
     this.childInherit_ = true;
     this.capture_      = false;
     childInherit_      = forwardingFlags.childInherit_;
     capture_           = forwardingFlags.capture_;
 }
Пример #2
0
 /// <summary>
 /// Create a new ForwardingFlags as a copy of the given value.
 /// </summary>
 ///
 /// <param name="forwardingFlags">The ForwardingFlags to copy.</param>
 public ForwardingFlags(ForwardingFlags forwardingFlags)
 {
     this.childInherit_ = true;
     this.capture_ = false;
     childInherit_ = forwardingFlags.childInherit_;
     capture_ = forwardingFlags.capture_;
 }
Пример #3
0
 /// <summary>
 /// Set the ForwardingFlags object to a copy of forwardingFlags. You can use
 /// getForwardingFlags() and change the existing ForwardingFlags object.
 /// </summary>
 ///
 /// <param name="forwardingFlags">The new cost value, or null for not specified.</param>
 /// <returns>This ControlParameters so that you can chain calls to update values.</returns>
 public ControlParameters setForwardingFlags(
     ForwardingFlags forwardingFlags)
 {
     flags_ = (forwardingFlags == null) ? new ForwardingFlags()
                                 : new ForwardingFlags(forwardingFlags);
     return(this);
 }
Пример #4
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);
        }
Пример #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);
 }
Пример #6
0
 /// <summary>
 /// Clear fields and reset to default values.
 /// </summary>
 ///
 public void clear()
 {
     name_   = null;
     faceId_ = -1;
     uri_    = "";
     localControlFeature_ = -1;
     origin_           = -1;
     cost_             = -1;
     flags_            = new ForwardingFlags();
     strategy_         = new Name();
     expirationPeriod_ = -1.0d;
 }
Пример #7
0
 /// <summary>
 /// Create a new ControlParameters where all values are unspecified.
 /// </summary>
 ///
 public ControlParameters()
 {
     this.name_ = null;
     this.faceId_ = -1;
     this.uri_ = "";
     this.localControlFeature_ = -1;
     this.origin_ = -1;
     this.cost_ = -1;
     this.flags_ = new ForwardingFlags();
     this.strategy_ = new Name();
     this.expirationPeriod_ = -1.0d;
 }
Пример #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;
 }
Пример #9
0
 /// <summary>
 /// Create a new ControlParameters as a deep copy of the given controlParameters.
 /// </summary>
 ///
 /// <param name="controlParameters">The ControlParameters to copy.</param>
 public ControlParameters(ControlParameters controlParameters)
 {
     this.name_   = null;
     this.faceId_ = -1;
     this.uri_    = "";
     this.localControlFeature_ = -1;
     this.origin_           = -1;
     this.cost_             = -1;
     this.flags_            = new ForwardingFlags();
     this.strategy_         = new Name();
     this.expirationPeriod_ = -1.0d;
     name_ = (controlParameters.name_ == null) ? null : new Name(
         controlParameters.name_);
     faceId_ = controlParameters.faceId_;
     uri_    = controlParameters.uri_;
     localControlFeature_ = controlParameters.localControlFeature_;
     origin_           = controlParameters.origin_;
     cost_             = controlParameters.cost_;
     flags_            = new ForwardingFlags(controlParameters.flags_);
     strategy_         = new Name(controlParameters.strategy_);
     expirationPeriod_ = controlParameters.expirationPeriod_;
 }
Пример #10
0
 /// <summary>
 /// Clear fields and reset to default values.
 /// </summary>
 ///
 public void clear()
 {
     name_ = null;
     faceId_ = -1;
     uri_ = "";
     localControlFeature_ = -1;
     origin_ = -1;
     cost_ = -1;
     flags_ = new ForwardingFlags();
     strategy_ = new Name();
     expirationPeriod_ = -1.0d;
 }
Пример #11
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;
        }
Пример #12
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().
        /// </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="flags"></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>
        public long registerPrefix(Name prefix, OnInterestCallback onInterest,
				OnRegisterFailed onRegisterFailed, ForwardingFlags flags)
        {
            return registerPrefix(prefix, onInterest, onRegisterFailed, null,
                    flags, net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
Пример #13
0
        /// <summary>
        /// Set the ForwardingFlags object to a copy of forwardingFlags. You can use
        /// getForwardingFlags() and change the existing ForwardingFlags object.
        /// </summary>
        ///
        /// <param name="forwardingFlags">The new cost value, or null for not specified.</param>
        /// <returns>This ControlParameters so that you can chain calls to update values.</returns>
        public ControlParameters setForwardingFlags(
				ForwardingFlags forwardingFlags)
        {
            flags_ = (forwardingFlags == null) ? new ForwardingFlags()
                    : new ForwardingFlags(forwardingFlags);
            return this;
        }
Пример #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.
        /// </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;
        }
Пример #15
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="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 long registerPrefix(Name prefix, OnInterestCallback onInterest,
				OnRegisterFailed onRegisterFailed, ForwardingFlags flags,
				WireFormat wireFormat)
        {
            return registerPrefix(prefix, onInterest, onRegisterFailed, null,
                    flags, wireFormat);
        }
Пример #16
0
 /// <summary>
 /// Create a new ControlParameters as a deep copy of the given controlParameters.
 /// </summary>
 ///
 /// <param name="controlParameters">The ControlParameters to copy.</param>
 public ControlParameters(ControlParameters controlParameters)
 {
     this.name_ = null;
     this.faceId_ = -1;
     this.uri_ = "";
     this.localControlFeature_ = -1;
     this.origin_ = -1;
     this.cost_ = -1;
     this.flags_ = new ForwardingFlags();
     this.strategy_ = new Name();
     this.expirationPeriod_ = -1.0d;
     name_ = (controlParameters.name_ == null) ? null : new Name(
             controlParameters.name_);
     faceId_ = controlParameters.faceId_;
     uri_ = controlParameters.uri_;
     localControlFeature_ = controlParameters.localControlFeature_;
     origin_ = controlParameters.origin_;
     cost_ = controlParameters.cost_;
     flags_ = new ForwardingFlags(controlParameters.flags_);
     strategy_ = new Name(controlParameters.strategy_);
     expirationPeriod_ = controlParameters.expirationPeriod_;
 }
Пример #17
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);
                }
            }
        }
Пример #18
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);
        }
Пример #19
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());
        }
Пример #20
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);
        }
Пример #21
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;
            }
Пример #22
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);
        }
Пример #23
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);
                }
            }
        }
Пример #24
0
        private static void decodeControlParameters(
				ControlParameters controlParameters, TlvDecoder decoder,
				bool copy)
        {
            controlParameters.clear();

            int endOffset = decoder
                    .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_ControlParameters);

            // decode name
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Name, endOffset)) {
                Name name = new Name();
                decodeName(name, new int[1], new int[1], decoder, copy);
                controlParameters.setName(name);
            }

            // decode face ID
            controlParameters.setFaceId((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_FaceId, endOffset));

            // decode URI
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Uri, endOffset)) {
                // Set copy false since we just immediately get the string.
                Blob uri = new Blob(decoder.readOptionalBlobTlv(
                        net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Uri, endOffset), false);
                controlParameters.setUri("" + uri);
            }

            // decode integers
            controlParameters.setLocalControlFeature((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_LocalControlFeature, endOffset));
            controlParameters.setOrigin((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Origin, endOffset));
            controlParameters.setCost((int) decoder
                    .readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Cost,
                            endOffset));

            // set forwarding flags
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Flags, endOffset)) {
                ForwardingFlags flags = new ForwardingFlags();
                flags.setNfdForwardingFlags((int) decoder
                        .readNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Flags));
                controlParameters.setForwardingFlags(flags);
            }

            // decode strategy
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Strategy, endOffset)) {
                int strategyEndOffset = decoder
                        .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Strategy);
                decodeName(controlParameters.getStrategy(), new int[1], new int[1],
                        decoder, copy);
                decoder.finishNestedTlvs(strategyEndOffset);
            }

            // decode expiration period
            controlParameters.setExpirationPeriod(decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_ExpirationPeriod, endOffset));

            decoder.finishNestedTlvs(endOffset);
        }