nfd::tools::nfdc Namespace Reference

Namespaces

 text
 
 xml
 

Classes

class  ChannelModule
 Provides access to NFD channel dataset. More...
 
class  CommandArguments
 Contains named command arguments. More...
 
class  CommandDefinition
 Defines a command. More...
 
class  CommandParser
 Parses a command. More...
 
class  CsModule
 Provides access to NFD CS management. More...
 
class  ExecuteContext
 Context for command execution. More...
 
class  FaceModule
 Provides access to NFD face management. More...
 
class  FibModule
 Provides access to NFD FIB management. More...
 
class  FindFace
 Procedure to find a face. More...
 
class  ForwarderGeneralModule
 Provides access to NFD forwarder general status. More...
 
class  Module
 Provides access to an NFD management module. More...
 
class  RibModule
 Provides access to NFD RIB management. More...
 
class  StatusReport
 Collects and prints NFD status report. More...
 
struct  StatusReportOptions
 
class  StrategyChoiceModule
 Provides access to NFD Strategy Choice management. More...
 

Typedefs

using ExecuteCommand = std::function< void(ExecuteContext &)>
 A function to execute a command. More...
 

Enumerations

enum class  ArgValueType {
  NONE ,
  ANY ,
  BOOLEAN ,
  UNSIGNED ,
  STRING ,
  REPORT_FORMAT ,
  NAME ,
  FACE_URI ,
  FACE_ID_OR_URI ,
  FACE_PERSISTENCY ,
  ROUTE_ORIGIN
}
 Indicates argument value type. More...
 
enum  AvailableIn : uint8_t {
  AVAILABLE_IN_NONE = 0 ,
  AVAILABLE_IN_ONE_SHOT = 1 << 0 ,
  AVAILABLE_IN_BATCH = 1 << 1 ,
  AVAILABLE_IN_HELP = 1 << 7 ,
  AVAILABLE_IN_ALL = 0xff
}
 Indicates which modes is a command allowed. More...
 
enum class  ParseMode : uint8_t {
  ONE_SHOT = AVAILABLE_IN_ONE_SHOT ,
  BATCH = AVAILABLE_IN_BATCH
}
 Indicates which mode is the parser operated in. More...
 
enum class  Positional {
  NO = false ,
  YES = true
}
 Indicates whether an argument can be specified as positional. More...
 
enum class  ReportFormat {
  XML = 1 ,
  TEXT = 2
}
 
enum class  Required {
  NO = false ,
  YES = true
}
 Indicates whether an argument is required. More...
 

Functions

static auto calculateUptime (const ForwarderStatus &status)
 
std::pair< std::optional< FaceUri >, std::string > canonize (ExecuteContext &ctx, const FaceUri &uri)
 Canonize a FaceUri. More...
 
std::pair< FindFace::Code, std::string > canonizeErrorHelper (const FaceUri &uri, const std::string &error, const std::string &field="")
 Helper to generate exit code and error message for face canonization failures. More...
 
static std::string getMetavarFromType (ArgValueType vt)
 
int help (std::ostream &os, const CommandParser &parser, std::vector< std::string > args)
 Tries to help the user, if requested on the command line. More...
 
static void helpCommand (const std::string &noun, const std::string &verb)
 
void helpList (std::ostream &os, const CommandParser &parser, ParseMode mode=ParseMode::ONE_SHOT, std::string_view noun="")
 Writes the list of available commands to a stream. More...
 
static int main (int argc, char **argv)
 
 NDN_LOG_INIT (nfdc.CommandDefinition)
 
std::ostream & operator<< (std::ostream &os, ArgValueType vt)
 
std::ostream & operator<< (std::ostream &os, AvailableIn modes)
 
std::ostream & operator<< (std::ostream &os, ParseMode mode)
 
std::ostream & operator<< (std::ostream &os, ReportFormat fmt)
 
static bool parseBoolean (const std::string &s)
 
static FacePersistency parseFacePersistency (const std::string &s)
 
static ReportFormat parseReportFormat (const std::string &s)
 
static bool persistencyLessThan (FacePersistency x, FacePersistency y)
 Order persistency in NONE < ON_DEMAND < PERSISTENCY < PERMANENT. More...
 
void registerCommands (CommandParser &parser)
 
void registerStatusCommands (CommandParser &parser)
 Registers status commands. More...
 
void reportStatus (ExecuteContext &ctx, const StatusReportOptions &options)
 Collect a status report and write to stdout. More...
 
