This module defines the ElementReader class which lets you call onReceivedData multiple times which uses a TlvStructureDecoder to detect the end of a TLV element, and calls elementListener.onReceivedElement(element) with the element. This handles the case where a single call to onReceivedData may contain multiple elements.
Bases: object
Create an ElementReader with the elementListener and an initial buffer for saving partial data.
Continue to read data until the end of an element, then call elementListener.onReceivedElement(element). The buffer passed to onReceivedElement is only valid during this call. If you need the data later, you must copy.
Parameters: | data (An array type with int elements) – The buffer with the incoming element’s bytes. |
---|
This module defines the ProtobufTlv class which has static methods to encode and decode an Protobuf Message object as NDN-TLV. The Protobuf tag value is used as the TLV type code. A Protobuf message is encoded/decoded as a nested TLV encoding. Protobuf types uint32, uint64 and enum are encoded/decoded as TLV nonNegativeInteger. (It is an error if an enum value is negative.) Protobuf types bytes and string are encoded/decoded as TLV bytes. The Protobuf type bool is encoded/decoded as a TLV boolean (a zero length value for True, omitted for False). Other Protobuf types are an error.
Protobuf has no “outer” message type, so you need to put your TLV message inside an outer “typeless” message.
Bases: object
Decode the input as NDN-TLV and update the fields of the Protobuf message object.
Parameters: |
|
---|
Encode the Protobuf message object as NDN-TLV.
Parameters: | message (google.protobuf.message) – The Protobuf message object. This calls message.IsInitialized() to ensure that all required fields are present and raises an exception if not. |
---|---|
Returns: | The encoded buffer in a Blob object. |
Return type: | Blob |
Bases: pyndn.encoding.wire_format.WireFormat
Decode input as an NDN-TLV ControlParameters and set the fields of the controlParameters object.
Parameters: |
|
---|
Decode input as an NDN-TLV data packet, set the fields in the data object, and return the signed offsets.
Parameters: |
|
---|---|
Returns: | A Tuple of (signedPortionBeginOffset, signedPortionEndOffset) where signedPortionBeginOffset is the offset in the encoding of the beginning of the signed portion, and signedPortionEndOffset is the offset in the encoding of the end of the signed portion. |
Return type: | (int, int) |
Decode input as an EncryptedContent in NDN-TLV and set the fields of the encryptedContent object.
Parameters: |
|
---|
Decode input as an NDN-TLV interest and set the fields of the interest object.
Parameters: |
|
---|---|
Returns: | A Tuple of (signedPortionBeginOffset, signedPortionEndOffset) where signedPortionBeginOffset is the offset in the encoding of the beginning of the signed portion, and signedPortionEndOffset is the offset in the encoding of the end of the signed portion. The signed portion starts from the first name component and ends just before the final name component (which is assumed to be a signature for a signed interest). |
Return type: | (int, int) |
Decode input as an NDN-TLV name and set the fields of the Name object.
Parameters: |
|
---|
Decode signatureInfo as a signature info and signatureValue as the related SignatureValue, and return a new object which is a subclass of Signature.
Parameters: |
|
---|---|
Returns: | A new object which is a subclass of Signature. |
Return type: | a subclass of Signature |
Encode controlParameters and return the encoding.
Parameters: | controlParameters (ControlParameters) – The ControlParameters object to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Encode data in NDN-TLV and return the encoding and signed offsets.
Parameters: | data (Data) – The Data object to encode. |
---|---|
Returns: | A Tuple of (encoding, signedPortionBeginOffset, signedPortionEndOffset) where encoding is a Blob containing the encoding, signedPortionBeginOffset is the offset in the encoding of the beginning of the signed portion, and signedPortionEndOffset is the offset in the encoding of the end of the signed portion. |
Return type: | (Blob, int, int) |
Encode the EncryptedContent in NDN-TLV and return the encoding.
Parameters: | encryptedContent (EncryptedContent) – The EncryptedContent object to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Encode interest in NDN-TLV and return the encoding.
Parameters: | interest (Interest) – The Interest object to encode. |
---|---|
Returns: | A Tuple of (encoding, signedPortionBeginOffset, signedPortionEndOffset) where encoding is a Blob containing the encoding, signedPortionBeginOffset is the offset in the encoding of the beginning of the signed portion, and signedPortionEndOffset is the offset in the encoding of the end of the signed portion. The signed portion starts from the first name component and ends just before the final name component (which is assumed to be a signature for a signed interest). |
Return type: | (Blob, int, int) |
Encode name in NDN-TLV and return the encoding.
Parameters: | name (Name) – The Name object to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Encode signature as an NDN-TLV SignatureInfo and return the encoding.
Parameters: | signature (An object of a subclass of Signature) – An object of a subclass of Signature to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Encode the signatureValue in the Signature object as an NDN-TLV SignatureValue (the signature bits) and return the encoding.
Parameters: | signature (An object of a subclass of Signature) – An object of a subclass of Signature with the signature value to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
This module defines the Tlv0_1WireFormat class which extends Tlv0_1_1WireFormat so that it is an alias in case any applications use Tlv0_1WireFormat directly. These two wire formats are the same except that Tlv0_1_1WireFormat adds support for Sha256WithEcdsaSignature.
Bases: pyndn.encoding.tlv_0_1_1_wire_format.Tlv0_1_1WireFormat
Bases: pyndn.encoding.tlv_0_1_1_wire_format.Tlv0_1_1WireFormat
Get a singleton instance of a TlvWireFormat. Assuming that the default wire format was set with WireFormat.setDefaultWireFormat(TlvWireFormat.get()), you can check if this is the default wire encoding with if WireFormat.getDefaultWireFormat() == TlvWireFormat.get().
Returns: | The singleton instance. |
---|---|
Return type: | TlvWireFormat |
This module defines the WireFormat class which is an abstract base class for encoding and decoding Interest, Data, etc. with a specific wire format. You should use a derived class such as TlvWireFormat.
Bases: object
Decode input as a controlParameters and set the fields of the controlParameters object. Your derived class should override.
Parameters: |
|
---|---|
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Decode input as a data packet, set the fields in the data object, and return the signed offsets. Your derived class should override.
Parameters: |
|
---|---|
Returns: | A Tuple of (signedPortionBeginOffset, signedPortionEndOffset) where signedPortionBeginOffset is the offset in the encoding of the beginning of the signed portion, and signedPortionEndOffset is the offset in the encoding of the end of the signed portion. |
Return type: | (int, int) |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Decode input as an EncryptedContent and set the fields of the encryptedContent object. Your derived class should override.
Parameters: |
|
---|---|
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Decode input as an interest and set the fields of the interest object. Your derived class should override.
Parameters: |
|
---|---|
Returns: | A Tuple of (signedPortionBeginOffset, signedPortionEndOffset) where signedPortionBeginOffset is the offset in the encoding of the beginning of the signed portion, and signedPortionEndOffset is the offset in the encoding of the end of the signed portion. The signed portion starts from the first name component and ends just before the final name component (which is assumed to be a signature for a signed interest). |
Return type: | (int, int) |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Decode input as a name and set the fields of the Name object. Your derived class should override.
Parameters: |
|
---|---|
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Decode signatureInfo as a signature info and signatureValue as the related SignatureValue, and return a new object which is a subclass of Signature. Your derived class should override.
Parameters: |
|
---|---|
Returns: | A new object which is a subclass of Signature. |
Return type: | a subclass of Signature |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Encode controlParameters and return the encoding. Your derived class should override.
Parameters: | controlParameters (ControlParameters) – The ControlParameters object to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Encode data and return the encoding and signed offsets. Your derived class should override.
Parameters: | data (Data) – The Data object to encode. |
---|---|
Returns: | A Tuple of (encoding, signedPortionBeginOffset, signedPortionEndOffset) where encoding is a Blob containing the encoding, signedPortionBeginOffset is the offset in the encoding of the beginning of the signed portion, and signedPortionEndOffset is the offset in the encoding of the end of the signed portion. |
Return type: | (Blob, int, int) |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Encode the EncryptedContent and return the encoding. Your derived class should override.
Parameters: | encryptedContent (EncryptedContent) – The EncryptedContent object to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Encode interest and return the encoding. Your derived class should override.
Parameters: | interest (Interest) – The Interest object to encode. |
---|---|
Returns: | A Tuple of (encoding, signedPortionBeginOffset, signedPortionEndOffset) where encoding is a Blob containing the encoding, signedPortionBeginOffset is the offset in the encoding of the beginning of the signed portion, and signedPortionEndOffset is the offset in the encoding of the end of the signed portion. The signed portion starts from the first name component and ends just before the final name component (which is assumed to be a signature for a signed interest). |
Return type: | (Blob, int, int) |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Encode name and return the encoding. Your derived class should override.
Parameters: | name (Name) – The Name object to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Encode signature as a SignatureInfo and return the encoding. Your derived class should override.
Parameters: | signature (An object of a subclass of Signature) – An object of a subclass of Signature to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Encode the signatureValue in the Signature object as a SignatureValue (the signature bits) and return the encoding. Your derived class should override.
Parameters: | signature (An object of a subclass of Signature) – An object of a subclass of Signature with the signature value to encode. |
---|---|
Returns: | A Blob containing the encoding. |
Return type: | Blob |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |