dump: change namespace
This commit also prepends ndn-tools license boilerplate,
and adds version string to ndndump.
refs #2692
Change-Id: I0b00157f79ba04109682db8e8372fe40d00b7fb2
diff --git a/tools/dump/config.hpp b/tools/dump/config.hpp
deleted file mode 100644
index e69de29..0000000
--- a/tools/dump/config.hpp
+++ /dev/null
diff --git a/tools/dump/main.cpp b/tools/dump/main.cpp
index c8cff68..1ed697c 100644
--- a/tools/dump/main.cpp
+++ b/tools/dump/main.cpp
@@ -1,5 +1,22 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
+ * Copyright (c) 2014-2015, Regents of the University of California.
+ *
+ * This file is part of ndn-tools (Named Data Networking Essential Tools).
+ * See AUTHORS.md for complete list of ndn-tools authors and contributors.
+ *
+ * ndn-tools is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
+/**
* Copyright (c) 2011-2014, Regents of the University of California,
*
* This file is part of ndndump, the packet capture and analysis tool for Named Data
@@ -18,6 +35,7 @@
**/
#include "ndndump.hpp"
+#include "core/version.hpp"
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
@@ -39,6 +57,9 @@
} // namespace boost
+namespace ndn {
+namespace dump {
+
void
usage(std::ostream& os, const std::string& appName, const po::options_description& options)
{
@@ -54,11 +75,12 @@
int
main(int argc, char* argv[])
{
- ndn::tools::Ndndump instance;
+ Ndndump instance;
po::options_description visibleOptions;
visibleOptions.add_options()
("help,h", "Produce this help message")
+ ("version,V", "display version and exit")
("interface,i", po::value<std::string>(&instance.interface),
"Interface from which to dump packets")
("read,r", po::value<std::string>(&instance.inputFile),
@@ -107,6 +129,11 @@
return 0;
}
+ if (vm.count("version") > 0) {
+ std::cout << "ndndump " << tools::VERSION << std::endl;
+ return 0;
+ }
+
if (vm.count("verbose") > 0) {
instance.isVerbose = true;
}
@@ -130,3 +157,12 @@
return 0;
}
+
+} // namespace dump
+} // namespace ndn
+
+int
+main(int argc, char** argv)
+{
+ return ndn::dump::main(argc, argv);
+}
diff --git a/tools/dump/ndndump.cpp b/tools/dump/ndndump.cpp
index e018cd6..cf8f839 100644
--- a/tools/dump/ndndump.cpp
+++ b/tools/dump/ndndump.cpp
@@ -1,5 +1,22 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
+ * Copyright (c) 2014-2015, Regents of the University of California.
+ *
+ * This file is part of ndn-tools (Named Data Networking Essential Tools).
+ * See AUTHORS.md for complete list of ndn-tools authors and contributors.
+ *
+ * ndn-tools is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
+/**
* Copyright (c) 2011-2014, Regents of the University of California,
*
* This file is part of ndndump, the packet capture and analysis tool for Named Data
@@ -19,22 +36,19 @@
#include "ndndump.hpp"
-#include "config.hpp"
-
#include "tcpdump/tcpdump-stdinc.h"
namespace ndn {
-namespace tools {
-// namespace is necessary for now to prevent clashing with system includes
-// this will not be needed after ndn-cxx/common.hpp will stop including <boost/asio.hpp>
+namespace dump {
+// namespace is necessary to prevent clashing with system includes
#include "tcpdump/ether.h"
#include "tcpdump/ip.h"
#include "tcpdump/udp.h"
#include "tcpdump/tcp.h"
-} // namespace tools
} // namespace ndn
+} // namespace dump
#include <boost/lexical_cast.hpp>
@@ -44,7 +58,7 @@
#include <ndn-cxx/data.hpp>
namespace ndn {
-namespace tools {
+namespace dump {
// const uint8_t NDNLP_HEADER[] = {'N', 'd', 'n', 'l', 'p'};
@@ -334,5 +348,5 @@
return 0;
}
-} // namespace tools
+} // namespace dump
} // namespace ndn
diff --git a/tools/dump/ndndump.hpp b/tools/dump/ndndump.hpp
index b5c3470..b46c109 100644
--- a/tools/dump/ndndump.hpp
+++ b/tools/dump/ndndump.hpp
@@ -1,5 +1,22 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
+ * Copyright (c) 2014-2015, Regents of the University of California.
+ *
+ * This file is part of ndn-tools (Named Data Networking Essential Tools).
+ * See AUTHORS.md for complete list of ndn-tools authors and contributors.
+ *
+ * ndn-tools is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
+/**
* Copyright (c) 2011-2014, Regents of the University of California,
*
* This file is part of ndndump, the packet capture and analysis tool for Named Data
@@ -17,8 +34,8 @@
* ndndump, e.g., in COPYING file. If not, see <http://www.gnu.org/licenses/>.
**/
-#ifndef NDNDUMP_NDNDUMP_HPP
-#define NDNDUMP_NDNDUMP_HPP
+#ifndef NDN_TOOLS_DUMP_NDNDUMP_HPP
+#define NDN_TOOLS_DUMP_NDNDUMP_HPP
#include <pcap.h>
@@ -26,7 +43,7 @@
#include <boost/regex.hpp>
namespace ndn {
-namespace tools {
+namespace dump {
class Ndndump : noncopyable
{
@@ -107,7 +124,7 @@
};
-} // namespace tools
+} // namespace dump
} // namespace ndn
-#endif // NDNDUMP_NDNDUMP_HPP
+#endif // NDN_TOOLS_DUMP_NDNDUMP_HPP