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 | |
| 34 | /** |
| 35 | * @brief NDNS iterative query type |
| 36 | */ |
| 37 | |
| 38 | const name::Component NdnsIterativeQuery("NDNS"); |
| 39 | |
| 40 | /** |
| 41 | * @brief NDNS recursive query type |
| 42 | */ |
| 43 | const name::Component NdnsRecursiveQuery("NDNS-R"); |
| 44 | |
| 45 | /** |
| 46 | * @brief NDNS ID-CERT query type |
| 47 | */ |
| 48 | const name::Component NdnsCertQuery("KEY"); |
| 49 | |
| 50 | ///////////////////////////////////////////// |
| 51 | |
| 52 | /** |
| 53 | * @brief label of forwarding hint |
| 54 | * @todo not support forwarding hint yet, for future use |
| 55 | */ |
| 56 | const name::Component ForwardingHintLabel("\xF0."); |
| 57 | |
| 58 | /** |
| 59 | * @brief label of update message, located at the last component in Interest name |
| 60 | */ |
| 61 | const name::Component NdnsUpdateLabel("UPDATE"); |
| 62 | |
| 63 | ////////////////////////////////////////////// |
| 64 | |
| 65 | /** |
| 66 | * @brief NS resource record type |
| 67 | */ |
| 68 | const name::Component NsRrType("NS"); |
| 69 | |
| 70 | /** |
| 71 | * @brief ID-CERT resource record type |
| 72 | */ |
| 73 | const name::Component CertRrType("ID-CERT"); |
| 74 | |
| 75 | ////////////////////////////////////////// |
| 76 | |
| 77 | /** |
| 78 | * @brief result of Matching. version only works when matching a Interest Name |
| 79 | */ |
| 80 | struct MatchResult |
| 81 | { |
| 82 | Name rrLabel; |
| 83 | name::Component rrType; |
| 84 | name::Component version; |
| 85 | }; |
| 86 | |
| 87 | /** |
| 88 | * @brief match the Interest (NDNS query, NDNS update) name |
| 89 | * |
| 90 | * @param[in] interest Interest to parse |
| 91 | * @param[in] hint Forwarding hint that is part of the Interest |
| 92 | * (only the length will be taken into account) |
| 93 | * @param[in] zone Zone that the Interest is related to |
| 94 | * (only the length will be taken into account) |
| 95 | * @param[out] result The matching result |
| 96 | * @return true if match succeeds, or false |
| 97 | */ |
| 98 | bool |
| 99 | matchName(const Interest& interest, |
| 100 | const Name& hint, const Name& zone, |
| 101 | MatchResult& result); |
| 102 | |
| 103 | /** |
| 104 | * @brief match the Data (NDNS query response, NDNS update response) name |
| 105 | * |
| 106 | * @param[in] data Data to parse |
| 107 | * @param[in] hint Forwarding hint that is part of the Data |
| 108 | * (only the length will be taken into account) |
| 109 | * @param[in] zone Zone that the Data is related to |
| 110 | * (only the length will be taken into account) |
| 111 | * @param[out] result The matching result |
| 112 | * @return true if match succeeds, or false |
| 113 | */ |
| 114 | bool |
| 115 | matchName(const Data& data, |
| 116 | const Name& hint, const Name& zone, |
| 117 | MatchResult& result); |
| 118 | |
| 119 | } // namespace label |
| 120 | } // namespace ndns |
| 121 | } // namespace ndn |
| 122 | |
| 123 | #endif // NDNS_NDNS_LABEL_HPP |