static void reportStatusComprehensive (ExecuteContext &ctx)
 The 'status report' command. More...
 
static void reportStatusSingleSection (ExecuteContext &ctx, bool StatusReportOptions::*wantSection)
 Single-section status command. More...
 

Variables

constexpr int LIST_COMMAND_NAME_COLUMN_WIDTH = 16
 

Typedef Documentation

◆ ExecuteCommand

using nfd::tools::nfdc::ExecuteCommand = typedef std::function<void(ExecuteContext&)>

A function to execute a command.

Definition at line 91 of file execute-command.hpp.

Enumeration Type Documentation

◆ ArgValueType

Indicates argument value type.

Enumerator
NONE 

Boolean argument without value.

The argument appears in CommandArguments as bool value true. It must not be declared as positional.

ANY 

Any arguments.

The argument appears in CommandArguments as std::vector<std::string>. It must be declared as positional, and will consume all subsequent tokens.

BOOLEAN 

Boolean.

The argument appears in CommandArguments as bool.

UNSIGNED 

Non-negative integer.

The argument appears in CommandArguments as uint64_t. Acceptable input range is [0, std::numeric_limits<int64_t>::max()].

STRING 

Arbitrary string.

The argument appears in CommandArguments as std::string.

REPORT_FORMAT 

Report format 'xml' or 'text'.

The argument appears in CommandArguments as nfd::tools::nfdc::ReportFormat.

NAME 

Name prefix.

The argument appears in CommandArguments as ndn::Name.

FACE_URI 

FaceUri.

The argument appears in CommandArguments as ndn::FaceUri.

FACE_ID_OR_URI 

FaceId or FaceUri.

The argument appears in CommandArguments as either uint64_t or ndn::FaceUri.

FACE_PERSISTENCY 

Face persistency 'persistent' or 'permanent'.

The argument appears in CommandArguments as ndn::nfd::FacePersistency.

ROUTE_ORIGIN 

Route origin.

The argument appears in CommandArguments as ndn::nfd::RouteOrigin.

Definition at line 35 of file command-definition.hpp.

◆ AvailableIn

Indicates which modes is a command allowed.

Enumerator
AVAILABLE_IN_NONE 
AVAILABLE_IN_ONE_SHOT 

one-shot mode

AVAILABLE_IN_BATCH 

batch mode

AVAILABLE_IN_HELP 

visible in help listing

AVAILABLE_IN_ALL 

Definition at line 38 of file command-parser.hpp.

◆ ParseMode

enum nfd::tools::nfdc::ParseMode : uint8_t
strong

Indicates which mode is the parser operated in.

Enumerator
ONE_SHOT 

one-shot mode

BATCH 

batch mode

Definition at line 51 of file command-parser.hpp.

◆ Positional

Indicates whether an argument can be specified as positional.

Enumerator
NO 

argument must be named

YES 

argument can be specified as positional

Definition at line 118 of file command-definition.hpp.

◆ ReportFormat

Enumerator
XML 
TEXT 

Definition at line 41 of file status-report.hpp.

◆ Required

Indicates whether an argument is required.

Enumerator
NO 

argument is optional

YES 

argument is required

Definition at line 111 of file command-definition.hpp.

Function Documentation

◆ calculateUptime()

static auto nfd::tools::nfdc::calculateUptime ( const ForwarderStatus &  status)
static

Definition at line 48 of file forwarder-general-module.cpp.

◆ canonize()

std::pair< std::optional< FaceUri >, std::string > nfd::tools::nfdc::canonize ( ExecuteContext ctx,
const FaceUri &  uri 
)

Canonize a FaceUri.

Returns
canonical FaceUri (nullopt on failure) and error string

Definition at line 181 of file face-helpers.cpp.

◆ canonizeErrorHelper()

std::pair< FindFace::Code, std::string > nfd::tools::nfdc::canonizeErrorHelper ( const FaceUri &  uri,
const std::string &  error,
const std::string &  field = "" 
)

Helper to generate exit code and error message for face canonization failures.

Parameters
uriThe FaceUri
errorThe error string returned by the canonization process
fieldAn optional field identifier to include with the message
Returns
exit code and error message

Definition at line 195 of file face-helpers.cpp.

◆ getMetavarFromType()

static std::string nfd::tools::nfdc::getMetavarFromType ( ArgValueType  vt)
static

Definition at line 67 of file command-definition.cpp.

◆ help()

