tools: Automatically start ndn-autoconfig in nfd-start, if enabled in autoconfig.conf
Change-Id: I09d3fff87f00ce8684e6e304e8327f9d03ca18bf Refs: #2716
This commit is contained in:
1 parent
6d8ee7acc9
commit
5c47597be9
8 files changed
+133
-35
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
# Enable ndn-autoconfig to run in parallel with NFD. Disabled by default
|
||||||
|
# enabled=true
|
||||||
|
enabled=false
|
||||||
+4
-2
@@ -242,9 +242,11 @@ latex_documents = [
|
|||||||
man_pages = [
|
man_pages = [
|
||||||
('manpages/nfd', 'nfd', u'Named Data Networking Forwarding Daemon', None, 1),
|
('manpages/nfd', 'nfd', u'Named Data Networking Forwarding Daemon', None, 1),
|
||||||
('manpages/ndn-autoconfig-server', 'ndn-autoconfig-server',
|
('manpages/ndn-autoconfig-server', 'ndn-autoconfig-server',
|
||||||
u'NFD Auto-configuration Server', None, 1),
|
u'NDN auto-configuration server', None, 1),
|
||||||
('manpages/ndn-autoconfig', 'ndn-autoconfig',
|
('manpages/ndn-autoconfig', 'ndn-autoconfig',
|
||||||
u'NFD Auto-configuration Client', None, 1),
|
u'NDN auto-configuration client', None, 1),
|
||||||
|
('manpages/ndn-autoconfig.conf', 'ndn-autoconfig.conf',
|
||||||
|
u'NDN auto-configuration client configuration file', None, 5),
|
||||||
('manpages/nfdc', 'nfdc',
|
('manpages/nfdc', 'nfdc',
|
||||||
u'NFD utility to manipulate the forwarding table (FIB)', None, 1),
|
u'NFD utility to manipulate the forwarding table (FIB)', None, 1),
|
||||||
('manpages/ndn-tlv-peek', 'ndn-tlv-peek', u'NFD consumer', None, 1),
|
('manpages/ndn-tlv-peek', 'ndn-tlv-peek', u'NFD consumer', None, 1),
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ Manpages
|
|||||||
schema
|
schema
|
||||||
manpages/nfd-status-http-server
|
manpages/nfd-status-http-server
|
||||||
manpages/ndn-autoconfig
|
manpages/ndn-autoconfig
|
||||||
|
manpages/ndn-autoconfig.conf
|
||||||
manpages/ndn-autoconfig-server
|
manpages/ndn-autoconfig-server
|
||||||
misc/local-prefix-discovery
|
misc/local-prefix-discovery
|
||||||
manpages/nfd-autoreg
|
manpages/nfd-autoreg
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
.. _ndn-autoconfig.conf:
|
||||||
|
|
||||||
|
autoconfig.conf
|
||||||
|
===============
|
||||||
|
|
||||||
|
Overview
|
||||||
|
--------
|
||||||
|
|
||||||
|
Configuration of NDN auto-configuration client daemon in INI format. Comments in the
|
||||||
|
configuration file must be prefixed with ``#``.
|
||||||
|
|
||||||
|
Example of ``autoconfig.conf``:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../autoconfig.conf.sample
|
||||||
|
|
||||||
|
Options
|
||||||
|
-------
|
||||||
|
|
||||||
|
``enabled``
|
||||||
|
(default: false) Enable or disable automatic NDN auto-configuration client daemon.
|
||||||
|
|
||||||
|
When enabled, NDN auto-configuration client daemon is automatically started by ``nfd-start``.
|
||||||
@@ -8,13 +8,33 @@ Usage
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
ndn-autoconfig
|
ndn-autoconfig [options]
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
Client tool to run :ref:`NDN hub discovery procedure`.
|
Client tool to run :ref:`NDN hub discovery procedure`.
|
||||||
|
|
||||||
|
Options
|
||||||
|
-------
|
||||||
|
|
||||||
|
``-h`` or ``--help``
|
||||||
|
Print usage information.
|
||||||
|
|
||||||
|
``-d`` or ``--daemon``
|
||||||
|
Run ndn-autoconfig in daemon mode, detecting network change events and re-running
|
||||||
|
auto-discovery procedure. In addition, the auto-discovery procedure is unconditionally
|
||||||
|
re-run every hour.
|
||||||
|
|
||||||
|
NOTE: if connection to NFD fails, the daemon will be terminated.
|
||||||
|
|
||||||
|
``-c [FILE]`` or ``--config=[FILE]``
|
||||||
|
Use the specified configuration file. If `enabled = true` is not specified in the
|
||||||
|
configuration file, no actions will be performed.
|
||||||
|
|
||||||
|
``-V`` or ``--version``
|
||||||
|
Print version information.
|
||||||
|
|
||||||
.. _NDN hub discovery procedure:
|
.. _NDN hub discovery procedure:
|
||||||
|
|
||||||
NDN hub discovery procedure
|
NDN hub discovery procedure
|
||||||
@@ -40,8 +60,8 @@ This procedure contains three methods to discover a NDN router:
|
|||||||
|
|
||||||
After connecting to an NDN router, two prefixes will be automatically registered:
|
After connecting to an NDN router, two prefixes will be automatically registered:
|
||||||
|
|
||||||
- /ndn
|
- ``/ndn``
|
||||||
- /localhop/nfd --- this to inform RIB manager that there is connectivity to the hub
|
- ``/localhop/nfd`` --- this to inform RIB manager that there is connectivity to the hub
|
||||||
|
|
||||||
Stage 1: multicast discovery
|
Stage 1: multicast discovery
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@@ -131,4 +151,4 @@ Stage 3
|
|||||||
See also
|
See also
|
||||||
--------
|
--------
|
||||||
|
|
||||||
:ref:`ndn-autoconfig-server`
|
:ref:`ndn-autoconfig-server`, :doc:`ndn-autoconfig.conf`
|
||||||
@@ -34,6 +34,11 @@
|
|||||||
#include <ndn-cxx/util/scheduler-scoped-event-id.hpp>
|
#include <ndn-cxx/util/scheduler-scoped-event-id.hpp>
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include <boost/program_options/options_description.hpp>
|
||||||
|
#include <boost/program_options/variables_map.hpp>
|
||||||
|
#include <boost/program_options/parsers.hpp>
|
||||||
|
|
||||||
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
namespace ndn {
|
namespace ndn {
|
||||||
namespace tools {
|
namespace tools {
|
||||||
@@ -113,21 +118,16 @@ public:
|
|||||||
m_io.stop();
|
m_io.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(const char* programName)
|
usage(std::ostream& os,
|
||||||
|
const po::options_description& optionDescription,
|
||||||
|
const char* programName)
|
||||||
{
|
{
|
||||||
std::cout << "Usage:\n"
|
os << "Usage:\n"
|
||||||
<< " " << programName << " [options]\n"
|
<< " " << programName << " [options]\n"
|
||||||
<< "\n"
|
<< "\n";
|
||||||
<< "Options:\n"
|
os << optionDescription;
|
||||||
<< " [-h] - print usage and exit\n"
|
|
||||||
<< " [-d] - run in daemon mode. In daemon mode, " << programName << " will try \n"
|
|
||||||
<< " to detect network change events and re-run auto-discovery procedure.\n"
|
|
||||||
<< " In addition, the auto-discovery procedure is unconditionally re-run\n"
|
|
||||||
<< " every hour.\n"
|
|
||||||
<< " NOTE: if connection to NFD fails, the daemon will be terminated.\n"
|
|
||||||
<< " [-V] - print version number and exit\n"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -162,22 +162,65 @@ private:
|
|||||||
int
|
int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int opt;
|
|
||||||
const char* programName = argv[0];
|
|
||||||
bool isDaemonMode = false;
|
bool isDaemonMode = false;
|
||||||
|
std::string configFile;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dhV")) != -1) {
|
po::options_description optionDescription("Options");
|
||||||
switch (opt) {
|
optionDescription.add_options()
|
||||||
case 'd':
|
("help,h", "produce help message")
|
||||||
isDaemonMode = true;
|
("daemon,d", po::bool_switch(&isDaemonMode)->default_value(isDaemonMode),
|
||||||
break;
|
"run in daemon mode, detecting network change events and re-running "
|
||||||
case 'h':
|
"auto-discovery procedure. In addition, the auto-discovery procedure "
|
||||||
ndn::tools::NdnAutoconfig::usage(programName);
|
"is unconditionally re-run every hour.\n"
|
||||||
return 0;
|
"NOTE: if connection to NFD fails, the daemon will be terminated.")
|
||||||
case 'V':
|
("config,c", po::value<std::string>(&configFile), "configuration file. If `enabled = true` "
|
||||||
std::cout << NFD_VERSION_BUILD_STRING << std::endl;
|
"is not specified, no actions will be performed.")
|
||||||
return 0;
|
("version,V", "show version and exit")
|
||||||
|
;
|
||||||
|
|
||||||
|
po::variables_map options;
|
||||||
|
try {
|
||||||
|
po::store(po::parse_command_line(argc, argv, optionDescription), options);
|
||||||
|
po::notify(options);
|
||||||
|
}
|
||||||
|
catch (const std::exception& e) {
|
||||||
|
std::cerr << "ERROR: " << e.what() << "\n" << std::endl;
|
||||||
|
ndn::tools::NdnAutoconfig::usage(std::cerr, optionDescription, argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.count("help")) {
|
||||||
|
ndn::tools::NdnAutoconfig::usage(std::cout, optionDescription, argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.count("version")) {
|
||||||
|
std::cout << NFD_VERSION_BUILD_STRING << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable (one-shot or daemon mode whenever config file is not specified)
|
||||||
|
bool isEnabled = true;
|
||||||
|
|
||||||
|
po::options_description configFileOptions;
|
||||||
|
configFileOptions.add_options()
|
||||||
|
("enabled", po::value<bool>(&isEnabled))
|
||||||
|
;
|
||||||
|
|
||||||
|
if (!configFile.empty()) {
|
||||||
|
isEnabled = false; // Disable by default if config file is specified
|
||||||
|
try {
|
||||||
|
po::store(po::parse_config_file<char>(configFile.c_str(), configFileOptions), options);
|
||||||
|
po::notify(options);
|
||||||
}
|
}
|
||||||
|
catch (const std::exception& e) {
|
||||||
|
std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isEnabled) {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
+8
-3
@@ -51,7 +51,12 @@ fi
|
|||||||
sudo @BINDIR@/nfd &
|
sudo @BINDIR@/nfd &
|
||||||
|
|
||||||
if [ -f @SYSCONFDIR@/ndn/nfd-init.sh ]; then
|
if [ -f @SYSCONFDIR@/ndn/nfd-init.sh ]; then
|
||||||
sleep 2 # post-start is executed just after nfd process starts, but there is no guarantee
|
sleep 2 # post-start is executed just after nfd process starts, but there is no guarantee
|
||||||
# that all initialization has been finished
|
# that all initialization has been finished
|
||||||
. @SYSCONFDIR@/ndn/nfd-init.sh
|
. @SYSCONFDIR@/ndn/nfd-init.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f @SYSCONFDIR@/ndn/autoconfig.conf ]; then
|
||||||
|
sleep 2 # post-start is executed just after nfd process starts, but there is no guarantee
|
||||||
|
@BINDIR@/ndn-autoconfig -d -c "@SYSCONFDIR@/ndn/autoconfig.conf" &
|
||||||
fi
|
fi
|
||||||
@@ -240,6 +240,8 @@ def build(bld):
|
|||||||
install_path="${MANDIR}/",
|
install_path="${MANDIR}/",
|
||||||
VERSION=VERSION)
|
VERSION=VERSION)
|
||||||
|
|
||||||
|
bld.install_files("${SYSCONFDIR}/ndn", "autoconfig.conf.sample")
|
||||||
|
|
||||||
def docs(bld):
|
def docs(bld):
|
||||||
from waflib import Options
|
from waflib import Options
|
||||||
Options.commands = ['doxygen', 'sphinx'] + Options.commands
|
Options.commands = ['doxygen', 'sphinx'] + Options.commands
|
||||||
|
|||||||
Reference in new issue
Block a user