blob: ebb741241e7dfc8b20731a09be35cbbcaca2692a [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson47eecfc2013-07-07 22:56:46 -07004 * See COPYING for copyright and distribution information.
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07005 */
6
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07007#ifndef NDN_BINARYXMLWIREFORMAT_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07008#define NDN_BINARYXMLWIREFORMAT_HPP
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07009
Jeff Thompson53412192013-08-06 13:35:50 -070010#include "wire-format.hpp"
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070011
12namespace ndn {
13
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070014/**
15 * A BinaryXmlWireFormat extends WireFormat to override its virtual methods to implement encoding and decoding
16 * using binary XML.
17 */
Jeff Thompsonf0fea002013-07-30 17:22:42 -070018class BinaryXmlWireFormat : public WireFormat {
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070019public:
Jeff Thompson990599b2013-08-27 15:14:25 -070020 /**
21 * Encode interest in binary XML and return the encoding.
22 * @param interest The Interest object to encode.
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070023 * @return A Blob containing the encoding.
Jeff Thompson990599b2013-08-27 15:14:25 -070024 */
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070025 virtual Blob encodeInterest(const Interest& interest);
Jeff Thompson990599b2013-08-27 15:14:25 -070026
27 /**
28 * Decode input as an interest in binary XML and set the fields of the interest object.
29 * @param interest The Interest object whose fields are updated.
30 * @param input A pointer to the input buffer to decode.
31 * @param inputLength The number of bytes in input.
32 */
Jeff Thompson1656e6a2013-08-29 18:01:48 -070033 virtual void decodeInterest(Interest& interest, const unsigned char *input, unsigned int inputLength);
Jeff Thompson5cae5e52013-07-10 19:41:20 -070034
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070035 /**
36 * Encode data with binary XML and return the encoding.
37 * @param data The Data object to encode.
Jeff Thompson9c661702013-09-13 14:35:44 -070038 * @param signedPortionBeginOffset Return the offset in the encoding of the beginning of the signed portion.
Jeff Thompson1656e6a2013-08-29 18:01:48 -070039 * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value.
Jeff Thompson9c661702013-09-13 14:35:44 -070040 * @param signedPortionEndOffset Return the offset in the encoding of the end of the signed portion.
Jeff Thompson1656e6a2013-08-29 18:01:48 -070041 * 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 -070042 * @return A Blob containing the encoding.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070043 */
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070044 virtual Blob encodeData
Jeff Thompson9c661702013-09-13 14:35:44 -070045 (const Data& data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset);
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070046
47 /**
48 * Decode input as a data packet in binary XML and set the fields in the data object.
49 * @param data The Data object whose fields are updated.
50 * @param input A pointer to the input buffer to decode.
51 * @param inputLength The number of bytes in input.
Jeff Thompson9c661702013-09-13 14:35:44 -070052 * @param signedPortionBeginOffset Return the offset in the input buffer of the beginning of the signed portion.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070053 * If you are not decoding in order to verify, you can call
Jeff Thompson1656e6a2013-08-29 18:01:48 -070054 * decodeData(Data& data, const unsigned char *input, unsigned int inputLength) to ignore this returned value.
Jeff Thompson9c661702013-09-13 14:35:44 -070055 * @param signedPortionEndOffset Return the offset in the input buffer of the end of the signed portion.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070056 * If you are not decoding in order to verify, you can call
Jeff Thompson1656e6a2013-08-29 18:01:48 -070057 * decodeData(Data& data, const unsigned char *input, unsigned int inputLength) to ignore this returned value.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070058 */
59 virtual void decodeData
Jeff Thompson9c661702013-09-13 14:35:44 -070060 (Data& data, const unsigned char *input, unsigned int inputLength, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset);
Jeff Thompson990599b2013-08-27 15:14:25 -070061
62 /**
63 * Encode forwardingEntry in binary XML and return the encoding.
64 * @param forwardingEntry The ForwardingEntry object to encode.
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070065 * @return A Blob containing the encoding.
Jeff Thompson990599b2013-08-27 15:14:25 -070066 */
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070067 virtual Blob encodeForwardingEntry(const ForwardingEntry& forwardingEntry);
Jeff Thompson990599b2013-08-27 15:14:25 -070068
69 /**
70 * Decode input as a forwarding entry in binary XML and set the fields of the forwardingEntry object.
71 * @param forwardingEntry The ForwardingEntry object whose fields are updated.
72 * @param input A pointer to the input buffer to decode.
73 * @param inputLength The number of bytes in input.
74 */
Jeff Thompson1656e6a2013-08-29 18:01:48 -070075 virtual void decodeForwardingEntry(ForwardingEntry& forwardingEntry, const unsigned char *input, unsigned int inputLength);
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070076};
77
78}
79
80#endif
81