build+face: Fixing regression that broke ethernet support

As of this commit, libpcap is required unless specifically disabled
using --without-libpcap parameter during configure stage.

Change-Id: Iec6f8bd9babfe4da193c98a49043b08319311106
Refs: #1472
diff --git a/.waf-tools/unix-socket.py b/.waf-tools/unix-socket.py
index f697f0c..d3c6b31 100644
--- a/.waf-tools/unix-socket.py
+++ b/.waf-tools/unix-socket.py
@@ -4,6 +4,8 @@
 #
 # GPL 3.0 license, see the COPYING.md file for more information
 
+from waflib import Options
+
 BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK = '''
 #include <iostream>
 #include <boost/asio.hpp>
@@ -17,9 +19,10 @@
 }
 '''
 
-def options(opt):
+def addUnixOptions(self, opt):
     opt.add_option('--force-unix-socket', action='store_true', default=False,
                    dest='force_unix_socket', help='''Forcefully enable UNIX sockets support''')
+setattr(Options.OptionsContext, "addUnixOptions", addUnixOptions)
 
 def configure(conf):
     def boost_asio_has_local_sockets():
diff --git a/daemon/core/face-uri.cpp b/daemon/core/face-uri.cpp
index 5cfaf72..c9ec548 100644
--- a/daemon/core/face-uri.cpp
+++ b/daemon/core/face-uri.cpp
@@ -25,9 +25,9 @@
 #include "face-uri.hpp"
 #include "core/logger.hpp"
 
-#ifdef HAVE_PCAP
+#ifdef HAVE_LIBPCAP
 #include "face/ethernet.hpp"
-#endif // HAVE_PCAP
+#endif // HAVE_LIBPCAP
 
 #include <boost/regex.hpp>
 
@@ -130,14 +130,14 @@
   return uri;
 }
 
-#ifdef HAVE_PCAP
+#ifdef HAVE_LIBPCAP
 FaceUri::FaceUri(const ethernet::Address& address)
   : m_isV6(false)
 {
   m_scheme = "ether";
   m_host = address.toString();
 }
-#endif // HAVE_PCAP
+#endif // HAVE_LIBPCAP
 
 FaceUri
 FaceUri::fromDev(const std::string& ifname)
