Added ndn_Interest_matchesName.
diff --git a/ndn-cpp/c/interest.c b/ndn-cpp/c/interest.c
index 15553b4..dce66e9 100644
--- a/ndn-cpp/c/interest.c
+++ b/ndn-cpp/c/interest.c
@@ -70,3 +70,23 @@
return 0;
}
+
+int ndn_Interest_matchesName(struct ndn_Interest *self, struct ndn_Name *name)
+{
+ if (!ndn_Name_match(&self->name, name))
+ return 0;
+
+ if (self->minSuffixComponents >= 0 &&
+ // Add 1 for the implicit digest.
+ !(name->nComponents + 1 - self->name.nComponents >= self->minSuffixComponents))
+ return 0;
+ if (self->maxSuffixComponents >= 0 &&
+ // Add 1 for the implicit digest.
+ !(name->nComponents + 1 - self->name.nComponents <= self->maxSuffixComponents))
+ return 0;
+ if (self->exclude.nEntries > 0 && name->nComponents > self->name.nComponents &&
+ ndn_Exclude_matches(&self->exclude, name->components + self->name.nComponents))
+ return 0;
+
+ return 1;
+}
diff --git a/ndn-cpp/c/interest.h b/ndn-cpp/c/interest.h
index 42b9c62..5def3a0 100644
--- a/ndn-cpp/c/interest.h
+++ b/ndn-cpp/c/interest.h
@@ -131,6 +131,15 @@
self->nonceLength = 0;
}
+/**
+ * Check if self's name matches the given name (using ndn_Name_match) and the given name also conforms to the
+ * interest selectors.
+ * @param self A pointer to the ndn_Interest struct.
+ * @param name A pointer to the name to check.
+ * @return 1 if the name and interest selectors match, 0 otherwise.
+ */
+int ndn_Interest_matchesName(struct ndn_Interest *self, struct ndn_Name *name);
+
#ifdef __cplusplus
}
#endif