Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 5 | * See COPYING for copyright and distribution information. |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 8 | #ifndef NDN_BINARYXMLWIREFORMAT_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 9 | #define NDN_BINARYXMLWIREFORMAT_HPP |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 10 | |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 11 | #include "wire-format.hpp" |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 12 | |
| 13 | namespace ndn { |
| 14 | |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 15 | /** |
| 16 | * A BinaryXmlWireFormat extends WireFormat to override its virtual methods to implement encoding and decoding |
| 17 | * using binary XML. |
| 18 | */ |
Jeff Thompson | f0fea00 | 2013-07-30 17:22:42 -0700 | [diff] [blame] | 19 | class BinaryXmlWireFormat : public WireFormat { |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 20 | public: |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 21 | /** |
| 22 | * Encode interest in binary XML and return the encoding. |
| 23 | * @param interest The Interest object to encode. |
Jeff Thompson | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 24 | * @return A Blob containing the encoding. |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 25 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 26 | virtual Blob |
| 27 | encodeInterest(const Interest& interest); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * Decode input as an interest in binary XML and set the fields of the interest object. |
| 31 | * @param interest The Interest object whose fields are updated. |
| 32 | * @param input A pointer to the input buffer to decode. |
| 33 | * @param inputLength The number of bytes in input. |
| 34 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 35 | virtual void |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 36 | decodeInterest(Interest& interest, const uint8_t *input, size_t inputLength); |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 37 | |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Encode data with binary XML and return the encoding. |
| 40 | * @param data The Data object to encode. |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 41 | * @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] | 42 | * 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] | 43 | * @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] | 44 | * 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] | 45 | * @return A Blob containing the encoding. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 46 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 47 | virtual Blob |
| 48 | encodeData |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 49 | (const Data& data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset); |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Decode input as a data packet in binary XML and set the fields in the data object. |
| 53 | * @param data The Data object whose fields are updated. |
| 54 | * @param input A pointer to the input buffer to decode. |
| 55 | * @param inputLength The number of bytes in input. |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 56 | * @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] | 57 | * If you are not decoding in order to verify, you can call |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 58 | * decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value. |
Jeff Thompson | 9c66170 | 2013-09-13 14:35:44 -0700 | [diff] [blame] | 59 | * @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] | 60 | * If you are not decoding in order to verify, you can call |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 61 | * decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 62 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 63 | virtual void |
| 64 | decodeData |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 65 | (Data& data, const uint8_t *input, size_t inputLength, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Encode forwardingEntry in binary XML and return the encoding. |
| 69 | * @param forwardingEntry The ForwardingEntry object to encode. |
Jeff Thompson | c2b7b14 | 2013-09-12 15:29:04 -0700 | [diff] [blame] | 70 | * @return A Blob containing the encoding. |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 71 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 72 | virtual Blob |
| 73 | encodeForwardingEntry(const ForwardingEntry& forwardingEntry); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Decode input as a forwarding entry in binary XML and set the fields of the forwardingEntry object. |
| 77 | * @param forwardingEntry The ForwardingEntry object whose fields are updated. |
| 78 | * @param input A pointer to the input buffer to decode. |
| 79 | * @param inputLength The number of bytes in input. |
| 80 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 81 | virtual void |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 82 | decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, size_t inputLength); |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | } |
| 86 | |
| 87 | #endif |
| 88 | |