blob: 38190490a89ffc9c1e308d27637874cbfceb0dad [file] [log] [blame]
Spyridon Mastorakis588fd102014-11-20 19:50:02 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08003 * Copyright (c) 2011-2015 Regents of the University of California.
Spyridon Mastorakis588fd102014-11-20 19:50:02 -08004 *
5 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
7 *
8 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20#ifndef NDN_FIB_HELPER_H
21#define NDN_FIB_HELPER_H
22
23#include "ns3/ndnSIM/model/ndn-common.hpp"
24#include "ns3/ndnSIM/model/ndn-face.hpp"
25
26#include "ns3/node.h"
27#include "ns3/object-vector.h"
28#include "ns3/pointer.h"
29
30#include <ndn-cxx/management/nfd-control-parameters.hpp>
31
32namespace ns3 {
33namespace ndn {
34
35using ::ndn::nfd::ControlParameters;
36
37class FibHelper {
38public:
39 /**
40 * \brief Add forwarding entry to FIB
41 *
42 * \param nodeName Node name
43 * \param prefix Routing prefix
44 * \param faceId Face index
45 * \param metric Routing metric
46 */
47 static void
48 AddRoute(const std::string& nodeName, const Name& prefix, uint32_t faceId, int32_t metric);
49
50 /**
51 * \brief Add forwarding entry to FIB
52 *
53 * \param nodeName Node
54 * \param prefix Routing prefix
55 * \param faceId Face index
56 * \param metric Routing metric
57 */
58 static void
59 AddRoute(Ptr<Node> node, const Name& prefix, uint32_t faceId, int32_t metric);
60
61 /**
62 * \brief Add forwarding entry to FIB
63 *
64 * \param node Node
65 * \param prefix Routing prefix
66 * \param face Face
67 * \param metric Routing metric
68 */
69 static void
70 AddRoute(Ptr<Node> node, const Name& prefix, shared_ptr<Face> face, int32_t metric);
71
72 /**
73 * @brief Add forwarding entry to FIB (work only with point-to-point links)
74 *
75 * \param node Node
76 * \param prefix Routing prefix
77 * \param otherNode The other node, to which interests (will be used to infer face id
78 * \param metric Routing metric
79 */
80 static void
81 AddRoute(Ptr<Node> node, const Name& prefix, Ptr<Node> otherNode, int32_t metric);
82
83 /**
84 * @brief Add forwarding entry to FIB (work only with point-to-point links)
85 *
86 * \param nodeName Node name (refer to ns3::Names)
87 * \param prefix Routing prefix
88 * \param otherNode The other node name, to which interests (will be
89 * used to infer face id (refer to ns3::Names)
90 * \param metric Routing metric
91 */
92 static void
93 AddRoute(const std::string& nodeName, const Name& prefix, const std::string& otherNodeName,
94 int32_t metric);
95
96private:
97 static void
98 GenerateCommand(Interest& interest);
99
100 static void
101 AddNextHop(const ControlParameters& parameters, Ptr<Node> node);
102
103 static void
104 RemoveNextHop(const ControlParameters& parameters, Ptr<Node> node);
105};
106
107} // namespace ndn
108
109} // namespace ns3
110
111#endif // NDN_FIB_HELPER_H