NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
general-config-section.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25
#include "
general-config-section.hpp
"
26
27
#include "common.hpp"
28
#include "
core/logger.hpp
"
29
#include "
core/privilege-helper.hpp
"
30
#include "
core/config-file.hpp
"
31
32
namespace
nfd
{
33
34
namespace
general {
35
36
NFD_LOG_INIT
(
"GeneralConfigSection"
);
37
38
static
void
39
onConfig
(
const
ConfigSection
& configSection,
40
bool
isDryRun,
41
const
std::string& filename)
42
{
43
// general
44
// {
45
// ; user "ndn-user"
46
// ; group "ndn-user"
47
// }
48
49
std::string user;
50
std::string group;
51
52
for
(ConfigSection::const_iterator i = configSection.begin();
53
i != configSection.end();
54
++i)
55
{
56
if
(i->first ==
"user"
)
57
{
58
try
59
{
60
user = i->second.get_value<std::string>(
"user"
);
61
62
if
(user.empty())
63
{
64
BOOST_THROW_EXCEPTION(
ConfigFile::Error
(
"Invalid value for \"user\""
65
" in \"general\" section"
));
66
}
67
}
68
catch
(
const
boost::property_tree::ptree_error& error)
69
{
70
BOOST_THROW_EXCEPTION(
ConfigFile::Error
(
"Invalid value for \"user\""
71
" in \"general\" section"
));
72
}
73
}
74
else
if
(i->first ==
"group"
)
75
{
76
try
77
{
78
group = i->second.get_value<std::string>(
"group"
);
79
80
if
(group.empty())
81
{
82
BOOST_THROW_EXCEPTION(
ConfigFile::Error
(
"Invalid value for \"group\""
83
" in \"general\" section"
));
84
}
85
}
86
catch
(
const
boost::property_tree::ptree_error& error)
87
{
88
BOOST_THROW_EXCEPTION(
ConfigFile::Error
(
"Invalid value for \"group\""
89
" in \"general\" section"
));
90
}
91
}
92
}
93
NFD_LOG_TRACE
(
"using user \""
<< user <<
"\" group \""
<< group <<
"\""
);
94
95
PrivilegeHelper::initialize
(user, group);
96
}
97
98
void
99
setConfigFile
(
ConfigFile
& configFile)
100
{
101
configFile.
addSectionHandler
(
"general"
, &
onConfig
);
102
}
103
104
}
// namespace general
105
106
}
// namespace nfd
privilege-helper.hpp
nfd::general::setConfigFile
void setConfigFile(ConfigFile &configFile)
Definition:
general-config-section.cpp:99
nfd::ConfigFile
Definition:
config-file.hpp:48
general-config-section.hpp
nfd::general::onConfig
static void onConfig(const ConfigSection &configSection, bool isDryRun, const std::string &filename)
Definition:
general-config-section.cpp:39
logger.hpp
config-file.hpp
nfd::PrivilegeHelper::initialize
static void initialize(const std::string &userName, const std::string &groupName)
Definition:
privilege-helper.cpp:45
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::ConfigFile::addSectionHandler
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
setup notification of configuration file sections
Definition:
config-file.cpp:79
nfd::ConfigSection
boost::property_tree::ptree ConfigSection
Definition:
ndn-l3-protocol.hpp:38
nfd::ConfigFile::Error
Definition:
config-file.hpp:51
NFD_LOG_INIT
#define NFD_LOG_INIT(name)
Definition:
logger.hpp:34
NFD_LOG_TRACE
#define NFD_LOG_TRACE(expression)
Definition:
logger.hpp:54
ndnSIM
NFD
daemon
mgmt
general-config-section.cpp
Generated on Sat Nov 12 2016 16:02:54 for ndnSIM by
1.8.12