blob: 9b920b98ef66962aa717e06d980f63a4fc504718 [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 {
Alexander Afanasyev79206512013-07-27 16:49:12 -070021
22/**
23 * @brief Namespace for CCNb wire format operations
24 */
Alexander Afanasyev1043c702013-07-15 16:21:09 -070025namespace 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 **/
32class Interest : public Header
33{
34public:
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
56private:
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 **/
66class Data : public Header
67{
68public:
69 Data ();
70 Data (Ptr<ndn::ContentObject> data);
71
72 Ptr<ndn::ContentObject>
73 GetData ();
74
75 static Ptr<Packet>
76 ToWire (Ptr<const ndn::ContentObject> data);
77
78 static Ptr<ndn::ContentObject>
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
89private:
90 Ptr<ndn::ContentObject> m_data;
91};
92
93} // ccnb
94} // wire
95
96NDN_NAMESPACE_END
97
98#endif // NDN_WIRE_CCNB_H