int nfd::tools::nfdc::help ( std::ostream &  os,
const CommandParser parser,
std::vector< std::string >  args 
)

Tries to help the user, if requested on the command line.

Depending on the provided command line arguments args, this function can either open the man page for a specific command, or list all commands available in parser. In the former case, this function never returns if successful.

Return values
0a list of available commands was successfully written to os
1help was requested, but an error was encountered while exec'ing the man binary
2help was not provided because args did not contain any help-related options

Definition at line 78 of file help.cpp.

◆ helpCommand()

static void nfd::tools::nfdc::helpCommand ( const std::string &  noun,
const std::string &  verb 
)
static

Definition at line 69 of file help.cpp.

◆ helpList()

void nfd::tools::nfdc::helpList ( std::ostream &  os,
const CommandParser parser,
ParseMode  mode = ParseMode::ONE_SHOT,
std::string_view  noun = "" 
)

Writes the list of available commands to a stream.

Parameters
osthe output stream to write the list to
parserinstance of CommandParser containing the commands to list
modeonly the commands available in this mode are listed
nounif not empty, only the commands starting with this noun are listed

Definition at line 42 of file help.cpp.

◆ main()

static int nfd::tools::nfdc::main ( int  argc,
char **  argv 
)
static

Definition at line 38 of file main.cpp.

◆ NDN_LOG_INIT()

nfd::tools::nfdc::NDN_LOG_INIT ( nfdc.  CommandDefinition)

◆ operator<<() [1/4]

std::ostream & nfd::tools::nfdc::operator<< ( std::ostream &  os,
ArgValueType  vt 
)

Definition at line 36 of file command-definition.cpp.

◆ operator<<() [2/4]

std::ostream & nfd::tools::nfdc::operator<< ( std::ostream &  os,
AvailableIn  modes 
)

Definition at line 44 of file command-parser.cpp.

◆ operator<<() [3/4]

std::ostream & nfd::tools::nfdc::operator<< ( std::ostream &  os,
ParseMode  mode 
)

Definition at line 64 of file command-parser.cpp.

◆ operator<<() [4/4]

std::ostream & nfd::tools::nfdc::operator<< ( std::ostream &  os,
ReportFormat  fmt 
)

Definition at line 31 of file status-report.cpp.

◆ parseBoolean()

static bool nfd::tools::nfdc::parseBoolean ( const std::string &  s)
static

Definition at line 220 of file command-definition.cpp.

◆ parseFacePersistency()

static FacePersistency nfd::tools::nfdc::parseFacePersistency ( const std::string &  s)
static

Definition at line 244 of file command-definition.cpp.

◆ parseReportFormat()

static ReportFormat nfd::tools::nfdc::parseReportFormat ( const std::string &  s)
static

Definition at line 232 of file command-definition.cpp.

◆ persistencyLessThan()

static bool nfd::tools::nfdc::persistencyLessThan ( FacePersistency  x,
FacePersistency  y 
)
static

Order persistency in NONE < ON_DEMAND < PERSISTENCY < PERMANENT.

Definition at line 137 of file face-module.cpp.

◆ registerCommands()

void nfd::tools::nfdc::registerCommands ( CommandParser parser)

Definition at line 136 of file command-parser.cpp.

◆ registerStatusCommands()

void nfd::tools::nfdc::registerStatusCommands ( CommandParser parser)

Registers status commands.

Providing the following commands:

  • status report
  • status show
  • channel list
  • strategy list
  • fib list
  • route list

Definition at line 118 of file status.cpp.

◆ reportStatus()

void nfd::tools::nfdc::reportStatus ( ExecuteContext ctx,
const StatusReportOptions options 
)

Collect a status report and write to stdout.

Definition at line 40 of file status.cpp.

◆ reportStatusComprehensive()

static void nfd::tools::nfdc::reportStatusComprehensive ( ExecuteContext ctx)
static

The 'status report' command.

Definition at line 108 of file status.cpp.

◆ reportStatusSingleSection()

static void nfd::tools::nfdc::reportStatusSingleSection ( ExecuteContext ctx,
bool StatusReportOptions::*  wantSection 
)
static

Single-section status command.

Definition at line 98 of file status.cpp.

Variable Documentation

◆ LIST_COMMAND_NAME_COLUMN_WIDTH

constexpr int nfd::tools::nfdc::LIST_COMMAND_NAME_COLUMN_WIDTH = 16
constexpr

Definition at line 39 of file help.cpp.