Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 Regents of the University of California. |
| 3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 7 | #ifndef NDN_BINARYXMLWIREFORMAT_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 8 | #define NDN_BINARYXMLWIREFORMAT_HPP |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 9 | |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 10 | #include "wire-format.hpp" |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 11 | |
| 12 | namespace ndn { |
| 13 | |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 14 | /** |
| 15 | * A BinaryXmlWireFormat extends WireFormat to override its virtual methods to implement encoding and decoding |
| 16 | * using binary XML. |
| 17 | */ |
Jeff Thompson | f0fea00 | 2013-07-30 17:22:42 -0700 | [diff] [blame] | 18 | class BinaryXmlWireFormat : public WireFormat { |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 19 | public: |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 20 | /** |
| 21 | * Encode interest in binary XML and return the encoding. |
| 22 | * @param interest The Interest object to encode. |
Jeff Thompson | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 23 | * @return A Blob containing the encoding. |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 24 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 25 | virtual Blob |
| 26 | encodeInterest(const Interest& interest); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 27 | |
| 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 Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 34 | virtual void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame^] | 35 | decodeInterest(Interest& interest, const uint8_t *input, unsigned int inputLength); |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 36 | |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Encode data with binary XML and return the encoding. |
| 39 | * @param data The Data object to encode. |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 40 | * @param signedPortionBeginOffset Return the offset in the encoding of the beginning of the signed portion. |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 41 | * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value. |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 42 | * @param signedPortionEndOffset Return the offset in the encoding of the end of the signed portion. |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 43 | * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value. |
Jeff Thompson | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 44 | * @return A Blob containing the encoding. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 45 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 46 | virtual Blob |
| 47 | encodeData |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 48 | (const Data& data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset); |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 49 | |
| 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 Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 55 | * @param signedPortionBeginOffset Return the offset in the input buffer of the beginning of the signed portion. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 56 | * If you are not decoding in order to verify, you can call |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame^] | 57 | * decodeData(Data& data, const uint8_t *input, unsigned int inputLength) to ignore this returned value. |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 58 | * @param signedPortionEndOffset Return the offset in the input buffer of the end of the signed portion. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 59 | * If you are not decoding in order to verify, you can call |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame^] | 60 | * decodeData(Data& data, const uint8_t *input, unsigned int inputLength) to ignore this returned value. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 61 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 62 | virtual void |
| 63 | decodeData |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame^] | 64 | (Data& data, const uint8_t *input, unsigned int inputLength, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Encode forwardingEntry in binary XML and return the encoding. |
| 68 | * @param forwardingEntry The ForwardingEntry object to encode. |
Jeff Thompson | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 69 | * @return A Blob containing the encoding. |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 70 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 71 | virtual Blob |
| 72 | encodeForwardingEntry(const ForwardingEntry& forwardingEntry); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 73 | |
| 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 Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 80 | virtual void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame^] | 81 | decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, unsigned int inputLength); |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | } |
| 85 | |
| 86 | #endif |
| 87 | |