mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralgw.git
synced 2025-10-29 09:52:27 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -211,7 +211,7 @@ add_executable( owgw
|
|||||||
src/RegulatoryInfo.cpp src/RegulatoryInfo.h
|
src/RegulatoryInfo.cpp src/RegulatoryInfo.h
|
||||||
src/RADIUSSessionTracker.cpp src/RADIUSSessionTracker.h
|
src/RADIUSSessionTracker.cpp src/RADIUSSessionTracker.h
|
||||||
src/libs/Scheduler.h src/libs/InterruptableSleep.h src/libs/ctpl_stl.h src/libs/Cron.h
|
src/libs/Scheduler.h src/libs/InterruptableSleep.h src/libs/ctpl_stl.h src/libs/Cron.h
|
||||||
src/GenericScheduler.cpp src/GenericScheduler.h src/framework/default_device_types.h src/AP_WS_Process_rebootLog.cpp)
|
src/GenericScheduler.cpp src/GenericScheduler.h src/framework/default_device_types.h src/AP_WS_Process_rebootLog.cpp src/AP_WS_ConfigAutoUpgrader.cpp src/AP_WS_ConfigAutoUpgrader.h)
|
||||||
|
|
||||||
if(NOT SMALL_BUILD)
|
if(NOT SMALL_BUILD)
|
||||||
|
|
||||||
|
|||||||
22213
issues/OWGW Logs.txt
Normal file
22213
issues/OWGW Logs.txt
Normal file
File diff suppressed because it is too large
Load Diff
2158
issues/OWLS Logs.rtf
Normal file
2158
issues/OWLS Logs.rtf
Normal file
File diff suppressed because it is too large
Load Diff
2154
issues/OWLS Logs.txt
Normal file
2154
issues/OWLS Logs.txt
Normal file
File diff suppressed because it is too large
Load Diff
59
src/AP_WS_ConfigAutoUpgrader.cpp
Normal file
59
src/AP_WS_ConfigAutoUpgrader.cpp
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2023-05-23.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "AP_WS_ConfigAutoUpgrader.h"
|
||||||
|
#include <framework/utils.h>
|
||||||
|
#include <RESTObjects/RESTAPI_GWobjects.h>
|
||||||
|
#include <StorageService.h>
|
||||||
|
|
||||||
|
namespace OpenWifi {
|
||||||
|
|
||||||
|
int AP_WS_ConfigAutoUpgrader::Start() {
|
||||||
|
poco_notice(Logger(), "Starting...");
|
||||||
|
QueueManager_.start(*this);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AP_WS_ConfigAutoUpgrader::Stop() {
|
||||||
|
poco_notice(Logger(), "Stopping...");
|
||||||
|
Running_ = false;
|
||||||
|
Queue_.wakeUpAll();
|
||||||
|
QueueManager_.join();
|
||||||
|
poco_notice(Logger(), "Stopped...");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AP_WS_ConfigAutoUpgrader::run() {
|
||||||
|
Utils::SetThreadName("auto:cfgmgr");
|
||||||
|
Running_ = true;
|
||||||
|
|
||||||
|
while (Running_) {
|
||||||
|
Poco::AutoPtr<Poco::Notification> NextMsg(Queue_.waitDequeueNotification());
|
||||||
|
try {
|
||||||
|
auto Entry = dynamic_cast<CheckConfiguration *>(NextMsg.get());
|
||||||
|
if (Entry != nullptr) {
|
||||||
|
GWObjects::Device DeviceInfo;
|
||||||
|
std::string SerialNumber = Utils::IntToSerialNumber(Entry->serial_);
|
||||||
|
if (StorageService()->GetDevice(SerialNumber, DeviceInfo)) {
|
||||||
|
if(DeviceInfo.pendingUUID!=0 && Entry->uuid_==DeviceInfo.pendingUUID) {
|
||||||
|
StorageService()->CompleteDeviceConfigurationChange(SerialNumber);
|
||||||
|
SetDeviceCacheEntry(Entry->serial_, Utils::Now(), Entry->uuid_, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(DeviceInfo.UUID==Entry->uuid_) {
|
||||||
|
SetDeviceCacheEntry(Entry->serial_, Utils::Now(), Entry->uuid_, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} catch (const Poco::Exception &E) {
|
||||||
|
Logger().log(E);
|
||||||
|
} catch (...) {
|
||||||
|
poco_warning(Logger(), "Exception occurred during run.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace OpenWifi
|
||||||
137
src/AP_WS_ConfigAutoUpgrader.h
Normal file
137
src/AP_WS_ConfigAutoUpgrader.h
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2023-05-23.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Poco/Notification.h"
|
||||||
|
#include "Poco/NotificationQueue.h"
|
||||||
|
#include "Poco/Timer.h"
|
||||||
|
|
||||||
|
#include <framework/SubSystemServer.h>
|
||||||
|
#include <framework/utils.h>
|
||||||
|
|
||||||
|
namespace OpenWifi {
|
||||||
|
|
||||||
|
class CheckConfiguration : public Poco::Notification {
|
||||||
|
public:
|
||||||
|
explicit CheckConfiguration(std::uint64_t s, std::uint64_t c) :
|
||||||
|
serial_(s), uuid_(c) {
|
||||||
|
}
|
||||||
|
std::uint64_t serial_;
|
||||||
|
std::uint64_t uuid_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ConfigurationCacheEntry {
|
||||||
|
std::uint64_t last_check_=0;
|
||||||
|
std::uint64_t current_config_=0;
|
||||||
|
std::uint64_t pending_config_=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AP_WS_ConfigAutoUpgrader : public SubSystemServer, Poco::Runnable {
|
||||||
|
public:
|
||||||
|
int Start() final;
|
||||||
|
void Stop() final;
|
||||||
|
void run() final;
|
||||||
|
|
||||||
|
static auto instance() {
|
||||||
|
static auto instance = new AP_WS_ConfigAutoUpgrader;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AddConfiguration(std::uint64_t serial, std::uint64_t config_uuid) {
|
||||||
|
std::lock_guard Guard(CacheMutex_);
|
||||||
|
auto hint = Cache_.find(serial);
|
||||||
|
if(hint==end(Cache_)) {
|
||||||
|
Cache_[serial] = { Utils::Now(),config_uuid , 0 };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(hint->second.pending_config_==0) {
|
||||||
|
hint->second.last_check_ = Utils::Now();
|
||||||
|
hint->second.current_config_ = config_uuid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AddConfiguration(std::uint64_t serial, std::uint64_t config_uuid, std::uint64_t pending_config_uuid) {
|
||||||
|
std::lock_guard Guard(CacheMutex_);
|
||||||
|
auto hint = Cache_.find(serial);
|
||||||
|
if(hint==end(Cache_)) {
|
||||||
|
Cache_[serial] = { Utils::Now(), config_uuid , pending_config_uuid };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(hint->second.pending_config_==0) {
|
||||||
|
hint->second.last_check_ = Utils::Now();
|
||||||
|
hint->second.current_config_ = config_uuid;
|
||||||
|
hint->second.pending_config_ = pending_config_uuid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline ConfigurationCacheEntry GetSerialInfo(std::uint64_t serial) const {
|
||||||
|
std::lock_guard Guard(CacheMutex_);
|
||||||
|
auto hint = Cache_.find(serial);
|
||||||
|
if(hint==end(Cache_)) {
|
||||||
|
return {0,0,0};
|
||||||
|
}
|
||||||
|
return hint->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool UpdateConfiguration(std::uint64_t serial, std::uint64_t config) {
|
||||||
|
|
||||||
|
if(serial==0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::lock_guard Guard(CacheMutex_);
|
||||||
|
auto hint = Cache_.find(serial);
|
||||||
|
if(hint!=end(Cache_)) {
|
||||||
|
|
||||||
|
if(hint->second.current_config_==config) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(config==hint->second.pending_config_) {
|
||||||
|
Queue_.enqueueNotification(new CheckConfiguration(serial,config));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(config!=hint->second.current_config_ && hint->second.pending_config_==0) {
|
||||||
|
Queue_.enqueueNotification(new CheckConfiguration(serial,config));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((Utils::Now()-hint->second.last_check_)<60*5) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hint->second.pending_config_!=0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetDeviceCacheEntry(std::uint64_t serial, std::uint64_t t, std::uint64_t uuid, std::uint64_t pending_uuid) {
|
||||||
|
std::lock_guard Guard(CacheMutex_);
|
||||||
|
Cache_[serial] = { t, uuid, pending_uuid };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Poco::NotificationQueue Queue_;
|
||||||
|
Poco::Thread QueueManager_;
|
||||||
|
std::atomic_bool Running_=false;
|
||||||
|
|
||||||
|
mutable std::mutex CacheMutex_;
|
||||||
|
std::map<std::uint64_t, ConfigurationCacheEntry> Cache_;
|
||||||
|
|
||||||
|
AP_WS_ConfigAutoUpgrader() noexcept
|
||||||
|
: SubSystemServer("AutoConfigUpgrade", "AUTO-CFG-MGR", "auto.config.updater") {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline auto AP_WS_ConfigAutoUpgrader() { return AP_WS_ConfigAutoUpgrader::instance(); }
|
||||||
|
|
||||||
|
} // namespace OpenWifi
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ namespace OpenWifi {
|
|||||||
GWObjects::Device DeviceInfo;
|
GWObjects::Device DeviceInfo;
|
||||||
auto DeviceExists = StorageService()->GetDevice(SerialNumber_, DeviceInfo);
|
auto DeviceExists = StorageService()->GetDevice(SerialNumber_, DeviceInfo);
|
||||||
if (Daemon()->AutoProvisioning() && !DeviceExists) {
|
if (Daemon()->AutoProvisioning() && !DeviceExists) {
|
||||||
StorageService()->CreateDefaultDevice(SerialNumber_, Caps, Firmware, PeerAddress_);
|
StorageService()->CreateDefaultDevice(SerialNumber_, Caps, Firmware, PeerAddress_, State_.VerifiedCertificate==GWObjects::SIMULATED );
|
||||||
} else if (!Daemon()->AutoProvisioning() && !DeviceExists) {
|
} else if (!Daemon()->AutoProvisioning() && !DeviceExists) {
|
||||||
SendKafkaDeviceNotProvisioned(SerialNumber_, Firmware, Compatible_, CId_);
|
SendKafkaDeviceNotProvisioned(SerialNumber_, Firmware, Compatible_, CId_);
|
||||||
poco_warning(Logger(),fmt::format("Device {} is a {} from {} and cannot be provisioned.",SerialNumber_,Compatible_, CId_));
|
poco_warning(Logger(),fmt::format("Device {} is a {} from {} and cannot be provisioned.",SerialNumber_,Compatible_, CId_));
|
||||||
|
|||||||
@@ -11,6 +11,10 @@
|
|||||||
#include "Poco/Util/Application.h"
|
#include "Poco/Util/Application.h"
|
||||||
#include "Poco/Util/Option.h"
|
#include "Poco/Util/Option.h"
|
||||||
|
|
||||||
|
#include <framework/ConfigurationValidator.h>
|
||||||
|
#include <framework/UI_WebSocketClientServer.h>
|
||||||
|
#include <framework/default_device_types.h>
|
||||||
|
|
||||||
#include "AP_WS_Server.h"
|
#include "AP_WS_Server.h"
|
||||||
#include "CommandManager.h"
|
#include "CommandManager.h"
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
@@ -29,10 +33,8 @@
|
|||||||
#include "GenericScheduler.h"
|
#include "GenericScheduler.h"
|
||||||
#include "UI_GW_WebSocketNotifications.h"
|
#include "UI_GW_WebSocketNotifications.h"
|
||||||
#include "VenueBroadcaster.h"
|
#include "VenueBroadcaster.h"
|
||||||
#include "framework/ConfigurationValidator.h"
|
#include "AP_WS_ConfigAutoUpgrader.h"
|
||||||
#include "framework/UI_WebSocketClientServer.h"
|
|
||||||
#include "rttys/RTTYS_server.h"
|
#include "rttys/RTTYS_server.h"
|
||||||
#include <framework/default_device_types.h>
|
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class Daemon *Daemon::instance() {
|
class Daemon *Daemon::instance() {
|
||||||
@@ -45,7 +47,8 @@ namespace OpenWifi {
|
|||||||
RTTYS_server(), RADIUS_proxy_server(), VenueBroadcaster(), ScriptManager(),
|
RTTYS_server(), RADIUS_proxy_server(), VenueBroadcaster(), ScriptManager(),
|
||||||
SignatureManager(), AP_WS_Server(),
|
SignatureManager(), AP_WS_Server(),
|
||||||
RegulatoryInfo(),
|
RegulatoryInfo(),
|
||||||
RADIUSSessionTracker()
|
RADIUSSessionTracker(),
|
||||||
|
AP_WS_ConfigAutoUpgrader()
|
||||||
});
|
});
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,8 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
bool CreateDevice(GWObjects::Device &);
|
bool CreateDevice(GWObjects::Device &);
|
||||||
bool CreateDefaultDevice(std::string &SerialNumber, const Config::Capabilities &Caps,
|
bool CreateDefaultDevice(std::string &SerialNumber, const Config::Capabilities &Caps,
|
||||||
std::string &Firmware, const Poco::Net::IPAddress &IPAddress);
|
std::string &Firmware, const Poco::Net::IPAddress &IPAddress,
|
||||||
|
bool simulated);
|
||||||
|
|
||||||
bool GetDevice(std::string &SerialNumber, GWObjects::Device &);
|
bool GetDevice(std::string &SerialNumber, GWObjects::Device &);
|
||||||
bool GetDevices(uint64_t From, uint64_t HowMany, std::vector<GWObjects::Device> &Devices,
|
bool GetDevices(uint64_t From, uint64_t HowMany, std::vector<GWObjects::Device> &Devices,
|
||||||
|
|||||||
@@ -451,7 +451,8 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
bool Storage::CreateDefaultDevice(std::string &SerialNumber, const Config::Capabilities &Caps,
|
bool Storage::CreateDefaultDevice(std::string &SerialNumber, const Config::Capabilities &Caps,
|
||||||
std::string &Firmware,
|
std::string &Firmware,
|
||||||
const Poco::Net::IPAddress &IPAddress) {
|
const Poco::Net::IPAddress &IPAddress,
|
||||||
|
bool simulated) {
|
||||||
|
|
||||||
GWObjects::Device D;
|
GWObjects::Device D;
|
||||||
poco_information(Logger(), fmt::format("AUTO-CREATION({})", SerialNumber));
|
poco_information(Logger(), fmt::format("AUTO-CREATION({})", SerialNumber));
|
||||||
@@ -494,6 +495,7 @@ namespace OpenWifi {
|
|||||||
D.MACAddress = Utils::SerialToMAC(SerialNumber);
|
D.MACAddress = Utils::SerialToMAC(SerialNumber);
|
||||||
D.Manufacturer = Caps.Model();
|
D.Manufacturer = Caps.Model();
|
||||||
D.Firmware = Firmware;
|
D.Firmware = Firmware;
|
||||||
|
D.simulated = simulated;
|
||||||
D.Notes = SecurityObjects::NoteInfoVec{
|
D.Notes = SecurityObjects::NoteInfoVec{
|
||||||
SecurityObjects::NoteInfo{(uint64_t)Utils::Now(), "", "Auto-provisioned."}};
|
SecurityObjects::NoteInfo{(uint64_t)Utils::Now(), "", "Auto-provisioned."}};
|
||||||
|
|
||||||
|
|||||||
@@ -183,6 +183,14 @@ deletesimdevices() {
|
|||||||
jq < ${result_file}
|
jq < ${result_file}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deletebulkdevices() {
|
||||||
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/devices?macPattern=$1" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Accept: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
||||||
|
jq < ${result_file}
|
||||||
|
}
|
||||||
|
|
||||||
listdevicesk() {
|
listdevicesk() {
|
||||||
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices" \
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
@@ -1174,6 +1182,7 @@ case "$1" in
|
|||||||
"radiussearch") login; radiussearch "$2"; logout;;
|
"radiussearch") login; radiussearch "$2"; logout;;
|
||||||
"radiussearchmac") login; radiussearchmac "$2"; logout;;
|
"radiussearchmac") login; radiussearchmac "$2"; logout;;
|
||||||
"deletesimdevices") login; deletesimdevices "$2"; logout;;
|
"deletesimdevices") login; deletesimdevices "$2"; logout;;
|
||||||
|
"deletebulkdevices") login; deletebulkdevices "$2"; logout;;
|
||||||
"testtoken") testtoken;;
|
"testtoken") testtoken;;
|
||||||
*) help ;;
|
*) help ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user