shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014, Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of NDNS (Named Data Networking Domain Name Service). |
| 6 | * See AUTHORS.md for complete list of NDNS authors and contributors. |
| 7 | * |
| 8 | * NDNS is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | #ifndef NAME_DIG_HPP_ |
| 20 | #define NAME_DIG_HPP_ |
| 21 | |
| 22 | #include "ndn-app.hpp" |
| 23 | #include "rr.hpp" |
| 24 | #include "response.hpp" |
| 25 | #include "query.hpp" |
| 26 | |
| 27 | namespace ndn { |
| 28 | namespace ndns { |
| 29 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 30 | class NameDig: public NDNApp |
| 31 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 32 | public: |
| 33 | NameDig(const char *programName, const char *prefix); |
| 34 | virtual ~NameDig(); |
| 35 | |
| 36 | void |
| 37 | onData(const ndn::Interest& interest, Data& data); |
| 38 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 39 | void |
| 40 | onTimeout(const ndn::Interest& interest); |
| 41 | |
| 42 | void |
| 43 | sendQuery(); |
| 44 | |
| 45 | void |
| 46 | run(); |
| 47 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 48 | const vector<RR>& getRrs() const |
| 49 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 50 | return m_rrs; |
| 51 | } |
| 52 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 53 | void setRrs(const vector<RR>& rrs) |
| 54 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 55 | m_rrs = rrs; |
| 56 | } |
| 57 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 58 | const Name& getResolverName() const |
| 59 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 60 | return m_resolverName; |
| 61 | } |
| 62 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 63 | void setResolverName(const Name& resolverName) |
| 64 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 65 | m_resolverName = resolverName; |
| 66 | } |
| 67 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 68 | const Name& getDstLabel() const |
| 69 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 70 | return m_dstLabel; |
| 71 | } |
| 72 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 73 | void setDstLabel(const Name& dstLabel) |
| 74 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 75 | m_dstLabel = dstLabel; |
| 76 | } |
| 77 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 78 | RR::RRType getRrType() const |
| 79 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 80 | return m_rrType; |
| 81 | } |
| 82 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 83 | void setRrType(RR::RRType rrType) |
| 84 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 85 | m_rrType = rrType; |
| 86 | } |
| 87 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 88 | const Response& getResponse() const |
| 89 | { |
| 90 | return response; |
| 91 | } |
| 92 | |
| 93 | void setResponse(const Response& response) |
| 94 | { |
| 95 | this->response = response; |
| 96 | } |
| 97 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 98 | private: |
| 99 | Name m_resolverName; |
| 100 | Name m_dstLabel; |
| 101 | RR::RRType m_rrType; |
| 102 | vector<RR> m_rrs; |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 103 | |
| 104 | Response response; |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | } /* namespace ndns */ |
| 108 | } /* namespace ndn */ |
| 109 | |
| 110 | #endif /* NAME_DIG_HPP_ */ |