aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Net/src/ICMPEventArgs.cpp
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/Net/src/ICMPEventArgs.cpp
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/Net/src/ICMPEventArgs.cpp')
-rw-r--r--contrib/libs/poco/Net/src/ICMPEventArgs.cpp336
1 files changed, 168 insertions, 168 deletions
diff --git a/contrib/libs/poco/Net/src/ICMPEventArgs.cpp b/contrib/libs/poco/Net/src/ICMPEventArgs.cpp
index 202f9cc0c5..3a219f9d74 100644
--- a/contrib/libs/poco/Net/src/ICMPEventArgs.cpp
+++ b/contrib/libs/poco/Net/src/ICMPEventArgs.cpp
@@ -1,168 +1,168 @@
-//
-// ICMPEventArgs.cpp
-//
-// Library: Net
-// Package: ICMP
-// Module: ICMPEventArgs
-//
-// Implementation of ICMPEventArgs
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Net/ICMPEventArgs.h"
-#include "Poco/Net/SocketAddress.h"
-#include "Poco/Net/DNS.h"
-#include "Poco/Exception.h"
-#include "Poco/Net/NetException.h"
-#include <numeric>
-
-
-using Poco::IOException;
-using Poco::InvalidArgumentException;
-
-
-namespace Poco {
-namespace Net {
-
-
-ICMPEventArgs::ICMPEventArgs(const SocketAddress& address, int repetitions, int dataSize, int ttl):
- _address(address),
- _sent(0),
- _dataSize(dataSize),
- _ttl(ttl),
- _rtt(repetitions, 0),
- _errors(repetitions)
-{
-}
-
-
-ICMPEventArgs::~ICMPEventArgs()
-{
-}
-
-
-std::string ICMPEventArgs::hostName() const
-{
- try
- {
- return DNS::resolve(_address.host().toString()).name();
- }
- catch (HostNotFoundException&)
- {
- }
- catch (NoAddressFoundException&)
- {
- }
- catch (DNSException&)
- {
- }
- catch (IOException&)
- {
- }
- return _address.host().toString();
-}
-
-
-std::string ICMPEventArgs::hostAddress() const
-{
- return _address.host().toString();
-}
-
-
-void ICMPEventArgs::setRepetitions(int repetitions)
-{
- _rtt.clear();
- _rtt.resize(repetitions, 0);
- _errors.assign(repetitions, "");
-}
-
-
-ICMPEventArgs& ICMPEventArgs::operator ++ ()
-{
- ++_sent;
- return *this;
-}
-
-
-ICMPEventArgs ICMPEventArgs::operator ++ (int)
-{
- ICMPEventArgs prev(*this);
- operator ++ ();
- return prev;
-}
-
-
-int ICMPEventArgs::received() const
-{
- int received = 0;
-
- for (int i = 0; i < _rtt.size(); ++i)
- {
- if (_rtt[i]) ++received;
- }
- return received;
-}
-
-
-void ICMPEventArgs::setError(int index, const std::string& text)
-{
- if (index >= _errors.size())
- throw InvalidArgumentException("Supplied index exceeds vector capacity.");
-
- _errors[index] = text;
-}
-
-
-const std::string& ICMPEventArgs::error(int index) const
-{
- if (0 == _errors.size())
- throw InvalidArgumentException("Supplied index exceeds vector capacity.");
-
- if (-1 == index) index = _sent - 1;
-
- return _errors[index];
-}
-
-
-void ICMPEventArgs::setReplyTime(int index, int time)
-{
- if (index >= _rtt.size())
- throw InvalidArgumentException("Supplied index exceeds array capacity.");
- if (0 == time) time = 1;
- _rtt[index] = time;
-}
-
-
-int ICMPEventArgs::replyTime(int index) const
-{
- if (0 == _rtt.size())
- throw InvalidArgumentException("Supplied index exceeds array capacity.");
-
- if (-1 == index) index = _sent - 1;
-
- return _rtt[index];
-}
-
-
-int ICMPEventArgs::avgRTT() const
-{
- if (0 == _rtt.size()) return 0;
-
- return (int) (std::accumulate(_rtt.begin(), _rtt.end(), 0) / _rtt.size());
-}
-
-
-float ICMPEventArgs::percent() const
-{
- if (0 == _rtt.size()) return 0;
-
- return ((float) received() / (float) _rtt.size()) * (float) 100.0;
-}
-
-
-} } // namespace Poco::Net
+//
+// ICMPEventArgs.cpp
+//
+// Library: Net
+// Package: ICMP
+// Module: ICMPEventArgs
+//
+// Implementation of ICMPEventArgs
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Net/ICMPEventArgs.h"
+#include "Poco/Net/SocketAddress.h"
+#include "Poco/Net/DNS.h"
+#include "Poco/Exception.h"
+#include "Poco/Net/NetException.h"
+#include <numeric>
+
+
+using Poco::IOException;
+using Poco::InvalidArgumentException;
+
+
+namespace Poco {
+namespace Net {
+
+
+ICMPEventArgs::ICMPEventArgs(const SocketAddress& address, int repetitions, int dataSize, int ttl):
+ _address(address),
+ _sent(0),
+ _dataSize(dataSize),
+ _ttl(ttl),
+ _rtt(repetitions, 0),
+ _errors(repetitions)
+{
+}
+
+
+ICMPEventArgs::~ICMPEventArgs()
+{
+}
+
+
+std::string ICMPEventArgs::hostName() const
+{
+ try
+ {
+ return DNS::resolve(_address.host().toString()).name();
+ }
+ catch (HostNotFoundException&)
+ {
+ }
+ catch (NoAddressFoundException&)
+ {
+ }
+ catch (DNSException&)
+ {
+ }
+ catch (IOException&)
+ {
+ }
+ return _address.host().toString();
+}
+
+
+std::string ICMPEventArgs::hostAddress() const
+{
+ return _address.host().toString();
+}
+
+
+void ICMPEventArgs::setRepetitions(int repetitions)
+{
+ _rtt.clear();
+ _rtt.resize(repetitions, 0);
+ _errors.assign(repetitions, "");
+}
+
+
+ICMPEventArgs& ICMPEventArgs::operator ++ ()
+{
+ ++_sent;
+ return *this;
+}
+
+
+ICMPEventArgs ICMPEventArgs::operator ++ (int)
+{
+ ICMPEventArgs prev(*this);
+ operator ++ ();
+ return prev;
+}
+
+
+int ICMPEventArgs::received() const
+{
+ int received = 0;
+
+ for (int i = 0; i < _rtt.size(); ++i)
+ {
+ if (_rtt[i]) ++received;
+ }
+ return received;
+}
+
+
+void ICMPEventArgs::setError(int index, const std::string& text)
+{
+ if (index >= _errors.size())
+ throw InvalidArgumentException("Supplied index exceeds vector capacity.");
+
+ _errors[index] = text;
+}
+
+
+const std::string& ICMPEventArgs::error(int index) const
+{
+ if (0 == _errors.size())
+ throw InvalidArgumentException("Supplied index exceeds vector capacity.");
+
+ if (-1 == index) index = _sent - 1;
+
+ return _errors[index];
+}
+
+
+void ICMPEventArgs::setReplyTime(int index, int time)
+{
+ if (index >= _rtt.size())
+ throw InvalidArgumentException("Supplied index exceeds array capacity.");
+ if (0 == time) time = 1;
+ _rtt[index] = time;
+}
+
+
+int ICMPEventArgs::replyTime(int index) const
+{
+ if (0 == _rtt.size())
+ throw InvalidArgumentException("Supplied index exceeds array capacity.");
+
+ if (-1 == index) index = _sent - 1;
+
+ return _rtt[index];
+}
+
+
+int ICMPEventArgs::avgRTT() const
+{
+ if (0 == _rtt.size()) return 0;
+
+ return (int) (std::accumulate(_rtt.begin(), _rtt.end(), 0) / _rtt.size());
+}
+
+
+float ICMPEventArgs::percent() const
+{
+ if (0 == _rtt.size()) return 0;
+
+ return ((float) received() / (float) _rtt.size()) * (float) 100.0;
+}
+
+
+} } // namespace Poco::Net