pyndn package¶
Subpackages¶
- pyndn.encoding package
- Subpackages
- Submodules
- pyndn.encoding.element_reader module
- pyndn.encoding.oid module
- pyndn.encoding.protobuf_tlv module
- pyndn.encoding.tlv_0_1_1_wire_format module
- pyndn.encoding.tlv_0_1_wire_format module
- pyndn.encoding.tlv_0_2_wire_format module
- pyndn.encoding.tlv_wire_format module
- pyndn.encoding.wire_format module
- Module contents
- pyndn.encrypt package
- Subpackages
- Submodules
- pyndn.encrypt.access_manager_v2 module
- pyndn.encrypt.consumer module
- pyndn.encrypt.consumer_db module
- pyndn.encrypt.decrypt_key module
- pyndn.encrypt.decryptor_v2 module
- pyndn.encrypt.encrypt_error module
- pyndn.encrypt.encrypt_key module
- pyndn.encrypt.encrypted_content module
- pyndn.encrypt.encryptor_v2 module
- pyndn.encrypt.group_manager module
- pyndn.encrypt.group_manager_db module
- pyndn.encrypt.interval module
- pyndn.encrypt.producer module
- pyndn.encrypt.producer_db module
- pyndn.encrypt.repetitive_interval module
- pyndn.encrypt.schedule module
- pyndn.encrypt.sqlite3_consumer_db module
- pyndn.encrypt.sqlite3_group_manager_db module
- pyndn.encrypt.sqlite3_producer_db module
- Module contents
- pyndn.impl package
- pyndn.in_memory_storage package
- pyndn.lp package
- pyndn.security package
- Subpackages
- pyndn.security.certificate package
- pyndn.security.identity package
- Submodules
- pyndn.security.identity.basic_identity_storage module
- pyndn.security.identity.file_private_key_storage module
- pyndn.security.identity.identity_manager module
- pyndn.security.identity.identity_storage module
- pyndn.security.identity.memory_identity_storage module
- pyndn.security.identity.memory_private_key_storage module
- pyndn.security.identity.osx_private_key_storage module
- pyndn.security.identity.private_key_storage module
- Module contents
- pyndn.security.pib package
- Subpackages
- Submodules
- pyndn.security.pib.pib module
- pyndn.security.pib.pib_certificate_container module
- pyndn.security.pib.pib_identity module
- pyndn.security.pib.pib_identity_container module
- pyndn.security.pib.pib_impl module
- pyndn.security.pib.pib_key module
- pyndn.security.pib.pib_key_container module
- pyndn.security.pib.pib_memory module
- pyndn.security.pib.pib_sqlite3 module
- Module contents
- pyndn.security.policy package
- Submodules
- pyndn.security.policy.certificate_cache module
- pyndn.security.policy.config_policy_manager module
- pyndn.security.policy.no_verify_policy_manager module
- pyndn.security.policy.policy_manager module
- pyndn.security.policy.self_verify_policy_manager module
- pyndn.security.policy.validation_request module
- Module contents
- pyndn.security.tpm package
- Submodules
- pyndn.security.tpm.tpm module
- pyndn.security.tpm.tpm_back_end module
- pyndn.security.tpm.tpm_back_end_file module
- pyndn.security.tpm.tpm_back_end_memory module
- pyndn.security.tpm.tpm_back_end_osx module
- pyndn.security.tpm.tpm_key_handle module
- pyndn.security.tpm.tpm_key_handle_memory module
- pyndn.security.tpm.tpm_key_handle_osx module
- pyndn.security.tpm.tpm_private_key module
- Module contents
- pyndn.security.v2 package
- Subpackages
- Submodules
- pyndn.security.v2.certificate_cache_v2 module
- pyndn.security.v2.certificate_container_interface module
- pyndn.security.v2.certificate_fetcher module
- pyndn.security.v2.certificate_fetcher_from_network module
- pyndn.security.v2.certificate_fetcher_offline module
- pyndn.security.v2.certificate_request module
- pyndn.security.v2.certificate_storage module
- pyndn.security.v2.certificate_v2 module
- pyndn.security.v2.data_validation_state module
- pyndn.security.v2.dynamic_trust_anchor_group module
- pyndn.security.v2.interest_validation_state module
- pyndn.security.v2.static_trust_anchor_group module
- pyndn.security.v2.trust_anchor_container module
- pyndn.security.v2.trust_anchor_group module
- pyndn.security.v2.validation_error module
- pyndn.security.v2.validation_policy module
- pyndn.security.v2.validation_policy_accept_all module
- pyndn.security.v2.validation_policy_command_interest module
- pyndn.security.v2.validation_policy_config module
- pyndn.security.v2.validation_policy_from_pib module
- pyndn.security.v2.validation_policy_simple_hierarchy module
- pyndn.security.v2.validation_state module
- pyndn.security.v2.validator module
- Module contents
- Submodules
- pyndn.security.command_interest_preparer module
- pyndn.security.command_interest_signer module
- pyndn.security.key_chain module
- pyndn.security.key_id_type module
- pyndn.security.key_params module
- pyndn.security.safe_bag module
- pyndn.security.security_exception module
- pyndn.security.security_types module
- pyndn.security.signing_info module
- pyndn.security.validator_config module
- pyndn.security.validator_config_error module
- pyndn.security.validator_null module
- pyndn.security.verification_helpers module
- Module contents
- Subpackages
- pyndn.sync package
- pyndn.transport package
- Submodules
- pyndn.transport.async_socket_transport module
- pyndn.transport.async_tcp_transport module
- pyndn.transport.async_unix_transport module
- pyndn.transport.socket_poller module
- pyndn.transport.tcp_transport module
- pyndn.transport.transport module
- pyndn.transport.udp_transport module
- pyndn.transport.unix_transport module
- Module contents
- pyndn.util package
- Subpackages
- pyndn.util.regex package
- Submodules
- pyndn.util.regex.ndn_regex_backref_manager module
- pyndn.util.regex.ndn_regex_backref_matcher module
- pyndn.util.regex.ndn_regex_component_matcher module
- pyndn.util.regex.ndn_regex_component_set_matcher module
- pyndn.util.regex.ndn_regex_matcher_base module
- pyndn.util.regex.ndn_regex_pattern_list_matcher module
- pyndn.util.regex.ndn_regex_pseudo_matcher module
- pyndn.util.regex.ndn_regex_repeat_matcher module
- pyndn.util.regex.ndn_regex_top_matcher module
- Module contents
- pyndn.util.regex package
- Submodules
- pyndn.util.blob module
- pyndn.util.boost_info_parser module
- pyndn.util.change_counter module
- pyndn.util.command_interest_generator module
- pyndn.util.common module
- pyndn.util.config_file module
- pyndn.util.dynamic_byte_array module
- pyndn.util.exponential_re_express module
- pyndn.util.memory_content_cache module
- pyndn.util.segment_fetcher module
- pyndn.util.signed_blob module
- Module contents
- Subpackages
Submodules¶
pyndn.control_parameters module¶
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.
-
class
pyndn.control_parameters.
ControlParameters
(value=None)[source]¶ Bases:
object
-
cost
¶ Get the cost value.
Returns: The cost value, or None if not specified. Return type: int
-
expirationPeriod
¶ Get the expiration period.
Returns: The expiration period in milliseconds, or None if not specified. Return type: float
-
faceId
¶ Get the face ID.
Returns: The face ID, or None if not specified. Return type: int
-
forwardingFlags
¶ Get the RegistrationOptions object containing the flags.
Returns: the RegistrationOptions object. Return type: RegistrationOptions
-
getCost
()[source]¶ Get the cost value.
Returns: The cost value, or None if not specified. Return type: int
-
getExpirationPeriod
()[source]¶ Get the expiration period.
Returns: The expiration period in milliseconds, or None if not specified. Return type: float
-
getFaceId
()[source]¶ Get the face ID.
Returns: The face ID, or None if not specified. Return type: int
-
getForwardingFlags
()[source]¶ Get the RegistrationOptions object containing the flags.
Returns: the RegistrationOptions object. Return type: RegistrationOptions
-
getLocalControlFeature
()[source]¶ Get the local control feature value.
Returns: The local control feature value, or None if not specified. Return type: int
-
getOrigin
()[source]¶ Get the origin value.
Returns: The origin value, or None if not specified. Return type: int
-
getUri
()[source]¶ Get the URI.
Returns: The face URI, or an empty string if not specified. Return type: str
-
localControlFeature
¶ Get the local control feature value.
Returns: The local control feature value, or None if not specified. Return type: int
-
origin
¶ Get the origin value.
Returns: The origin value, or None if not specified. Return type: int
-
setCost
(cost)[source]¶ Set the cost value.
Parameters: cost (int) – The new cost value, or None for not specified.
-
setExpirationPeriod
(expirationPeriod)[source]¶ Set the expiration period.
Parameters: expirationPeriod (float) – The expiration period in milliseconds, or None for not specified.
-
setFaceId
(faceId)[source]¶ Set the Face ID.
Parameters: faceId (int) – The new face ID, or None for not specified.
-
setForwardingFlags
(flags)[source]¶ Set the RegistrationOptions object to a copy of flags. You can use getForwardingFlags() and change the existing RegistrationOptions object.
Parameters: flags (RegistrationOptions) – The new RegistrationOptions object containing the flags, or None if not specified.
-
setLocalControlFeature
(localControlFeature)[source]¶ Set the local control feature value.
Parameters: localControlFeature (int) – The new local control feature value, or None for not specified.
-
setName
(name)[source]¶ Set the name.
Parameters: name (Name) – The name. If not specified, set to None. If specified, this makes a copy of the name.
-
setOrigin
(origin)[source]¶ Set the origin value.
Parameters: origin (int) – The new origin value, or None for not specified.
-
setStrategy
(strategy)[source]¶ Set the strategy to a copy of the given Name.
Parameters: strategy (Name) – The Name to copy, or an empty Name if not specified.
-
setUri
(uri)[source]¶ Set the URI.
Parameters: uri (str) – The new uri, or an empty string for not specified.
-
uri
¶ Get the URI.
Returns: The face URI, or an empty string if not specified. Return type: str
-
wireDecode
(input, wireFormat=None)[source]¶ Decode the input using a particular wire format and update this ControlParameters.
Parameters: - input (An array type with int elements) – The array with the bytes to decode.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to decode this ControlParameters. If omitted, use WireFormat.getDefaultWireFormat().
-
wireEncode
(wireFormat=None)[source]¶ Encode this ControlParameters for a particular wire format. This ignores getForwardingFlags().getOrigin(). To encode an origin value, you must use setOrigin().
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
-
pyndn.control_response module¶
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
-
class
pyndn.control_response.
ControlResponse
(value=None)[source]¶ 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. -
bodyAsControlParameters
¶ 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
-
getBodyAsControlParameters
()[source]¶ 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
-
getStatusCode
()[source]¶ Get the status code.
Returns: The status code. If not specified, return None. Return type: int
-
getStatusText
()[source]¶ Get the status text.
Returns: The status text. If not specified, return “”. Return type: str
-
setBodyAsControlParameters
(controlParameters)[source]¶ 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
-
setStatusCode
(statusCode)[source]¶ 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
-
setStatusText
(statusText)[source]¶ 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
-
statusCode
¶ Get the status code.
Returns: The status code. If not specified, return None. Return type: int
-
statusText
¶ Get the status text.
Returns: The status text. If not specified, return “”. Return type: str
-
wireDecode
(input, wireFormat=None)[source]¶ Decode the input using a particular wire format and update this ControlResponse.
Parameters: - input (An array type with int elements) – The array with the bytes to decode.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to decode this ControlParameters. If omitted, use WireFormat.getDefaultWireFormat().
-
wireEncode
(wireFormat=None)[source]¶ 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
-
pyndn.data module¶
This module defines the NDN Data class.
-
class
pyndn.data.
Data
(value=None)[source]¶ Bases:
object
-
content
¶ Get the data packet’s content.
Returns: The content as a Blob, which isNull() if unspecified. Return type: Blob
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: The change count. Return type: int
-
getCongestionMark
()[source]¶ Get the congestion mark according to the incoming packet header.
Returns: The congestion mark. If not specified, return 0. Return type: int
-
getContent
()[source]¶ Get the data packet’s content.
Returns: The content as a Blob, which isNull() if unspecified. Return type: Blob
-
getDefaultWireEncoding
()[source]¶ 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
-
getDefaultWireEncodingFormat
()[source]¶ Get the WireFormat which is used by getDefaultWireEncoding().
Returns: The WireFormat, which is only meaningful if the getDefaultWireEncoding() is not isNull(). Return type: WireFormat
-
getFullName
(wireFormat=None)[source]¶ Get the Data packet’s full name, which includes the final ImplicitSha256Digest component based on the wire encoding for a particular wire format.
Parameters: wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode this object. If omitted, use WireFormat.getDefaultWireFormat(). Returns: The full name. You must not change the Name object - if you need to change it then make a copy. Return type: Name
-
getIncomingFaceId
()[source]¶ Get the incoming face ID according to the incoming packet header.
Returns: The incoming face ID. If not specified, return None. Return type: int
-
getSignature
()[source]¶ Get the data packet’s signature object.
Returns: The signature object. Return type: a subclass of Signature such as Sha256WithRsaSignature
-
setContent
(content)[source]¶ 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).
-
setLpPacket
(lpPacket)[source]¶ 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.
-
setMetaInfo
(metaInfo)[source]¶ 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
-
setName
(name)[source]¶ 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
-
setSignature
(signature)[source]¶ 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
-
signature
¶ Get the data packet’s signature object.
Returns: The signature object. Return type: a subclass of Signature such as Sha256WithRsaSignature
-
wireDecode
(input, wireFormat=None)[source]¶ 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: - input (A Blob or an array type with int elements) – The array with the bytes to decode. If input is not a Blob, then copy the bytes to save the defaultWireEncoding (otherwise take another pointer to the same Blob).
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to decode this Data object. If omitted, use WireFormat.getDefaultWireFormat().
-
wireEncode
(wireFormat=None)[source]¶ 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
-
pyndn.delegation_set module¶
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”).
-
class
pyndn.delegation_set.
DelegationSet
(value=None)[source]¶ 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. -
class
Delegation
(preference, name)[source]¶ Bases:
object
A DelegationSet.Delegation holds a preference number and delegation name. Create a new DelegationSet.Delegation with the given values.
Parameters: - preference (int) – The preference number.
- name (Name) – The delegation name. This makes a copy of the name.
-
compare
(other)[source]¶ 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
(preference, name)[source]¶ 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: - preference (int) – The preference number.
- name (Name) – The delegation name. This makes a copy of the name.
-
addUnsorted
(preference, name)[source]¶ 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: - preference (int) – The preference number.
- name (Name) – The delegation name. This makes a copy of the name.
-
find
(name)[source]¶ 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
(i)[source]¶ 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
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object is changed.
Returns: The change count. Return type: int
-
remove
(name)[source]¶ 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
-
size
()[source]¶ Get the number of delegation entries.
Returns: The number of delegation entries. Return type: int
-
wireDecode
(input, wireFormat=None)[source]¶ Decode the input using a particular wire format and update this DelegationSet.
Parameters: - input (A Blob or an array type with int elements) – The array with the bytes to decode.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to decode this DelegationSet. If omitted, use WireFormat.getDefaultWireFormat().
-
wireEncode
(wireFormat=None)[source]¶ 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
-
class
pyndn.digest_sha256_signature module¶
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.
-
class
pyndn.digest_sha256_signature.
DigestSha256Signature
(value=None)[source]¶ 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. -
clone
()[source]¶ 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
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object is changed.
Returns: The change count. Return type: int
-
getSignature
()[source]¶ Get the data packet’s signature bytes (which is the digest).
Returns: The signature bytes as a Blob, which maybe isNull(). Return type: Blob
-
setSignature
(signature)[source]¶ 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).
-
pyndn.exclude module¶
-
class
pyndn.exclude.
Exclude
(value=None)[source]¶ 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. -
ANY
= 0¶
-
COMPONENT
= 1¶
-
class
Entry
(value=None)[source]¶ Bases:
object
Create a new Exclude.Entry.
Parameters: value (Name.Component or a value for the Name.Component constructor which makes a GENERIC name component.) – (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. -
getComponent
()[source]¶ - Get the component for this Exclude.Entry (if the type of this
- is Exclude.COMPONENT).
Returns: The component for this entry, or None if the type of this entry is not Exclude.COMPONENT. Return type: Name.Component
-
-
appendAny
()[source]¶ Append a new entry of type Exclude.ANY.
Returns: This Exclude so that you can chain calls to append. Return type: Exclude
-
appendComponent
(component)[source]¶ Append a new entry of type Exclude.COMPONENT with the given component.
Parameters: component (Exclude.Entry, Name.Component or a value for the Name.Component constructor which makes a GENERIC name component.) – The new exclude component. Returns: This Exclude so that you can chain calls to append. Return type: Exclude
-
appendImplicitSha256Digest
(digest)[source]¶ Append a new entry of type Exclude.COMPONENT with a component of type ImplicitSha256DigestComponent using Name.Component.fromImplicitSha256Digest.
Parameters: digest (Blob or value for Blob constructor) – The SHA-256 digest value. Returns: This Exclude so that you can chain calls to append. Return type: Exclude
-
get
(i)[source]¶ 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
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object is changed.
Returns: The change count. Return type: int
-
matches
(component)[source]¶ Check if the component matches any of the exclude criteria.
Parameters: component (Name.Component) – The name component to check. Returns: True if the component matches any of the exclude criteria, otherwise False.
-
pyndn.face module¶
This module defines the Face class which provides the main methods for NDN communication.
-
class
pyndn.face.
Face
(arg1=None, arg2=None)[source]¶ 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: - transport (Transport) – An object of a subclass of Transport used for communication.
- connectionInfo (Transport.ConnectionInfo) – An object of a subclass of Transport.ConnectionInfo to be used to connect to the transport.
- host (str) – In the Face(host, port) form of the constructor, host is the host of the NDN hub to connect using TcpTransport.
- port (int) – (optional) In the Face(host, port) form of the constructor, port is the port of the NDN hub. If omitted. use 6363.
-
callLater
(delayMilliseconds, callback)[source]¶ 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: - delayMilliseconds (float) – The delay in milliseconds.
- callback (function object) – This calls callback() after the delay.
-
expressInterest
(interestOrName, arg2, arg3=None, arg4=None, arg5=None, arg6=None)[source]¶ 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: - interest (Interest) – The Interest (if the first form is used). This copies the Interest.
- name (Name) – A name for the Interest (if the second form is used).
- interestTemplate (Interest) – (optional) if not None, copy interest selectors from the template (if the second form is used). If omitted, use a default interest lifetime.
- onData (function object) – When a matching data packet is received, this calls onData(interest, data) where interest is the interest given to expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions raised by this callback, but for better error handling the callback should catch and properly handle any exceptions.
- onTimeout (function object) – (optional) If the interest times out according to the interest lifetime, this calls onTimeout(interest) where interest is the interest given to expressInterest. However, if onTimeout is None or omitted, this does not use it. NOTE: The library will log any exceptions raised by this callback, but for better error handling the callback should catch and properly handle any exceptions.
- onNetworkNack (function object) – (optional) When a network Nack packet for the interest is received and onNetworkNack is not None, this calls onNetworkNack(interest, networkNack) and does not call onTimeout. interest is the sent Interest and networkNack is the received NetworkNack. If onNetworkNack is supplied, then onTimeout must be supplied too. However, if a network Nack is received and onNetworkNack is None, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions raised by this callback, but for better error handling the callback should catch and properly handle any exceptions.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode the message. If omitted, use WireFormat.getDefaultWireFormat().
Returns: The pending interest ID which can be used with removePendingInterest.
Return type: int
Throws: RuntimeError If the encoded interest size exceeds Face.getMaxNdnPacketSize().
-
static
getMaxNdnPacketSize
()[source]¶ 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
-
isLocal
()[source]¶ 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:
-
makeCommandInterest
(interest, wireFormat=None)[source]¶ 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: - interest (Interest) – The interest whose name is appended with components.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode the SignatureInfo and to encode the interest name for signing. If omitted, use WireFormat.getDefaultWireFormat().
-
processEvents
()[source]¶ 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.
-
putData
(data, wireFormat=None)[source]¶ The OnInterest callback calls this to put a Data packet which satisfies an Interest.
Parameters: - data (Data) – The Data packet which satisfies the interest.
- wireFormat (WireFormat) – (optional) A WireFormat object used to encode the Data packet. If omitted, use WireFormat.getDefaultWireFormat().
Throws: RuntimeError If the encoded Data packet size exceeds getMaxNdnPacketSize().
-
putNack
(interest, networkNack)[source]¶ The OnInterest callback can call this to put a Nack for the received Interest. :note: This method is an experimental feature, and the API may change.
Parameters: - interest (Interest) – The Interest to put in the Nack packet.
- networkNack (NetworkNack) – The NetworkNack with the reason code. For example, NetworkNack().setReason(NetworkNack.Reason.NO_ROUTE).
Raises: RuntimeError – If the encoded Nack packet size exceeds getMaxNdnPacketSize().
-
registerPrefix
(prefix, onInterest, onRegisterFailed, onRegisterSuccess=None, registrationOptions=None, wireFormat=None)[source]¶ 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: - prefix (Name) – The Name for the prefix to register. This copies the Name.
- onInterest (function object) – If not None, this creates an interest filter from prefix so that when an Interest is received which matches the filter, this calls onInterest(prefix, interest, face, interestFilterId, filter). NOTE: You must not change the prefix or filter objects - if you need to change them then make a copy. If onInterest is None, it is ignored and you must call setInterestFilter. NOTE: The library will log any exceptions raised by this callback, but for better error handling the callback should catch and properly handle any exceptions.
- onRegisterFailed (function object) – If register prefix fails for any reason, this calls onRegisterFailed(prefix). NOTE: The library will log any exceptions raised by this callback, but for better error handling the callback should catch and properly handle any exceptions.
- onRegisterSuccess (function object) – (optional) This calls onRegisterSuccess(prefix, registeredPrefixId) when this receives a success message from the forwarder. If onRegisterSuccess is None or omitted, this does not use it. (The onRegisterSuccess parameter comes after onRegisterFailed because it can be None or omitted, unlike onRegisterFailed.) NOTE: The library will log any exceptions raised by this callback, but for better error handling the callback should catch and properly handle any exceptions.
- registrationOptions (RegistrationOptions) – (optional) The registration options for finer control of how to forward an interest and other options.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode this ControlParameters. If omitted, use WireFormat.getDefaultWireFormat().
Raises: This raises an exception if setCommandSigningInfo has not been called to set the KeyChain, etc. for signing the command interest.
-
removePendingInterest
(pendingInterestId)[source]¶ 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.
-
removeRegisteredPrefix
(registeredPrefixId)[source]¶ 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
(encoding)[source]¶ 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().
-
setCommandCertificateName
(certificateName)[source]¶ 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.
-
setCommandSigningInfo
(keyChain, certificateName)[source]¶ Set the KeyChain and certificate name used to sign command interests (e.g. for registerPrefix).
Parameters: - keyChain (KeyChain) – The KeyChain object for signing interests, which must remain valid for the life of this Face. You must create the KeyChain object and pass it in. You can create a default KeyChain for your system with the default KeyChain constructor.
- certificateName (Name) – The certificate name for signing interests. This makes a copy of the Name. You can get the default certificate name with keyChain.getDefaultCertificateName() .
-
setInterestFilter
(filterOrPrefix, onInterest)[source]¶ 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: - filter (InterestFilter) – The InterestFilter with a prefix and optional regex filter used to match the name of an incoming Interest. This makes a copy of filter.
- prefix (Name) – The Name prefix used to match the name of an incoming Interest. This makes a copy of the Name.
- onInterest (function object) – When an Interest is received which matches the filter, this calls onInterest(prefix, interest, face, interestFilterId, filter). NOTE: The library will log any exceptions raised by this callback, but for better error handling the callback should catch and properly handle any exceptions.
Returns: The interest filter ID which can be used with unsetInterestFilter.
Return type: int
-
setInterestLoopbackEnabled
(interestLoopbackEnabled)[source]¶ Enable or disable Interest loopback. If Interest loopback is enabled, then an Interest to expressInterest is also sent to each of the matching OnInterest callbacks that the application gave to registerPrefix or setInterestFilter, and a Data that the application gives to putData can satisfy pending Interests. This way one part of an application can do Interest/Data exchange with another part through the same Face. Interest loopback is disabled by default.
Parameters: interestLoopbackEnabled (bool) – If True, enable Interest loopback, otherwise disable it.
-
unsetInterestFilter
(interestFilterId)[source]¶ 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.
pyndn.forwarding_flags module¶
This module defines the ForwardingFlags class which is deprecated. Use RegistrationOptions.
-
class
pyndn.forwarding_flags.
ForwardingFlags
(value=None)[source]¶ Bases:
pyndn.registration_options.RegistrationOptions
Create a new ForwardingFlags object, possibly copying values from another object.
Parameters: value (RegistrationOptions) – (optional) If value is a RegistrationOptions (or ForwardingFlags), copy its values. If value is omitted, the type is the default with “childInherit” True and other flags False. Deprecated: Use RegistrationOptions.
pyndn.generic_signature module¶
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.
-
class
pyndn.generic_signature.
GenericSignature
(value=None)[source]¶ 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. -
clone
()[source]¶ 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
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: The change count. Return type: int
-
getSignature
()[source]¶ Get the data packet’s signature bytes.
Returns: The signature bytes as a Blob, which maybe isNull(). Return type: Blob
-
getSignatureInfoEncoding
()[source]¶ 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
-
getTypeCode
()[source]¶ 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
-
setSignature
(signature)[source]¶ 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).
-
setSignatureInfoEncoding
(signatureInfoEncoding, typeCode=None)[source]¶ Set the bytes of the entire signature info encoding (including the type code).
Parameters: - signatureInfoEncoding (A Blob or an array type with int elements) – The array with the encoding bytes. If signatureInfoEncoding is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob).
- typeCode (int) – (optional) The type code of the signature type, or None if not known. (When a GenericSignature is created by wire decoding, it sets the typeCode.)
-
signature
¶ 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
-
pyndn.hmac_with_sha256_signature module¶
This module defines the HmacWithSha256Signature which extends Signature and holds the signature bits and other info representing an HmacWithSha256 signature in a packet.
-
class
pyndn.hmac_with_sha256_signature.
HmacWithSha256Signature
(value=None)[source]¶ 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. -
clone
()[source]¶ 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
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: The change count. Return type: int
-
getKeyLocator
()[source]¶ Get the key locator.
Returns: The key locator. Return type: KeyLocator
-
getSignature
()[source]¶ Get the data packet’s signature bytes.
Returns: The signature bytes as a Blob, which maybe isNull(). Return type: Blob
-
keyLocator
¶ Get the key locator.
Returns: The key locator. Return type: KeyLocator
-
setKeyLocator
(keyLocator)[source]¶ Set the key locator to a copy of the given keyLocator.
Parameters: keyLocator (KeyLocator) – The KeyLocator to copy.
-
pyndn.interest module¶
This module defines the NDN Interest class.
-
class
pyndn.interest.
Interest
(value=None)[source]¶ Bases:
object
-
appendParametersDigestToName
()[source]¶ Append the digest of the application parameters to the Name as a ParametersSha256DigestComponent. However, if the application parameters is unspecified, do nothing. This does not check if the Name already has a parameters digest component, so calling again will append another component.
Returns: This Interest so that you can chain calls to update values. Return type: Interest
-
applicationParameters
¶ Get the application parameters.
Returns: The application parameters as a Blob, which isNull() if unspecified. Return type: Blob
-
canBePrefix
¶ Get the CanBePrefix flag. If not specified, the default is True, or the value from setDefaultCanBePrefix().
Returns: The CanBePrefix flag. Return type: bool
-
childSelector
¶ Get the child selector.
Returns: The child selector, or None if not specified. Return type: int
-
exclude
¶ Get the exclude object.
Returns: The exclude object. If the exclude size() is zero, then the exclude is not specified. Return type: Exclude
-
forwardingHint
¶ Get the forwarding hint object which you can modify to add or remove forwarding hints.
Returns: The forwarding hint as a DelegationSet. Return type: DelegationSet
-
getApplicationParameters
()[source]¶ Get the application parameters.
Returns: The application parameters as a Blob, which isNull() if unspecified. Return type: Blob
-
getCanBePrefix
()[source]¶ Get the CanBePrefix flag. If not specified, the default is True, or the value from setDefaultCanBePrefix().
Returns: The CanBePrefix flag. Return type: bool
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: The change count. Return type: int
-
getChildSelector
()[source]¶ Get the child selector.
Returns: The child selector, or None if not specified. Return type: int
-
static
getDefaultCanBePrefix
()[source]¶ Get the default value of the CanBePrefix flag used in the Interest constructor. You can change this with Interest.setDefaultCanBePrefix().
Returns: The default value of the CanBePrefix flag. Return type: bool
-
getDefaultWireEncoding
()[source]¶ 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
-
getDefaultWireEncodingFormat
()[source]¶ Get the WireFormat which is used by getDefaultWireEncoding().
Returns: The WireFormat, which is only meaningful if the getDefaultWireEncoding() is not isNull(). Return type: WireFormat
-
getExclude
()[source]¶ Get the exclude object.
Returns: The exclude object. If the exclude size() is zero, then the exclude is not specified. Return type: Exclude
-
getForwardingHint
()[source]¶ Get the forwarding hint object which you can modify to add or remove forwarding hints.
Returns: The forwarding hint as a DelegationSet. Return type: DelegationSet
-
getIncomingFaceId
()[source]¶ Get the incoming face ID according to the incoming packet header.
Returns: The incoming face ID. If not specified, return None. Return type: int
-
getInterestLifetimeMilliseconds
()[source]¶ Get the interest lifetime.
Returns: The interest lifetime in milliseconds, or None if not specified. Return type: float
-
getKeyLocator
()[source]¶ Get the interest key locator.
Returns: The key locator. If getType() is None, then the key locator is not specified. Return type: KeyLocator
-
getLink
()[source]¶ Get the link object. If necessary, decode it from the link wire encoding.
Returns: The link object, or None if not specified. Return type: Link Raises: ValueError – For error decoding the link wire encoding (if necessary). Deprecated: Use getForwardingHint.
-
getLinkWireEncoding
(wireFormat=None)[source]¶ 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 Deprecated: Use getForwardingHint.
-
getMaxSuffixComponents
()[source]¶ Get the max suffix components.
Returns: The max suffix components, or None if not specified. Return type: int
-
getMinSuffixComponents
()[source]¶ Get the min suffix components.
Returns: The min suffix components, or None if not specified. Return type: int
-
getMustBeFresh
()[source]¶ Get the must be fresh flag.
Returns: The must be fresh flag. If not specified, the default is False. Return type: bool
-
getName
()[source]¶ Get the interest Name.
Returns: The name. The name size() may be 0 if not specified. Return type: Name
-
getNonce
()[source]¶ 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
-
getSelectedDelegationIndex
()[source]¶ Get the selected delegation index.
Returns: The selected delegation index. If not specified, return None. Return type: int Deprecated: Use getForwardingHint.
-
hasApplicationParameters
()[source]¶ Check if the application parameters are specified.
Returns: True if the application parameters are specified, False if not. Return type: bool
-
hasLink
()[source]¶ 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 Deprecated: Use getForwardingHint.
-
interestLifetimeMilliseconds
¶ Get the interest lifetime.
Returns: The interest lifetime in milliseconds, or None if not specified. Return type: float
-
keyLocator
¶ Get the interest key locator.
Returns: The key locator. If getType() is None, then the key locator is not specified. Return type: KeyLocator
-
matchesData
(data, wireFormat=None)[source]¶ Check if the given Data packet can satisfy this Interest. This method considers the Name, MinSuffixComponents, MaxSuffixComponents, PublisherPublicKeyLocator, and Exclude. It does not consider the ChildSelector or MustBeFresh. This uses the given wireFormat to get the Data packet encoding for the full Name.
Parameters: - data (Data) – The Data packet to check.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode the Data packet to get its full Name. If omitted, use WireFormat.getDefaultWireFormat().
Returns: True if the given Data packet can satisfy this Interest.
Return type: bool
-
matchesName
(name)[source]¶ 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
-
maxSuffixComponents
¶ Get the max suffix components.
Returns: The max suffix components, or None if not specified. Return type: int
-
minSuffixComponents
¶ Get the min suffix components.
Returns: The min suffix components, or None if not specified. Return type: int
-
mustBeFresh
¶ Get the must be fresh flag.
Returns: The must be fresh flag. If not specified, the default is False. Return type: bool
-
name
¶ Get the interest Name.
Returns: The name. The name size() may be 0 if not specified. Return type: Name
-
nonce
¶ 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
-
refreshNonce
()[source]¶ 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.
-
setApplicationParameters
(applicationParameters)[source]¶ Set the application parameters to the given value.
Parameters: applicationParameters (A Blob or an array type with int elements) – The array with the application parameters bytes. If applicationParameters is not a Blob, then this creates a new Blob to copy the bytes (otherwise this takes another pointer to the same Blob). Returns: This Interest so that you can chain calls to update values. Return type: Interest
-
setCanBePrefix
(canBePrefix)[source]¶ Set the CanBePrefix flag.
Parameters: canBePrefix (int) – True if the Interest name can be a prefix. Returns: This Interest so that you can chain calls to update values. Return type: Interest
-
setChildSelector
(childSelector)[source]¶ 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
-
static
setDefaultCanBePrefix
(defaultCanBePrefix)[source]¶ Set the default value of the CanBePrefix flag used in the Interest constructor. The default is currently True, but will be changed at a later date. The application should call this before creating any Interest (even to set the default again to True), or the application should explicitly call setCanBePrefix() after creating the Interest. Otherwise wireEncode will print a warning message. This is to avoid breaking any code when the library default for CanBePrefix is changed at a later date.
Parameters: defaultCanBePrefix (bool) – The default value of the CanBePrefix flag.
-
setExclude
(exclude)[source]¶ 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
-
setForwardingHint
(forwardingHint)[source]¶ Set this interest to use a copy of the given DelegationSet object as the forwarding hint.
Note: You can also call getForwardingHint and change the forwarding hint directly. Parameters: forwardingHint (DelegationSet) – The DelegationSet object to use as the forwarding hint. This makes a copy of the object. If no forwarding hint is specified, set to a new default DelegationSet() with no entries. Returns: This Interest so that you can chain calls to update values. Return type: Interest
-
setInterestLifetimeMilliseconds
(interestLifetimeMilliseconds)[source]¶ Set the interest lifetime.
Parameters: interestLifetimeMilliseconds (float) – The interest lifetime in milliseconds. If not specified, set to None. Returns: This Interest so that you can chain calls to update values. Return type: Interest
-
setKeyLocator
(keyLocator)[source]¶ 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
-
setLinkWireEncoding
(encoding, wireFormat=None)[source]¶ Set the link wire encoding bytes, without decoding them. If there is a link object, set it to None. If you later call getLink(), it will decode the wireEncoding to create the link object.
Parameters: - encoding (Blob) – The Blob with the bytes of the link wire encoding. If no link is specified, set to an empty Blob() or call unsetLink().
- wireFormat (WireFormat) – The wire format of the encoding, to be used later if necessary to decode. If omitted, use WireFormat.getDefaultWireFormat().
Returns: This Interest so that you can chain calls to update values.
Return type: Deprecated: Use setForwardingHint.
-
setLpPacket
(lpPacket)[source]¶ 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.
-
setMaxSuffixComponents
(maxSuffixComponents)[source]¶ 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
-
setMinSuffixComponents
(minSuffixComponents)[source]¶ 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
-
setMustBeFresh
(mustBeFresh)[source]¶ 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 False. Returns: This Interest so that you can chain calls to update values. Return type: Interest
-
setName
(name)[source]¶ 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
-
setNonce
(nonce)[source]¶ Deprecated: You should let the wire encoder generate a random nonce internally before sending the interest.
-
setSelectedDelegationIndex
(selectedDelegationIndex)[source]¶ 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 Deprecated: Use setForwardingHint.
-
toUri
()[source]¶ 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: str
-
unsetLink
()[source]¶ 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 Deprecated: Use setForwardingHint.
-
wireDecode
(input, wireFormat=None)[source]¶ 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: - input (A Blob or an array type with int elements) – The array with the bytes to decode. If input is not a Blob, then copy the bytes to save the defaultWireEncoding (otherwise take another pointer to the same Blob).
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to decode this Interest. If omitted, use WireFormat.getDefaultWireFormat().
-
wireEncode
(wireFormat=None)[source]¶ 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
-
pyndn.interest_filter module¶
This module defines the InterestFilter class which holds a Name prefix and optional regex match expression for use in Face.setInterestFilter.
-
class
pyndn.interest_filter.
InterestFilter
(prefix, regexFilter=None)[source]¶ 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: - prefix (Name or str) – The prefix. If a Name then this makes a copy of the Name. Otherwise it create a Name from the URI string.
- regexFilter (str) – (optional) The regular expression for matching the remaining name components.
-
doesMatch
(name)[source]¶ 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/zNote 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
-
getPrefix
()[source]¶ Get the prefix given to the constructor.
Returns: The prefix Name which you should not modify. Return type: Name
-
getRegexFilter
()[source]¶ 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
pyndn.key_locator module¶
This module defines the KeyLocator class which represents an NDN KeyLocator which is used in a Sha256WithRsaSignature and Interest selectors.
-
class
pyndn.key_locator.
KeyLocator
(value=None)[source]¶ 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. -
static
canGetFromSignature
(signature)[source]¶ 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
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: The change count. Return type: int
-
static
getFromSignature
(signature)[source]¶ If the signature is a type that has a KeyLocator, then return it. Otherwise raise an error. To check if the signature has a KeyLocator without raising an error, you can use canGetFromSignature().
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
-
getKeyData
()[source]¶ 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
-
getKeyName
()[source]¶ 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
-
getType
()[source]¶ 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
-
keyData
¶ 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
-
keyName
¶ 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
-
setKeyData
(keyData)[source]¶ 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).
-
setKeyName
(keyName)[source]¶ 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.
-
setType
(type)[source]¶ 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.
-
type
¶ 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
-
static
pyndn.link module¶
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 .
-
class
pyndn.link.
Link
(value=None)[source]¶ Bases:
pyndn.data.Data
-
addDelegation
(preference, name, wireFormat=None)[source]¶ 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: - preference (int) – The preference number.
- name (Name) – The delegation name. This makes a copy of the name. If there is already a delegation with the same name, this updates its preference.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode the DelegationSet. If omitted, use WireFormat.getDefaultWireFormat().
Returns: This Link so that you can chain calls to update values.
Return type:
-
encodeContent
(wireFormat)[source]¶ 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.
-
getDelegations
()[source]¶ 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
-
removeDelegation
(name, wireFormat=None)[source]¶ Remove every delegation with the given name. Re-encode this object’s content using the optional wireFormat.
Parameters: - name (Name) – Then name to match the name of the delegation(s) to be removed.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode the DelegationSet. If omitted, use WireFormat.getDefaultWireFormat().
Returns: True if a delegation was removed, otherwise False.
Return type: bool
-
wireDecode
(input, wireFormat=None)[source]¶ Override to call the base class wireDecode then populate the list of delegations from the content.
Parameters: - input (A Blob or an array type with int elements) – The array with the bytes to decode.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to decode this DelegationSet. If omitted, use WireFormat.getDefaultWireFormat().
-
pyndn.meta_info module¶
This module defines the MetaInfo class which is used by Data and represents the fields of an NDN MetaInfo.
-
class
pyndn.meta_info.
ContentType
[source]¶ Bases:
object
A ContentType specifies the content type in a MetaInfo object. If the content type in the packet is not a recognized enum value, then we use ContentType.OTHER_CODE and you can call MetaInfo.getOtherTypeCode(). We do this to keep the recognized content type values independent of packet encoding formats.
-
BLOB
= 0¶
-
KEY
= 2¶
-
LINK
= 1¶
-
NACK
= 3¶
-
OTHER_CODE
= 32767¶
-
-
class
pyndn.meta_info.
MetaInfo
(value=None)[source]¶ 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. -
finalBlockID
¶ Deprecated: Use getFinalBlockId.
-
finalBlockId
¶ 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
-
freshnessPeriod
¶ Get the freshness period.
Returns: The freshness period in milliseconds, or None if not specified. Return type: float
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object is changed.
Returns: The change count. Return type: int
-
getFinalBlockId
()[source]¶ 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
-
getFreshnessPeriod
()[source]¶ Get the freshness period.
Returns: The freshness period in milliseconds, or None if not specified. Return type: float
-
getOtherTypeCode
()[source]¶ Get the content type code from the packet which is other than a recognized ContentType enum value. This is only meaningful if getType() is ContentType.OTHER_CODE.
Returns: The type code. Return type: int
-
getType
()[source]¶ Get the content type.
Returns: The content type enum value. If this is ContentType.OTHER_CODE, then call getOtherTypeCode() to get the unrecognized content type code. Return type: an int from ContentType
-
setFinalBlockId
(finalBlockId)[source]¶ 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.
-
setFreshnessPeriod
(freshnessPeriod)[source]¶ Set the freshness period.
Parameters: freshnessPeriod (float) – The freshness period in milliseconds, or None for not specified.
-
setOtherTypeCode
(otherTypeCode)[source]¶ Set the packet’s content type code to use when the content type enum is ContentType.OTHER_CODE. If the packet’s content type code is a recognized enum value, just call setType().
Parameters: otherTypeCode (int) – The packet’s unrecognized content type code, which must be non-negative.
-
setType
(type)[source]¶ Set the content type.
Parameters: type (an int from ContentType) – The content type. If None, this uses ContentType.BLOB. If the packet’s content type is not a recognized ContentType enum value, use ContentType.OTHER_CODE and call setOtherTypeCode().
-
type
¶ Get the content type.
Returns: The content type enum value. If this is ContentType.OTHER_CODE, then call getOtherTypeCode() to get the unrecognized content type code. Return type: an int from ContentType
-
pyndn.name module¶
This module defines the NDN Name class.
-
class
pyndn.name.
ComponentType
[source]¶ Bases:
object
A ComponentType specifies the recognized types of a name component. If the component type in the packet is not a recognized enum value, then we use ComponentType.OTHER_CODE and you can call Name.Component.getOtherTypeCode(). We do this to keep the recognized component type values independent of packet encoding details.
-
GENERIC
= 8¶
-
IMPLICIT_SHA256_DIGEST
= 1¶
-
OTHER_CODE
= 32767¶
-
PARAMETERS_SHA256_DIGEST
= 2¶
-
-
class
pyndn.name.
Name
(value=None)[source]¶ 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. -
class
Component
(value=None, type=None, otherTypeCode=None)[source]¶ Bases:
object
Create a new Name.Component with a copy of the given value. (To create an ImplicitSha256Digest component, use fromImplicitSha256Digest.) (To create a ParametersSha256Digest component, use fromParametersSha256Digest.)
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.
- type (int) – (optional) The component type as an int from the ComponentType enum. If name component type is not a recognized ComponentType enum value, then set this to ComponentType.OTHER_CODE and use the otherTypeCode parameter. If omitted, use ComponentType.GENERIC.
- otherTypeCode (int) – (optional) If type is ComponentType.OTHER_CODE, then this is the packet’s unrecognized content type code, which must be non-negative.
-
compare
(other)[source]¶ 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
-
equals
(other)[source]¶ 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
-
static
fromImplicitSha256Digest
(digest)[source]¶ Create a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true.
Parameters: digest (Blob or value for Blob constructor) – The SHA-256 digest value. Returns: The new Component. Return type: Name.Component Raises: RuntimeError – If the digest length is not 32 bytes.
-
static
fromNumber
(number, type=None, otherTypeCode=None)[source]¶ Create a component whose value is the nonNegativeInteger encoding of the number.
Parameters: - number (int) – The number to be encoded.
- type (int) – (optional) The component type as an int from the ComponentType enum. If name component type is not a recognized ComponentType enum value, then set this to ComponentType.OTHER_CODE and use the otherTypeCode parameter. If omitted, use ComponentType.GENERIC.
- otherTypeCode (int) – (optional) If type is ComponentType.OTHER_CODE, then this is the packet’s unrecognized content type code, which must be non-negative.
Returns: The new component value.
Return type:
-
static
fromNumberWithMarker
(number, marker)[source]¶ Create a component whose value is the marker appended with the nonNegativeInteger encoding of the number.
Parameters: - number (int) – The number to be encoded.
- marker (int) – The marker to use as the first byte of the component.
Returns: The component value.
Return type:
-
static
fromParametersSha256Digest
(digest)[source]¶ Create a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is true.
Parameters: digest (Blob or value for Blob constructor) – The SHA-256 digest value. Returns: The new Component. Return type: Name.Component Raises: RuntimeError – If the digest length is not 32 bytes.
-
static
fromSegment
(segment)[source]¶ 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
-
static
fromSegmentOffset
(segmentOffset)[source]¶ 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
-
static
fromSequenceNumber
(sequenceNumber)[source]¶ 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
-
static
fromTimestamp
(timestamp)[source]¶ 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
-
static
fromVersion
(version)[source]¶ 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
-
getOtherTypeCode
()[source]¶ - Get the component type code from the packet which is other than a
- recognized ComponentType enum value. This is only meaningful if getType() is ComponentType.OTHER_CODE.
Returns: The type code. Return type: int
-
getSuccessor
()[source]¶ 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
-
getType
()[source]¶ Get the name component type.
Returns: The name component type as an int from the ComponentType enum. If this is ComponentType.OTHER_CODE, then call getOtherTypeCode() to get the unrecognized component type code. Return type: int
-
isGeneric
()[source]¶ Check if this component is a generic component.
Returns: True if this is an generic component. Return type: bool
-
isImplicitSha256Digest
()[source]¶ Check if this component is an ImplicitSha256Digest component.
Returns: True if this is an ImplicitSha256Digest component. Return type: bool
-
isParametersSha256Digest
()[source]¶ Check if this component is a ParametersSha256Digest component.
Returns: True if this is a ParametersSha256Digest component. Return type: bool
-
isSegment
()[source]¶ 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
-
isSegmentOffset
()[source]¶ 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
-
isSequenceNumber
()[source]¶ 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
-
isTimestamp
()[source]¶ 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
-
isVersion
()[source]¶ 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
-
toEscapedString
(result=None)[source]¶ Convert this component to a string, escaping characters according to the NDN URI Scheme. This also adds “…” to a value with zero or more “.”. This adds a type code prefix as needed, such as “sha256digest=”.
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
-
toNumber
()[source]¶ Interpret this name component as a network-ordered number and return an integer.
Returns: The integer number. Return type: int
-
toNumberWithMarker
(marker)[source]¶ 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.
-
toSegment
()[source]¶ 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.
-
toSegmentOffset
()[source]¶ 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.
-
toSequenceNumber
()[source]¶ 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.
-
toTimestamp
()[source]¶ 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.
-
toVersion
()[source]¶ 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
(value, type=None, otherTypeCode=None)[source]¶ Append a new component to this Name. (To append an ImplicitSha256Digest component, use appendImplicitSha256Digest.) (To append a ParametersSha256Digest component, use appendParametersSha256Digest.)
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.
- type (int) – (optional) The component type as an int from the ComponentType enum. If name component type is not a recognized ComponentType enum value, then set this to ComponentType.OTHER_CODE and use the otherTypeCode parameter. If omitted, use ComponentType.GENERIC. If the component param is a Name or another Name.Component, then this is ignored.
- otherTypeCode (int) – (optional) If type is ComponentType.OTHER_CODE, then this is the packet’s unrecognized content type code, which must be non-negative. If the component param is a Name or another Name.Component, then this is ignored.
Returns: This name so that you can chain calls to append.
Return type:
-
appendImplicitSha256Digest
(digest)[source]¶ Append a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true.
Parameters: digest (Blob or value for Blob constructor) – The SHA-256 digest value. Returns: This name so that you can chain calls to append. Return type: Name Raises: RuntimeError – If the digest length is not 32 bytes.
-
appendNumber
(number, type=None, otherTypeCode=None)[source]¶ Append a component whose value is the nonNegativeInteger encoding of the number.
Parameters: - number (int) – The number to be encoded.
- type (int) – (optional) The component type as an int from the ComponentType enum. If name component type is not a recognized ComponentType enum value, then set this to ComponentType.OTHER_CODE and use the otherTypeCode parameter. If omitted, use ComponentType.GENERIC.
- otherTypeCode (int) – (optional) If type is ComponentType.OTHER_CODE, then this is the packet’s unrecognized content type code, which must be non-negative.
Returns: This name so that you can chain calls to append.
Return type:
-
appendParametersSha256Digest
(digest)[source]¶ Append a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is true.
Parameters: digest (Blob or value for Blob constructor) – The SHA-256 digest value. Returns: This name so that you can chain calls to append. Return type: Name Raises: RuntimeError – If the digest length is not 32 bytes.
-
appendSegment
(segment)[source]¶ 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
-
appendSegmentOffset
(segmentOffset)[source]¶ 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
-
appendSequenceNumber
(sequenceNumber)[source]¶ 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
-
appendTimestamp
(timestamp)[source]¶ 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
-
appendVersion
(version)[source]¶ 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
(iStartComponent, nComponents=None, other=None, iOtherStartComponent=None, nOtherComponents=None)[source]¶ 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: - iStartComponent (int) – The index if the first component of this name to get. If iStartComponent is -N then compare components starting from name.size() - N.
- nComponents (int) – The number of components starting at iStartComponent. If greater than the size of this name, compare until the end of the name.
- other (Name) – The other Name to compare with.
- iOtherStartComponent (int) – (optional) The index if the first component of the other name to compare. If iOtherStartComponent is -N then compare components starting from other.size() - N. If omitted, compare starting from index 0.
- nOtherComponents (int) – (optional) The number of components starting at iOtherStartComponent. If omitted or greater than the size of this name, compare until the end of the name.
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:
-
equals
(name)[source]¶ 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
-
static
fromEscapedString
(escapedString, beginOffset=0, endOffset=None)[source]¶ 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. This does not check for a type code prefix such as “sha256digest=”.
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
(i)[source]¶ 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).
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object is changed.
Returns: The change count. Return type: int
-
getPrefix
(nComponents)[source]¶ 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
-
getSubName
(iStartComponent, nComponents=None)[source]¶ Get a new name, constructed as a subset of components.
Parameters: - iStartComponent (int) – The index if the first component to get. If iStartComponent is -N then return return components starting from name.size() - N.
- nComponents (int) – (optional) The number of components starting at iStartComponent. If omitted or greater than the size of this name, get until the end of the name.
Returns: A new name.
Return type:
-
getSuccessor
()[source]¶ 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:
- The successor of / is /sha256digest=0000000000000000000000000000000000000000000000000000000000000000
- The successor of /%00%01/%01%02 is /%00%01/%01%03
- The successor of /%00%01/%01%FF is /%00%01/%02%00
- The successor of /%00%01/%FF%FF is /%00%01/%00%00%00
Returns: A new name which is the successor of this. Return type: Name
-
isPrefixOf
(name)[source]¶ 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
-
match
(name)[source]¶ 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
-
set
(uri)[source]¶ Parse the uri according to the NDN URI Scheme and set the name with the components.
Parameters: uri (str) – The URI string.
-
static
toEscapedString
(value, result=None)[source]¶ Convert value to a string, escaping characters according to the NDN URI Scheme. This also adds “…” to a value with zero or more “.”. This does not add a type code prefix such as “sha256digest=”.
Parameters: - value (An array type with int elements) – The buffer with the value to escape.
- 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
-
toUri
(includeScheme=False)[source]¶ 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
-
wireDecode
(input, wireFormat=None)[source]¶ Decode the input using a particular wire format and update this Name.
Parameters: - input (A Blob or an array type with int elements) – The array with the bytes to decode.
- wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to decode this Name. If omitted, use WireFormat.getDefaultWireFormat().
-
class
pyndn.network_nack module¶
This module defines the NetworkNack class which represents a network Nack packet and includes a Nack reason.
-
class
pyndn.network_nack.
NetworkNack
[source]¶ Bases:
object
-
class
Reason
[source]¶ 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.
-
CONGESTION
= 50¶
-
DUPLICATE
= 100¶
-
NONE
= 0¶
-
NO_ROUTE
= 150¶
-
OTHER_CODE
= 32767¶
-
-
static
getFirstHeader
(lpPacket)[source]¶ 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
-
getOtherReasonCode
()[source]¶ 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
-
getReason
()[source]¶ 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
-
setOtherReasonCode
(otherReasonCode)[source]¶ Set the packet’s reason code to use when the reason enum is Reason.OTHER_CODE. If the packet’s reason code is a recognized enum value, just call setReason().
Parameters: otherReasonCode (int) – The packet’s unrecognized reason code, which must be non-negative. Returns: This NetworkNack so that you can chain calls to update values. Return type: NetworkNack
-
setReason
(reason)[source]¶ Set the network Nack reason.
Parameters: reason (an int from NetworkNack.Reason) – The network Nack reason enum value. If the packet’s reason code is not a recognized Reason enum value, use Reason.OTHER_CODE and call setOtherReasonCode(). Returns: This NetworkNack so that you can chain calls to update values. Return type: NetworkNack
-
class
pyndn.node module¶
This module defines the Node class which provides functionality for the Face class.
-
class
pyndn.node.
Node
(transport, connectionInfo)[source]¶ Bases:
object
Create a new Node for communication with an NDN hub with the given Transport object and connectionInfo.
Parameters: - transport (Transport) – An object of a subclass of Transport used for communication.
- connectionInfo (Transport.ConnectionInfo) – An object of a subclass of Transport.ConnectionInfo to be used to connect to the transport.
-
callLater
(delayMilliseconds, callback)[source]¶ Call callback() after the given delay. This adds to self._delayedCallTable which is used by processEvents().
Parameters: - delayMilliseconds (float) – The delay in milliseconds.
- callback (function object) – This calls callback() after the delay.
-
expressInterest
(pendingInterestId, interestCopy, onData, onTimeout, onNetworkNack, wireFormat, face)[source]¶ Send the Interest through the transport, read the entire response and call onData, onTimeout or onNetworkNack as described below.
Parameters: - pendingInterestId (int) – The getNextEntryId() for the pending interest ID which Face got so it could return it to the caller.
- interestCopy (Interest) – The Interest which is NOT copied for this internal Node method. The Face expressInterest is responsible for making a copy for Node to use.
- onData (function object) – When a matching data packet is received, this calls onData(interest, data) where interest is the Interest given to expressInterest and data is the received Data object.
- onTimeout (function object) – If the interest times out according to the interest lifetime, this calls onTimeout(interest) where interest is the Interest given to expressInterest. If onTimeout is None, this does not use it.
- onNetworkNack (function object) – When a network Nack packet for the interest is received and onNetworkNack is not None, this calls onNetworkNack(interest, networkNack) and does not call onTimeout. interest is the sent Interest and networkNack is the received NetworkNack. However, if a network Nack is received and onNetworkNack is None, do nothing and wait for the interest to time out.
- wireFormat (a subclass of WireFormat) – A WireFormat object used to encode the message.
- face (Face) – The face which has the callLater method, used for interest timeouts. The callLater method may be overridden in a subclass of Face.
Throws: RuntimeError If the encoded interest size exceeds getMaxNdnPacketSize().
-
getConnectionInfo
()[source]¶ Get the connectionInfo object given to the constructor.
Returns: The connectionInfo object. Return type: Transport.ConnectionInfo
-
static
getMaxNdnPacketSize
()[source]¶ 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
-
getNextEntryId
()[source]¶ 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
-
getTransport
()[source]¶ Get the transport object given to the constructor.
Returns: The transport object. Return type: Transport
-
isLocal
()[source]¶ 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:
-
makeCommandInterest
(interest, keyChain, certificateName, wireFormat)[source]¶ 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: - interest (Interest) – The interest whose name is append with components.
- keyChain (KeyChain) – The KeyChain for calling sign.
- certificateName (Name) – The certificate name of the key to use for signing.
- wireFormat (A subclass of WireFormat) – A WireFormat object used to encode the SignatureInfo and to encode the interest name for signing.
-
onReceivedElement
(element)[source]¶ 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.
-
processEvents
()[source]¶ 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.
-
putData
(data, wireFormat=None)[source]¶ The OnInterest callback calls this to put a Data packet which satisfies an Interest.
Parameters: - data (Data) – The Data packet which satisfies the interest.
- wireFormat (WireFormat) – A WireFormat object used to encode the Data packet.
-
putNack
(interest, networkNack)[source]¶ The OnInterest callback can call this to put a Nack for the received Interest.
Parameters: - interest (Interest) – The Interest to put in the Nack packet.
- networkNack (NetworkNack) – The NetworkNack with the reason code. For example, NetworkNack().setReason(NetworkNack.Reason.NO_ROUTE).
Raises: RuntimeError – If the encoded Nack packet size exceeds getMaxNdnPacketSize().
-
registerPrefix
(registeredPrefixId, prefixCopy, onInterest, onRegisterFailed, onRegisterSuccess, registrationOptions, wireFormat, commandKeyChain, commandCertificateName, face)[source]¶ 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: - registeredPrefixId (int) – The getNextEntryId() for the registered prefix ID which Face got so it could return it to the caller.
- prefixCopy (Name) – The Name for the prefix to register which is NOT copied for this internal Node method. The Face registerPrefix is responsible for making a copy for Node to use.
- onInterest (function object) – (optional) If not None, this creates an interest filter from prefixCopy so that when an Interest is received which matches the filter, this calls onInterest(prefix, interest, face, interestFilterId, filter). NOTE: You must not change the prefix or filter objects - if you need to change them then make a copy. If onInterest is None, it is ignored and you must call setInterestFilter.
- onRegisterFailed (function object) – A function object to call if failed to retrieve the connected hub’s ID or failed to register the prefix.
- onRegisterSuccess (function object) – This calls onRegisterSuccess(prefix, registeredPrefixId) when this receives a success message from the forwarder. If onRegisterSuccess is None, this does not use it.
- registrationOptions (RegistrationOptions) – The registration options for finer control of how to forward an interest and other options.
- wireFormat (a subclass of WireFormat) – A WireFormat object used to encode the message.
- commandKeyChain (KeyChain) – The KeyChain object for signing interests.
- commandCertificateName (Name) – The certificate name for signing interests.
- face (Face) – The face which is passed to the onInterest callback. If onInterest is None, this is ignored.
-
removePendingInterest
(pendingInterestId)[source]¶ 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.
-
removeRegisteredPrefix
(registeredPrefixId)[source]¶ 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
(encoding)[source]¶ 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().
-
setInterestFilter
(interestFilterId, filterCopy, onInterest, face)[source]¶ 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: - interestFilterId (int) – The getNextEntryId() for the interest filter ID which Face got so it could return it to the caller.
- filterCopy (InterestFilter) – The InterestFilter with a prefix and optional regex filter used to match the name of an incoming Interest, which is NOT copied for this internal Node method. The Face setInterestFilter is responsible for making a copy for Node to use.
- onInterest (function object) – When an Interest is received which matches the filter, this calls onInterest(prefix, interest, face, interestFilterId, filter).
- face (Face) – The face which is passed to the onInterest callback.
-
setInterestLoopbackEnabled
(interestLoopbackEnabled)[source]¶ Enable or disable Interest loopback.
Parameters: interestLoopbackEnabled (bool) – If True, enable Interest loopback, otherwise disable it.
-
unsetInterestFilter
(interestFilterId)[source]¶ 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.
pyndn.registration_options module¶
This module defines the RegistrationOptions class which holds the options used when registering with the forwarder to specify how to forward an interest and other options. We use a separate RegistrationOptions object to retain future compatibility if the format of the registration command is changed. (This class was renamed from ForwardingFlags, which is deprecated.)
-
class
pyndn.registration_options.
RegistrationOptions
(value=None)[source]¶ Bases:
object
Create a new RegistrationOptions object, possibly copying values from another object.
Parameters: value (RegistrationOptions) – (optional) If value is a RegistrationOptions, copy its values. If value is omitted, the type is the default with “childInherit” True and other flags False. -
NfdForwardingFlags_CAPTURE
= 2¶
-
NfdForwardingFlags_CHILD_INHERIT
= 1¶
-
capture
¶
-
childInherit
¶
-
getNfdForwardingFlags
()[source]¶ Get an integer with the bits set according to the NFD forwarding flags as used in the ControlParameters of the command interest.
Returns: An integer with the bits set. Return type: int
-
getOrigin
()[source]¶ Get the origin value.
Returns: The origin value, or None if not specified. Return type: int
-
origin
¶ Get the origin value.
Returns: The origin value, or None if not specified. Return type: int
-
setCapture
(capture)[source]¶ Set the value of the “capture” flag.
Parameters: capture (bool) – True to set the “capture” flag, False to clear it. Returns: This RegistrationOptions so that you can chain calls to update values. Return type: RegistrationOptions
-
setChildInherit
(childInherit)[source]¶ Set the value of the “childInherit” flag.
Parameters: childInherit (bool) – True to set the “childInherit” flag, False to clear it. Returns: This RegistrationOptions so that you can chain calls to update values. Return type: RegistrationOptions
-
setNfdForwardingFlags
(nfdForwardingFlags)[source]¶ Set the flags according to the NFD forwarding flags as used in the ControlParameters of the command interest. This ignores the origin value.
Parameters: nfdForwardingFlags (int) – An integer with the bits set. Returns: This RegistrationOptions so that you can chain calls to update values. Return type: RegistrationOptions
-
setOrigin
(origin)[source]¶ Set the origin value. This is used to set the origin value of the ControlParameters for the register prefix command.
Parameters: origin (int) – The new origin value, or None for not specified. Returns: This RegistrationOptions so that you can chain calls to update values. Return type: RegistrationOptions
-
pyndn.sha256_with_ecdsa_signature module¶
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.
-
class
pyndn.sha256_with_ecdsa_signature.
Sha256WithEcdsaSignature
(value=None)[source]¶ 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. -
clone
()[source]¶ 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
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: The change count. Return type: int
-
getKeyLocator
()[source]¶ Get the key locator.
Returns: The key locator. Return type: KeyLocator
-
getSignature
()[source]¶ Get the data packet’s signature bytes.
Returns: The signature bytes as a Blob, which maybe isNull(). Return type: Blob
-
getValidityPeriod
()[source]¶ Get the validity period.
Returns: The validity period. Return type: ValidityPeriod
-
keyLocator
¶ Get the key locator.
Returns: The key locator. Return type: KeyLocator
-
setKeyLocator
(keyLocator)[source]¶ Set the key locator to a copy of the given keyLocator.
Parameters: keyLocator (KeyLocator) – The KeyLocator to copy.
-
setSignature
(signature)[source]¶ 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).
-
setValidityPeriod
(validityPeriod)[source]¶ Set the validity period to a copy of the given ValidityPeriod.
Parameters: validityPeriod (ValidityPeriod) – The ValidityPeriod which is copied.
-
pyndn.sha256_with_rsa_signature module¶
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.
-
class
pyndn.sha256_with_rsa_signature.
Sha256WithRsaSignature
(value=None)[source]¶ 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. -
clone
()[source]¶ 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
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object (or a child object) is changed.
Returns: The change count. Return type: int
-
getKeyLocator
()[source]¶ Get the key locator.
Returns: The key locator. Return type: KeyLocator
-
getSignature
()[source]¶ Get the data packet’s signature bytes.
Returns: The signature bytes as a Blob, which maybe isNull(). Return type: Blob
-
getValidityPeriod
()[source]¶ Get the validity period.
Returns: The validity period. Return type: ValidityPeriod
-
keyLocator
¶ Get the key locator.
Returns: The key locator. Return type: KeyLocator
-
setKeyLocator
(keyLocator)[source]¶ Set the key locator to a copy of the given keyLocator.
Parameters: keyLocator (KeyLocator) – The KeyLocator to copy.
-
setSignature
(signature)[source]¶ 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).
-
setValidityPeriod
(validityPeriod)[source]¶ Set the validity period to a copy of the given ValidityPeriod.
Parameters: validityPeriod (ValidityPeriod) – The ValidityPeriod which is copied.
-
pyndn.signature module¶
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.
-
class
pyndn.signature.
Signature
[source]¶ Bases:
object
-
clone
()[source]¶ 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.
-
getChangeCount
()[source]¶ 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.
-
getSignature
()[source]¶ 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.
-
setSignature
(signature)[source]¶ 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.
-
pyndn.threadsafe_face module¶
This module defines the ThreadsafeFace class which extends Face to provide the main methods for NDN communication in a thread-safe manner.
-
class
pyndn.threadsafe_face.
ThreadsafeFace
(loop, arg1=None, arg2=None)[source]¶ 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: - loop – The event loop, for example from asyncio.get_event_loop(). It is the responsibility of the application to start and stop the loop.
- transport (Transport) – An object of a subclass of Transport used for communication. If you do not want to call processEvents, then the transport should be an async transport like AsyncTcpTransport, in which case the transport should use the same loop.
- connectionInfo (Transport.ConnectionInfo) – An object of a subclass of Transport.ConnectionInfo to be used to connect to the transport.
- host (str) – In the Face(host, port) form of the constructor, host is the host of the NDN hub to connect using TcpTransport.
- port (int) – (optional) In the Face(host, port) form of the constructor, port is the port of the NDN hub. If omitted. use 6363.
-
callLater
(delayMilliseconds, callback)[source]¶ 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: - delayMilliseconds (float) – The delay in milliseconds.
- callback (function object) – This calls callback() after the delay.
-
expressInterest
(interestOrName, arg2, arg3=None, arg4=None, arg5=None, arg6=None)[source]¶ 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.
-
putData
(data, wireFormat=None)[source]¶ Override to use the event loop given to the constructor to schedule putData to be called in a thread-safe manner. See Face.putData for calling details.
-
putNack
(interest, networkNack)[source]¶ Override to use the event loop given to the constructor to schedule putData to be called in a thread-safe manner. See Face.putData for calling details.
-
registerPrefix
(prefix, onInterest, onRegisterFailed, onRegisterSuccess=None, registrationOptions=None, wireFormat=None)[source]¶ 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.
-
removePendingInterest
(pendingInterestId)[source]¶ 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.
-
removeRegisteredPrefix
(registeredPrefixId)[source]¶ 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.
-
send
(encoding)[source]¶ Override to use the event loop given to the constructor to schedule send to be called in a thread-safe manner. See Face.send for calling details.
pyndn.validity_period module¶
This module defines the ValidityPeriod class which is used in a Data packet’s SignatureInfo and represents the begin and end times of a certificate’s validity period.
-
class
pyndn.validity_period.
ValidityPeriod
(validityPeriodOrNotBefore=None, notAfter=None)[source]¶ Bases:
object
There are three forms of the ValidityPeriod constructor: ValidityPeriod() - Create a default ValidityPeriod where the period is not specified. ValidityPeriod(validityPeriod) - Create a new ValidityPeriod with a copy of the fields in the given validityPeriod object. ValidityPeriod(notBefore, notAfter) - Create a ValidityPeriod with the given period.
Parameters: - validityPeriod (ValidityPeriod) – The ValidityPeriod to copy.
- notBefore (float) – The beginning of the validity period range as milliseconds since Jan 1, 1970 UTC. Note that this is rounded up to the nearest whole second.
- notAfter (float) – The end of the validity period range as milliseconds since Jan 1, 1970 UTC. Note that this is rounded down to the nearest whole second.
-
static
canGetFromSignature
(signature)[source]¶ If the signature is a type that has a ValidityPeriod (so that getFromSignature will succeed), return true. Note: This is a static method of ValidityPeriod 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 ValidityPeriod, otherwise False. Return type: bool
-
getChangeCount
()[source]¶ Get the change count, which is incremented each time this object is changed.
Returns: The change count. Return type: int
-
static
getFromSignature
(signature)[source]¶ If the signature is a type that has a ValidityPeriod, then return it. Otherwise raise an error. To check if the signature has a ValidityPeriod without raising an error, you can use canGetFromSignature().
Parameters: signature (Signature) – An object of a subclass of Signature. Returns: The signature’s ValidityPeriod. It is an error if signature doesn’t have a ValidityPeriod. Return type: ValidityPeriod
-
getNotAfter
()[source]¶ Get the end of the validity period range.
Returns: The time as milliseconds since Jan 1, 1970 UTC. Return type: float
-
getNotBefore
()[source]¶ Get the beginning of the validity period range.
Returns: The time as milliseconds since Jan 1, 1970 UTC. Return type: float
-
hasPeriod
()[source]¶ Check if the period has been set.
Returns: True if the period has been set, False if the period is not specified (after calling the default constructor or clear). Return type: bool
-
isValid
(time=None)[source]¶ Check if the time falls within the validity period.
Parameters: time (float) – (optional) The time to check as milliseconds since Jan 1, 1970 UTC. If omitted, use the current time. Returns: True if the beginning of the validity period is less than or equal to time and time is less than or equal to the end of the validity period. Return type: bool
-
setPeriod
(notBefore, notAfter)[source]¶ Set the validity period.
Parameters: - notBefore (float) – The beginning of the validity period range as milliseconds since Jan 1, 1970 UTC. Note that this is rounded up to the nearest whole second.
- notAfter (float) – The end of the validity period range as milliseconds since Jan 1, 1970 UTC. Note that this is rounded down to the nearest whole second.
Returns: This ValidityPeriod so that you can chain calls to update values.
Return type: