Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 2 | /* |
| 3 | * Copyright (C) 2014-2018 Arizona Board of Regents. |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 4 | * |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 17 | * |
| 18 | * Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu> |
| 19 | */ |
| 20 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 21 | #include "logger.hpp" |
| 22 | |
| 23 | #include <ndn-cxx/face.hpp> |
| 24 | #include <ndn-cxx/security/key-chain.hpp> |
| 25 | #include <ndn-cxx/security/signing-info.hpp> |
| 26 | #include <ndn-cxx/util/backports.hpp> |
| 27 | #include <ndn-cxx/util/scheduler.hpp> |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 28 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 29 | #include <boost/asio/io_service.hpp> |
| 30 | #include <boost/asio/signal_set.hpp> |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 31 | #include <boost/filesystem.hpp> |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 32 | #include <boost/noncopyable.hpp> |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 33 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 34 | #include <cctype> |
| 35 | #include <cstdlib> |
| 36 | #include <fstream> |
| 37 | #include <string> |
| 38 | #include <unistd.h> |
| 39 | #include <vector> |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 40 | |
| 41 | namespace ndn { |
| 42 | |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 43 | class NdnTrafficServer : boost::noncopyable |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 44 | { |
| 45 | public: |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 46 | explicit |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 47 | NdnTrafficServer(const char* programName) |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 48 | : m_logger("NdnTrafficServer") |
| 49 | , m_programName(programName) |
| 50 | , m_hasError(false) |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 51 | , m_hasQuietLogging(false) |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 52 | , m_nRegistrationsFailed(0) |
| 53 | , m_nMaximumInterests(-1) |
| 54 | , m_nInterestsReceived(0) |
| 55 | , m_contentDelay(time::milliseconds(-1)) |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 56 | , m_instanceId(to_string(std::rand())) |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 57 | , m_face(m_ioService) |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 58 | , m_scheduler(m_ioService) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 59 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | class DataTrafficConfiguration |
| 63 | { |
| 64 | public: |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 65 | DataTrafficConfiguration() |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 66 | : m_contentType(-1) |
| 67 | , m_freshnessPeriod(time::milliseconds(-1)) |
| 68 | , m_contentBytes(-1) |
| 69 | , m_contentDelay(time::milliseconds(-1)) |
| 70 | , m_nInterestsReceived(0) |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 71 | , m_signingInfo() |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 72 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 76 | printTrafficConfiguration(Logger& logger) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 77 | { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 78 | std::stringstream detail; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 79 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 80 | if (!m_name.empty()) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 81 | detail << "Name=" << m_name << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 82 | } |
| 83 | if (m_contentType >= 0) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 84 | detail << "ContentType=" << to_string(m_contentType) << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 85 | } |
| 86 | if (m_freshnessPeriod >= time::milliseconds(0)) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 87 | detail << "FreshnessPeriod=" << |
| 88 | to_string(static_cast<int>(m_freshnessPeriod.count())) << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 89 | } |
| 90 | if (m_contentBytes >= 0) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 91 | detail << "ContentBytes=" << to_string(m_contentBytes) << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 92 | } |
| 93 | if (m_contentDelay >= time::milliseconds(0)) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 94 | detail << "ContentDelay=" << to_string(m_contentDelay.count()) << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 95 | } |
| 96 | if (!m_content.empty()) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 97 | detail << "Content=" << m_content << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 98 | } |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 99 | detail << "SigningInfo=" << m_signingInfo; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 100 | |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 101 | logger.log(detail.str(), false, false); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 102 | } |
| 103 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 104 | bool |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 105 | extractParameterValue(const std::string& detail, std::string& parameter, std::string& value) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 106 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 107 | std::string allowedCharacters = ":/+._-%"; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 108 | std::size_t i = 0; |
| 109 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 110 | parameter = ""; |
| 111 | value = ""; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 112 | while (detail[i] != '=' && i < detail.length()) { |
| 113 | parameter += detail[i]; |
| 114 | i++; |
| 115 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 116 | if (i == detail.length()) |
| 117 | return false; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 118 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 119 | i++; |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 120 | while ((std::isalnum(detail[i]) || |
| 121 | allowedCharacters.find(detail[i]) != std::string::npos) && |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 122 | i < detail.length()) { |
| 123 | value += detail[i]; |
| 124 | i++; |
| 125 | } |
| 126 | |
| 127 | if (parameter.empty() || value.empty()) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 128 | return false; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 129 | else |
| 130 | return true; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | bool |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 134 | processConfigurationDetail(const std::string& detail, |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 135 | Logger& logger, |
| 136 | int lineNumber) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 137 | { |
| 138 | std::string parameter, value; |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 139 | if (extractParameterValue(detail, parameter, value)) { |
| 140 | if (parameter == "Name") { |
| 141 | m_name = value; |
| 142 | } |
| 143 | else if (parameter == "ContentType") { |
| 144 | m_contentType = std::stoi(value); |
| 145 | } |
| 146 | else if (parameter == "FreshnessPeriod") { |
| 147 | m_freshnessPeriod = time::milliseconds(std::stoi(value)); |
| 148 | } |
| 149 | else if (parameter == "ContentDelay") { |
| 150 | m_contentDelay = time::milliseconds(std::stoi(value)); |
| 151 | } |
| 152 | else if (parameter == "ContentBytes") { |
| 153 | m_contentBytes = std::stoi(value); |
| 154 | } |
| 155 | else if (parameter == "Content") { |
| 156 | m_content = value; |
| 157 | } |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 158 | else if (parameter == "SigningInfo") { |
| 159 | m_signingInfo = security::SigningInfo(value); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 160 | } |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 161 | else { |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 162 | logger.log("Line " + to_string(lineNumber) + |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 163 | " \t- Invalid Parameter='" + parameter + "'", false, true); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 164 | } |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 165 | } |
| 166 | else { |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 167 | logger.log("Line " + to_string(lineNumber) + |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 168 | " \t- Improper Traffic Configuration Line - " + detail, false, true); |
| 169 | return false; |
| 170 | } |
| 171 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 172 | return true; |
| 173 | } |
| 174 | |
| 175 | bool |
| 176 | checkTrafficDetailCorrectness() |
| 177 | { |
| 178 | return true; |
| 179 | } |
| 180 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 181 | private: |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 182 | std::string m_name; |
| 183 | int m_contentType; |
| 184 | time::milliseconds m_freshnessPeriod; |
| 185 | int m_contentBytes; |
| 186 | time::milliseconds m_contentDelay; |
| 187 | std::string m_content; |
| 188 | int m_nInterestsReceived; |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 189 | security::SigningInfo m_signingInfo; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 190 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 191 | friend class NdnTrafficServer; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 192 | }; |
| 193 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 194 | void |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 195 | usage() const |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 196 | { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 197 | std::cout << "Usage:\n" |
| 198 | << " " << m_programName << " [options] <Traffic_Configuration_File>\n" |
| 199 | << "\n" |
| 200 | << "Respond to Interests as per provided Traffic Configuration File.\n" |
| 201 | << "Multiple prefixes can be configured for handling.\n" |
| 202 | << "Set environment variable NDN_TRAFFIC_LOGFOLDER to redirect output to a log file.\n" |
| 203 | << "\n" |
| 204 | << "Options:\n" |
| 205 | << " [-d interval] - set delay before responding to interest, in milliseconds\n" |
| 206 | << " [-c count] - specify maximum number of interests to be satisfied\n" |
| 207 | << " [-q] - quiet mode: no interest reception/data generation logging\n" |
| 208 | << " [-h] - print this help text and exit\n"; |
| 209 | exit(EXIT_FAILURE); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 210 | } |
| 211 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 212 | void |
| 213 | setMaximumInterests(int maximumInterests) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 214 | { |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 215 | if (maximumInterests < 0) { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 216 | usage(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 217 | } |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 218 | m_nMaximumInterests = maximumInterests; |
| 219 | } |
| 220 | |
| 221 | bool |
| 222 | hasError() const |
| 223 | { |
| 224 | return m_hasError; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | void |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 228 | setContentDelay(int contentDelay) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 229 | { |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 230 | if (contentDelay < 0) { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 231 | usage(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 232 | } |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 233 | m_contentDelay = time::milliseconds(contentDelay); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | void |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 237 | setConfigurationFile(const char* configurationFile) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 238 | { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 239 | m_configurationFile = configurationFile; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | void |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 243 | setQuietLogging() |
| 244 | { |
| 245 | m_hasQuietLogging = true; |
| 246 | } |
| 247 | |
| 248 | void |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 249 | signalHandler() |
| 250 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 251 | logStatistics(); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 252 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 253 | m_logger.shutdownLogger(); |
| 254 | m_face.shutdown(); |
Alexander Afanasyev | 976c397 | 2014-05-26 17:03:40 +0300 | [diff] [blame] | 255 | m_ioService.stop(); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 256 | |
| 257 | exit(m_hasError ? EXIT_FAILURE : EXIT_SUCCESS); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | void |
| 261 | logStatistics() |
| 262 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 263 | m_logger.log("\n\n== Interest Traffic Report ==\n", false, true); |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 264 | m_logger.log("Total Traffic Pattern Types = " + |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 265 | to_string(m_trafficPatterns.size()), false, true); |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 266 | m_logger.log("Total Interests Received = " + |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 267 | to_string(m_nInterestsReceived), false, true); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 268 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 269 | if (m_nInterestsReceived < m_nMaximumInterests) { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 270 | m_hasError = true; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 271 | } |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 272 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 273 | for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++) { |
| 274 | m_logger.log("\nTraffic Pattern Type #" + to_string(patternId + 1), false, true); |
| 275 | m_trafficPatterns[patternId].printTrafficConfiguration(m_logger); |
| 276 | m_logger.log("Total Interests Received = " + to_string( |
| 277 | m_trafficPatterns[patternId].m_nInterestsReceived) + "\n", false, true); |
| 278 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | bool |
| 282 | checkTrafficPatternCorrectness() |
| 283 | { |
| 284 | return true; |
| 285 | } |
| 286 | |
| 287 | void |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 288 | parseConfigurationFile() |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 289 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 290 | std::string patternLine; |
| 291 | std::ifstream patternFile; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 292 | m_logger.log("Analyzing Traffic Configuration File: " + m_configurationFile, true, true); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 293 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 294 | patternFile.open(m_configurationFile.c_str()); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 295 | if (patternFile.is_open()) { |
| 296 | int lineNumber = 0; |
| 297 | while (getline(patternFile, patternLine)) { |
| 298 | lineNumber++; |
| 299 | if (std::isalpha(patternLine[0])) { |
| 300 | DataTrafficConfiguration dataData; |
| 301 | bool shouldSkipLine = false; |
| 302 | if (dataData.processConfigurationDetail(patternLine, m_logger, lineNumber)) { |
| 303 | while (getline(patternFile, patternLine) && std::isalpha(patternLine[0])) { |
| 304 | lineNumber++; |
| 305 | if (!dataData.processConfigurationDetail(patternLine, m_logger, lineNumber)) { |
| 306 | shouldSkipLine = true; |
| 307 | break; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 308 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 309 | } |
| 310 | lineNumber++; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 311 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 312 | else { |
| 313 | shouldSkipLine = true; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 314 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 315 | if (!shouldSkipLine) { |
| 316 | if (dataData.checkTrafficDetailCorrectness()) { |
| 317 | m_trafficPatterns.push_back(dataData); |
| 318 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 319 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 320 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 321 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 322 | patternFile.close(); |
| 323 | |
| 324 | if (!checkTrafficPatternCorrectness()) { |
| 325 | m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper - " + |
| 326 | m_configurationFile, false, true); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 327 | m_logger.shutdownLogger(); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 328 | exit(EXIT_FAILURE); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 329 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 330 | |
| 331 | m_logger.log("Traffic Configuration File Processing Completed\n", true, false); |
| 332 | for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++) { |
| 333 | m_logger.log("Traffic Pattern Type #" + |
| 334 | to_string(patternId + 1), false, false); |
| 335 | m_trafficPatterns[patternId].printTrafficConfiguration(m_logger); |
| 336 | m_logger.log("", false, false); |
| 337 | } |
| 338 | } |
| 339 | else { |
| 340 | m_logger.log("ERROR - Unable To Open Traffic Configuration File: " + |
| 341 | m_configurationFile, false, true); |
| 342 | m_logger.shutdownLogger(); |
| 343 | exit(EXIT_FAILURE); |
| 344 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | void |
| 348 | initializeTrafficConfiguration() |
| 349 | { |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 350 | if (boost::filesystem::exists(boost::filesystem::path(m_configurationFile))) { |
| 351 | if (boost::filesystem::is_regular_file(boost::filesystem::path(m_configurationFile))) { |
| 352 | parseConfigurationFile(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 353 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 354 | else { |
| 355 | m_logger.log("ERROR - Traffic Configuration File Is Not A Regular File: " + |
| 356 | m_configurationFile, false, true); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 357 | m_logger.shutdownLogger(); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 358 | exit(EXIT_FAILURE); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 359 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 360 | } |
| 361 | else { |
| 362 | m_logger.log("ERROR - Traffic Configuration File Does Not Exist: " + |
| 363 | m_configurationFile, false, true); |
| 364 | m_logger.shutdownLogger(); |
| 365 | exit(EXIT_FAILURE); |
| 366 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | static std::string |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 370 | getRandomByteString(std::size_t randomSize) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 371 | { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 372 | std::string randomString; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 373 | for (std::size_t i = 0; i < randomSize; i++) { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 374 | randomString += static_cast<char>(std::rand() % 128); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 375 | } |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 376 | return randomString; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | void |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 380 | onInterest(const Name& name, const Interest& interest, int patternId) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 381 | { |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 382 | auto& pattern = m_trafficPatterns[patternId]; |
| 383 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 384 | if (m_nMaximumInterests < 0 || m_nInterestsReceived < m_nMaximumInterests) { |
| 385 | Data data(interest.getName()); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 386 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 387 | if (pattern.m_contentType >= 0) |
| 388 | data.setContentType(pattern.m_contentType); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 389 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 390 | if (pattern.m_freshnessPeriod >= time::milliseconds(0)) |
| 391 | data.setFreshnessPeriod(pattern.m_freshnessPeriod); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 392 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 393 | std::string content; |
| 394 | if (pattern.m_contentBytes >= 0) |
| 395 | content = getRandomByteString(pattern.m_contentBytes); |
| 396 | if (!pattern.m_content.empty()) |
| 397 | content = pattern.m_content; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 398 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 399 | data.setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.length()); |
| 400 | m_keyChain.sign(data, pattern.m_signingInfo); |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 401 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 402 | m_nInterestsReceived++; |
| 403 | pattern.m_nInterestsReceived++; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 404 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 405 | if (!m_hasQuietLogging) { |
| 406 | std::string logLine = |
| 407 | "Interest Received - PatternType=" + to_string(patternId + 1) + |
| 408 | ", GlobalID=" + to_string(m_nInterestsReceived) + |
| 409 | ", LocalID=" + to_string(pattern.m_nInterestsReceived) + |
| 410 | ", Name=" + pattern.m_name; |
| 411 | m_logger.log(logLine, true, false); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 412 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 413 | |
| 414 | if (pattern.m_contentDelay > time::milliseconds(-1)) |
| 415 | usleep(pattern.m_contentDelay.count() * 1000); |
| 416 | if (m_contentDelay > time::milliseconds(-1)) |
| 417 | usleep(m_contentDelay.count() * 1000); |
| 418 | m_face.put(data); |
| 419 | } |
| 420 | if (m_nMaximumInterests >= 0 && m_nInterestsReceived == m_nMaximumInterests) { |
| 421 | logStatistics(); |
| 422 | m_scheduler.scheduleEvent(2_s, [this] { |
| 423 | m_logger.shutdownLogger(); |
| 424 | m_face.shutdown(); |
| 425 | m_ioService.stop(); |
| 426 | }); |
| 427 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | void |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 431 | onRegisterFailed(const ndn::Name& prefix, const std::string& reason, int patternId) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 432 | { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 433 | std::string logLine; |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 434 | logLine += "Prefix Registration Failed - PatternType=" + to_string(patternId + 1); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 435 | logLine += ", Name=" + m_trafficPatterns[patternId].m_name; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 436 | m_logger.log(logLine, true, true); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 437 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 438 | m_nRegistrationsFailed++; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 439 | if (m_nRegistrationsFailed == m_trafficPatterns.size()) { |
| 440 | m_hasError = true; |
| 441 | signalHandler(); |
| 442 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | void |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 446 | run() |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 447 | { |
Alexander Afanasyev | 976c397 | 2014-05-26 17:03:40 +0300 | [diff] [blame] | 448 | boost::asio::signal_set signalSet(m_ioService, SIGINT, SIGTERM); |
Alexander Afanasyev | 740812e | 2014-10-30 15:37:45 -0700 | [diff] [blame] | 449 | signalSet.async_wait(bind(&NdnTrafficServer::signalHandler, this)); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 450 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 451 | m_logger.initializeLog(m_instanceId); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 452 | initializeTrafficConfiguration(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 453 | if (m_nMaximumInterests == 0) { |
| 454 | logStatistics(); |
| 455 | m_logger.shutdownLogger(); |
| 456 | return; |
| 457 | } |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 458 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 459 | for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++) { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 460 | m_face.setInterestFilter(m_trafficPatterns[patternId].m_name, |
| 461 | bind(&NdnTrafficServer::onInterest, this, _1, _2, patternId), |
| 462 | bind(&NdnTrafficServer::onRegisterFailed, this, _1, _2, patternId)); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 463 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 464 | |
| 465 | try { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 466 | m_face.processEvents(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 467 | } |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 468 | catch (const std::exception& e) { |
| 469 | m_logger.log("ERROR: " + std::string(e.what()), true, true); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 470 | m_logger.shutdownLogger(); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 471 | m_hasError = true; |
Alexander Afanasyev | 976c397 | 2014-05-26 17:03:40 +0300 | [diff] [blame] | 472 | m_ioService.stop(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 473 | } |
| 474 | } |
| 475 | |
| 476 | private: |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 477 | KeyChain m_keyChain; |
Alexander Afanasyev | 740812e | 2014-10-30 15:37:45 -0700 | [diff] [blame] | 478 | Logger m_logger; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 479 | std::string m_programName; |
| 480 | bool m_hasError; |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 481 | bool m_hasQuietLogging; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 482 | std::size_t m_nRegistrationsFailed; |
Alexander Afanasyev | 740812e | 2014-10-30 15:37:45 -0700 | [diff] [blame] | 483 | int m_nMaximumInterests; |
| 484 | int m_nInterestsReceived; |
| 485 | time::milliseconds m_contentDelay; |
| 486 | std::string m_instanceId; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 487 | std::string m_configurationFile; |
Alexander Afanasyev | 740812e | 2014-10-30 15:37:45 -0700 | [diff] [blame] | 488 | |
Alexander Afanasyev | 976c397 | 2014-05-26 17:03:40 +0300 | [diff] [blame] | 489 | boost::asio::io_service m_ioService; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 490 | Face m_face; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 491 | util::scheduler::Scheduler m_scheduler; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 492 | std::vector<DataTrafficConfiguration> m_trafficPatterns; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 493 | }; |
| 494 | |
| 495 | } // namespace ndn |
| 496 | |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 497 | int |
| 498 | main(int argc, char* argv[]) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 499 | { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 500 | std::srand(std::time(nullptr)); |
| 501 | |
| 502 | ndn::NdnTrafficServer server(argv[0]); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 503 | int option; |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 504 | while ((option = getopt(argc, argv, "hqc:d:")) != -1) { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 505 | switch (option) { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 506 | case 'h': |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 507 | server.usage(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 508 | break; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 509 | case 'c': |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 510 | server.setMaximumInterests(atoi(optarg)); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 511 | break; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 512 | case 'd': |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 513 | server.setContentDelay(atoi(optarg)); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 514 | break; |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 515 | case 'q': |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 516 | server.setQuietLogging(); |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 517 | break; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 518 | default: |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 519 | server.usage(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 520 | break; |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | argc -= optind; |
| 525 | argv += optind; |
| 526 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 527 | if (!argc) { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 528 | server.usage(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 529 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 530 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 531 | server.setConfigurationFile(argv[0]); |
| 532 | server.run(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 533 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 534 | return server.hasError() ? EXIT_FAILURE : EXIT_SUCCESS; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame^] | 535 | } |