Add initial integration test
diff --git a/src/main/java/com/intel/jndn/management/NFD.java b/src/main/java/com/intel/jndn/management/NFD.java
index 8f8cdab..e05b2a9 100644
--- a/src/main/java/com/intel/jndn/management/NFD.java
+++ b/src/main/java/com/intel/jndn/management/NFD.java
@@ -14,6 +14,7 @@
import com.intel.jndn.management.types.StatusDataset;
import com.intel.jndn.management.types.ControlResponse;
import com.intel.jndn.management.types.FaceStatus;
+import com.intel.jndn.management.types.FibEntry;
import com.intel.jndn.management.types.RibEntry;
import com.intel.jndn.utils.Client;
import java.io.IOException;
@@ -89,7 +90,7 @@
interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
- // TODO verify that all faces are being returned; right now they don't
+ // 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
@@ -104,6 +105,36 @@
}
/**
+ * Retrieve a list of FIB entries and their NextHopRecords from the given
+ * forwarder; calls /localhost/nfd/fib/list which requires a local Face (all
+ * non-local packets are dropped).
+ *
+ * @param forwarder Only a localhost Face
+ * @return
+ * @throws Exception
+ */
+ public static List<FibEntry> getFibList(Face forwarder) throws Exception {
+ // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
+ Interest interest = new Interest(new Name("/localhost/nfd/fib/list"));
+ interest.setMustBeFresh(true);
+ 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);
+ if (data == null) {
+ throw new Exception("Failed to retrieve list of fib entries from the forwarder.");
+ }
+
+ // parse packet
+ return StatusDataset.wireDecode(data.getContent(), FibEntry.class);
+ }
+
+ /**
* Retrieve a list of routing entries from the RIB; calls
* /localhost/nfd/rib/list which requires a local Face (all non-local packets
* are dropped)
@@ -250,6 +281,31 @@
}
/**
+ * 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);
+
+ // build command name
+ Name command = new Name("/localhost/nfd/rib/unregister");
+ command.append(controlParameters.wireEncode());
+
+ // send the interest
+ return sendCommandAndErrorCheck(forwarder, new Interest(command));
+ }
+
+ /**
* 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