encoding+mgmt: fix definition of INVALID_FACE_ID

Change-Id: I220b183a6f1d007d2c71fcb6491a2c4a487b7673
Refs: #3172
diff --git a/src/encoding/nfd-constants.hpp b/src/encoding/nfd-constants.hpp
index 4c38bd9..688ea74 100644
--- a/src/encoding/nfd-constants.hpp
+++ b/src/encoding/nfd-constants.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -27,7 +27,7 @@
 namespace ndn {
 namespace nfd {
 
-static const uint64_t INVALID_FACE_ID = std::numeric_limits<uint64_t>::max();
+const uint64_t INVALID_FACE_ID = 0;
 
 /** \ingroup management
  */
diff --git a/src/mgmt/nfd/control-command.cpp b/src/mgmt/nfd/control-command.cpp
index 2a6eda7..96bba6c 100644
--- a/src/mgmt/nfd/control-command.cpp
+++ b/src/mgmt/nfd/control-command.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -82,13 +82,11 @@
     bool isPresent = presentFields[i];
     if (m_required[i]) {
       if (!isPresent) {
-        BOOST_THROW_EXCEPTION(ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is required but "
-                                            "missing"));
+        BOOST_THROW_EXCEPTION(ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is required but missing"));
       }
     }
     else if (isPresent && !m_optional[i]) {
-      BOOST_THROW_EXCEPTION(ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is forbidden but "
-                                          "present"));
+      BOOST_THROW_EXCEPTION(ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is forbidden but present"));
     }
   }
 }
@@ -111,8 +109,6 @@
 void
 FaceCreateCommand::applyDefaultsToRequest(ControlParameters& parameters) const
 {
-  parameters.setFaceId(0);
-
   if (!parameters.hasFacePersistency()) {
     parameters.setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT);
   }
@@ -133,8 +129,8 @@
 {
   this->ControlCommand::validateResponse(parameters);
 
-  if (parameters.getFaceId() == 0) {
-    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+  if (parameters.getFaceId() == INVALID_FACE_ID) {
+    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must be valid"));
   }
 }
 
@@ -175,8 +171,8 @@
 {
   this->ControlCommand::validateResponse(parameters);
 
-  if (parameters.getFaceId() == 0) {
-    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+  if (parameters.getFaceId() == INVALID_FACE_ID) {
+    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must be valid"));
   }
 }
 
@@ -193,8 +189,8 @@
 {
   this->ControlCommand::validateRequest(parameters);
 
-  if (parameters.getFaceId() == 0) {
-    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+  if (parameters.getFaceId() == INVALID_FACE_ID) {
+    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must be valid"));
   }
 }
 
@@ -271,8 +267,8 @@
 {
   this->ControlCommand::validateResponse(parameters);
 
-  if (parameters.getFaceId() == 0) {
-    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+  if (parameters.getFaceId() == INVALID_FACE_ID) {
+    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must be valid"));
   }
 }
 
@@ -300,8 +296,8 @@
 {
   this->ControlCommand::validateResponse(parameters);
 
-  if (parameters.getFaceId() == 0) {
-    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+  if (parameters.getFaceId() == INVALID_FACE_ID) {
+    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must be valid"));
   }
 }
 
@@ -379,8 +375,8 @@
 {
   this->ControlCommand::validateResponse(parameters);
 
-  if (parameters.getFaceId() == 0) {
-    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+  if (parameters.getFaceId() == INVALID_FACE_ID) {
+    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must be valid"));
   }
 }
 
@@ -413,8 +409,8 @@
 {
   this->ControlCommand::validateResponse(parameters);
 
-  if (parameters.getFaceId() == 0) {
-    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+  if (parameters.getFaceId() == INVALID_FACE_ID) {
+    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must be valid"));
   }
 }
 
diff --git a/src/mgmt/nfd/face-traits.hpp b/src/mgmt/nfd/face-traits.hpp
index e88e1bc..dee973c 100644
--- a/src/mgmt/nfd/face-traits.hpp
+++ b/src/mgmt/nfd/face-traits.hpp
@@ -47,7 +47,7 @@
   };
 
   FaceTraits()
-    : m_faceId(0)
+    : m_faceId(INVALID_FACE_ID)
     , m_faceScope(FACE_SCOPE_NON_LOCAL)
     , m_facePersistency(FACE_PERSISTENCY_PERSISTENT)
     , m_linkType(LINK_TYPE_POINT_TO_POINT)
diff --git a/src/mgmt/nfd/fib-entry.cpp b/src/mgmt/nfd/fib-entry.cpp
index ad10054..e3633aa 100644
--- a/src/mgmt/nfd/fib-entry.cpp
+++ b/src/mgmt/nfd/fib-entry.cpp
@@ -34,7 +34,7 @@
 BOOST_CONCEPT_ASSERT((StatusDatasetItem<FibEntry>));
 
 NextHopRecord::NextHopRecord()
-  : m_faceId(0) // INVALID_FACEID
+  : m_faceId(INVALID_FACE_ID)
   , m_cost(0)
 {
 }
diff --git a/src/mgmt/nfd/rib-entry.cpp b/src/mgmt/nfd/rib-entry.cpp
index d47d316..d8293d5 100644
--- a/src/mgmt/nfd/rib-entry.cpp
+++ b/src/mgmt/nfd/rib-entry.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -42,7 +42,7 @@
 const time::milliseconds Route::INFINITE_EXPIRATION_PERIOD(time::milliseconds::max());
 
 Route::Route()
-  : m_faceId(0)
+  : m_faceId(INVALID_FACE_ID)
   , m_origin(0)
   , m_cost(0)
   , m_flags(ROUTE_FLAG_CHILD_INHERIT)
diff --git a/tests/unit-tests/mgmt/nfd/control-command.t.cpp b/tests/unit-tests/mgmt/nfd/control-command.t.cpp
index d282acf..0ebf450 100644
--- a/tests/unit-tests/mgmt/nfd/control-command.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/control-command.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -48,7 +48,7 @@
 
   ControlParameters p3;
   p3.setUri("tcp4://192.0.2.1")
-    .setFaceId(0);
+    .setFaceId(INVALID_FACE_ID);
   BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError);
 
   ControlParameters p4;
@@ -96,6 +96,7 @@
   ControlParameters p1;
   p1.setFaceId(0);
   BOOST_CHECK_NO_THROW(command.validateRequest(p1));
+  p1.setFaceId(INVALID_FACE_ID);
   BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError);
 
   p1.setFaceId(1);
@@ -154,7 +155,7 @@
   BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError);
 
   ControlParameters p2;
-  p2.setFaceId(0);
+  p2.setFaceId(INVALID_FACE_ID);
   BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError);
   BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
 
@@ -233,6 +234,7 @@
     .setFaceId(0)
     .setCost(6);
   BOOST_CHECK_NO_THROW(command.validateRequest(p2));
+  p2.setFaceId(INVALID_FACE_ID);
   BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
 
   command.applyDefaultsToRequest(p1);
@@ -263,6 +265,7 @@
   p2.setName("ndn:/example")
     .setFaceId(0);
   BOOST_CHECK_NO_THROW(command.validateRequest(p2));
+  p2.setFaceId(INVALID_FACE_ID);
   BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
 
   p1.unsetFaceId();
@@ -365,6 +368,7 @@
     .setFaceId(0)
     .setOrigin(ROUTE_ORIGIN_APP);
   BOOST_CHECK_NO_THROW(command.validateRequest(p2));
+  p2.setFaceId(INVALID_FACE_ID);
   BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
 
   p2.unsetFaceId();