blob: c1696692bbde0c24d4b211c557ca6e4c706571dd [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 Thompson0050abe2013-09-17 12:50:25 -070025 virtual Blob
26 encodeInterest(const Interest& interest);
Jeff Thompson990599b2013-08-27 15:14:25 -070027
28 /**
29 * Decode input as an interest in binary XML and set the fields of the interest object.
30 * @param interest The Interest object whose fields are updated.
31 * @param input A pointer to the input buffer to decode.
32 * @param inputLength The number of bytes in input.
33 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070034 virtual void
Jeff Thompson97223af2013-09-24 17:01:27 -070035 decodeInterest(Interest& interest, const uint8_t *input, size_t inputLength);
Jeff Thompson5cae5e52013-07-10 19:41:20 -070036
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070037 /**
38 * Encode data with binary XML and return the encoding.
39 * @param data The Data object to encode.
Jeff Thompson9c661702013-09-13 14:35:44 -070040 * @param signedPortionBeginOffset Return the offset in the encoding of the beginning 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 Thompson9c661702013-09-13 14:35:44 -070042 * @param signedPortionEndOffset Return the offset in the encoding of the end of the signed portion.
Jeff Thompson1656e6a2013-08-29 18:01:48 -070043 * 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 -070044 * @return A Blob containing the encoding.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070045 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070046 virtual Blob
47 encodeData
Jeff Thompson97223af2013-09-24 17:01:27 -070048 (const Data& data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset);
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070049
50 /**
51 * Decode input as a data packet in binary XML and set the fields in the data object.
52 * @param data The Data object whose fields are updated.
53 * @param input A pointer to the input buffer to decode.
54 * @param inputLength The number of bytes in input.
Jeff Thompson9c661702013-09-13 14:35:44 -070055 * @param signedPortionBeginOffset Return the offset in the input buffer of the beginning 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 Thompson97223af2013-09-24 17:01:27 -070057 * decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value.
Jeff Thompson9c661702013-09-13 14:35:44 -070058 * @param signedPortionEndOffset Return the offset in the input buffer of the end of the signed portion.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070059 * If you are not decoding in order to verify, you can call
Jeff Thompson97223af2013-09-24 17:01:27 -070060 * decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070061 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070062 virtual void
63 decodeData
Jeff Thompson97223af2013-09-24 17:01:27 -070064 (Data& data, const uint8_t *input, size_t inputLength, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset);
Jeff Thompson990599b2013-08-27 15:14:25 -070065
66 /**
67 * Encode forwardingEntry in binary XML and return the encoding.
68 * @param forwardingEntry The ForwardingEntry object to encode.
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070069 * @return A Blob containing the encoding.
Jeff Thompson990599b2013-08-27 15:14:25 -070070 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070071 virtual Blob
72 encodeForwardingEntry(const ForwardingEntry& forwardingEntry);
Jeff Thompson990599b2013-08-27 15:14:25 -070073
74 /**
75 * Decode input as a forwarding entry in binary XML and set the fields of the forwardingEntry object.
76 * @param forwardingEntry The ForwardingEntry object whose fields are updated.
77 * @param input A pointer to the input buffer to decode.
78 * @param inputLength The number of bytes in input.
79 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070080 virtual void
Jeff Thompson97223af2013-09-24 17:01:27 -070081 decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, size_t inputLength);
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070082};
83
84}
85
86#endif
87