aboutsummaryrefslogtreecommitdiffstats
path: root/apps/http-proxy/includes/hicn/http-proxy/forwarder_config.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/http-proxy/includes/hicn/http-proxy/forwarder_config.h')
-rw-r--r--apps/http-proxy/includes/hicn/http-proxy/forwarder_config.h29
1 files changed, 14 insertions, 15 deletions
diff --git a/apps/http-proxy/includes/hicn/http-proxy/forwarder_config.h b/apps/http-proxy/includes/hicn/http-proxy/forwarder_config.h
index 19c96a9e3..14e0068ed 100644
--- a/apps/http-proxy/includes/hicn/http-proxy/forwarder_config.h
+++ b/apps/http-proxy/includes/hicn/http-proxy/forwarder_config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2022 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -15,9 +15,9 @@
#pragma once
+#include <hicn/apps/utils/logger.h>
#include <hicn/transport/portability/c_portability.h>
#include <hicn/transport/utils/branch_prediction.h>
-#include <hicn/transport/utils/log.h>
#include <hicn/transport/utils/string_utils.h>
#include <asio.hpp>
@@ -27,7 +27,6 @@
#include "forwarder_interface.h"
-
#define RETRY_INTERVAL 300
namespace transport {
@@ -61,14 +60,14 @@ class ForwarderConfig {
doTryToConnectToForwarder(std::make_error_code(std::errc(0)));
}
- void doTryToConnectToForwarder(std::error_code ec) {
+ void doTryToConnectToForwarder(const std::error_code& ec) {
if (!ec) {
// ec == 0 --> timer expired
int ret = forwarder_interface_.connectToForwarder();
if (ret < 0) {
// We were not able to connect to the local forwarder. Do not give up
// and retry.
- TRANSPORT_LOGE("Could not connect to local forwarder. Retrying.");
+ LoggerErr() << "Could not connect to local forwarder. Retrying.";
timer_.expires_from_now(std::chrono::milliseconds(RETRY_INTERVAL));
timer_.async_wait(std::bind(&ForwarderConfig::doTryToConnectToForwarder,
@@ -79,20 +78,20 @@ class ForwarderConfig {
doGetMainListener(std::make_error_code(std::errc(0)));
}
} else {
- TRANSPORT_LOGD("Timer for re-trying forwarder connection canceled.");
+ LoggerErr() << "Timer for re-trying forwarder connection canceled.";
}
}
- void doGetMainListener(std::error_code ec) {
+ void doGetMainListener(const std::error_code& ec) {
if (!ec) {
// ec == 0 --> timer expired
int ret = forwarder_interface_.getMainListenerPort();
if (ret <= 0) {
// Since without the main listener of the forwarder the proxy cannot
// work, we can stop the program here until we get the listener port.
- TRANSPORT_LOGE(
- "Could not retrieve main listener port from the forwarder. "
- "Retrying.");
+ LoggerErr()
+ << "Could not retrieve main listener port from the forwarder. "
+ "Retrying.";
timer_.expires_from_now(std::chrono::milliseconds(RETRY_INTERVAL));
timer_.async_wait(std::bind(&ForwarderConfig::doGetMainListener, this,
@@ -104,7 +103,7 @@ class ForwarderConfig {
listener_retrieved_callback_(std::make_error_code(std::errc(0)));
}
} else {
- TRANSPORT_LOGI("Timer for retrieving main hicn listener canceled.");
+ LoggerErr() << "Timer for retrieving main hicn listener canceled.";
}
}
@@ -112,7 +111,7 @@ class ForwarderConfig {
TRANSPORT_ALWAYS_INLINE bool parseHicnHeader(std::string& header,
Callback&& callback) {
std::stringstream ss(header);
- route_info_t* ret = new route_info_t();
+ RouteInfoPtr ret = std::make_shared<route_info_t>();
std::string port_string;
while (ss.good()) {
@@ -172,9 +171,9 @@ class ForwarderConfig {
ret->family = AF_INET;
std::string _prefix = ret->route_addr;
forwarder_interface_.createFaceAndRoute(
- RouteInfoPtr(ret), [callback = std::forward<Callback>(callback),
- configured_prefix = std::move(_prefix)](
- uint32_t route_id, bool result) {
+ std::move(ret), [callback = std::forward<Callback>(callback),
+ configured_prefix = std::move(_prefix)](
+ uint32_t route_id, bool result) {
callback(result, configured_prefix);
});