blob: eca8707cfa4091e3c306e6173cf04ae71a2664ad [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"
Alexander Afanasyev6eba36f2013-08-07 17:42:54 -070016#include "ns3/ndn-data.h"
Alexander Afanasyev1043c702013-07-15 16:21:09 -070017
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 ();
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070070 Data (Ptr<ndn::Data> data);
Alexander Afanasyev1043c702013-07-15 16:21:09 -070071
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070072 Ptr<ndn::Data>
Alexander Afanasyev1043c702013-07-15 16:21:09 -070073 GetData ();
74
75 static Ptr<Packet>
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070076 ToWire (Ptr<const ndn::Data> data);
Alexander Afanasyev1043c702013-07-15 16:21:09 -070077
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070078 static Ptr<ndn::Data>
Alexander Afanasyev1043c702013-07-15 16:21:09 -070079 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:
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070090 Ptr<ndn::Data> m_data;
Alexander Afanasyev1043c702013-07-15 16:21:09 -070091};
92
93} // ccnb
94} // wire
95
96NDN_NAMESPACE_END
97
98#endif // NDN_WIRE_CCNB_H