diff --git a/daemon/core/face-uri.hpp b/daemon/core/face-uri.hpp
index 766f353..487f8f8 100644
--- a/daemon/core/face-uri.hpp
+++ b/daemon/core/face-uri.hpp
@@ -29,11 +29,11 @@
 
 namespace nfd {
 
-#ifdef HAVE_PCAP
+#ifdef HAVE_LIBPCAP
 namespace ethernet {
 class Address;
 } // namespace ethernet
-#endif // HAVE_PCAP
+#endif // HAVE_LIBPCAP
 
 /** \brief represents the underlying protocol and address used by a Face
  *  \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#FaceUri
@@ -89,11 +89,11 @@
   static FaceUri
   fromFd(int fd);
 
-#ifdef HAVE_PCAP
+#ifdef HAVE_LIBPCAP
   /// construct ether canonical FaceUri
   explicit
   FaceUri(const ethernet::Address& address);
-#endif // HAVE_PCAP
+#endif // HAVE_LIBPCAP
 
   /// create dev FaceUri from network device name
   static FaceUri
diff --git a/daemon/face/ethernet-face.hpp b/daemon/face/ethernet-face.hpp
index 2b4771e..4eaf0b4 100644
--- a/daemon/face/ethernet-face.hpp
+++ b/daemon/face/ethernet-face.hpp
@@ -28,8 +28,8 @@
 #include "ethernet.hpp"
 #include "face.hpp"
 
-#ifndef HAVE_PCAP
-#error "Cannot include this file when pcap is not available"
+#ifndef HAVE_LIBPCAP
+#error "Cannot include this file when libpcap is not available"
 #endif
 
 // forward declarations
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 855bc85..7861935 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -37,9 +37,9 @@
 #include "face/unix-stream-factory.hpp"
 #endif // HAVE_UNIX_SOCKETS
 
-#ifdef HAVE_PCAP
+#ifdef HAVE_LIBPCAP
 #include "face/ethernet-factory.hpp"
-#endif // HAVE_PCAP
+#endif // HAVE_LIBPCAP
 
 #include <ndn-cpp-dev/management/nfd-face-event-notification.hpp>
 
@@ -529,7 +529,7 @@
   //   mcast_group 01:00:5E:00:17:AA ; Ethernet multicast group
   // }
 
-#if defined(HAVE_PCAP)
+#if defined(HAVE_LIBPCAP)
 
   using ethernet::Address;
 
@@ -595,7 +595,7 @@
     }
 #else
   throw ConfigFile::Error("NFD was compiled without libpcap, cannot process \"ether\" section");
-#endif // HAVE_PCAP
+#endif // HAVE_LIBPCAP
 }
 
 
diff --git a/nfd.conf.sample.in b/nfd.conf.sample.in
index 11cd009..22aae5a 100644
--- a/nfd.conf.sample.in
+++ b/nfd.conf.sample.in
@@ -19,7 +19,7 @@
   ;  TRACE ; trace messages (most verbose)
   ;  ALL ; all messages
 
-  ; default_level INFO
+  default_level INFO
 
   ; You may override default_level by assigning a logging level
   ; to the desired module name. Module names can be found in two ways:
@@ -64,14 +64,12 @@
     idle_timeout 600 ; idle time (seconds) before closing a UDP unicast face
     keep_alive_interval 25; interval (seconds) between keep-alive refreshes
 
-    mcast yes
-
-    ; Example multicast settings
+    ; UDP multicast settings
     ; NFD creates one UDP multicast face per NIC
 
-    ; mcast yes ; set to 'no' to disable UDP multicast, default 'yes'
-    ; mcast_port 56363 ; UDP multicast port number
-    ; mcast_group 224.0.23.170 ; UDP multicast group (IPv4 only)
+    mcast yes ; set to 'no' to disable UDP multicast, default 'yes'
+    mcast_port 56363 ; UDP multicast port number
+    mcast_group 224.0.23.170 ; UDP multicast group (IPv4 only)
   }
 
   ; The ether section contains settings of Ethernet faces and channels.
@@ -97,16 +95,14 @@
   ;    sudo chgrp admin /dev/bpf*
   ;    sudo chmod g+rw /dev/bpf*
 
-  ether
-  {
-    mcast yes
-
-  ;    Example multicast settings
-  ;    NFD creates one Ethernet multicast face per NIC
-  ;
-  ;    mcast yes ; set to 'no' to disable Ethernet multicast, default 'yes'
-  ;    mcast_group 01:00:5E:00:17:AA ; Ethernet multicast group
-  }
+  @IF_HAVE_LIBPCAP@ether
+  @IF_HAVE_LIBPCAP@{
+  @IF_HAVE_LIBPCAP@  ; Ethernet multicast settings
+  @IF_HAVE_LIBPCAP@  ; NFD creates one Ethernet multicast face per NIC
+  @IF_HAVE_LIBPCAP@
+  @IF_HAVE_LIBPCAP@  mcast yes ; set to 'no' to disable Ethernet multicast, default 'yes'
+  @IF_HAVE_LIBPCAP@  mcast_group 01:00:5E:00:17:AA ; Ethernet multicast group
+  @IF_HAVE_LIBPCAP@}
 }
 
 ; The authorizations section grants privileges to authorized keys.
@@ -149,13 +145,13 @@
   ; You may have multiple authorize sections that specify additional
   ; certificates and their privileges.
 
-;  authorize
-;  {
-;    certfile keys/this_cert_does_not_exist.ndncert
-;    authorize
-;    privileges
-;    {
-;      faces
-;    }
-;  }
+  ; authorize
+  ; {
+  ;   certfile keys/this_cert_does_not_exist.ndncert
+  ;   authorize
+  ;   privileges
+  ;   {
+  ;     faces
+  ;   }
+  ; }
 }
diff --git a/tests/core/face-uri.cpp b/tests/core/face-uri.cpp
index 6259d77..5d31f66 100644
--- a/tests/core/face-uri.cpp
+++ b/tests/core/face-uri.cpp
@@ -23,9 +23,9 @@
  **/
 
 #include "core/face-uri.hpp"
-#ifdef HAVE_PCAP
+#ifdef HAVE_LIBPCAP
 #include "face/ethernet.hpp"
-#endif // HAVE_PCAP
+#endif // HAVE_LIBPCAP
 
 #include "tests/test-common.hpp"
 
@@ -164,11 +164,11 @@
 
   BOOST_CHECK_EQUAL(uri.parse("ether://08:00:27:zz:dd:01"), false);
 
-#ifdef HAVE_PCAP
+#ifdef HAVE_LIBPCAP
   ethernet::Address address = ethernet::Address::fromString("33:33:01:01:01:01");
   BOOST_REQUIRE_NO_THROW(FaceUri(address));
   BOOST_CHECK_EQUAL(FaceUri(address).toString(), "ether://33:33:01:01:01:01");
-#endif // HAVE_PCAP
+#endif // HAVE_LIBPCAP
 }
 
 BOOST_AUTO_TEST_CASE(Dev)
