aboutsummaryrefslogtreecommitdiffstats
path: root/apps/http-proxy/includes
diff options
context:
space:
mode:
authorMichele Papalini <micpapal@cisco.com>2023-02-01 17:25:21 +0100
committerMichele Papalini <micpapal@cisco.com>2023-02-02 14:56:22 +0100
commitb96d1545a8d2a173dc5911ed0bca3e04dbb02176 (patch)
treea69893191b0f7d52c10135e8b0c7702378ffee69 /apps/http-proxy/includes
parentf72846be51c7fd70310ea166cfc2ffbdc930f0e6 (diff)
fix(apps): fix issues reported by sonarqube
Ref: HICN-836 Signed-off-by: Michele Papalini <micpapal@cisco.com> Change-Id: Ie76771ca75bd224084ce3c893aba661b97064419
Diffstat (limited to 'apps/http-proxy/includes')
-rw-r--r--apps/http-proxy/includes/hicn/http-proxy/forwarder_interface.h23
-rw-r--r--apps/http-proxy/includes/hicn/http-proxy/http_proxy.h13
-rw-r--r--apps/http-proxy/includes/hicn/http-proxy/http_session.h24
-rw-r--r--apps/http-proxy/includes/hicn/http-proxy/icn_receiver.h10
-rw-r--r--apps/http-proxy/includes/hicn/http-proxy/utils.h4
5 files changed, 34 insertions, 40 deletions
diff --git a/apps/http-proxy/includes/hicn/http-proxy/forwarder_interface.h b/apps/http-proxy/includes/hicn/http-proxy/forwarder_interface.h
index c60e26c63..ae9562a12 100644
--- a/apps/http-proxy/includes/hicn/http-proxy/forwarder_interface.h
+++ b/apps/http-proxy/includes/hicn/http-proxy/forwarder_interface.h
@@ -52,16 +52,11 @@ using RouteInfoPtr = std::shared_ptr<route_info_t>;
class ForwarderInterface {
public:
- ForwarderInterface(asio::io_service &io_service)
+ explicit ForwarderInterface(asio::io_service &io_service)
: external_ioservice_(io_service),
work_(std::make_unique<asio::io_service::work>(internal_ioservice_)),
- sock_(nullptr),
thread_(std::make_unique<std::thread>(
- [this]() { internal_ioservice_.run(); })),
- check_routes_timer_(nullptr),
- pending_add_route_counter_(0),
- route_id_(0),
- closed_(false) {}
+ [this]() { internal_ioservice_.run(); })) {}
~ForwarderInterface();
@@ -95,20 +90,20 @@ class ForwarderInterface {
void internalCreateFaceAndRoute(RouteInfoPtr route_info, uint8_t max_try,
asio::steady_timer *timer,
- SetRouteCallback callback);
+ const SetRouteCallback &callback);
- int tryToCreateFaceAndRoute(route_info_t *route_info);
+ int tryToCreateFaceAndRoute(const route_info_t *route_info);
asio::io_service &external_ioservice_;
asio::io_service internal_ioservice_;
std::unique_ptr<asio::io_service::work> work_;
- hc_sock_t *sock_;
+ hc_sock_t *sock_ = nullptr;
std::unique_ptr<std::thread> thread_;
std::unordered_map<uint32_t, RouteInfoPtr> route_status_;
- std::unique_ptr<asio::steady_timer> check_routes_timer_;
- uint32_t pending_add_route_counter_;
- uint32_t route_id_;
- bool closed_;
+ std::unique_ptr<asio::steady_timer> check_routes_timer_ = nullptr;
+ uint32_t pending_add_route_counter_ = 0;
+ uint32_t route_id_ = 0;
+ bool closed_ = false;
};
} // namespace transport
diff --git a/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h b/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h
index 1fa96956a..567ab4540 100644
--- a/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h
+++ b/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h
@@ -34,7 +34,8 @@ class TcpListener {
public:
using AcceptCallback = std::function<void(asio::ip::tcp::socket&&)>;
- TcpListener(asio::io_service& io_service, short port, AcceptCallback callback)
+ TcpListener(asio::io_service& io_service, short port,
+ const AcceptCallback& callback)
: acceptor_(io_service),
#if ((ASIO_VERSION / 100 % 1000) < 12)
socket_(io_service),
@@ -49,7 +50,6 @@ class TcpListener {
acceptor_.listen();
}
- public:
void doAccept() {
#if ((ASIO_VERSION / 100 % 1000) >= 12)
acceptor_.async_accept(
@@ -80,7 +80,7 @@ class HTTPClientConnectionCallback;
class Receiver {
public:
- Receiver() : thread_() {}
+ Receiver() {}
virtual ~Receiver() = default;
void stopAndJoinThread() { thread_.stop(); }
virtual void stop() = 0;
@@ -115,13 +115,13 @@ class TcpReceiver : public Receiver {
std::deque<HTTPClientConnectionCallback*> http_clients_;
std::unordered_set<HTTPClientConnectionCallback*> used_http_clients_;
ForwarderConfig forwarder_config_;
- bool stopped_;
+ bool stopped_ = false;
};
class IcnReceiver : public Receiver {
public:
template <typename... Args>
- IcnReceiver(Args&&... args)
+ explicit IcnReceiver(Args&&... args)
: Receiver(),
icn_consum_producer_(thread_.getIoService(),
std::forward<Args>(args)...) {
@@ -148,6 +148,7 @@ class HTTPProxy {
std::string prefix;
std::string first_ipv6_word;
+ virtual ~CommonParams() {}
virtual void printParams() { LoggerInfo() << "Parameters: "; };
};
@@ -206,4 +207,4 @@ class HTTPProxy {
asio::signal_set signals_;
};
-} // namespace transport \ No newline at end of file
+} // namespace transport
diff --git a/apps/http-proxy/includes/hicn/http-proxy/http_session.h b/apps/http-proxy/includes/hicn/http-proxy/http_session.h
index 1563431dc..1b7df96a6 100644
--- a/apps/http-proxy/includes/hicn/http-proxy/http_session.h
+++ b/apps/http-proxy/includes/hicn/http-proxy/http_session.h
@@ -73,13 +73,16 @@ class HTTPSession {
};
public:
- HTTPSession(asio::io_service &io_service, std::string &ip_address,
- std::string &port, ContentReceivedCallback receive_callback,
- OnConnectionClosed on_reconnect_callback, bool client = false);
+ HTTPSession(asio::io_service &io_service, const std::string &ip_address,
+ const std::string &port,
+ const ContentReceivedCallback &receive_callback,
+ const OnConnectionClosed &on_reconnect_callback,
+ bool client = false);
HTTPSession(asio::ip::tcp::socket socket,
- ContentReceivedCallback receive_callback,
- OnConnectionClosed on_reconnect_callback, bool client = true);
+ const ContentReceivedCallback &receive_callback,
+ const OnConnectionClosed &on_reconnect_callback,
+ bool client = true);
~HTTPSession();
@@ -103,7 +106,6 @@ class HTTPSession {
bool checkConnected();
- private:
void handleRead(const std::error_code &ec, std::size_t length);
void tryReconnection();
void startConnectionTimer();
@@ -120,14 +122,14 @@ class HTTPSession {
asio::streambuf input_buffer_;
bool reverse_;
- bool is_reconnection_;
- bool data_available_;
+ bool is_reconnection_ = false;
+ bool data_available_ = false;
- std::size_t content_length_;
+ std::size_t content_length_ = 0;
// Chunked encoding
- bool is_last_chunk_;
- bool chunked_;
+ bool is_last_chunk_ = false;
+ bool chunked_ = false;
ContentReceivedCallback receive_callback_;
OnConnectionClosed on_connection_closed_callback_;
diff --git a/apps/http-proxy/includes/hicn/http-proxy/icn_receiver.h b/apps/http-proxy/includes/hicn/http-proxy/icn_receiver.h
index a402d44cf..e3ab97fdd 100644
--- a/apps/http-proxy/includes/hicn/http-proxy/icn_receiver.h
+++ b/apps/http-proxy/includes/hicn/http-proxy/icn_receiver.h
@@ -24,7 +24,6 @@
#include <cstring>
#include <queue>
#include <utility>
-//#include "http_session.h"
namespace transport {
@@ -48,9 +47,7 @@ class AsyncConsumerProducer {
const std::string& content_lifetime, bool manifest)
: AsyncConsumerProducer(internal_io_service_, prefix, first_ipv6_word,
origin_address, origin_port, cache_size, mtu,
- content_lifetime, manifest) {
- external_io_service_ = false;
- }
+ content_lifetime, manifest) {}
void run();
@@ -72,7 +69,7 @@ class AsyncConsumerProducer {
core::Prefix prefix_;
asio::io_service& io_service_;
asio::io_service internal_io_service_;
- bool external_io_service_;
+ bool external_io_service_ = false;
interface::ProducerSocket producer_socket_;
std::string ip_address_;
@@ -80,9 +77,8 @@ class AsyncConsumerProducer {
uint32_t cache_size_;
uint32_t mtu_;
- uint64_t request_counter_;
+ uint64_t request_counter_ = 0;
- // std::unordered_map<core::Name, std::shared_ptr<ATSConnector>>
// connection_map_;
HTTPSession connector_;
diff --git a/apps/http-proxy/includes/hicn/http-proxy/utils.h b/apps/http-proxy/includes/hicn/http-proxy/utils.h
index 0df24dfd9..9865d8e4c 100644
--- a/apps/http-proxy/includes/hicn/http-proxy/utils.h
+++ b/apps/http-proxy/includes/hicn/http-proxy/utils.h
@@ -35,7 +35,7 @@ TRANSPORT_ALWAYS_INLINE std::string generatePrefix(
str += pos;
uint32_t locator_hash = utils::hash::fnv32_buf(str, strlen(str));
- uint16_t* word = (uint16_t*)&locator_hash;
+ const uint16_t* word = (const uint16_t*)&locator_hash;
std::stringstream stream;
stream << first_ipv6_word << ":0";
@@ -47,4 +47,4 @@ TRANSPORT_ALWAYS_INLINE std::string generatePrefix(
stream << "::";
return stream.str();
-} \ No newline at end of file
+}