Fix compilation errors.

This commit is contained in:
Vibhav Pant
2023-08-27 14:06:50 +05:30
parent 24cd783755
commit f50abe1677
7 changed files with 42 additions and 27 deletions
@@ -1,5 +1,6 @@
#include <cassert>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <ctime>
@@ -17,7 +18,7 @@ namespace nearby {
static std::unique_ptr<linux::LogControl> global_log_control_;
static absl::once_flag log_control_init_;
static void init_log_control() {
static void init_log_control(std::nullptr_t) {
global_log_control_ =
std::make_unique<linux::LogControl>(linux::getDefaultBusConnection());
}
@@ -79,15 +80,16 @@ void LogControl::send(google::LogSeverity severity, const char *full_filename,
static inline google::LogSeverity
ConvertSeverity(api::LogMessage::Severity severity) {
switch (severity) {
case api::LogMessage::Severity::kVerbose:
case api::LogMessage::Severity::kInfo:
return google::GLOG_INFO;
case api::LogMessage::Severity::kWarning:
return google::GLOG_WARNING;
case api::LogMessage::Severity::kError:
return google::GLOG_ERROR;
case api::LogMessage::Severity::kFatal:
return google::GLOG_FATAL;
case api::LogMessage::Severity::kVerbose:
case api::LogMessage::Severity::kInfo:
default:
return google::GLOG_INFO;
}
}
@@ -45,19 +45,17 @@ public:
protected:
std::string LogLevel() override {
switch (severity_) {
case api::LogMessage::Severity::kVerbose:
return "debug";
break;
case api::LogMessage::Severity::kInfo:
return "info";
break;
case api::LogMessage::Severity::kWarning:
return "warning";
break;
case api::LogMessage::Severity::kError:
return "err";
case api::LogMessage::Severity::kFatal:
return "emerg";
case api::LogMessage::Severity::kVerbose:
default:
return "debug";
}
}
@@ -78,14 +76,15 @@ protected:
std::string LogTarget() override {
switch (log_target_) {
case kConsole:
return "console";
case kKernel:
return "kmsg";
case kJournal:
return "journal";
case kSyslog:
return "syslog";
case kConsole:
default:
return "console";
}
}
@@ -300,7 +300,7 @@ ImplementationPlatform::SendRequest(const WebRequest &request) {
if (request.method == "GET")
curl_easy_setopt(handle, CURLOPT_HTTPGET, 1L);
else if (request.method == "POST")
curl_easy_setopt(handle, CURLOPT_HTTPPOST, 1L);
curl_easy_setopt(handle, CURLOPT_POST, 1L);
else
curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, request.method.c_str());
@@ -72,7 +72,7 @@ NetworkManagerWifiHotspotMedium::ListenForService(int port) {
NEARBY_LOGS(ERROR)
<< __func__
<< "Could not find any IPv4 addresses for active connection "
<< active_connection->getObjectPath();
<< active_connection->getObjectPath();
return nullptr;
}
@@ -106,9 +106,9 @@ NetworkManagerWifiHotspotMedium::ListenForService(int port) {
<< std::strerror(errno);
return nullptr;
}
return std::make_unique<NetworkManagerWifiHotspotServerSocket>(sock,
system_bus_, active_connection->getObjectPath(), network_manager_);
return std::make_unique<NetworkManagerWifiHotspotServerSocket>(
sock, system_bus_, active_connection->getObjectPath(), network_manager_);
}
bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
@@ -126,7 +126,11 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
<< std::strerror(ret);
return false;
}
std::string ssid = absl::StrCat("DIRECT-", SD_ID128_TO_STRING(id));
char id_cstr[SD_ID128_STRING_MAX];
sd_id128_to_string(id, id_cstr);
std::string ssid = absl::StrCat("DIRECT-", id_cstr);
ssid.resize(32);
hotspot_credentials->SetSSID(ssid);
@@ -135,7 +139,9 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
<< std::strerror(ret);
return false;
}
std::string password = std::string(SD_ID128_TO_STRING(id), 15);
sd_id128_to_string(id, id_cstr);
std::string password = std::string(id_cstr, 15);
hotspot_credentials->SetPassword(password);
if (auto ret = sd_id128_randomize(&id); ret < 0) {
@@ -143,6 +149,7 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
<< std::strerror(ret);
return false;
}
sd_id128_to_string(id, id_cstr);
std::vector<uint8_t> ssid_bytes(ssid.begin(), ssid.end());
std::map<std::string, std::map<std::string, sdbus::Variant>>
@@ -150,7 +157,7 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
{
"connection",
std::map<std::string, sdbus::Variant>{
{"uuid", SD_ID128_TO_UUID_STRING(id)},
{"uuid", std::string(id_cstr)},
{"id", "Google Nearby Hotspot"},
{"type", "802-11-wireless"},
{"zone", "Public"}},
@@ -171,7 +178,7 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
},
{"proto", std::vector<std::string>{"rsn"}},
{"psk", password}}},
{"ipv4", std::map<std::string, sdbus::Variant>{"method", "shared"}},
{"ipv4", std::map<std::string, sdbus::Variant>{{"method", "shared"}}},
{"ipv6", std::map<std::string, sdbus::Variant>{
{"addr-gen-mode", static_cast<std::int32_t>(1)},
{"method", "shared"},
@@ -135,8 +135,10 @@ bool WifiLanMedium::StartDiscovery(
<< __func__
<< ": Created a new org.freedesktop.Avahi.ServiceBrowser object at "
<< browser_object_path;
service_browsers_.emplace(service_type, system_bus_, browser_object_path,
std::move(callback));
service_browsers_.emplace(
service_type,
std::make_unique<avahi::ServiceBrowser>(
system_bus_, browser_object_path, std::move(callback)));
} catch (const sdbus::Error &e) {
DBUS_LOG_METHOD_CALL_ERROR(avahi_, "ServiceBrowserPrepare", e);
return false;
@@ -330,12 +330,16 @@ NetworkManagerWifiMedium::ConnectToNetwork(absl::string_view ssid,
{
sd_id128_t id;
char id_cstr[SD_ID128_UUID_STRING_MAX];
if (auto ret = sd_id128_randomize(&id); ret < 0) {
NEARBY_LOGS(ERROR) << __func__
<< ": could not generation a connection UUID";
return api::WifiConnectionStatus::kUnknown;
}
connection_id = SD_ID128_TO_UUID_STRING(id);
sd_id128_to_uuid_string(id, id_cstr);
connection_id = std::string(id_cstr);
}
auto [auth_alg, key_mgmt] = AuthAlgAndKeyMgmt(auth_type);
@@ -346,7 +350,7 @@ NetworkManagerWifiMedium::ConnectToNetwork(absl::string_view ssid,
std::map<std::string, sdbus::Variant>{
{"uuid", connection_id},
{"autoconnect", true},
{"id", ssid},
{"id", std::string(ssid)},
{"type", "802-11-wireless"},
{"zone", "Public"},
}},
@@ -438,7 +442,7 @@ NetworkManagerWifiMedium::GetActiveConnection() {
auto object_manager = NetworkManagerObjectManager(getProxy().getConnection());
auto conn = object_manager.GetActiveConnectionForAccessPoint(active_ap_path,
getObjectPath());
if (conn == nullptr) {
NEARBY_LOGS(ERROR)
<< __func__
@@ -282,8 +282,9 @@ protected:
ABSL_LOCKS_EXCLUDED(known_access_points_lock_) {
absl::MutexLock l(&known_access_points_lock_);
known_access_points_.erase(access_point);
known_access_points_.emplace(access_point, getProxy().getConnection(),
access_point);
known_access_points_.emplace(access_point,
std::make_unique<NetworkManagerAccessPoint>(
getProxy().getConnection(), access_point));
}
void onAccessPointRemoved(const sdbus::ObjectPath &access_point) override
ABSL_LOCKS_EXCLUDED(known_access_points_lock_) {