diff --git a/tests/mgmt/face-manager.cpp b/tests/mgmt/face-manager.cpp
index c410878..e799944 100644
--- a/tests/mgmt/face-manager.cpp
+++ b/tests/mgmt/face-manager.cpp
@@ -653,7 +653,7 @@
                              "Unrecognized option \"hello\" in \"udp\" section"));
 }
 
-#ifdef HAVE_PCAP
+#ifdef HAVE_LIBPCAP
 
 BOOST_AUTO_TEST_CASE(TestProcessSectionEther)
 {
diff --git a/wscript b/wscript
index ef4eade..938eed1 100644
--- a/wscript
+++ b/wscript
@@ -39,7 +39,12 @@
              tooldir=['.waf-tools'])
 
     nfdopt = opt.add_option_group('NFD Options')
-    opt.addDependencyOptions(nfdopt, 'libpcap',   '(optional)')
+    opt.addUnixOptions(nfdopt)
+    opt.addDependencyOptions(nfdopt, 'libpcap')
+    nfdopt.add_option('--without-libpcap', action='store_true', default=False,
+                      dest='without_libpcap',
+                      help='''Disable libpcap (Ethernet face support will be disabled)''')
+
     opt.addDependencyOptions(nfdopt, 'librt',     '(optional)')
     opt.addDependencyOptions(nfdopt, 'libresolv', '(optional)')
 
@@ -84,8 +89,11 @@
     conf.load('unix-socket')
 
     conf.checkDependency(name='librt', lib='rt', mandatory=False)
-    conf.checkDependency(name='libpcap', lib='pcap', mandatory=False)
     conf.checkDependency(name='libresolv', lib='resolv', mandatory=False)
+    if not conf.options.without_libpcap:
+        conf.checkDependency(name='libpcap', lib='pcap', mandatory=True,
+                             errmsg='not found, but required for Ethernet face support. '
+                                    'Specify --without-libpcap to disable Ethernet face support.')
 
     conf.load('coverage')
 
@@ -106,7 +114,7 @@
         includes='. daemon',
         )
 
-    if bld.env['HAVE_PCAP']:
+    if bld.env['HAVE_LIBPCAP']:
         nfd_objects.source += bld.path.ant_glob('daemon/face/ethernet-*.cpp')
         nfd_objects.use += ' LIBPCAP'
 
@@ -141,7 +149,7 @@
             install_prefix=None,
           )
 
-        if bld.env['HAVE_PCAP']:
+        if bld.env['HAVE_LIBPCAP']:
             unit_tests.source += bld.path.ant_glob('tests/face/ethernet.cpp')
 
         if bld.env['HAVE_UNIX_SOCKETS']:
@@ -153,7 +161,8 @@
     bld(features="subst",
         source='nfd.conf.sample.in',
         target='nfd.conf.sample',
-        install_path="${SYSCONFDIR}/ndn")
+        install_path="${SYSCONFDIR}/ndn",
+        IF_HAVE_LIBPCAP="" if bld.env['HAVE_LIBPCAP'] else "; ")
 
     bld(features='subst',
         source='tools/nfd-status-http-server.py',