Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -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 | |
| 20 | #ifndef NDNS_NDNS_LABEL_HPP |
| 21 | #define NDNS_NDNS_LABEL_HPP |
| 22 | |
| 23 | #include "ndns-enum.hpp" |
| 24 | |
| 25 | #include <ndn-cxx/name.hpp> |
| 26 | #include <ndn-cxx/interest.hpp> |
| 27 | |
| 28 | #include <string> |
| 29 | |
| 30 | namespace ndn { |
| 31 | namespace ndns { |
| 32 | namespace label { |
| 33 | |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 34 | |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 35 | /** |
| 36 | * @brief NDNS iterative query type |
| 37 | */ |
| 38 | |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 39 | const name::Component NDNS_ITERATIVE_QUERY("NDNS"); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * @brief NDNS recursive query type |
| 43 | */ |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 44 | const name::Component NDNS_RECURSIVE_QUERY("NDNS-R"); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * @brief NDNS ID-CERT query type |
| 48 | */ |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 49 | const name::Component NDNS_CERT_QUERY("KEY"); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 50 | |
| 51 | ///////////////////////////////////////////// |
| 52 | |
| 53 | /** |
| 54 | * @brief label of forwarding hint |
| 55 | * @todo not support forwarding hint yet, for future use |
| 56 | */ |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 57 | const name::Component FORWARDING_HINT_LABEL("\xF0."); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * @brief label of update message, located at the last component in Interest name |
| 61 | */ |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 62 | const name::Component NDNS_UPDATE_LABEL("UPDATE"); |
| 63 | |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 64 | |
| 65 | ////////////////////////////////////////////// |
| 66 | |
| 67 | /** |
| 68 | * @brief NS resource record type |
| 69 | */ |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 70 | const name::Component NS_RR_TYPE("NS"); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * @brief ID-CERT resource record type |
| 74 | */ |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 75 | const name::Component CERT_RR_TYPE("ID-CERT"); |
| 76 | |
| 77 | /** |
| 78 | * @brief TXT resource record type |
| 79 | */ |
| 80 | const name::Component TXT_RR_TYPE("TXT"); |
| 81 | |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 82 | |
| 83 | ////////////////////////////////////////// |
| 84 | |
| 85 | /** |
| 86 | * @brief result of Matching. version only works when matching a Interest Name |
| 87 | */ |
| 88 | struct MatchResult |
| 89 | { |
| 90 | Name rrLabel; |
| 91 | name::Component rrType; |
| 92 | name::Component version; |
| 93 | }; |
| 94 | |
| 95 | /** |
| 96 | * @brief match the Interest (NDNS query, NDNS update) name |
| 97 | * |
| 98 | * @param[in] interest Interest to parse |
| 99 | * @param[in] hint Forwarding hint that is part of the Interest |
| 100 | * (only the length will be taken into account) |
| 101 | * @param[in] zone Zone that the Interest is related to |
| 102 | * (only the length will be taken into account) |
| 103 | * @param[out] result The matching result |
| 104 | * @return true if match succeeds, or false |
| 105 | */ |
| 106 | bool |
| 107 | matchName(const Interest& interest, |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 108 | const Name& hint, const Name& zone, |
| 109 | MatchResult& result); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * @brief match the Data (NDNS query response, NDNS update response) name |
| 113 | * |
| 114 | * @param[in] data Data to parse |
| 115 | * @param[in] hint Forwarding hint that is part of the Data |
| 116 | * (only the length will be taken into account) |
| 117 | * @param[in] zone Zone that the Data is related to |
| 118 | * (only the length will be taken into account) |
| 119 | * @param[out] result The matching result |
| 120 | * @return true if match succeeds, or false |
| 121 | */ |
| 122 | bool |
| 123 | matchName(const Data& data, |
| 124 | const Name& hint, const Name& zone, |
| 125 | MatchResult& result); |
| 126 | |
Shock Jiang | 895bc1b | 2014-10-01 20:00:58 -0700 | [diff] [blame] | 127 | |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 128 | } // namespace label |
| 129 | } // namespace ndns |
| 130 | } // namespace ndn |
| 131 | |
| 132 | #endif // NDNS_NDNS_LABEL_HPP |