blob: 6647566fa4d794e774592653c04d342953661bda [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07004 */
5
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07006#ifndef NDN_BINARYXMLWIREFORMAT_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07007#define NDN_BINARYXMLWIREFORMAT_HPP
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07008
Jeff Thompson53412192013-08-06 13:35:50 -07009#include "wire-format.hpp"
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070010
11namespace ndn {
12
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070013/**
14 * A BinaryXmlWireFormat extends WireFormat to override its virtual methods to implement encoding and decoding
15 * using binary XML.
16 */
Jeff Thompsonf0fea002013-07-30 17:22:42 -070017class BinaryXmlWireFormat : public WireFormat {
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070018public:
Jeff Thompson990599b2013-08-27 15:14:25 -070019 /**
20 * Encode interest in binary XML and return the encoding.
21 * @param interest The Interest object to encode.
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070022 * @return A Blob containing the encoding.
Jeff Thompson990599b2013-08-27 15:14:25 -070023 */
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070024 virtual Blob encodeInterest(const Interest& interest);
Jeff Thompson990599b2013-08-27 15:14:25 -070025
26 /**
27 * Decode input as an interest in binary XML and set the fields of the interest object.
28 * @param interest The Interest object whose fields are updated.
29 * @param input A pointer to the input buffer to decode.
30 * @param inputLength The number of bytes in input.
31 */
Jeff Thompson1656e6a2013-08-29 18:01:48 -070032 virtual void decodeInterest(Interest& interest, const unsigned char *input, unsigned int inputLength);
Jeff Thompson5cae5e52013-07-10 19:41:20 -070033
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070034 /**
35 * Encode data with binary XML and return the encoding.
36 * @param data The Data object to encode.
37 * @param signedFieldsBeginOffset Return the offset in the encoding of the beginning of the fields which are signed.
Jeff Thompson1656e6a2013-08-29 18:01:48 -070038 * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070039 * @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed.
Jeff Thompson1656e6a2013-08-29 18:01:48 -070040 * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value.
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070041 * @return A Blob containing the encoding.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070042 */
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070043 virtual Blob encodeData
Jeff Thompson1656e6a2013-08-29 18:01:48 -070044 (const Data& data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset);
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070045
46 /**
47 * Decode input as a data packet in binary XML and set the fields in the data object.
48 * @param data The Data object whose fields are updated.
49 * @param input A pointer to the input buffer to decode.
50 * @param inputLength The number of bytes in input.
51 * @param signedFieldsBeginOffset Return the offset in the input buffer of the beginning of the fields which are signed.
52 * If you are not decoding in order to verify, you can call
Jeff Thompson1656e6a2013-08-29 18:01:48 -070053 * decodeData(Data& data, const unsigned char *input, unsigned int inputLength) to ignore this returned value.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070054 * @param signedFieldsEndOffset Return the offset in the input buffer of the end of the fields which are signed.
55 * If you are not decoding in order to verify, you can call
Jeff Thompson1656e6a2013-08-29 18:01:48 -070056 * decodeData(Data& data, const unsigned char *input, unsigned int inputLength) to ignore this returned value.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070057 */
58 virtual void decodeData
Jeff Thompson1656e6a2013-08-29 18:01:48 -070059 (Data& data, const unsigned char *input, unsigned int inputLength, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset);
Jeff Thompson990599b2013-08-27 15:14:25 -070060
61 /**
62 * Encode forwardingEntry in binary XML and return the encoding.
63 * @param forwardingEntry The ForwardingEntry object to encode.
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070064 * @return A Blob containing the encoding.
Jeff Thompson990599b2013-08-27 15:14:25 -070065 */
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070066 virtual Blob encodeForwardingEntry(const ForwardingEntry& forwardingEntry);
Jeff Thompson990599b2013-08-27 15:14:25 -070067
68 /**
69 * Decode input as a forwarding entry in binary XML and set the fields of the forwardingEntry object.
70 * @param forwardingEntry The ForwardingEntry object whose fields are updated.
71 * @param input A pointer to the input buffer to decode.
72 * @param inputLength The number of bytes in input.
73 */
Jeff Thompson1656e6a2013-08-29 18:01:48 -070074 virtual void decodeForwardingEntry(ForwardingEntry& forwardingEntry, const unsigned char *input, unsigned int inputLength);
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070075};
76
77}
78
79#endif
80