blob: 893d4813d6e1f29fcbb9269e5940bddcd2a9d7b2 [file] [log] [blame]
Alexander Afanasyev1043c702013-07-15 16:21:09 -07001/** -*- 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"
16#include "ns3/ndn-content-object.h"
17
18NDN_NAMESPACE_BEGIN
19
20namespace wire {
21namespace ccnb {
22
23/**
24 * @brief Routines to serialize/deserialize NDN interest in ccnb format
25 *
26 * @see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
27 **/
28class Interest : public Header
29{
30public:
31 Interest ();
32 Interest (Ptr<ndn::Interest> interest);
33
34 Ptr<ndn::Interest>
35 GetInterest ();
36
37 static Ptr<Packet>
38 ToWire (Ptr<const ndn::Interest> interest);
39
40 static Ptr<ndn::Interest>
41 FromWire (Ptr<Packet> packet);
42
43 //////////////////////////////////////////////////////////////////
44 // from Header
45 static TypeId GetTypeId (void);
46 virtual TypeId GetInstanceTypeId (void) const;
47 virtual void Print (std::ostream &os) const;
48 virtual uint32_t GetSerializedSize (void) const;
49 virtual void Serialize (Buffer::Iterator start) const;
50 virtual uint32_t Deserialize (Buffer::Iterator start);
51
52private:
53 Ptr<ndn::Interest> m_interest;
54};
55
56
57/**
58 * @brief Routines to serialize/deserialize NDN Data packet in ccnb format
59 *
60 * @see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
61 **/
62class Data : public Header
63{
64public:
65 Data ();
66 Data (Ptr<ndn::ContentObject> data);
67
68 Ptr<ndn::ContentObject>
69 GetData ();
70
71 static Ptr<Packet>
72 ToWire (Ptr<const ndn::ContentObject> data);
73
74 static Ptr<ndn::ContentObject>
75 FromWire (Ptr<Packet> packet);
76
77 // from Header
78 static TypeId GetTypeId (void);
79 virtual TypeId GetInstanceTypeId (void) const;
80 virtual void Print (std::ostream &os) const;
81 virtual uint32_t GetSerializedSize (void) const;
82 virtual void Serialize (Buffer::Iterator start) const;
83 virtual uint32_t Deserialize (Buffer::Iterator start);
84
85private:
86 Ptr<ndn::ContentObject> m_data;
87};
88
89} // ccnb
90} // wire
91
92NDN_NAMESPACE_END
93
94#endif // NDN_WIRE_CCNB_H