Add enable-local-control and disable-local-control commands
diff --git a/src/main/java/com/intel/jndn/management/NFD.java b/src/main/java/com/intel/jndn/management/NFD.java
index 58d5d70..026faca 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.ControlResponse;
import com.intel.jndn.management.types.FaceStatus;
import com.intel.jndn.management.types.FibEntry;
+import com.intel.jndn.management.types.LocalControlHeader;
import com.intel.jndn.management.types.RibEntry;
import com.intel.jndn.utils.Client;
import com.intel.jndn.utils.SegmentedClient;
@@ -232,6 +233,46 @@
}
/**
+ * Enable a local control feature on the given forwarder. See
+ * http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Enable-a-LocalControlHeader-feature
+ *
+ * @param forwarder
+ * @param header
+ * @return
+ * @throws Exception
+ */
+ public static boolean enableLocalControlHeader(Face forwarder, LocalControlHeader header) throws Exception {
+ // build command name
+ Name command = new Name("/localhost/nfd/faces/enable-local-control");
+ ControlParameters parameters = new ControlParameters();
+ parameters.setLocalControlFeature(header.getNumericValue());
+ command.append(parameters.wireEncode());
+
+ // send command and return
+ return sendCommandAndErrorCheck(forwarder, new Interest(command));
+ }
+
+ /**
+ * Disable a local control feature on the given forwarder. See
+ * http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Disable-a-LocalControlHeader-feature
+ *
+ * @param forwarder
+ * @param header
+ * @return
+ * @throws Exception
+ */
+ public static boolean disableLocalControlHeader(Face forwarder, LocalControlHeader header) throws Exception {
+ // build command name
+ Name command = new Name("/localhost/nfd/faces/disable-local-control");
+ ControlParameters parameters = new ControlParameters();
+ parameters.setLocalControlFeature(header.getNumericValue());
+ command.append(parameters.wireEncode());
+
+ // send command and return
+ return sendCommandAndErrorCheck(forwarder, new Interest(command));
+ }
+
+ /**
* Register a route 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/RibMgmt for
diff --git a/src/main/java/com/intel/jndn/management/types/LocalControlHeader.java b/src/main/java/com/intel/jndn/management/types/LocalControlHeader.java
new file mode 100644
index 0000000..4a2aee2
--- /dev/null
+++ b/src/main/java/com/intel/jndn/management/types/LocalControlHeader.java
@@ -0,0 +1,36 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.management.types;
+
+/**
+ * Define constants for local control header options. See
+ * http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Enable-a-LocalControlHeader-feature
+ *
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public enum LocalControlHeader {
+
+ INCOMING_FACE_ID(1),
+ NEXT_HOP_FACE_ID(2),
+ CACHING_POLICY(3);
+
+ LocalControlHeader(int value) {
+ value_ = value;
+ }
+
+ public final int getNumericValue() {
+ return value_;
+ }
+ private final int value_;
+}
diff --git a/src/test/java/com/intel/jndn/management/LocalControlHeaderTest.java b/src/test/java/com/intel/jndn/management/LocalControlHeaderTest.java
new file mode 100644
index 0000000..a8116fb
--- /dev/null
+++ b/src/test/java/com/intel/jndn/management/LocalControlHeaderTest.java
@@ -0,0 +1,56 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.management;
+
+import com.intel.jndn.management.types.LocalControlHeader;
+import com.intel.jndn.utils.Client;
+import java.util.logging.Logger;
+import net.named_data.jndn.Data;
+import net.named_data.jndn.Face;
+import net.named_data.jndn.Name;
+import net.named_data.jndn.encoding.EncodingException;
+import net.named_data.jndn.security.KeyChain;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test functionality for LocalControlHeader
+ *
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public class LocalControlHeaderTest {
+
+ private static final Logger logger = Logger.getLogger(IntegrationSuite.class.getName());
+
+ /**
+ * Integration test to run on actual system
+ *
+ * @param args
+ * @throws EncodingException
+ */
+ public static void main(String[] args) throws Exception {
+ // setup forwarder face
+ Face forwarder = new Face("localhost");
+ KeyChain keyChain = IntegrationSuite.buildTestKeyChain();
+ forwarder.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
+
+ // enable incoming face ID header
+ boolean success = NFD.enableLocalControlHeader(forwarder, LocalControlHeader.INCOMING_FACE_ID);
+ assertTrue(success);
+
+ // use and verify
+ Data data = Client.getDefault().getSync(forwarder, new Name("/localhop/nfd"));
+ long faceId = data.getIncomingFaceId();
+ logger.info("Face ID for this client on the forwarder: " + faceId);
+ }
+}