Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 1 | /** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Alexander Afanasyev |
| 5 | * |
| 6 | * BSD license, See the doc/LICENSE file for more information |
| 7 | * |
| 8 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 9 | */ |
| 10 | |
| 11 | #ifndef NDN_WIRE_CCNB_H |
| 12 | #define NDN_WIRE_CCNB_H |
| 13 | |
| 14 | #include "ns3/ndn-common.h" |
| 15 | #include "ns3/ndn-interest.h" |
Alexander Afanasyev | 6eba36f | 2013-08-07 17:42:54 -0700 | [diff] [blame] | 16 | #include "ns3/ndn-data.h" |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 17 | |
| 18 | NDN_NAMESPACE_BEGIN |
| 19 | |
| 20 | namespace wire { |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * @brief Namespace for CCNb wire format operations |
| 24 | */ |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 25 | namespace ccnb { |
| 26 | |
| 27 | /** |
| 28 | * @brief Routines to serialize/deserialize NDN interest in ccnb format |
| 29 | * |
| 30 | * @see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html |
| 31 | **/ |
| 32 | class Interest : public Header |
| 33 | { |
| 34 | public: |
| 35 | Interest (); |
| 36 | Interest (Ptr<ndn::Interest> interest); |
| 37 | |
| 38 | Ptr<ndn::Interest> |
| 39 | GetInterest (); |
| 40 | |
| 41 | static Ptr<Packet> |
| 42 | ToWire (Ptr<const ndn::Interest> interest); |
| 43 | |
| 44 | static Ptr<ndn::Interest> |
| 45 | FromWire (Ptr<Packet> packet); |
| 46 | |
| 47 | ////////////////////////////////////////////////////////////////// |
| 48 | // from Header |
| 49 | static TypeId GetTypeId (void); |
| 50 | virtual TypeId GetInstanceTypeId (void) const; |
| 51 | virtual void Print (std::ostream &os) const; |
| 52 | virtual uint32_t GetSerializedSize (void) const; |
| 53 | virtual void Serialize (Buffer::Iterator start) const; |
| 54 | virtual uint32_t Deserialize (Buffer::Iterator start); |
| 55 | |
| 56 | private: |
| 57 | Ptr<ndn::Interest> m_interest; |
| 58 | }; |
| 59 | |
| 60 | |
| 61 | /** |
| 62 | * @brief Routines to serialize/deserialize NDN Data packet in ccnb format |
| 63 | * |
| 64 | * @see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html |
| 65 | **/ |
| 66 | class Data : public Header |
| 67 | { |
| 68 | public: |
| 69 | Data (); |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 70 | Data (Ptr<ndn::Data> data); |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 71 | |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 72 | Ptr<ndn::Data> |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 73 | GetData (); |
| 74 | |
| 75 | static Ptr<Packet> |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 76 | ToWire (Ptr<const ndn::Data> data); |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 77 | |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 78 | static Ptr<ndn::Data> |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 79 | FromWire (Ptr<Packet> packet); |
| 80 | |
| 81 | // from Header |
| 82 | static TypeId GetTypeId (void); |
| 83 | virtual TypeId GetInstanceTypeId (void) const; |
| 84 | virtual void Print (std::ostream &os) const; |
| 85 | virtual uint32_t GetSerializedSize (void) const; |
| 86 | virtual void Serialize (Buffer::Iterator start) const; |
| 87 | virtual uint32_t Deserialize (Buffer::Iterator start); |
| 88 | |
| 89 | private: |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 90 | Ptr<ndn::Data> m_data; |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // ccnb |
| 94 | } // wire |
| 95 | |
| 96 | NDN_NAMESPACE_END |
| 97 | |
| 98 | #endif // NDN_WIRE_CCNB_H |