This module defines the ControlParameters class which holds a Name and other fields for a ControlParameters which is used, for example, in the command interest to register a prefix with a forwarder.
Bases: object
Get the cost value.
Returns: | The cost value, or None if not specified. |
---|---|
Return type: | int |
Get the expiration period.
Returns: | The expiration period in milliseconds, or None if not specified. |
---|---|
Return type: | float |
Get the face ID.
Returns: | The face ID, or None if not specified. |
---|---|
Return type: | int |
Get the ForwardingFlags object.
Returns: | the ForwardingFlags object. |
---|---|
Return type: | ForwardingFlags |
Get the cost value.
Returns: | The cost value, or None if not specified. |
---|---|
Return type: | int |
Get the expiration period.
Returns: | The expiration period in milliseconds, or None if not specified. |
---|---|
Return type: | float |
Get the face ID.
Returns: | The face ID, or None if not specified. |
---|---|
Return type: | int |
Get the ForwardingFlags object.
Returns: | the ForwardingFlags object. |
---|---|
Return type: | ForwardingFlags |
Get the local control feature value.
Returns: | The local control feature value, or None if not specified. |
---|---|
Return type: | int |
Get the origin value.
Returns: | The origin value, or None if not specified. |
---|---|
Return type: | int |
Get the URI.
Returns: | The face URI, or an empty string if not specified. |
---|---|
Return type: | str |
Get the local control feature value.
Returns: | The local control feature value, or None if not specified. |
---|---|
Return type: | int |
Get the name.
Returns: | The name. If not specified, return None. |
---|---|
Return type: | Name |
Get the origin value.
Returns: | The origin value, or None if not specified. |
---|---|
Return type: | int |
Set the cost value.
Parameters: | cost (int) – The new cost value, or None for not specified. |
---|
Set the expiration period.
Parameters: | expirationPeriod (float) – The expiration period in milliseconds, or None for not specified. |
---|
Set the Face ID.
Parameters: | faceId (int) – The new face ID, or None for not specified. |
---|
Set the ForwardingFlags object to a copy of forwardingFlags. You can use getForwardingFlags() and change the existing ForwardingFlags object.
Parameters: | forwardingFlags (ForwardingFlags) – The new ForwardingFlace object. |
---|
Set the local control feature value.
Parameters: | localControlFeature (int) – The new local control feature value, or None for not specified. |
---|
Set the name.
Parameters: | name (Name) – The name. If not specified, set to None. If specified, this makes a copy of the name. |
---|
Set the origin value.
Parameters: | origin (int) – The new origin value, or None for not specified. |
---|
Set the strategy to a copy of the given Name.
Parameters: | strategy (Name) – The Name to copy, or an empty Name if not specified. |
---|
Set the URI.
Parameters: | uri (str) – The new uri, or an empty string for not specified. |
---|
Get the strategy.
Returns: | The strategy or an empty Name. |
---|---|
Return type: | Name |
Get the URI.
Returns: | The face URI, or an empty string if not specified. |
---|---|
Return type: | str |
Decode the input using a particular wire format and update this ControlParameters.
Parameters: |
|
---|
Encode this ControlParameters for a particular wire format.
Parameters: | wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode this ControlParameters. If omitted, use WireFormat.getDefaultWireFormat(). |
---|---|
Returns: | The encoded buffer. |
Return type: | Blob |
This module defines the ControlResponse class which holds a status code, status text and other fields for a ControlResponse which is used, for example, in the response from sending a register prefix control command to a forwarder. See http://redmine.named-data.net/projects/nfd/wiki/ControlCommand
Bases: object
Create a new ControlResponse object, possibly copying values from another object.
Parameters: | value (ControlResponse) – (optional) If value is a ControlResponse, copy its values. If value is omitted, all values are unspecified. |
---|
Get the control response body as a ControlParameters.
Returns: | The ControlParameters, or None if the body is not specified or if it is not a ControlParameters. |
---|---|
Return type: | ControlParameters |
Get the control response body as a ControlParameters.
Returns: | The ControlParameters, or None if the body is not specified or if it is not a ControlParameters. |
---|---|
Return type: | ControlParameters |
Get the status code.
Returns: | The status code. If not specified, return None. |
---|---|
Return type: | int |
Get the status text.
Returns: | The status text. If not specified, return “”. |
---|---|
Return type: | str |
Set the control response body as a ControlParameters.
Parameters: | controlParameters (ControlParameters) – The ControlParameters for the body. This makes a copy of the ControlParameters. If not specified or if the body is not a ControlParameters, set to None. |
---|---|
Returns: | This ControlResponse so that you can chain calls to update values. |
Return type: | ControlResponse |
Set the status code.
Parameters: | statusCode (int) – The status code. If not specified, set to None. |
---|---|
Returns: | This ControlResponse so that you can chain calls to update values. |
Return type: | ControlResponse |
Set the status text.
Parameters: | statusText (str) – The status text. If not specified, set to “”. |
---|---|
Returns: | This ControlResponse so that you can chain calls to update values. |
Return type: | ControlResponse |
Get the status code.
Returns: | The status code. If not specified, return None. |
---|---|
Return type: | int |
Get the status text.
Returns: | The status text. If not specified, return “”. |
---|---|
Return type: | str |
Decode the input using a particular wire format and update this ControlResponse.
Parameters: |
|
---|
Encode this ControlResponse for a particular wire format.
Parameters: | wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode this ControlParameters. If omitted, use WireFormat.getDefaultWireFormat(). |
---|---|
Returns: | The encoded buffer. |
Return type: | Blob |
This module defines the NDN Data class.
Bases: object
Get the data packet’s content.
Returns: | The content as a Blob, which isNull() if unspecified. |
---|---|
Return type: | Blob |
Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Get the data packet’s content.
Returns: | The content as a Blob, which isNull() if unspecified. |
---|---|
Return type: | Blob |
Return the default wire encoding, which was encoded with getDefaultWireEncodingFormat().
Returns: | The default wire encoding, whose isNull() may be true if there is no default wire encoding. |
---|---|
Return type: | SignedBlob |
Get the WireFormat which is used by getDefaultWireEncoding().
Returns: | The WireFormat, which is only meaningful if the getDefaultWireEncoding() is not isNull(). |
---|---|
Return type: | WireFormat |
Get the incoming face ID according to the incoming packet header.
Returns: | The incoming face ID. If not specified, return None. |
---|---|
Return type: | int |
Get the data packet’s signature object.
Returns: | The signature object. |
---|---|
Return type: | a subclass of Signature such as Sha256WithRsaSignature |
Get the data packet’s meta info.
Returns: | The meta info. |
---|---|
Return type: | MetaInfo |
Get the data packet’s name.
Returns: | The name. |
---|---|
Return type: | Name |
Set the content to the given value.
Parameters: | content (A Blob or an array type with int elements) – The array with the content bytes. If content is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
---|
An internal library method to set the LpPacket for an incoming packet. The application should not call this.
Parameters: | lpPacket (LpPacket) – The LpPacket. This does not make a copy. |
---|---|
Returns: | This Data so that you can chain calls to update values. |
Return type: | Data |
Note : | This is an experimental feature. This API may change in the future. |
Set metaInfo to a copy of the given MetaInfo.
Parameters: | metaInfo (MetaInfo) – The MetaInfo which is copied. |
---|---|
Returns: | This Data so that you can chain calls to update values. |
Return type: | Data |
Set name to a copy of the given Name.
Parameters: | name (Name) – The Name which is copied. |
---|---|
Returns: | This Data so that you can chain calls to update values. |
Return type: | Data |
Set the signature to a copy of the given signature.
Parameters: | signature (a subclass of Signature such as Sha256WithRsaSignature) – The signature object which is cloned. |
---|---|
Returns: | This Data so that you can chain calls to update values. |
Return type: | Data |
Get the data packet’s signature object.
Returns: | The signature object. |
---|---|
Return type: | a subclass of Signature such as Sha256WithRsaSignature |
Decode the input using a particular wire format and update this Data. If wireFormat is the default wire format, also set the defaultWireEncoding to another pointer to the input.
Parameters: |
|
---|
Encode this Data for a particular wire format. If wireFormat is the default wire format, also set the defaultWireEncoding field to the encoded result.
Parameters: | wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode this Data object. If omitted, use WireFormat.getDefaultWireFormat(). |
---|---|
Returns: | The encoded buffer in a SignedBlob object. |
Return type: | SignedBlob |
This module defines the DelegationSet class which holds a list of DelegationSet.Delegation entries which is used as the content of a Link instance. If you add elements with add(), then the list is a set sorted by preference number then by name. But wireDecode will add the elements from the wire encoding, preserving the given order and possible duplicates (in which case a DelegationSet really holds a “list” and not necessarily a “set”).
Bases: object
Create a new DelegationSet object, possibly copying values from another object.
Parameters: | value (DelegationSet) – (optional) If value is a DelegationSet, copy its values. |
---|
Bases: object
A DelegationSet.Delegation holds a preference number and delegation name. Create a new DelegationSet.Delegation with the given values.
Parameters: |
|
---|
Compare this Delegation with other according to the ordering, based first on the preference number, then on the delegation name.
Parameters: | other (DelegationSet.Delegation) – The other Delegation to compare with. |
---|---|
Returns: | 0 If they compare equal, -1 if this Delegation comes before other in the ordering, or 1 if this Delegation comes after. |
Return type: | int |
Add a new DelegationSet.Delegation to the list of delegations, sorted by preference number then by name. If there is already a delegation with the same name, update its preference, and remove any extra delegations with the same name.
Parameters: |
|
---|
Add a new DelegationSet.Delegation to the end of the list of delegations, without sorting or updating any existing entries. This is useful for adding preferences from a wire encoding, preserving the supplied ordering and possible duplicates.
Parameters: |
|
---|
Find the first delegation with the given name and return its index.
Parameters: | name (Name) – Then name of the delegation to find. |
---|---|
Returns: | The index of the delegation, or -1 if not found. |
Return type: | int |
Get the delegation at the given index, according to the ordering described in add().
Parameters: | i (int) – The index of the component, starting from 0. |
---|---|
Returns: | The delegation at the index. |
Return type: | DelegationSet.Delegation |
Remove every DelegationSet.Delegation with the given name.
Parameters: | name (Name) – The name to match the name of the delegation(s) to be removed. |
---|---|
Returns: | True if a DelegationSet.Delegation was removed, otherwise False. |
Return type: | bool |
Get the number of delegation entries.
Returns: | The number of delegation entries. |
---|---|
Return type: | int |
Decode the input using a particular wire format and update this DelegationSet.
Parameters: |
|
---|
Encode this DelegationSet for a particular wire format.
Parameters: | wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode this DelegationSet. If omitted, use WireFormat.getDefaultWireFormat(). |
---|---|
Returns: | The encoded buffer. |
Return type: | Blob |
This module defines the DigestSha256Signature class which extends Signature and holds the signature bits (which are only the SHA256 digest) and an empty SignatureInfo for a data packet or signed interest.
Bases: pyndn.signature.Signature
Create a new DigestSha256Signature object, possibly copying values from another object.
Parameters: | value (DigestSha256Signature) – (optional) If value is a DigestSha256Signature, copy its values. If value is omitted, the signature is unspecified. |
---|
Create a new DigestSha256Signature which is a copy of this object.
Returns: | A new object which is a copy of this object. |
---|---|
Return type: | DigestSha256Signature |
Get the change count, which is incremented each time this object is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Get the data packet’s signature bytes (which is the digest).
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
Set the signature bytes (which is the digest) to the given value.
Parameters: | signature (A Blob or an array type with int elements) – The array with the signature bytes. If signature is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
---|
Get the data packet’s signature bytes (which is the digest).
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
Bases: object
Create a new Interest object, possibly copying values from another object.
Parameters: | value (Exclude) – (optional) If value is an Exclude, copy its values. If value is omitted, this creates an object with no entries. |
---|
Bases: object
Create a new Exclude.Entry.
Parameters: | value (Name.Component or a value for the Name.Component constructor) – (optional) If value is omitted, create an Exclude.Entry of type Exclude.ANY. Otherwise creat an Exclude.Entry of type Exclude.COMPONENT with the value. |
---|
Append a new entry of type Exclude.ANY.
Returns: | This Exclude so that you can chain calls to append. |
---|---|
Return type: | Exclude |
Append a new entry of type Exclude.COMPONENT with the give component.
Parameters: | component (Exclude.Entry, Name.Component or a value for the Name.Component constructor) – The new exclude component. |
---|---|
Returns: | This Exclude so that you can chain calls to append. |
Return type: | Exclude |
Compare the components using NDN component ordering. A component is less if it is shorter, otherwise if equal length do a byte comparison.
Parameters: |
|
---|---|
Returns: | -1 if component1 is less than component2, 1 if greater or 0 if equal. |
Return type: | int |
Get the entry at the given index.
Parameters: | i (int) – The index of the entry, starting from 0. |
---|---|
Returns: | The entry at the index. |
Return type: | Exclude.Entry |
Get the change count, which is incremented each time this object is changed.
Returns: | The change count. |
---|---|
Return type: | int |
This module defines the Face class which provides the main methods for NDN communication.
Bases: object
Create a new Face for communication with an NDN hub. This constructor has the forms Face(), Face(transport, connectionInfo) or Face(host, port). If the default Face() constructor is used, if the forwarder’s Unix socket file exists then connect using UnixTransport, otherwise connect to “localhost” on port 6363 using TcpTransport.
Parameters: |
|
---|
Call callback() after the given delay. Even though this is public, it is not part of the public API of Face.This default implementation just calls Node.callLater, but a subclass can override.
Parameters: |
|
---|
Send the Interest through the transport, read the entire response and call onData, onTimeout or onNetworkNack as described below. There are two forms of expressInterest. The first form takes the exact interest (including lifetime): expressInterest(interest, onData [, onTimeout] [, onNetworkNack] [, wireFormat]). The second form creates the interest from a name and optional interest template: expressInterest(name [, interestTemplate], onData [, onTimeout] [, onNetworkNack] [, wireFormat]).
Parameters: |
|
---|---|
Returns: | The pending interest ID which can be used with removePendingInterest. |
Return type: | int |
Throws : | RuntimeError If the encoded interest size exceeds Face.getMaxNdnPacketSize(). |
Get the practical limit of the size of a network-layer packet. If a packet is larger than this, the library or application MAY drop it.
Returns: | The maximum NDN packet size. |
---|---|
Return type: | int |
Check if the face is local based on the current connection through the Transport; some Transport may cause network I/O (e.g. an IP host name lookup).
Returns: | True if the face is local, false if not. |
---|---|
Rtype bool: |
Append a timestamp component and a random value component to interest’s name. Then use the keyChain and certificateName from setCommandSigningInfo to sign the interest. If the interest lifetime is not set, this sets it. :note: This method is an experimental feature. See the API docs for more detail at http://named-data.net/doc/ndn-ccl-api/face.html#face-makecommandinterest-method .
Parameters: |
|
---|
Process any packets to receive and call callbacks such as onData, onInterest or onTimeout. This returns immediately if there is no data to receive. This blocks while calling the callbacks. You should repeatedly call this from an event loop, with calls to sleep as needed so that the loop doesn’t use 100% of the CPU. Since processEvents modifies the pending interest table, your application should make sure that it calls processEvents in the same thread as expressInterest (which also modifies the pending interest table).
Raises : | This may raise an exception for reading data or in the callback for processing the data. If you call this from an main event loop, you may want to catch and log/disregard all exceptions. |
---|
The OnInterest callback calls this to put a Data packet which satisfies an Interest.
Parameters: |
|
---|---|
Throws : | RuntimeError If the encoded Data packet size exceeds getMaxNdnPacketSize(). |
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.
Parameters: |
|
---|---|
Raises : | This raises an exception if setCommandSigningInfo has not been called to set the KeyChain, etc. for signing the command interest. |
Remove the pending interest entry with the pendingInterestId from the pending interest table. This does not affect another pending interest with a different pendingInterestId, even if it has the same interest name. If there is no entry with the pendingInterestId, do nothing.
Parameters: | pendingInterestId (int) – The ID returned from expressInterest. |
---|
Remove the registered prefix entry with the registeredPrefixId from the registered prefix table. This does not affect another registered prefix with a different registeredPrefixId, even if it has the same prefix name. If there is no entry with the registeredPrefixId, do nothing.
Parameters: | registeredPrefixId (int) – The ID returned from registerPrefix. |
---|
Send the encoded packet out through the face.
Parameters: | encoding (Blob or an array type with int elements) – The blob or array with the the encoded packet to send. |
---|---|
Throws : | RuntimeError If the packet size exceeds getMaxNdnPacketSize(). |
Set the certificate name used to sign command interest (e.g. for registerPrefix), using the KeyChain that was set with setCommandSigningInfo.
Parameters: | certificateName (Name) – The certificate name for signing interest. This makes a copy of the Name. |
---|
Set the KeyChain and certificate name used to sign command interests (e.g. for registerPrefix).
Parameters: |
|
---|
Add an entry to the local interest filter table to call the onInterest callback for a matching incoming Interest. This method only modifies the library’s local callback table and does not register the prefix with the forwarder. It will always succeed. To register a prefix with the forwarder, use registerPrefix. There are two forms of setInterestFilter. The first form uses the exact given InterestFilter: setInterestFilter(filter, onInterest). The second form creates an InterestFilter from the given prefix Name: setInterestFilter(prefix, onInterest).
Parameters: |
|
---|---|
Returns: | The interest filter ID which can be used with unsetInterestFilter. |
Return type: | int |
Remove the interest filter entry which has the interestFilterId from the interest filter table. This does not affect another interest filter with a different interestFilterId, even if it has the same prefix name. If there is no entry with the interestFilterId, do nothing.
Parameters: | interestFilterId (int) – The ID returned from setInterestFilter. |
---|
This module defines the ForwardingFlags class which holds the flags which specify how the forwarding daemon should forward an interest for a registered prefix. We use a separate ForwardingFlags object to retain future compatibility if the daemon forwarding bits are changed, amended or deprecated.
Bases: object
Create a new ForwardingFlags object, possibly copying values from another object.
Parameters: | value (ForwardingFlags) – (optional) If value is a ForwardingFlags, copy its values. If value is omitted, the type is the default with “childInherit” True and other flags False. |
---|
This module defines the GenericSignature class which extends Signature and holds the encoding bytes of the SignatureInfo so that the application can process experimental signature types. When decoding a packet, if the type of SignatureInfo is not recognized, the library creates a GenericSignature.
Bases: pyndn.signature.Signature
Create a new GenericSignature object, possibly copying values from another object.
Parameters: | value (GenericSignature) – (optional) If value is a GenericSignature, copy its values. |
---|
Create a new GenericSignature which is a copy of this object.
Returns: | A new object which is a copy of this object. |
---|---|
Return type: | GenericSignature |
Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Get the data packet’s signature bytes.
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
Get the bytes of the entire signature info encoding (including the type code).
Returns: | The encoding bytes. If not specified, the value isNull(). |
---|---|
Return type: | Blob |
Get the type code of the signature type. When wire decode calls setSignatureInfoEncoding, it sets the type code. Note that the type code is ignored during wire encode, which simply uses getSignatureInfoEncoding() where the encoding already has the type code.
:return:The type code, or None if not known. :rtype: int
Set the signature bytes to the given value.
Parameters: | signature (A Blob or an array type with int elements) – The array with the signature bytes. If signature is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
---|
Set the bytes of the entire signature info encoding (including the type code).
Parameters: |
|
---|
Get the type code of the signature type. When wire decode calls setSignatureInfoEncoding, it sets the type code. Note that the type code is ignored during wire encode, which simply uses getSignatureInfoEncoding() where the encoding already has the type code.
:return:The type code, or None if not known. :rtype: int
Get the bytes of the entire signature info encoding (including the type code).
Returns: | The encoding bytes. If not specified, the value isNull(). |
---|---|
Return type: | Blob |
This module defines the HmacWithSha256Signature which extends Signature and holds the signature bits and other info representing an HmacWithSha256 signature in a packet.
Bases: pyndn.signature.Signature
Create a new HmacWithSha256Signature object, possibly copying values from another object.
Parameters: | value (HmacWithSha256Signature) – (optional) If value is a HmacWithSha256Signature, copy its values. If value is omitted, the keyLocator is the default with unspecified values and the signature is unspecified. |
---|
Create a new HmacWithSha256Signature which is a copy of this object.
Returns: | A new object which is a copy of this object. |
---|---|
Return type: | HmacWithSha256Signature |
Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Get the data packet’s signature bytes.
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
Get the key locator.
Returns: | The key locator. |
---|---|
Return type: | KeyLocator |
Set the key locator to a copy of the given keyLocator.
Parameters: | keyLocator (KeyLocator) – The KeyLocator to copy. |
---|
Set the signature bytes to the given value.
Parameters: | signature (A Blob or an array type with int elements) – The array with the signature bytes. If signature is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
---|
Get the data packet’s signature bytes.
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
This module defines the NDN Interest class.
Bases: object
Get the child selector.
Returns: | The child selector, or None if not specified. |
---|---|
Return type: | int |
Get the exclude object.
Returns: | The exclude object. If the exclude size() is zero, then the exclude is not specified. |
---|---|
Return type: | Exclude |
Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Get the child selector.
Returns: | The child selector, or None if not specified. |
---|---|
Return type: | int |
Return the default wire encoding, which was encoded with getDefaultWireEncodingFormat().
Returns: | The default wire encoding, whose isNull() may be true if there is no default wire encoding. |
---|---|
Return type: | SignedBlob |
Get the WireFormat which is used by getDefaultWireEncoding().
Returns: | The WireFormat, which is only meaningful if the getDefaultWireEncoding() is not isNull(). |
---|---|
Return type: | WireFormat |
Get the exclude object.
Returns: | The exclude object. If the exclude size() is zero, then the exclude is not specified. |
---|---|
Return type: | Exclude |
Get the incoming face ID according to the incoming packet header.
Returns: | The incoming face ID. If not specified, return None. |
---|---|
Return type: | int |
Get the interest lifetime.
Returns: | The interest lifetime in milliseconds, or None if not specified. |
---|---|
Return type: | float |
Get the interest key locator.
Returns: | The key locator. If getType() is None, then the key locator is not specified. |
---|---|
Return type: | KeyLocator |
Get the link object. If necessary, decode it from the link wire encoding.
Returns: | The link object, or null if not specified. |
---|---|
Return type: | Link |
Raises ValueError: | |
For error decoding the link wire encoding (if necessary). |
Get the wire encoding of the link object. If there is already a wire encoding then return it. Otherwise encode from the link object (if available).
Parameters: | wireFormat (WireFormat) – (optional) A WireFormat object used to encode the Link. If omitted, use WireFormat.getDefaultWireFormat(). |
---|---|
Returns: | The wire encoding, or an isNull Blob if the link is not specified. |
Return type: | Blob |
Get the max suffix components.
Returns: | The max suffix components, or None if not specified. |
---|---|
Return type: | int |
Get the min suffix components.
Returns: | The min suffix components, or None if not specified. |
---|---|
Return type: | int |
Get the must be fresh flag.
Returns: | The must be fresh flag. If not specified, the default is True. |
---|---|
Return type: | bool |
Get the interest Name.
Returns: | The name. The name size() may be 0 if not specified. |
---|---|
Return type: | Name |
Return the nonce value from the incoming interest. If you change any of the fields in this Interest object, then the nonce value is cleared.
Returns: | The nonce. If isNull() then the nonce is omitted. |
---|---|
Return type: | Blob |
Get the selected delegation index.
Returns: | The selected delegation index. If not specified, return None. |
---|---|
Return type: | int |
Check if this interest has a link object (or a link wire encoding which can be decoded to make the link object).
Returns: | True if this interest has a link object, False if not. |
---|---|
Return type: | bool |
Get the interest lifetime.
Returns: | The interest lifetime in milliseconds, or None if not specified. |
---|---|
Return type: | float |
Get the interest key locator.
Returns: | The key locator. If getType() is None, then the key locator is not specified. |
---|---|
Return type: | KeyLocator |
Check if this interest’s name matches the given name (using Name.match) and the given name also conforms to the interest selectors.
Parameters: | name (Name) – The name to check. |
---|---|
Returns: | True if the name and interest selectors match, False otherwise. |
Return type: | bool |
Get the max suffix components.
Returns: | The max suffix components, or None if not specified. |
---|---|
Return type: | int |
Get the min suffix components.
Returns: | The min suffix components, or None if not specified. |
---|---|
Return type: | int |
Get the must be fresh flag.
Returns: | The must be fresh flag. If not specified, the default is True. |
---|---|
Return type: | bool |
Get the interest Name.
Returns: | The name. The name size() may be 0 if not specified. |
---|---|
Return type: | Name |
Return the nonce value from the incoming interest. If you change any of the fields in this Interest object, then the nonce value is cleared.
Returns: | The nonce. If isNull() then the nonce is omitted. |
---|---|
Return type: | Blob |
Update the bytes of the nonce with new random values. This ensures that the new nonce value is different than the current one. If the current nonce is not specified, this does nothing.
Set the child selector.
Parameters: | childSelector (int) – The child selector. If not specified, set to None. |
---|---|
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Set this interest to use a copy of the given Exclude object.
Note : | You can also call getExclude and change the exclude entries directly. |
---|---|
Parameters: | exclude (Exclude) – The Exclude object. This makes a copy of the object. If no exclude is specified, set to a new default Exclude(), or to an Exclude with size() 0. |
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Set the interest lifetime.
Parameters: | interestLifetimeMilliseconds (float) – The interest lifetime in milliseconds. If not specified, set to -1. |
---|---|
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Set this interest to use a copy of the given KeyLocator object.
Note : | You can also call getKeyLocator and change the key locator directly. |
---|---|
Parameters: | keyLocator (KeyLocator) – The KeyLocator object. This makes a copy of the object. If no key locator is specified, set to a new default KeyLocator(), or to a KeyLocator with an unspecified type. |
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Set the link wire encoding bytes, without decoding them. If there is a link object, set it to null. If you later call getLink(), it will decode the wireEncoding to create the link object.
Parameters: |
|
---|---|
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
An internal library method to set the LpPacket for an incoming packet. The application should not call this.
Parameters: | lpPacket (LpPacket) – The LpPacket. This does not make a copy. |
---|---|
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Note : | This is an experimental feature. This API may change in the future. |
Set the max suffix components count.
Parameters: | maxSuffixComponents (int) – The max suffix components count. If not specified, set to None. |
---|---|
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Set the min suffix components count.
Parameters: | minSuffixComponents (int) – The min suffix components count. If not specified, set to None. |
---|---|
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Set the MustBeFresh flag.
Parameters: | mustBeFresh (bool) – True if the content must be fresh, otherwise False. If you do not set this flag, the default value is true. |
---|---|
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Set the interest name.
Note : | You can also call getName and change the name values directly. |
---|---|
Parameters: | name (Name) – The interest name. This makes a copy of the name. |
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Deprecated : | You should let the wire encoder generate a random nonce |
---|
internally before sending the interest.
Set the selected delegation index.
Parameters: | selectedDelegationIndex (int) – The selected delegation index. If not specified, set to None. |
---|---|
Returns: | This Interest so that you can chain calls to update values. |
Return type: | Interest |
Encode the name according to the “NDN URI Scheme”. If there are interest selectors, append ”?” and add the selectors as a query string. For example “/test/name?ndn.ChildSelector=1”. :note: This is an experimental feature. See the API docs for more detail at http://named-data.net/doc/ndn-ccl-api/interest.html#interest-touri-method .
Returns: | The URI string. |
---|---|
Return type: | string |
Clear the link wire encoding and link object so that getLink() returns None.
Returns: | This Interest so that you can chain calls to update values. |
---|---|
Return type: | Interest |
Decode the input using a particular wire format and update this Interest. If wireFormat is the default wire format, also set the defaultWireEncoding to another pointer to the input.
Parameters: |
|
---|
Encode this Interest for a particular wire format. If wireFormat is the default wire format, also set the defaultWireEncoding field to the encoded result.
Parameters: | wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode this Interest. If omitted, use WireFormat.getDefaultWireFormat(). |
---|---|
Returns: | The encoded buffer. |
Return type: | SignedBlob |
This module defines the InterestFilter class which holds a Name prefix and optional regex match expression for use in Face.setInterestFilter.
Bases: object
Create an InterestFilter to match any Interest whose name starts with the given prefix. If the optional regexFilter is provided then the remaining components match the regexFilter regular expression as described in doesMatch.
Parameters: |
|
---|
Check if the given name matches this filter. Match if name starts with this filter’s prefix. If this filter has the optional regexFilter then the remaining components match the regexFilter regular expression. For example, the following InterestFilter:
InterestFilter(“/hello”, “<world><>+”)
will match all Interests, whose name has the prefix /hello which is followed by a component world and has at least one more component after it. Examples:
/hello/world/! /hello/world/x/y/z
Note that the regular expression will need to match all remaining components (e.g., there are implicit heading ^ and trailing $ symbols in the regular expression).
Parameters: | name (Name) – The name to check against this filter. |
---|---|
Returns: | True if name matches this filter, otherwise False. |
Return type: | bool |
Get the prefix given to the constructor.
Returns: | The prefix Name which you should not modify. |
---|---|
Return type: | Name |
Get the regex filter. This is only valid if hasRegexFilter() is True.
Returns: | The regular expression for matching the remaining name components. |
---|---|
Return type: | str |
This module defines the KeyLocator class which represents an NDN KeyLocator which is used in a Sha256WithRsaSignature and Interest selectors.
Bases: object
Create a new KeyLocator object, possibly copying values from another object.
Parameters: | value (KeyLocator) – (optional) If value is a KeyLocator, copy its values. If value is omitted, set the fields to unspecified. |
---|
If the signature is a type that has a KeyLocator (so that getFromSignature will succeed), return true. Note: This is a static method of KeyLocator instead of a method of Signature so that the Signature base class does not need to be overloaded with all the different kinds of information that various signature algorithms may use.
Parameters: | signature (Signature) – An object of a subclass of Signature. |
---|---|
Returns: | True if the signature is a type that has a KeyLocator, otherwise False. |
Return type: | bool |
Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: | The change count. |
---|---|
Return type: | int |
If the signature is a type that has a KeyLocator, then return it. Otherwise throw an error.
Parameters: | signature (Signature) – An object of a subclass of Signature. |
---|---|
Returns: | The signature’s KeyLocator. It is an error if signature doesn’t have a KeyLocator. |
Return type: | KeyLocator |
Get the key data. This is the digest bytes if getType() is KeyLocatorType.KEY_LOCATOR_DIGEST.
Returns: | The key data as a Blob, which isNull() if unspecified. |
---|---|
Return type: | Blob |
Get the key name. This is meaningful if getType() is KeyLocatorType.KEYNAME.
Returns: | The key name. If not specified, the Name is empty. |
---|---|
Return type: | Name |
Get the key locator type. If KeyLocatorType.KEYNAME, you may also getKeyName(). If KeyLocatorType.KEY_LOCATOR_DIGEST, you may also getKeyData() to get the digest.
Returns: | The key locator type, or None if not specified. |
---|---|
Return type: | an int from KeyLocatorType |
Get the key data. This is the digest bytes if getType() is KeyLocatorType.KEY_LOCATOR_DIGEST.
Returns: | The key data as a Blob, which isNull() if unspecified. |
---|---|
Return type: | Blob |
Get the key name. This is meaningful if getType() is KeyLocatorType.KEYNAME.
Returns: | The key name. If not specified, the Name is empty. |
---|---|
Return type: | Name |
Set the key data to the given value. This is the digest bytes if getType() is KeyLocatorType.KEY_LOCATOR_DIGEST.
Parameters: | keyData (A Blob or an array type with int elements) – The array with the key data bytes. If keyData is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
---|
Set key name to a copy of the given Name. This is the name if getType() is KeyLocatorType.KEYNAME.
Parameters: | keyName (Name) – The key name which is copied. |
---|
Set the key locator type. If KeyLocatorType.KEYNAME, you must also setKeyName(). If KeyLocatorType.KEY_LOCATOR_DIGEST, you must also setKeyData() to set the digest.
Parameters: | type (an int from KeyLocatorType) – The key locator type. If None, the type is unspecified. |
---|
Get the key locator type. If KeyLocatorType.KEYNAME, you may also getKeyName(). If KeyLocatorType.KEY_LOCATOR_DIGEST, you may also getKeyData() to get the digest.
Returns: | The key locator type, or None if not specified. |
---|---|
Return type: | an int from KeyLocatorType |
This module defines the Link class which extends Data and represents a Link instance where the Data content is an encoded delegation set. The format is defined in “link.pdf” attached to Redmine issue http://redmine.named-data.net/issues/2587 .
Bases: pyndn.data.Data
Add a new delegation to the list of delegations, sorted by preference number then by name. Re-encode this object’s content using the optional wireFormat.
Parameters: |
|
---|---|
Returns: | This Link so that you can chain calls to update values. |
Return type: | Link |
A private method to encode the delegations and set this object’s content. Also set the meta info content type to LINK.
Parameters: | wireFormat (WireFormat) – A WireFormat object used to encode the DelegationSet. |
---|
Get the list of delegation for read only.
Returns: | The list of delegation, which you should treat as read-only. To modify it, call Link.addDelegation, etc. |
---|---|
Return type: | DelegationSet |
Remove every delegation with the given name. Re-encode this object’s content using the optional wireFormat.
Parameters: |
|
---|---|
Returns: | True if a delegation was removed, otherwise False. |
Return type: | bool |
Override to call the base class wireDecode then populate the list of delegations from the content.
Parameters: |
|
---|
This module defines the MetaInfo class which is used by Data and represents the fields of an NDN MetaInfo.
Bases: object
A ContentType specifies the content type in a MetaInfo object.
Bases: object
Create a new MetaInfo object, possibly copying values from another object.
Parameters: | value (MetaInfo) – (optional) If value is a MetaInfo, copy its values. If value is omitted, the type is the default ContentType.BLOB and the freshness period is not specified. |
---|
Deprecated : | Use getFinalBlockId. |
---|
Get the final block ID.
Returns: | The final block ID as a Name.Component. If the Name.Component getValue().size() is 0, then the final block ID is not specified. |
---|---|
Return type: | Name.Component |
Get the freshness period.
Returns: | The freshness period in milliseconds, or None if not specified. |
---|---|
Return type: | float |
Get the change count, which is incremented each time this object is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Get the final block ID.
Returns: | The final block ID as a Name.Component. If the Name.Component getValue().size() is 0, then the final block ID is not specified. |
---|---|
Return type: | Name.Component |
Get the freshness period.
Returns: | The freshness period in milliseconds, or None if not specified. |
---|---|
Return type: | float |
Get the content type.
Returns: | The content type. |
---|---|
Return type: | an int from ContentType |
Set the final block ID.
Parameters: | finalBlockId (Name.Component or value for the Name.Component constructor) – The final block ID. If it is another Name.Component, use its value. Otherwise pass value to the Name.Component constructor. If finalBlockId is None, set to a Name.Component of size 0 so that the finalBlockId is not specified and not encoded. |
---|
Set the freshness period.
Parameters: | freshnessPeriod (float) – The freshness period in milliseconds, or None for not specified. |
---|
Set the content type.
Parameters: | type (an int from ContentType) – The content type. If None, this uses ContentType.BLOB. |
---|
Get the content type.
Returns: | The content type. |
---|---|
Return type: | an int from ContentType |
This module defines the NDN Name class.
Bases: object
Create a new Name which holds an array of Name.Component and represents an NDN name.
Parameters: | value (Name or str) – (optional) If value is another Name, then copy it. If value is a str then call set(value) to create from the URI. If ommitted, create an empty name. |
---|
Bases: object
Create a new Name.Component.
Parameters: | value (Blob or Name.Component or value for Blob constructor) – (optional) If value is already a Blob or Name.Component, then take another pointer to the value. Otherwise, create a new Blob with a copy of the value. If omitted, create an empty component. |
---|
Compare this to the other Component using NDN canonical ordering.
Parameters: | other (Name.Component) – The other Component to compare with. |
---|---|
Returns: | 0 If they compare equal, -1 if self comes before other in the canonical ordering, or 1 if self comes after other in the canonical ordering. |
Return type: | int |
See : | http://named-data.net/doc/0.2/technical/CanonicalOrder.html |
Check if this is the same component as other.
Parameters: | other (Name.Component) – The other Component to compare with. |
---|---|
Returns: | True if the components are equal, otherwise False. |
Return type: | bool |
Create a component whose value is the nonNegativeInteger encoding of the number.
Parameters: | number (int) – The number to be encoded. |
---|---|
Returns: | The component value. |
Return type: | Name.Component |
Create a component whose value is the marker appended with the nonNegativeInteger encoding of the number.
Parameters: |
|
---|---|
Returns: | The component value. |
Return type: | Name.Component |
Create a component with the encoded segment number according to NDN naming conventions for “Segment number” (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters: | segment (int) – The segment number. |
---|---|
Returns: | The new Component. |
Return type: | Name.Component |
Create a component with the encoded segment byte offset according to NDN naming conventions for segment “Byte offset” (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters: | segmentOffset (int) – The segment byte offset. |
---|---|
Returns: | The new Component. |
Return type: | Name.Component |
Create a component with the encoded sequence number according to NDN naming conventions for “Sequencing” (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters: | sequenceNumber (int) – The sequence number. |
---|---|
Returns: | The new Component. |
Return type: | Name.Component |
Create a component with the encoded timestamp according to NDN naming conventions for “Timestamp” (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters: | timestamp (int) – The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds. |
---|---|
Returns: | The new Component. |
Return type: | Name.Component |
Create a component with the encoded version number according to NDN naming conventions for “Versioning” (marker 0xFD). http://named-data.net/doc/tech-memos/naming-conventions.pdf Note that this encodes the exact value of version without converting from a time representation.
Parameters: | version (int) – The version number. |
---|---|
Returns: | The new Component. |
Return type: | Name.Component |
Get the successor of this component, as described in Name.getSuccessor.
Returns: | A new Name.Component which is the successor of this. |
---|---|
Return type: | Name.Component |
Check if this component is a segment number according to NDN naming conventions for “Segment number” (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | True if this is a segment number. |
---|---|
Return type: | bool |
Check if this component is a segment byte offset according to NDN naming conventions for segment “Byte offset” (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | True if this is a segment byte offset. |
---|---|
Return type: | bool |
Check if this component is a sequence number according to NDN naming conventions for “Sequencing” (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | True if this is a sequence number. |
---|---|
Return type: | bool |
Check if this component is a timestamp according to NDN naming conventions for “Timestamp” (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | True if this is a timestamp. |
---|---|
Return type: | bool |
Check if this component is a version number according to NDN naming conventions for “Versioning” (marker 0xFD). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | True if this is a version number. |
---|---|
Return type: | bool |
Convert this component to a string, escaping characters according to the NDN URI Scheme. This also adds ”...” to a value with zero or more ”.”.
Parameters: | result (BytesIO) – (optional) The BytesIO stream to write to. If omitted, return a str with the result. |
---|---|
Returns: | The result as a string (only if result is omitted). |
Return type: | str |
Interpret this name component as a network-ordered number and return an integer.
Returns: | The integer number. |
---|---|
Return type: | int |
Interpret this name component as a network-ordered number with a marker and return an integer.
Parameters: | marker (int) – The required first byte of the component. |
---|---|
Returns: | The integer number. |
Return type: | int |
Raises RuntimeError: | |
If the first byte of the component does not equal the marker. |
Interpret this name component as a segment number according to NDN naming conventions for “Segment number” (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | The integer segment number. |
---|---|
Return type: | int |
Raises RuntimeError: | |
If the first byte of the component is not the expected marker. |
Interpret this name component as a segment byte offset according to NDN naming conventions for segment “Byte offset” (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | The integer segment byte offset. |
---|---|
Return type: | int |
Raises RuntimeError: | |
If the first byte of the component is not the expected marker. |
Interpret this name component as a sequence number according to NDN naming conventions for “Sequencing” (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | The integer sequence number. |
---|---|
Return type: | int |
Raises RuntimeError: | |
If the first byte of the component is not the expected marker. |
Interpret this name component as a timestamp according to NDN naming conventions for “Timestamp” (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds. |
---|---|
Return type: | int |
Raises RuntimeError: | |
If the first byte of the component is not the expected marker. |
Interpret this name component as a version number according to NDN naming conventions for “Versioning” (marker 0xFD). Note that this returns the exact number from the component without converting it to a time representation. http://named-data.net/doc/tech-memos/naming-conventions.pdf
Returns: | The integer version number. |
---|---|
Return type: | int |
Raises RuntimeError: | |
If the first byte of the component is not the expected marker. |
Append a new component.
Parameters: | value (Name, Name.Component or value for Name.Component constructor) – If value is another Name, append all its components. If value is another Name.Component, use its value. Otherwise pass value to the Name.Component constructor. |
---|
Append a component with the encoded segment number according to NDN naming conventions for “Segment number” (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters: | segment (int) – The segment number. |
---|---|
Returns: | This name so that you can chain calls to append. |
Return type: | Name |
Append a component with the encoded segment byte offset according to NDN naming conventions for segment “Byte offset” (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters: | segmentOffset (int) – The segment byte offset. |
---|---|
Returns: | This name so that you can chain calls to append. |
Return type: | Name |
Append a component with the encoded sequence number according to NDN naming conventions for “Sequencing” (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters: | sequenceNumber (int) – The sequence number. |
---|---|
Returns: | This name so that you can chain calls to append. |
Return type: | Name |
Append a component with the encoded timestamp according to NDN naming conventions for “Timestamp” (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters: | timestamp (int) – The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds. |
---|---|
Returns: | This name so that you can chain calls to append. |
Return type: | Name |
Append a component with the encoded version number according to NDN naming conventions for “Versioning” (marker 0xFD). http://named-data.net/doc/tech-memos/naming-conventions.pdf Note that this encodes the exact value of version without converting from a time representation.
Parameters: | version (int) – The version number. |
---|---|
Returns: | This name so that you can chain calls to append. |
Return type: | Name |
Compare this to the other Name using NDN canonical ordering. If the first components of each name are not equal, this returns -1 if the first comes before the second using the NDN canonical ordering for name components, or 1 if it comes after. If they are equal, this compares the second components of each name, etc. If both names are the same up to the size of the shorter name, this returns -1 if the first name is shorter than the second or 1 if it is longer. For example, sorted gives: /a/b/d /a/b/cc /c /c/a /bb . This is intuitive because all names with the prefix /a are next to each other. But it may be also be counter-intuitive because /c comes before /bb according to NDN canonical ordering since it is shorter. The first form of compare is simply compare(other). The second form is compare(iStartComponent, nComponents, other [, iOtherStartComponent] [, nOtherComponents]) which is equivalent to self.getSubName(iStartComponent, nComponents).compare (other.getSubName(iOtherStartComponent, nOtherComponents)) .
Parameters: |
|
---|---|
Returns: | 0 If they compare equal, -1 if self comes before other in the canonical ordering, or 1 if self comes after other in the canonical ordering. |
Return type: | int |
See : |
Check if this name has the same component count and components as the given name.
Parameters: | name (Name) – |
---|---|
Returns: | True if the names are equal, otherwise False. |
Return type: | bool |
Make a Blob value by decoding the escapedString between beginOffset and endOffset according to the NDN URI Scheme. (If offsets are omitted, then decode the whole string.) If the escaped string is “”, ”.” or ”..” then return a Blob with a null pointer, which means the component should be skipped in a URI name.
Parameters: | escapedString (str) – The escaped string. |
---|---|
Returns: | The unescaped Blob value. If the escapedString is not a valid escaped component, then the Blob isNull(). |
Get the component at the given index.
Parameters: | i (int) – The index of the component, starting from 0. However, if i is negative, return the component at size() - (-i). |
---|
Get the change count, which is incremented each time this object is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Return a new Name with the first nComponents components of this Name.
Parameters: | nComponents (int) – The number of prefix components. If nComponents is -N then return the prefix up to name.size() - N. For example getPrefix(-1) returns the name without the final component. |
---|---|
Returns: | The name prefix. |
Return type: | Name |
Get a new name, constructed as a subset of components.
Parameters: |
|
---|---|
Returns: | A new name. |
Return type: | Name |
Get the successor of this name which is defined as follows.
N represents the set of NDN Names, and X,Y in N. Operator < is defined by the NDN canonical order on N. Y is the successor of X, if (a) X < Y, and (b) not exists Z in N s.t. X < Z < Y.
In plain words, the successor of a name is the same name, but with its last component advanced to a next possible value.
Examples:
Returns: | A new name which is the successor of this. |
---|---|
Return type: | Name |
Check if the N components of this name are the same as the first N components of the given name.
Parameters: | name (Name) – The Name to check. |
---|---|
Returns: | True if this matches the given name, otherwise False. This always returns True if this name is empty. |
Return type: | bool |
Check if the N components of this name are the same as the first N components of the given name.
Parameters: | name (Name) – The Name to check. |
---|---|
Returns: | True if this matches the given name, otherwise False. This always returns True if this name is empty. |
Return type: | bool |
Parse the uri according to the NDN URI Scheme and set the name with the components.
Parameters: | uri (str) – The URI string. |
---|
Get the number of components.
Returns: | The number of components. |
---|---|
Return type: | int |
Convert value to a string, escaping characters according to the NDN URI Scheme. This also adds ”...” to a value with zero or more ”.”.
Parameters: |
|
---|---|
Returns: | The result as a string (only if result is omitted). |
Return type: | str |
Encode this name as a URI according to the NDN URI Scheme.
Parameters: | includeScheme (bool) – (optional) If True, include the “ndn:” scheme in the URI, e.g. “ndn:/example/name”. If False, just return the path, e.g. “/example/name”. If ommitted, then just return the path which is the default case where toUri() is used for display. |
---|---|
Returns: | The encoded URI. |
Return type: | str |
Decode the input using a particular wire format and update this Name.
Parameters: |
|
---|
This module defines the NetworkNack class which represents a network Nack packet and includes a Nack reason.
Bases: object
Bases: object
A NetworkNack.Reason specifies the reason in a NetworkNack packet. If the reason code in the packet is not a recognized enum value, then we use Reason.OTHER_CODE and you can call getOtherReasonCode(). We do this to keep the recognized reason values independent of packet encoding formats.
Get the first header field in lpPacket which is a NetworkNack. This is an internal method which the application normally would not use.
Parameters: | lpPacket (LpPacket) – The LpPacket with the header fields to search. |
---|---|
Returns: | The first NetworkNack header field, or None if not found. |
Return type: | NetworkNack |
Get the reason code from the packet which is other than a recognized Reason enum value. This is only meaningful if getReason() is Reason.OTHER_CODE.
Returns: | The reason code. |
---|---|
Return type: | int |
Get the network Nack reason.
Returns: | The reason enum value. If this is Reason.OTHER_CODE, then call getOtherReasonCode() to get the unrecognized reason code. |
---|---|
Return type: | an int from NetworkNack.Reason |
This module defines the Node class which provides functionality for the Face class.
Bases: object
Create a new Node for communication with an NDN hub with the given Transport object and connectionInfo.
Parameters: |
|
---|
Call callback() after the given delay. This adds to self._delayedCallTable which is used by processEvents().
Parameters: |
|
---|
Send the Interest through the transport, read the entire response and call onData, onTimeout or onNetworkNack as described below.
Parameters: |
|
---|---|
Throws : | RuntimeError If the encoded interest size exceeds getMaxNdnPacketSize(). |
Get the connectionInfo object given to the constructor.
Returns: | The connectionInfo object. |
---|---|
Return type: | Transport.ConnectionInfo |
Get the practical limit of the size of a network-layer packet. If a packet is larger than this, the library or application MAY drop it.
Returns: | The maximum NDN packet size. |
---|---|
Return type: | int |
Get the next unique entry ID for the pending interest table, interest filter table, etc. This uses a threading.Lock() to be thread safe. Most entry IDs are for the pending interest table (there usually are not many interest filter table entries) so we use a common pool to only have to do the thread safe lock in one method which is called by Face.
Returns: | The next entry ID. |
---|---|
Return type: | int |
Get the transport object given to the constructor.
Returns: | The transport object. |
---|---|
Return type: | Transport |
Check if the face is local based on the current connection through the Transport; some Transport may cause network I/O (e.g. an IP host name lookup).
Returns: | True if the face is local, False if not. |
---|---|
Rtype bool: |
Append a timestamp component and a random value component to interest’s name. Then use the keyChain and certificateName to sign the interest. If the interest lifetime is not set, this sets it.
Parameters: |
|
---|
This is called by the transport’s ElementReader to process an entire received Data or Interest element.
Parameters: | element (An array type with int elements) – The bytes of the incoming element. |
---|
Process any packets to receive and call callbacks such as onData, onInterest or onTimeout. This returns immediately if there is no data to receive. This blocks while calling the callbacks. You should repeatedly call this from an event loop, with calls to sleep as needed so that the loop doesn’t use 100% of the CPU. Since processEvents modifies the pending interest table, your application should make sure that it calls processEvents in the same thread as expressInterest (which also modifies the pending interest table).
Raises : | This may raise an exception for reading data or in the callback for processing the data. If you call this from an main event loop, you may want to catch and log/disregard all exceptions. |
---|
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.
Parameters: |
|
---|
Remove the pending interest entry with the pendingInterestId from the pending interest table. This does not affect another pending interest with a different pendingInterestId, even if it has the same interest name. If there is no entry with the pendingInterestId, do nothing.
Parameters: | pendingInterestId (int) – The ID returned from expressInterest. |
---|
Remove the registered prefix entry with the registeredPrefixId from the registered prefix table. This does not affect another registered prefix with a different registeredPrefixId, even if it has the same prefix name. If an interest filter was automatically created by registerPrefix, also remove it. If there is no entry with the registeredPrefixId, do nothing.
Parameters: | registeredPrefixId (int) – The ID returned from registerPrefix. |
---|
Send the encoded packet out through the transport.
Parameters: | encoding (An array type with int elements) – The array of bytes for the encoded packet to send. |
---|---|
Throws : | RuntimeError If the packet size exceeds getMaxNdnPacketSize(). |
Add an entry to the local interest filter table to call the onInterest callback for a matching incoming Interest. This method only modifies the library’s local callback table and does not register the prefix with the forwarder. It will always succeed. To register a prefix with the forwarder, use registerPrefix.
Parameters: |
|
---|
Remove the interest filter entry which has the interestFilterId from the interest filter table. This does not affect another interest filter with a different interestFilterId, even if it has the same prefix name. If there is no entry with the interestFilterId, do nothing.
Parameters: | interestFilterId (int) – The ID returned from setInterestFilter. |
---|
This module defines the Sha256WithEcdsaSignature class which extends Signature and holds the signature bits and other info representing a SHA256-with-ECDSA signature in a data packet.
Bases: pyndn.signature.Signature
Create a new Sha256WithEcdsaSignature object, possibly copying values from another object.
Parameters: | value (Sha256WithEcdsaSignature) – (optional) If value is a Sha256WithEcdsaSignature, copy its values. If value is omitted, the keyLocator is the default with unspecified values and the signature is unspecified. |
---|
Create a new Sha256WithEcdsaSignature which is a copy of this object.
Returns: | A new object which is a copy of this object. |
---|---|
Return type: | Sha256WithEcdsaSignature |
Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Get the data packet’s signature bytes.
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
Get the key locator.
Returns: | The key locator. |
---|---|
Return type: | KeyLocator |
Set the key locator to a copy of the given keyLocator.
Parameters: | keyLocator (KeyLocator) – The KeyLocator to copy. |
---|
Set the signature bytes to the given value.
Parameters: | signature (A Blob or an array type with int elements) – The array with the signature bytes. If signature is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
---|
Get the data packet’s signature bytes.
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
This module defines the Sha256WithRsaSignature class which extends Signature and holds the signature bits and other info representing a SHA256-with-RSA signature in a data packet.
Bases: pyndn.signature.Signature
Create a new Sha256WithRsaSignature object, possibly copying values from another object.
Parameters: | value (Sha256WithRsaSignature) – (optional) If value is a Sha256WithRsaSignature, copy its values. If value is omitted, the keyLocator is the default with unspecified values and the signature is unspecified. |
---|
Create a new Sha256WithRsaSignature which is a copy of this object.
Returns: | A new object which is a copy of this object. |
---|---|
Return type: | Sha256WithRsaSignature |
Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: | The change count. |
---|---|
Return type: | int |
Get the data packet’s signature bytes.
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
Get the key locator.
Returns: | The key locator. |
---|---|
Return type: | KeyLocator |
Set the key locator to a copy of the given keyLocator.
Parameters: | keyLocator (KeyLocator) – The KeyLocator to copy. |
---|
Set the signature bytes to the given value.
Parameters: | signature (A Blob or an array type with int elements) – The array with the signature bytes. If signature is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
---|
Get the data packet’s signature bytes.
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
This module defines the Signature class which is an abstract base class providing methods to work with the signature information in an NDN Data packet. You must use an object of a subclass, for example Sha256WithRsaSignature.
Bases: object
Create a new Signature which is a copy of this signature. Your derived class should override.
Returns: | A new object which is a copy of this object. |
---|---|
Return type: | A subclass of Signature |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Get the change count, which is incremented each time this object (or a child object) is changed. Your derived class should override.
Returns: | The change count. |
---|---|
Return type: | int |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Get the data packet’s signature bytes. Your derived class should override.
Returns: | The signature bytes as a Blob, which maybe isNull(). |
---|---|
Return type: | Blob |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Set the signature bytes to the given value. Your derived class should override.
Parameters: | signature (A Blob or an array type with int elements) – The array with the signature bytes. If signature is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
---|---|
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
This module defines the ThreadsafeFace class which extends Face to provide the main methods for NDN communication in a thread-safe manner.
Bases: pyndn.face.Face
Create a new ThreadsafeFace to use the asyncio loop to process events and schedule communication calls. You must start the loop on the thread in which you want the library to call communication callbacks such as onData and onInterest. In Python <= 3.2, you must have the prerequisite Trollius library. See the INSTALL file for installation details. For usage, see the example test_get_async_threadsafe.py. This constructor has the forms ThreadsafeFace(loop), ThreadsafeFace(loop, transport, connectionInfo) or ThreadsafeFace(loop, host, port). If the default Face(loop) constructor is used, if the forwarder’s Unix socket file exists then connect using AsyncUnixTransport, otherwise connect to “localhost” on port 6363 using AsyncTcpTransport. You do not need to call processEvents since the asyncio loop does all processing. (Exception: If you pass a transport that is not an async transport like AsyncTcpTransport, then your application needs to call processEvents.)
Parameters: |
|
---|
Override to call callback() after the given delay, using self._loop.call_later. This means that processEvents() is not needed to handle interest timeouts. Even though this is public, it is not part of the public API of Face.
Parameters: |
|
---|
Override to use the event loop given to the constructor to schedule expressInterest to be called in a thread-safe manner. See Face.expressInterest for calling details.
Override to use the event loop given to the constructor to schedule registerPrefix to be called in a thread-safe manner. See Face.registerPrefix for calling details.
Override to use the event loop given to the constructor to schedule removePendingInterest to be called in a thread-safe manner. See Face.removePendingInterest for calling details.
Override to use the event loop given to the constructor to schedule removeRegisteredPrefix to be called in a thread-safe manner. See Face.removeRegisteredPrefix for calling details.
Override to use the event loop given to the constructor to schedule send to be called in a manner. See Face.send for calling details.