Merge branch 'cawka-master'
diff --git a/pom.xml b/pom.xml
index 8ee30a9..e0d6da0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.intel.jndn.management</groupId>
<artifactId>jndn-management</artifactId>
- <version>0.9.4</version>
+ <version>0.9.5</version>
<name>jndn-management</name>
<description>Tools for managing an NDN forwarding daemon</description>
<url>https://github.com/01org/jndn-management</url>
diff --git a/src/main/java/com/intel/jndn/management/NFD.java b/src/main/java/com/intel/jndn/management/NFD.java
index 026faca..2578713 100644
--- a/src/main/java/com/intel/jndn/management/NFD.java
+++ b/src/main/java/com/intel/jndn/management/NFD.java
@@ -233,6 +233,33 @@
}
/**
+ * Destroy a face on given forwarder. Ensure the forwarding face is on
+ * the local machine (management requests are to /localhost/...) and that
+ * command signing has been set up (e.g. forwarder.setCommandSigningInfo()).
+ *
+ * @param forwarder Only a localhost Face
+ * @param faceId
+ * @return
+ * @throws java.lang.Exception
+ */
+ public static boolean destroyFace(Face forwarder, int faceId) throws Exception {
+ Name command = new Name("/localhost/nfd/faces/destroy");
+ ControlParameters parameters = new ControlParameters();
+ parameters.setFaceId(faceId);
+ command.append(parameters.wireEncode());
+
+ // send the interest
+ ControlResponse response = sendCommand(forwarder, new Interest(command));
+
+ // check for body and that status code is OK (TODO: 200 should be replaced with a CONSTANT like ControlResponse.STATUS_OK)
+ if (response.getBody().isEmpty() || response.getStatusCode() != 200) {
+ throw new Exception("Failed to destroy face: " + String.valueOf(faceId) + " " + response.getStatusText());
+ }
+
+ return true;
+ }
+
+ /**
* Enable a local control feature on the given forwarder. See
* http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Enable-a-LocalControlHeader-feature
*