management: nfd::FaceLocalControlCommand validates LocalControlFeature value

refs #1397

Change-Id: I30c8bfc71daebed52ea03d9a5c4b345d192b7784
diff --git a/src/management/nfd-control-command.hpp b/src/management/nfd-control-command.hpp
index 168daec..c1cb438 100644
--- a/src/management/nfd-control-command.hpp
+++ b/src/management/nfd-control-command.hpp
@@ -226,6 +226,27 @@
 
 class FaceLocalControlCommand : public ControlCommand
 {
+public:
+  virtual void
+  validateRequest(const ControlParameters& parameters) const
+  {
+    this->ControlCommand::validateRequest(parameters);
+
+    switch (parameters.getLocalControlFeature()) {
+      case LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID:
+      case LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID:
+        break;
+      default:
+        throw ArgumentError("LocalControlFeature is invalid");
+    }
+  }
+
+  virtual void
+  validateResponse(const ControlParameters& parameters) const
+  {
+    this->validateRequest(parameters);
+  }
+
 protected:
   explicit
   FaceLocalControlCommand(const std::string& verb)
diff --git a/tests/management/nfd-control-command.cpp b/tests/management/nfd-control-command.cpp
index eeb18ed..5cf1910 100644
--- a/tests/management/nfd-control-command.cpp
+++ b/tests/management/nfd-control-command.cpp
@@ -73,6 +73,11 @@
     .setFaceId(9);
   BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError);
   BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
+
+  ControlParameters p3;
+  p3.setLocalControlFeature(static_cast<LocalControlFeature>(666));
+  BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError);
+  BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError);
 }
 
 BOOST_AUTO_TEST_CASE(FaceDisableLocalControl)
@@ -90,6 +95,11 @@
     .setFaceId(9);
   BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError);
   BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
+
+  ControlParameters p3;
+  p3.setLocalControlFeature(static_cast<LocalControlFeature>(666));
+  BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError);
+  BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError);
 }
 
 BOOST_AUTO_TEST_CASE(FibAddNextHop)