blob: 8786a39c1f678ba39b0ec9f7be5a0df618a6868e [file] [log] [blame]
hilata198cadb2014-02-15 23:46:19 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NFD_TOOLS_NFDC_HPP
8#define NFD_TOOLS_NFDC_HPP
9
10#include <ndn-cpp-dev/face.hpp>
11#include <ndn-cpp-dev/management/controller.hpp>
12#include <ndn-cpp-dev/management/nfd-controller.hpp>
13#include <ndn-cpp-dev/management/nfd-fib-management-options.hpp>
14#include <ndn-cpp-dev/management/nfd-face-management-options.hpp>
15#include <vector>
16
17namespace nfdc {
18
19class Controller : public ndn::nfd::Controller
20{
21public:
22 struct Error : public std::runtime_error
23 {
24 Error(const std::string& what) : std::runtime_error(what) {}
25 };
26
27 explicit
28 Controller(ndn::Face& face);
29
30 ~Controller();
31
32 bool
33 dispatch(const std::string& cmd,
34 const char* cmdOptions[],
35 int nOptions);
36 /**
hilatadc947ec2014-03-10 12:48:31 -050037 * \brief Adds a nexthop to a FIB entry.
38 *
39 * If the FIB entry does not exist, it is inserted automatically
hilata198cadb2014-02-15 23:46:19 -060040 *
41 * cmd format:
42 * name
43 *
44 * @param cmdOptions add command without leading 'insert' component
45 */
46 void
hilata198cadb2014-02-15 23:46:19 -060047 fibAddNextHop(const char* cmdOptions[], bool hasCost);
48 /**
hilatadc947ec2014-03-10 12:48:31 -050049 * \brief Removes a nexthop from an existing FIB entry
hilata198cadb2014-02-15 23:46:19 -060050 *
hilatadc947ec2014-03-10 12:48:31 -050051 * If the last nexthop record in a FIB entry is removed, the FIB entry is also deleted
hilata198cadb2014-02-15 23:46:19 -060052 *
53 * cmd format:
54 * name faceId
55 *
56 * @param cmdOptions delNext command without leading 'remove-nexthop' component
57 */
58 void
59 fibRemoveNextHop(const char* cmdOptions[]);
60 /**
61 * \brief Sets a forwarding strategy for a namespace
62 *
hilatadc947ec2014-03-10 12:48:31 -050063 * This command sets a forwarding strategy for a namespace.
hilata198cadb2014-02-15 23:46:19 -060064 *
65 * cmd format:
66 * name strategy
67 *
68 * @param cmdOptions setStrategy command without leading 'setStrategy' component
69 */
70 void
71 fibSetStrategy(const char* cmdOptions[]);
72
73 /**
74 * \brief create new face
75 *
hilatadc947ec2014-03-10 12:48:31 -050076 * This command allows creation of UDP unicast and TCP faces only.
hilata198cadb2014-02-15 23:46:19 -060077 *
78 * cmd format:
79 * uri
80 *
81 * @param cmdOptions create command without leading 'create' component
82 */
83 void
84 faceCreate(const char* cmdOptions[]);
85 /**
86 * \brief destroy a face
87 *
88 * cmd format:
89 * faceId
90 *
91 * @param cmdOptions destroy command without leading 'destroy' component
92 */
93 void
94 faceDestroy(const char* cmdOptions[]);
95
96private:
97 void
98 onFibSuccess(const ndn::nfd::FibManagementOptions& fibOptions, const std::string& message);
99
100 void
101 onFaceSuccess(const ndn::nfd::FaceManagementOptions& faceOptions, const std::string& message);
102
103 void
104 onError(const std::string& error, const std::string& message);
105
106public:
107 const char* m_programName;
108};
109
110}// namespace nfdc
111
112#endif // NFD_TOOLS_NFDC_HPP
113