blob: cb4f0aa955e9ba67b54e6a0956d63a31d8d2e226 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompson47eecfc2013-07-07 22:56:46 -07002/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07003 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson47eecfc2013-07-07 22:56:46 -07005 * See COPYING for copyright and distribution information.
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07006 */
7
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07008#ifndef NDN_BINARYXMLWIREFORMAT_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07009#define NDN_BINARYXMLWIREFORMAT_HPP
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070010
Jeff Thompson53412192013-08-06 13:35:50 -070011#include "wire-format.hpp"
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070012
13namespace ndn {
14
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070015/**
16 * A BinaryXmlWireFormat extends WireFormat to override its virtual methods to implement encoding and decoding
17 * using binary XML.
18 */
Jeff Thompsonf0fea002013-07-30 17:22:42 -070019class BinaryXmlWireFormat : public WireFormat {
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070020public:
Jeff Thompson990599b2013-08-27 15:14:25 -070021 /**
22 * Encode interest in binary XML and return the encoding.
23 * @param interest The Interest object to encode.
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070024 * @return A Blob containing the encoding.
Jeff Thompson990599b2013-08-27 15:14:25 -070025 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070026 virtual Blob
27 encodeInterest(const Interest& interest);
Jeff Thompson990599b2013-08-27 15:14:25 -070028
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 Thompson0050abe2013-09-17 12:50:25 -070035 virtual void
Jeff Thompson97223af2013-09-24 17:01:27 -070036 decodeInterest(Interest& interest, const uint8_t *input, size_t inputLength);
Jeff Thompson5cae5e52013-07-10 19:41:20 -070037
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070038 /**
39 * Encode data with binary XML and return the encoding.
40 * @param data The Data object to encode.
Jeff Thompson9c661702013-09-13 14:35:44 -070041 * @param signedPortionBeginOffset Return the offset in the encoding of the beginning of the signed portion.
Jeff Thompson1656e6a2013-08-29 18:01:48 -070042 * 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 -070043 * @param signedPortionEndOffset Return the offset in the encoding of the end of the signed portion.
Jeff Thompson1656e6a2013-08-29 18:01:48 -070044 * 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 -070045 * @return A Blob containing the encoding.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070046 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070047 virtual Blob
48 encodeData
Jeff Thompson97223af2013-09-24 17:01:27 -070049 (const Data& data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset);
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070050
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 Thompson9c661702013-09-13 14:35:44 -070056 * @param signedPortionBeginOffset Return the offset in the input buffer of the beginning of the signed portion.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070057 * If you are not decoding in order to verify, you can call
Jeff Thompson97223af2013-09-24 17:01:27 -070058 * decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value.
Jeff Thompson9c661702013-09-13 14:35:44 -070059 * @param signedPortionEndOffset Return the offset in the input buffer of the end of the signed portion.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070060 * If you are not decoding in order to verify, you can call
Jeff Thompson97223af2013-09-24 17:01:27 -070061 * decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value.
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070062 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070063 virtual void
64 decodeData
Jeff Thompson97223af2013-09-24 17:01:27 -070065 (Data& data, const uint8_t *input, size_t inputLength, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset);
Jeff Thompson990599b2013-08-27 15:14:25 -070066
67 /**
68 * Encode forwardingEntry in binary XML and return the encoding.
69 * @param forwardingEntry The ForwardingEntry object to encode.
Jeff Thompsonc2b7b142013-09-12 15:29:04 -070070 * @return A Blob containing the encoding.
Jeff Thompson990599b2013-08-27 15:14:25 -070071 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070072 virtual Blob
73 encodeForwardingEntry(const ForwardingEntry& forwardingEntry);
Jeff Thompson990599b2013-08-27 15:14:25 -070074
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 Thompson0050abe2013-09-17 12:50:25 -070081 virtual void
Jeff Thompson97223af2013-09-24 17:01:27 -070082 decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, size_t inputLength);
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070083};
84
85}
86
87#endif
88