Fix integration test key chain; add ability to parse segmented status datasets
diff --git a/src/main/java/com/intel/jndn/management/NFD.java b/src/main/java/com/intel/jndn/management/NFD.java
index e05b2a9..5b7442f 100644
--- a/src/main/java/com/intel/jndn/management/NFD.java
+++ b/src/main/java/com/intel/jndn/management/NFD.java
@@ -17,6 +17,7 @@
import com.intel.jndn.management.types.FibEntry;
import com.intel.jndn.management.types.RibEntry;
import com.intel.jndn.utils.Client;
+import com.intel.jndn.utils.SegmentedClient;
import java.io.IOException;
import java.util.List;
import net.named_data.jndn.ControlParameters;
@@ -90,12 +91,8 @@
interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
- // TODO verify that all faces are being returned; right now they don't
- // match up with the results from nfd-status-http-server but no
- // additional segments are present;
- // see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
// send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
+ Data data = SegmentedClient.getDefault().getSync(forwarder, interest);
if (data == null) {
throw new Exception("Failed to retrieve list of faces from the forwarder.");
}
@@ -125,7 +122,7 @@
// additional segments are present;
// see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
// send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
+ Data data = SegmentedClient.getDefault().getSync(forwarder, interest);
if (data == null) {
throw new Exception("Failed to retrieve list of fib entries from the forwarder.");
}
@@ -151,7 +148,7 @@
interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
// send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
+ Data data = SegmentedClient.getDefault().getSync(forwarder, interest);
if (data == null) {
throw new Exception("Failed to retrieve list of faces from the forwarder.");
}
@@ -289,14 +286,10 @@
* been set up (e.g. forwarder.setCommandSigningInfo()
*
* @param forwarder
- * @param route
+ * @param controlParameters
* @return
*/
- public static boolean unregister(Face forwarder, Name route) throws Exception{
- // build command name
- ControlParameters controlParameters = new ControlParameters();
- controlParameters.setName(route);
-
+ public static boolean unregister(Face forwarder, ControlParameters controlParameters) throws Exception {
// build command name
Name command = new Name("/localhost/nfd/rib/unregister");
command.append(controlParameters.wireEncode());
@@ -306,6 +299,80 @@
}
/**
+ * Unregister a route on a forwarder; see
+ * http://named-data.net/doc/NFD/current/manpages/nfdc.html for command-line
+ * usage and http://redmine.named-data.net/projects/nfd/wiki/RibMgmt for
+ * protocol documentation. 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
+ * @param route
+ * @return
+ */
+ public static boolean unregister(Face forwarder, Name route) throws Exception {
+ // build command name
+ ControlParameters controlParameters = new ControlParameters();
+ controlParameters.setName(route);
+
+ // send the interest
+ return unregister(forwarder, controlParameters);
+ }
+
+ /**
+ * Unregister a route on a forwarder; see
+ * http://named-data.net/doc/NFD/current/manpages/nfdc.html for command-line
+ * usage and http://redmine.named-data.net/projects/nfd/wiki/RibMgmt for
+ * protocol documentation. 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
+ * @param route
+ * @param faceId
+ * @return
+ */
+ public static boolean unregister(Face forwarder, Name route, int faceId) throws Exception {
+ // build command name
+ ControlParameters controlParameters = new ControlParameters();
+ controlParameters.setName(route);
+ controlParameters.setFaceId(faceId);
+
+ // send the interest
+ return unregister(forwarder, controlParameters);
+ }
+
+ /**
+ * Unregister a route on a forwarder; see
+ * http://named-data.net/doc/NFD/current/manpages/nfdc.html for command-line
+ * usage and http://redmine.named-data.net/projects/nfd/wiki/RibMgmt for
+ * protocol documentation. 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
+ * @param route
+ * @param uri
+ * @return
+ */
+ public static boolean unregister(Face forwarder, Name route, String uri) throws Exception {
+ int faceId = -1;
+ for(FaceStatus face : getFaceList(forwarder)){
+ if(face.getUri().matches(uri)){
+ faceId = face.getFaceId();
+ break;
+ }
+ }
+
+ if(faceId == -1){
+ throw new Exception("Face not found: " + uri);
+ }
+
+ // send the interest
+ return unregister(forwarder, route, faceId);
+ }
+
+ /**
* Set a strategy on the forwarder; see
* http://named-data.net/doc/NFD/current/manpages/nfdc.html for command-line
* usage and http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice