blob: 52e11c62ea05ca1b8721b4c04bc48b3faf78f859 [file] [log] [blame]
shockjiange9c1ab92014-07-21 12:02:52 -07001/*
2 * response.h
3 *
4 * Created on: 19 Jul, 2014
5 * Author: shock
6 */
7
8#ifndef RESPONSE_H_
9#define RESPONSE_H_
10
11#include <boost/asio.hpp> // /opt/local/include
12#include <boost/bind.hpp>
13#include <boost/date_time/posix_time/posix_time.hpp>
14#include <boost/noncopyable.hpp>
15
16#include <ndn-cxx/face.hpp> // /usr/local/include
17#include <ndn-cxx/name.hpp>
18#include <ndn-cxx/data.hpp>
19
20#include <ndn-cxx/encoding/block-helpers.hpp>
21#include <ndn-cxx/encoding/block.hpp>
22#include <ndn-cxx/encoding/tlv-ndnd.hpp>
23
24#include<vector>
25
26#include "ndns-tlv.h"
27
28using namespace std;
29
30namespace ndn {
31
32
33
34enum class ResponseType
35{
36 NDNS_Resp,
37 NDNS_Nack,
38 NDNS_Auth
39};
40
41
42static const string
43toString(ResponseType responseType) const
44{
45 string label;
46 switch (responseType)
47 {
48 case ResponseType::NDNS_Resp:
49 label = "NDNS Resp";
50 break;
51 case ResponseType::NDNS_Nack:
52 label = "NDNS Nack";
53 break;
54 case ResponseType::NDNS_Auth:
55 label = "NDNS Auth";
56 break;
57 default:
58 label = "Default";
59 break;
60 }
61 return label;
62}
63
64class Response {
65public:
66 Response();
67 virtual ~Response();
68
69Data
70toWire() const;
71
72void
73fromWire(const Interest &interest, const Data &data);
74
75private:
76 Name m_queryName;
77 string m_serial;
78 ResponseType m_responseType;
79
80 time::milliseconds m_freshness;
81
82 unsigned int m_numberOfRR;
83 vector<RR> m_rrs;
84
85};
86
87} /* namespace ndn */
88
89#endif /* RESPONSE_H_ */