In ndn_decodeBinaryXmlData, added signedFieldsBeginOffset and signedFieldsEndOffset.
diff --git a/ndn-cpp/c/encoding/binary-xml-data.c b/ndn-cpp/c/encoding/binary-xml-data.c
index b2d391a..564e6f4 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -159,7 +159,8 @@
return NDN_ERROR_success;
}
-ndn_Error ndn_decodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlDecoder *decoder)
+ndn_Error ndn_decodeBinaryXmlData
+ (struct ndn_Data *data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset, struct ndn_BinaryXmlDecoder *decoder)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(decoder, ndn_BinaryXml_DTag_ContentObject)))
@@ -175,6 +176,8 @@
else
ndn_Signature_init(&data->signature);
+ *signedFieldsBeginOffset = decoder->offset;
+
if ((error = ndn_decodeBinaryXmlName(&data->name, decoder)))
return error;
@@ -192,6 +195,8 @@
(decoder, ndn_BinaryXml_DTag_Content, 1, &data->content, &data->contentLength)))
return error;
+ *signedFieldsEndOffset = decoder->offset;
+
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
return error;
diff --git a/ndn-cpp/c/encoding/binary-xml-data.h b/ndn-cpp/c/encoding/binary-xml-data.h
index df77d69..cfbfa3d 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.h
+++ b/ndn-cpp/c/encoding/binary-xml-data.h
@@ -16,19 +16,30 @@
#endif
/**
- * Encode the data as binary XML.
+ * Encode the data packet as binary XML.
* @param data Pointer to the data object the encode.
* @param signedFieldsBeginOffset Return the offset in the encoding of the beginning of the fields which are signed.
* If you are not encoding in order to sign, you can ignore this.
* @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed.
* If you are not encoding in order to sign, you can ignore this.
- * @param encoder Pointer to the encoder object which receives the encoding.
- * @return
+ * @param encoder Pointer to the ndn_BinaryXmlEncoder struct which receives the encoding.
+ * @return 0 for success, else an error code.
*/
ndn_Error ndn_encodeBinaryXmlData
(struct ndn_Data *data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset, struct ndn_BinaryXmlEncoder *encoder);
-ndn_Error ndn_decodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlDecoder *decoder);
+/**
+ * Decode the data packet as binary XML.
+ * @param data Pointer to the data object the decode.
+ * @param signedFieldsBeginOffset Return the offset in the encoding of the beginning of the fields which are signed.
+ * If you are not encoding in order to sign, you can ignore this.
+ * @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed.
+ * If you are not encoding in order to sign, you can ignore this.
+ * @param decoder Pointer to the ndn_BinaryXmlDecoder struct which has been initialized with the buffer to decode.
+ * @return 0 for success, else an error code.
+ */
+ndn_Error ndn_decodeBinaryXmlData
+ (struct ndn_Data *data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset, struct ndn_BinaryXmlDecoder *decoder);
#ifdef __cplusplus
}
diff --git a/ndn-cpp/encoding/binary-xml-wire-format.cpp b/ndn-cpp/encoding/binary-xml-wire-format.cpp
index 3ef731c..43e09bc 100644
--- a/ndn-cpp/encoding/binary-xml-wire-format.cpp
+++ b/ndn-cpp/encoding/binary-xml-wire-format.cpp
@@ -82,8 +82,9 @@
(&dataStruct, nameComponents, sizeof(nameComponents) / sizeof(nameComponents[0]));
BinaryXmlDecoder decoder(input, inputLength);
+ unsigned int dummyBeginOffset, dummyEndOffset;
ndn_Error error;
- if ((error = ndn_decodeBinaryXmlData(&dataStruct, &decoder)))
+ if ((error = ndn_decodeBinaryXmlData(&dataStruct, &dummyBeginOffset, &dummyEndOffset, &decoder)))
throw std::runtime_error(ndn_getErrorString(error));
data.set(dataStruct);