blob: e83c2170ec6d18019ba03c925ae76832758f32e7 [file] [log] [blame]
Alexander Afanasyev7b923f32013-07-16 13:23:04 -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 * GNU 3.0 license, See the LICENSE file for more information
7 *
8 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
9 */
10
11#ifndef NDN_WIRE_H
12#define NDN_WIRE_H
13
14#include "ns3/buffer.h"
15
16#include "ns3/ndn-common.h"
17#include "ns3/ndn-name.h"
18#include "ns3/ndn-interest.h"
19#include "ns3/ndn-content-object.h"
20
21NDN_NAMESPACE_BEGIN
22
23struct Wire
24{
25 enum
26 {
27 WIRE_FORMAT_DEFAULT = -2,
28 WIRE_FORMAT_AUTODETECT = -1,
29
30 WIRE_FORMAT_NDNSIM = 0,
31 WIRE_FORMAT_CCNB = 1
32 };
33
34 static Ptr<Packet>
35 FromInterest (Ptr<const Interest> interest, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
36
37 static Ptr<Interest>
38 ToInterest (Ptr<Packet> packet, int8_t type = WIRE_FORMAT_AUTODETECT);
39
40 static Ptr<Packet>
41 FromData (Ptr<const ContentObject> data, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
42
43 static Ptr<ContentObject>
44 ToData (Ptr<Packet> packet, int8_t type = WIRE_FORMAT_AUTODETECT);
45
46 /*
47 * @brief Get size of buffer to fit wire-formatted name object
48 */
49 static uint32_t
50 FromNameSize (Ptr<const Name> name, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
51
52 /**
53 * @brief Convert name to wire format
54 */
55 static void
56 FromName (Buffer::Iterator start, Ptr<const Name> name, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
57
58 /**
59 * @brief Convert name from wire format
60 */
61 static Ptr<Name>
62 ToName (Buffer::Iterator start, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
63};
64
65NDN_NAMESPACE_END
66
67#endif // NDN_WIRE_H