face: Specify signing certificate/identity in setInterestFilter/unsetInterestFilter

Refs: #1509

Change-Id: I359553e5f8eb77ae314873852eba8a10fb5e3a93
diff --git a/src/face.cpp b/src/face.cpp
index 4a5d5b8..d351c0a 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -235,6 +235,42 @@
   return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get());
 }
 
+const RegisteredPrefixId*
+Face::setInterestFilter(const Name& prefix,
+                        const OnInterest& onInterest,
+                        const OnSetInterestFilterFailed& onSetInterestFilterFailed,
+                        const IdentityCertificate& certificate)
+{
+  shared_ptr<RegisteredPrefix> prefixToRegister(new RegisteredPrefix(prefix, onInterest));
+
+  m_fwController->selfRegisterPrefix(prefixToRegister->getPrefix(),
+                                     bind(&RegisteredPrefixTable::push_back,
+                                          &m_registeredPrefixTable, prefixToRegister),
+                                     bind(onSetInterestFilterFailed,
+                                          prefixToRegister->getPrefix(), _1),
+                                     certificate);
+
+  return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get());
+}
+
+const RegisteredPrefixId*
+Face::setInterestFilter(const Name& prefix,
+                        const OnInterest& onInterest,
+                        const OnSetInterestFilterFailed& onSetInterestFilterFailed,
+                        const Name& identity)
+{
+  shared_ptr<RegisteredPrefix> prefixToRegister(new RegisteredPrefix(prefix, onInterest));
+
+  m_fwController->selfRegisterPrefix(prefixToRegister->getPrefix(),
+                                     bind(&RegisteredPrefixTable::push_back,
+                                          &m_registeredPrefixTable, prefixToRegister),
+                                     bind(onSetInterestFilterFailed,
+                                          prefixToRegister->getPrefix(), _1),
+                                     identity);
+
+  return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get());
+}
+
 void
 Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId)
 {
@@ -242,6 +278,22 @@
 }
 
 void
+Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
+                          const IdentityCertificate& certificate)
+{
+  m_ioService->post(bind(&Face::asyncUnsetInterestFilterWithCertificate, this,
+                         registeredPrefixId, certificate));
+}
+
+void
+Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
+                          const Name& identity)
+{
+  m_ioService->post(bind(&Face::asyncUnsetInterestFilterWithIdentity, this,
+                         registeredPrefixId, identity));
+}
+
+void
 Face::asyncUnsetInterestFilter(const RegisteredPrefixId* registeredPrefixId)
 {
   RegisteredPrefixTable::iterator i = std::find_if(m_registeredPrefixTable.begin(),
@@ -258,6 +310,42 @@
 }
 
 void
+Face::asyncUnsetInterestFilterWithCertificate(const RegisteredPrefixId* registeredPrefixId,
+                                              const IdentityCertificate& certificate)
+{
+  RegisteredPrefixTable::iterator i = std::find_if(m_registeredPrefixTable.begin(),
+                                                   m_registeredPrefixTable.end(),
+                                                   MatchRegisteredPrefixId(registeredPrefixId));
+  if (i != m_registeredPrefixTable.end())
+    {
+      m_fwController->selfDeregisterPrefix((*i)->getPrefix(),
+                                           bind(&Face::finalizeUnsetInterestFilter, this, i),
+                                           Controller::FailCallback(),
+                                           certificate);
+    }
+
+  // there cannot be two registered prefixes with the same id
+}
+
+void
+Face::asyncUnsetInterestFilterWithIdentity(const RegisteredPrefixId* registeredPrefixId,
+                                           const Name& identity)
+{
+  RegisteredPrefixTable::iterator i = std::find_if(m_registeredPrefixTable.begin(),
+                                                   m_registeredPrefixTable.end(),
+                                                   MatchRegisteredPrefixId(registeredPrefixId));
+  if (i != m_registeredPrefixTable.end())
+    {
+      m_fwController->selfDeregisterPrefix((*i)->getPrefix(),
+                                           bind(&Face::finalizeUnsetInterestFilter, this, i),
+                                           Controller::FailCallback(),
+                                           identity);
+    }
+
+  // there cannot be two registered prefixes with the same id
+}
+
+void
 Face::finalizeUnsetInterestFilter(RegisteredPrefixTable::iterator item)
 {
   m_registeredPrefixTable.erase(item);