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 | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 25 | virtual Blob encodeInterest(const Interest& interest); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 26 | |
| 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 Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 33 | virtual void decodeInterest(Interest& interest, const unsigned char *input, unsigned int inputLength); |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 34 | |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Encode data with binary XML and return the encoding. |
| 37 | * @param data The Data object to encode. |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 38 | * @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] | 39 | * 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] | 40 | * @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] | 41 | * 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] | 42 | * @return A Blob containing the encoding. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 43 | */ |
Jeff Thompson | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 44 | virtual Blob encodeData |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 45 | (const Data& data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset); |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 46 | |
| 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 Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 52 | * @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] | 53 | * If you are not decoding in order to verify, you can call |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 54 | * decodeData(Data& data, const unsigned char *input, unsigned int inputLength) to ignore this returned value. |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 55 | * @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] | 56 | * If you are not decoding in order to verify, you can call |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 57 | * decodeData(Data& data, const unsigned char *input, unsigned int inputLength) to ignore this returned value. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 58 | */ |
| 59 | virtual void decodeData |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 60 | (Data& data, const unsigned char *input, unsigned int inputLength, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Encode forwardingEntry in binary XML and return the encoding. |
| 64 | * @param forwardingEntry The ForwardingEntry object to encode. |
Jeff Thompson | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 65 | * @return A Blob containing the encoding. |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 66 | */ |
Jeff Thompson | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 67 | virtual Blob encodeForwardingEntry(const ForwardingEntry& forwardingEntry); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 68 | |
| 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 Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 75 | virtual void decodeForwardingEntry(ForwardingEntry& forwardingEntry, const unsigned char *input, unsigned int inputLength); |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } |
| 79 | |
| 80 | #endif |
| 81 | |