diff --git a/build b/build index ca7bf83..da2d398 100644 --- a/build +++ b/build @@ -1 +1 @@ -13 \ No newline at end of file +14 \ No newline at end of file diff --git a/src/RESTObjects/RESTAPI_GWobjects.cpp b/src/RESTObjects/RESTAPI_GWobjects.cpp index 7d42e74..505b779 100644 --- a/src/RESTObjects/RESTAPI_GWobjects.cpp +++ b/src/RESTObjects/RESTAPI_GWobjects.cpp @@ -171,6 +171,31 @@ namespace OpenWifi::GWObjects { field_to_json(Obj, "lastModified", LastModified); } + void DefaultFirmware::to_json(Poco::JSON::Object &Obj) const { + field_to_json(Obj, "deviceType", deviceType); + field_to_json(Obj, "description", Description); + field_to_json(Obj, "uri", uri); + field_to_json(Obj, "revision", revision); + field_to_json(Obj, "imageCreationDate", imageCreationDate); + field_to_json(Obj, "created", Created); + field_to_json(Obj, "lastModified", LastModified); + } + + bool DefaultFirmware::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "deviceType", deviceType); + field_from_json(Obj, "description", Description); + field_from_json(Obj, "uri", uri); + field_from_json(Obj, "revision", revision); + field_from_json(Obj, "imageCreationDate", imageCreationDate); + field_from_json(Obj, "created", Created); + field_from_json(Obj, "lastModified", LastModified); + return true; + } catch (const Poco::Exception &E) { + } + return false; + } + void CommandDetails::to_json(Poco::JSON::Object &Obj) const { EmbedDocument("details", Obj, Details); EmbedDocument("results", Obj, Results); @@ -246,6 +271,8 @@ namespace OpenWifi::GWObjects { field_to_json(Obj, "connectionCompletionTime", connectionCompletionTime); field_to_json(Obj, "totalConnectionTime", Utils::Now() - started); field_to_json(Obj, "certificateExpiryDate", certificateExpiryDate); + field_to_json(Obj, "connectReason", connectReason); + #ifdef TIP_GATEWAY_SERVICE hasRADIUSSessions = RADIUSSessionTracker()->HasSessions(SerialNumber); AP_WS_Server()->ExtendedAttributes(SerialNumber, hasGPS, sanity, @@ -403,6 +430,10 @@ namespace OpenWifi::GWObjects { field_to_json(Obj, "acctConfig", acctConfig); field_to_json(Obj, "coaConfig", coaConfig); field_to_json(Obj, "useByDefault", useByDefault); + field_to_json(Obj, "radsecKeepAlive", radsecKeepAlive); + field_to_json(Obj, "poolProxyIp", poolProxyIp); + field_to_json(Obj, "radsecPoolType", radsecPoolType); + field_to_json(Obj, "enabled", enabled); } bool RadiusProxyPool::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -413,6 +444,10 @@ namespace OpenWifi::GWObjects { field_from_json(Obj, "acctConfig", acctConfig); field_from_json(Obj, "coaConfig", coaConfig); field_from_json(Obj, "useByDefault", useByDefault); + field_from_json(Obj, "radsecKeepAlive", radsecKeepAlive); + field_from_json(Obj, "poolProxyIp", poolProxyIp); + field_from_json(Obj, "radsecPoolType", radsecPoolType); + field_from_json(Obj, "enabled", enabled); return true; } catch (const Poco::Exception &E) { } @@ -630,18 +665,50 @@ namespace OpenWifi::GWObjects { field_to_json(Obj, "chargeableUserIdentity", chargeableUserIdentity); field_to_json(Obj, "interface", interface); field_to_json(Obj, "secret", secret); + field_to_json(Obj, "nasId", nasId); + field_to_json(Obj, "calledStationId", calledStationId); } void RADIUSSessionList::to_json(Poco::JSON::Object &Obj) const { field_to_json(Obj, "sessions", sessions); } + void RadiusCoADMParameters::to_json(Poco::JSON::Object &Obj) const { + field_to_json(Obj, "accountingSessionId", accountingSessionId); + field_to_json(Obj, "accountingMultiSessionId", accountingMultiSessionId); + field_to_json(Obj, "callingStationId", callingStationId); + field_to_json(Obj, "chargeableUserIdentity", chargeableUserIdentity); + field_to_json(Obj, "userName", userName); + } + bool RadiusCoADMParameters::from_json(const Poco::JSON::Object::Ptr &Obj) { try { field_from_json(Obj, "accountingSessionId", accountingSessionId); field_from_json(Obj, "accountingMultiSessionId", accountingMultiSessionId); field_from_json(Obj, "callingStationId", callingStationId); field_from_json(Obj, "chargeableUserIdentity", chargeableUserIdentity); + field_from_json(Obj, "userName", userName); + return true; + } catch (const Poco::Exception &E) { + } + return false; + } + + bool DeviceTransferRequest::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "serialNumber", serialNumber); + field_from_json(Obj, "server", server); + field_from_json(Obj, "port", port); + return true; + } catch (const Poco::Exception &E) { + } + return false; + } + + bool DeviceCertificateUpdateRequest::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "serialNumber", serialNumber); + field_from_json(Obj, "encodedCertificate", encodedCertificate); return true; } catch (const Poco::Exception &E) { } diff --git a/src/RESTObjects/RESTAPI_GWobjects.h b/src/RESTObjects/RESTAPI_GWobjects.h index 7740db1..880e256 100644 --- a/src/RESTObjects/RESTAPI_GWobjects.h +++ b/src/RESTObjects/RESTAPI_GWobjects.h @@ -42,12 +42,13 @@ namespace OpenWifi::GWObjects { uint64_t sessionId = 0; double connectionCompletionTime = 0.0; std::uint64_t certificateExpiryDate = 0; - bool hasRADIUSSessions = false; + std::uint64_t hasRADIUSSessions = 0; bool hasGPS = false; std::uint64_t sanity=0; std::double_t memoryUsed=0.0; std::double_t load=0.0; std::double_t temperature=0.0; + std::string connectReason; void to_json(const std::string &SerialNumber, Poco::JSON::Object &Obj) ; }; @@ -181,6 +182,26 @@ namespace OpenWifi::GWObjects { bool from_json(const Poco::JSON::Object::Ptr &Obj); }; + struct DefaultFirmware { + std::string deviceType; + std::string Description; + std::string uri; + std::string revision; + uint64_t imageCreationDate; + uint64_t Created; + uint64_t LastModified; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct DefaultFirmwareList { + std::vector firmwares; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + struct CommandDetails { std::string UUID; std::string SerialNumber; @@ -339,6 +360,10 @@ namespace OpenWifi::GWObjects { RadiusProxyServerConfig acctConfig; RadiusProxyServerConfig coaConfig; bool useByDefault = false; + std::string radsecPoolType; + std::string poolProxyIp; + std::uint64_t radsecKeepAlive=25; + bool enabled=true; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -393,7 +418,8 @@ namespace OpenWifi::GWObjects { callingStationId, chargeableUserIdentity, secret, - interface; + interface, + nasId; std::uint64_t inputPackets = 0, outputPackets = 0, inputOctets = 0, @@ -401,6 +427,7 @@ namespace OpenWifi::GWObjects { inputGigaWords = 0, outputGigaWords = 0; std::uint32_t sessionTime = 0; + std::string calledStationId; #ifdef TIP_GATEWAY_SERVICE RADIUS::RadiusPacket accountingPacket; @@ -418,7 +445,68 @@ namespace OpenWifi::GWObjects { std::string accountingSessionId, accountingMultiSessionId, callingStationId, - chargeableUserIdentity; + chargeableUserIdentity, + userName; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + void to_json(Poco::JSON::Object &Obj) const; + }; + + enum class RadiusPoolStrategy { + round_robin, random, weighted, unknown + }; + + enum class RadiusEndpointType { + generic, radsec, globalreach, orion, unknown + }; + + static inline RadiusEndpointType RadiusEndpointType(const std::string &T) { + if(T=="generic") return RadiusEndpointType::generic; + if(T=="radsec") return RadiusEndpointType::radsec; + if(T=="globalreach") return RadiusEndpointType::globalreach; + if(T=="orion") return RadiusEndpointType::orion; + return RadiusEndpointType::unknown; + } + + static inline RadiusPoolStrategy RadiusPoolStrategy(const std::string &T) { + if(T=="round_robin") return RadiusPoolStrategy::round_robin; + if(T=="random") return RadiusPoolStrategy::random; + if(T=="weighted") return RadiusPoolStrategy::weighted; + return RadiusPoolStrategy::unknown; + } + + static inline std::string to_string(enum RadiusEndpointType T) { + switch(T) { + case RadiusEndpointType::generic: return "generic"; + case RadiusEndpointType::radsec: return "radsec"; + case RadiusEndpointType::globalreach: return "globalreach"; + case RadiusEndpointType::orion: return "orion"; + default: + return "unknown"; + } + } + + static inline std::string to_string(enum RadiusPoolStrategy T) { + switch(T) { + case RadiusPoolStrategy::round_robin: return "round_robin"; + case RadiusPoolStrategy::random: return "random"; + case RadiusPoolStrategy::weighted: return "weighted"; + default: + return "unknown"; + } + } + + struct DeviceTransferRequest { + std::string serialNumber; + std::string server; + std::uint64_t port; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct DeviceCertificateUpdateRequest { + std::string serialNumber; + std::string encodedCertificate; bool from_json(const Poco::JSON::Object::Ptr &Obj); }; diff --git a/src/RESTObjects/RESTAPI_ProvObjects.cpp b/src/RESTObjects/RESTAPI_ProvObjects.cpp index 533d0f4..2a139f5 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.cpp +++ b/src/RESTObjects/RESTAPI_ProvObjects.cpp @@ -1194,4 +1194,243 @@ namespace OpenWifi::ProvObjects { return false; } + void GLBLRAccountInfo::to_json(Poco::JSON::Object &Obj) const { + info.to_json(Obj); + field_to_json(Obj, "privateKey", privateKey); + field_to_json(Obj, "country", country); + field_to_json(Obj, "province", province); + field_to_json(Obj, "city", city); + field_to_json(Obj, "organization", organization); + field_to_json(Obj, "commonName", commonName); + field_to_json(Obj, "CSR", CSR); + field_to_json(Obj, "CSRPrivateKey", CSRPrivateKey); + field_to_json(Obj, "CSRPublicKey", CSRPublicKey); + field_to_json(Obj, "GlobalReachAcctId", GlobalReachAcctId); + } + + bool GLBLRAccountInfo::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + info.from_json(Obj); + field_from_json(Obj, "privateKey", privateKey); + field_from_json(Obj, "country", country); + field_from_json(Obj, "province", province); + field_from_json(Obj, "city", city); + field_from_json(Obj, "organization", organization); + field_from_json(Obj, "commonName", commonName); + field_from_json(Obj, "CSR", CSR); + field_from_json(Obj, "CSRPrivateKey", CSRPrivateKey); + field_from_json(Obj, "CSRPublicKey", CSRPublicKey); + field_from_json(Obj, "GlobalReachAcctId", GlobalReachAcctId); + return true; + } catch (const Poco::Exception &E) { + + } + return false; + } + + void GLBLRCertificateInfo::to_json(Poco::JSON::Object &Obj) const { + field_to_json(Obj, "id", id); + field_to_json(Obj, "name", name); + field_to_json(Obj, "accountId", accountId); + field_to_json(Obj, "csr", csr); + field_to_json(Obj, "certificate", certificate); + field_to_json(Obj, "certificateChain", certificateChain); + field_to_json(Obj, "certificateId", certificateId); + field_to_json(Obj, "expiresAt", expiresAt); + field_to_json(Obj, "created", created); + } + + bool GLBLRCertificateInfo::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "id", id); + field_from_json(Obj, "name", name); + field_from_json(Obj, "accountId", accountId); + field_from_json(Obj, "csr", csr); + field_from_json(Obj, "certificate", certificate); + field_from_json(Obj, "certificateChain", certificateChain); + field_from_json(Obj, "certificateId", certificateId); + field_from_json(Obj, "expiresAt", expiresAt); + field_from_json(Obj, "created", created); + return true; + } catch (const Poco::Exception &E) { + + } + return false; + } + + void GooglOrionAccountInfo::to_json(Poco::JSON::Object &Obj) const { + info.to_json(Obj); + field_to_json(Obj, "privateKey", privateKey); + field_to_json(Obj, "certificate", certificate); + field_to_json(Obj, "cacerts", cacerts); + } + + bool GooglOrionAccountInfo::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + info.from_json(Obj); + field_from_json(Obj, "privateKey", privateKey); + field_from_json(Obj, "certificate", certificate); + field_from_json(Obj, "cacerts", cacerts); + return true; + } catch (const Poco::Exception &E) { + + } + return false; + } + + void RADIUSServer::to_json(Poco::JSON::Object &Obj) const { + field_to_json(Obj, "Hostname", Hostname); + field_to_json(Obj, "IP", IP); + field_to_json(Obj, "Port", Port); + field_to_json(Obj, "Secret", Secret); + } + + bool RADIUSServer::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "Hostname", Hostname); + field_from_json(Obj, "IP", IP); + field_from_json(Obj, "Port", Port); + field_from_json(Obj, "Secret", Secret); + return true; + } catch (const Poco::Exception &E) { + + } + return false; + } + + void RADIUSEndPointRadiusType::to_json(Poco::JSON::Object &Obj) const { + field_to_json(Obj, "Authentication", Authentication); + field_to_json(Obj, "Accounting", Accounting); + field_to_json(Obj, "CoA", CoA); + field_to_json(Obj, "AccountingInterval", AccountingInterval); + } + + bool RADIUSEndPointRadiusType::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "Authentication", Authentication); + field_from_json(Obj, "Accounting", Accounting); + field_from_json(Obj, "CoA", CoA); + field_from_json(Obj, "AccountingInterval", AccountingInterval); + return true; + } catch (const Poco::Exception &E) { + + } + return false; + } + + void RADIUSEndPointRadsecType::to_json(Poco::JSON::Object &Obj) const { + field_to_json(Obj, "Hostname", Hostname); + field_to_json(Obj, "IP", IP); + field_to_json(Obj, "Port", Port); + field_to_json(Obj, "Secret", Secret); + field_to_json(Obj, "OpenRoamingType", OpenRoamingType); + field_to_json(Obj, "UseOpenRoamingAccount", UseOpenRoamingAccount); + field_to_json(Obj, "Weight", Weight); + field_to_json(Obj, "Certificate", Certificate); + field_to_json(Obj, "PrivateKey", PrivateKey); + field_to_json(Obj, "CaCerts", CaCerts); + field_to_json(Obj, "AllowSelfSigned", AllowSelfSigned); + } + + bool RADIUSEndPointRadsecType::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "Hostname", Hostname); + field_from_json(Obj, "IP", IP); + field_from_json(Obj, "Port", Port); + field_from_json(Obj, "Secret", Secret); + field_from_json(Obj, "OpenRoamingType", OpenRoamingType); + field_from_json(Obj, "UseOpenRoamingAccount", UseOpenRoamingAccount); + field_from_json(Obj, "Weight", Weight); + field_from_json(Obj, "Certificate", Certificate); + field_from_json(Obj, "PrivateKey", PrivateKey); + field_from_json(Obj, "CaCerts", CaCerts); + field_from_json(Obj, "AllowSelfSigned", AllowSelfSigned); + return true; + } catch (const Poco::Exception &E) { + + } + return false; + } + + void RADIUSEndPoint::to_json(Poco::JSON::Object &Obj) const { + info.to_json(Obj); + field_to_json(Obj, "Type", Type); + field_to_json(Obj, "RadsecServers", RadsecServers); + field_to_json(Obj, "RadiusServers", RadiusServers); + field_to_json(Obj, "PoolStrategy", PoolStrategy); + field_to_json(Obj, "Index", Index); + field_to_json(Obj, "UsedBy", UsedBy); + field_to_json(Obj, "UseGWProxy", UseGWProxy); + field_to_json(Obj, "NasIdentifier", NasIdentifier); + field_to_json(Obj, "AccountingInterval", AccountingInterval); + } + + bool RADIUSEndPoint::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + info.from_json(Obj); + field_from_json(Obj, "Type", Type); + field_from_json(Obj, "RadsecServers", RadsecServers); + field_from_json(Obj, "RadiusServers", RadiusServers); + field_from_json(Obj, "PoolStrategy", PoolStrategy); + field_from_json(Obj, "Index", Index); + field_from_json(Obj, "UsedBy", UsedBy); + field_from_json(Obj, "UseGWProxy", UseGWProxy); + field_from_json(Obj, "NasIdentifier", NasIdentifier); + field_from_json(Obj, "AccountingInterval", AccountingInterval); + return true; + } catch (const Poco::Exception &E) { + + } + return false; + } + + void RADIUSEndpointUpdateStatus::to_json(Poco::JSON::Object &Obj) const { + field_to_json(Obj, "lastUpdate", lastUpdate); + field_to_json(Obj, "lastConfigurationChange", lastConfigurationChange); + } + + bool RADIUSEndpointUpdateStatus::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "lastUpdate", lastUpdate); + field_from_json(Obj, "lastConfigurationChange", lastConfigurationChange); + return true; + } catch (const Poco::Exception &E) { + + } + return false; + } + + bool RADIUSEndpointUpdateStatus::Read() { + Poco::File F(OpenWifi::MicroServiceDataDirectory()+"/RADIUSEndpointUpdateStatus.json"); + try { + if (F.exists()) { + Poco::JSON::Parser P; + std::ifstream ifs(F.path(), std::ios_base::in | std::ios_base::binary); + auto Obj = P.parse(ifs); + return from_json(Obj.extract()); + } + } catch (...) { + } + return false; + } + + bool RADIUSEndpointUpdateStatus::Save() { + Poco::File F(OpenWifi::MicroServiceDataDirectory()+"/RADIUSEndpointUpdateStatus.json"); + try { + Poco::JSON::Object Obj; + to_json(Obj); + std::ofstream O(F.path(), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary); + Poco::JSON::Stringifier::stringify(Obj, O); + return true; + } catch (...) { + } + return false; + } + + bool RADIUSEndpointUpdateStatus::ChangeConfiguration() { + Read(); + lastConfigurationChange = Utils::Now(); + return Save(); + } + } // namespace OpenWifi::ProvObjects diff --git a/src/RESTObjects/RESTAPI_ProvObjects.h b/src/RESTObjects/RESTAPI_ProvObjects.h index 9f4edf3..6014d61 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.h +++ b/src/RESTObjects/RESTAPI_ProvObjects.h @@ -12,738 +12,906 @@ namespace OpenWifi::ProvObjects { - enum FIRMWARE_UPGRADE_RULES { - dont_upgrade, - upgrade_inherit, - upgrade_release_only, - upgrade_latest - }; - - struct ObjectInfo { - Types::UUID_t id; - std::string name; - std::string description; - SecurityObjects::NoteInfoVec notes; - uint64_t created = 0; - uint64_t modified = 0; - Types::TagList tags; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct SerialNumberList { - Types::UUIDvec_t serialNumbers; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ManagementPolicyEntry { - Types::UUIDvec_t users; - Types::UUIDvec_t resources; - Types::StringVec access; - std::string policy; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ManagementPolicy { - ObjectInfo info; - std::vector entries; - Types::StringVec inUse; - Types::UUID_t entity; - Types::UUID_t venue; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector ManagementPolicyVec; - - struct RRMAlgorithmDetails { - std::string name; - std::string parameters; - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct RRMDetails { - std::string vendor; - std::string schedule; - std::vector algorithms; - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct DeviceRules { - std::string rcOnly{"inherit"}; - std::string rrm{"inherit"}; - std::string firmwareUpgrade{"inherit"}; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct Entity { - ObjectInfo info; - Types::UUID_t parent; - Types::UUIDvec_t children; - Types::UUIDvec_t venues; - Types::UUIDvec_t contacts; // all contacts associated in this entity - Types::UUIDvec_t locations; // all locations associated in this entity - Types::UUID_t managementPolicy; - Types::UUIDvec_t deviceConfiguration; - Types::UUIDvec_t devices; - DeviceRules deviceRules; - Types::StringVec sourceIP; - Types::UUIDvec_t variables; - Types::UUIDvec_t managementPolicies; - Types::UUIDvec_t managementRoles; - Types::UUIDvec_t maps; - Types::UUIDvec_t configurations; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector EntityVec; - - struct DiGraphEntry { - Types::UUID_t parent; - Types::UUID_t child; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - typedef std::vector DiGraph; - - struct Venue { - ObjectInfo info; - Types::UUID_t entity; - Types::UUID_t parent; - Types::UUIDvec_t children; - Types::UUID_t managementPolicy; - Types::UUIDvec_t devices; - DiGraph topology; - std::string design; - Types::UUIDvec_t deviceConfiguration; - Types::UUIDvec_t contacts; - std::string location; - DeviceRules deviceRules; - Types::StringVec sourceIP; - Types::UUIDvec_t variables; - Types::UUIDvec_t configurations; - Types::UUIDvec_t maps; - Types::UUIDvec_t managementPolicies; - Types::UUIDvec_t managementRoles; - Types::UUIDvec_t boards; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector VenueVec; - - struct UserInfoDigest { - std::string id; - std::string loginId; - std::string userType; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ManagementRole { - ObjectInfo info; - Types::UUID_t managementPolicy; - Types::UUIDvec_t users; - Types::StringVec inUse; - Types::UUID_t entity; - Types::UUID_t venue; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector ManagementRoleVec; - - enum LocationType { - LT_SERVICE, - LT_EQUIPMENT, - LT_AUTO, - LT_MANUAL, - LT_SPECIAL, - LT_UNKNOWN, - LT_CORPORATE - }; - - inline std::string to_string(LocationType L) { - switch (L) { - case LT_SERVICE: - return "SERVICE"; - case LT_EQUIPMENT: - return "EQUIPMENT"; - case LT_AUTO: - return "AUTO"; - case LT_MANUAL: - return "MANUAL"; - case LT_SPECIAL: - return "SPECIAL"; - case LT_UNKNOWN: - return "UNKNOWN"; - case LT_CORPORATE: - return "CORPORATE"; - default: - return "UNKNOWN"; - } - } - - inline LocationType location_from_string(const std::string &S) { - if (!Poco::icompare(S, "SERVICE")) - return LT_SERVICE; - else if (!Poco::icompare(S, "EQUIPMENT")) - return LT_EQUIPMENT; - else if (!Poco::icompare(S, "AUTO")) - return LT_AUTO; - else if (!Poco::icompare(S, "MANUAL")) - return LT_MANUAL; - else if (!Poco::icompare(S, "SPECIAL")) - return LT_SPECIAL; - else if (!Poco::icompare(S, "UNKNOWN")) - return LT_UNKNOWN; - else if (!Poco::icompare(S, "CORPORATE")) - return LT_CORPORATE; - return LT_UNKNOWN; - } - - struct Location { - ObjectInfo info; - LocationType type; - std::string buildingName; - Types::StringVec addressLines; - std::string city; - std::string state; - std::string postal; - std::string country; - Types::StringVec phones; - Types::StringVec mobiles; - std::string geoCode; - Types::StringVec inUse; - Types::UUID_t entity; - Types::UUID_t managementPolicy; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector LocationVec; - - struct OperatorLocation { - ObjectInfo info; - std::string type; - std::string buildingName; - Types::StringVec addressLines; - std::string city; - std::string state; - std::string postal; - std::string country; - Types::StringVec phones; - Types::StringVec mobiles; - std::string geoCode; - Types::UUID_t operatorId; - Types::UUID_t subscriberDeviceId; - Types::UUID_t managementPolicy; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector LocationVec; - - struct SubLocation { - std::string type; - std::string buildingName; - Types::StringVec addressLines; - std::string city; - std::string state; - std::string postal; - std::string country; - Types::StringVec phones; - Types::StringVec mobiles; - std::string geoCode; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct OperatorLocationList { - std::vector locations; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - enum ContactType { - CT_SUBSCRIBER, - CT_USER, - CT_INSTALLER, - CT_CSR, - CT_MANAGER, - CT_BUSINESSOWNER, - CT_TECHNICIAN, - CT_CORPORATE, - CT_UNKNOWN - }; - - inline std::string to_string(ContactType L) { - switch (L) { - case CT_SUBSCRIBER: - return "SUBSCRIBER"; - case CT_USER: - return "USER"; - case CT_INSTALLER: - return "INSTALLER"; - case CT_CSR: - return "CSR"; - case CT_MANAGER: - return "MANAGER"; - case CT_BUSINESSOWNER: - return "BUSINESSOWNER"; - case CT_TECHNICIAN: - return "TECHNICIAN"; - case CT_CORPORATE: - return "CORPORATE"; - case CT_UNKNOWN: - return "UNKNOWN"; - default: - return "UNKNOWN"; - } - } - - inline ContactType contact_from_string(const std::string &S) { - if (!Poco::icompare(S, "SUBSCRIBER")) - return CT_SUBSCRIBER; - else if (!Poco::icompare(S, "USER")) - return CT_USER; - else if (!Poco::icompare(S, "INSTALLER")) - return CT_INSTALLER; - else if (!Poco::icompare(S, "CSR")) - return CT_CSR; - else if (!Poco::icompare(S, "BUSINESSOWNER")) - return CT_BUSINESSOWNER; - else if (!Poco::icompare(S, "TECHNICIAN")) - return CT_TECHNICIAN; - else if (!Poco::icompare(S, "CORPORATE")) - return CT_CORPORATE; - else if (!Poco::icompare(S, "UNKNOWN")) - return CT_UNKNOWN; - return CT_UNKNOWN; - } - - struct Contact { - ObjectInfo info; - ContactType type = CT_USER; - std::string title; - std::string salutation; - std::string firstname; - std::string lastname; - std::string initials; - std::string visual; - Types::StringVec mobiles; - Types::StringVec phones; - std::string primaryEmail; - std::string secondaryEmail; - std::string accessPIN; - Types::StringVec inUse; - Types::UUID_t entity; - Types::UUID_t managementPolicy; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector ContactVec; - - struct OperatorContact { - ObjectInfo info; - std::string type; - std::string title; - std::string salutation; - std::string firstname; - std::string lastname; - std::string initials; - std::string visual; - Types::StringVec mobiles; - Types::StringVec phones; - std::string primaryEmail; - std::string secondaryEmail; - std::string accessPIN; - Types::UUID_t operatorId; - Types::UUID_t subscriberDeviceId; - Types::UUID_t managementPolicy; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct SubContact { - std::string type; - std::string title; - std::string salutation; - std::string firstname; - std::string lastname; - std::string initials; - std::string visual; - Types::StringVec mobiles; - Types::StringVec phones; - std::string primaryEmail; - std::string secondaryEmail; - std::string accessPIN; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct OperatorContactList { - std::vector contacts; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - typedef std::vector OperatorContactVec; - - struct DeviceConfigurationElement { - std::string name; - std::string description; - uint64_t weight; - std::string configuration; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector DeviceConfigurationElementVec; - - struct DeviceConfiguration { - ObjectInfo info; - Types::UUID_t managementPolicy; - Types::StringVec deviceTypes; - DeviceConfigurationElementVec configuration; - Types::StringVec inUse; - Types::UUIDvec_t variables; - DeviceRules deviceRules; - bool subscriberOnly = false; - std::string venue; - std::string entity; - std::string subscriber; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - typedef std::vector DeviceConfigurationVec; - - struct InventoryTag { - ObjectInfo info; - std::string serialNumber; - std::string venue; - std::string entity; - std::string subscriber; - std::string deviceType; - std::string qrCode; - std::string geoCode; - std::string location; - std::string contact; - std::string deviceConfiguration; - DeviceRules deviceRules; - Types::UUID_t managementPolicy; - std::string state; - std::string devClass; - std::string locale; - std::string realMacAddress; - bool doNotAllowOverrides = false; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - typedef std::vector InventoryTagVec; - - struct InventoryTagList { - InventoryTagVec taglist; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct InventoryConfigApplyResult { - std::string appliedConfiguration; - Types::StringVec errors; - Types::StringVec warnings; - uint64_t errorCode; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct Report { - uint64_t snapShot = 0; - Types::CountedMap tenants; - - void reset(); - void to_json(Poco::JSON::Object &Obj) const; - }; - - struct ExpandedUseEntry { - std::string uuid; - std::string name; - std::string description; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ExpandedUseEntryList { - std::string type; - std::vector entries; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ExpandedUseEntryMapList { - std::vector entries; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct UuidList { - Types::UUIDvec_t list; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - enum ACLACCESS { NONE = 0, READ = 1, MODIFY = 2, CREATE = 3, DELETE = 4 }; - - struct ObjectACL { - UuidList users; - UuidList roles; - uint64_t access = (uint64_t)NONE; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ObjectACLList { - std::vector list; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct Map { - ObjectInfo info; - std::string data; - std::string entity; - std::string creator; - std::string visibility{"private"}; - ObjectACLList access; - Types::UUID_t managementPolicy; - std::string venue; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct MapList { - std::vector list; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - enum SignupStatusCodes { - SignupCreated = 0, - SignupWaitingForEmail, - SignupWaitingForDevice, - SignupSuccess, - SignupFailure, - SignupCanceled, - SignupTimedOut - }; - - struct SignupEntry { - ObjectInfo info; - std::string email; - std::string userId; - std::string macAddress; - std::string serialNumber; - uint64_t submitted = 0; - uint64_t completed = 0; - std::string status; - uint64_t error = 0; - uint64_t statusCode = 0; - std::string deviceID; - std::string registrationId; - std::string operatorId; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct Variable { - std::string type; - uint64_t weight = 0; - std::string prefix; - std::string value; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct VariableList { - std::vector variables; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct VariableBlock { - ObjectInfo info; - std::vector variables; - std::string entity; - std::string venue; - std::string subscriber; - std::string inventory; - Types::UUIDvec_t configurations; - Types::UUID_t managementPolicy; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct VariableBlockList { - std::vector variableBlocks; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct Operator { - ObjectInfo info; - Types::UUID_t managementPolicy; - Types::UUIDvec_t managementRoles; - DeviceRules deviceRules; - std::vector variables; - bool defaultOperator = false; - Types::StringVec sourceIP; - std::string registrationId; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct OperatorList { - std::vector operators; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct VenueDeviceList { - std::string id; - std::string name; - std::string description; - Types::UUIDvec_t devices; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ServiceClass { - ObjectInfo info; - Types::UUID_t operatorId; - Types::UUID_t managementPolicy; - double cost = 0.0; - std::string currency; - std::string period; - std::string billingCode; - std::vector variables; - bool defaultService = false; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ServiceClassList { - std::vector serviceClasses; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ConfigurationDetails { - DeviceConfigurationElementVec configuration; - std::string rrm{"inherit"}; - std::string firmwareUpgrade{"inherit"}; - std::string firmwareRCOnly{"inherit"}; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct SubscriberDevice { - ObjectInfo info; - std::string serialNumber; - std::string deviceType; - Types::UUID_t operatorId; - Types::UUID_t subscriberId; - SubLocation location; - SubContact contact; - Types::UUID_t managementPolicy; - Types::UUID_t serviceClass; - std::string qrCode; - std::string geoCode; - DeviceRules deviceRules; - std::string state; - std::string locale; - std::string billingCode; - DeviceConfigurationElementVec configuration; - bool suspended = false; - std::string realMacAddress; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct SubscriberDeviceList { - std::vector subscriberDevices; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ConfigurationOverride { - std::string source; - std::string reason; - std::string parameterName; - std::string parameterType; - std::string parameterValue; - std::uint64_t modified; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - struct ConfigurationOverrideList { - std::string serialNumber; - Types::UUID_t managementPolicy; - std::vector overrides; - - void to_json(Poco::JSON::Object &Obj) const; - bool from_json(const Poco::JSON::Object::Ptr &Obj); - }; - - bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, - ObjectInfo &I); - bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, - ObjectInfo &I); - bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I); + enum FIRMWARE_UPGRADE_RULES { + dont_upgrade, + upgrade_inherit, + upgrade_release_only, + upgrade_latest + }; + + struct ObjectInfo { + Types::UUID_t id; + std::string name; + std::string description; + SecurityObjects::NoteInfoVec notes; + uint64_t created = 0; + uint64_t modified = 0; + Types::TagList tags; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct SerialNumberList { + Types::UUIDvec_t serialNumbers; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ManagementPolicyEntry { + Types::UUIDvec_t users; + Types::UUIDvec_t resources; + Types::StringVec access; + std::string policy; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ManagementPolicy { + ObjectInfo info; + std::vector entries; + Types::StringVec inUse; + Types::UUID_t entity; + Types::UUID_t venue; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector ManagementPolicyVec; + + struct RRMAlgorithmDetails { + std::string name; + std::string parameters; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct RRMDetails { + std::string vendor; + std::string schedule; + std::vector algorithms; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct DeviceRules { + std::string rcOnly{"inherit"}; + std::string rrm{"inherit"}; + std::string firmwareUpgrade{"inherit"}; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct Entity { + ObjectInfo info; + Types::UUID_t parent; + Types::UUIDvec_t children; + Types::UUIDvec_t venues; + Types::UUIDvec_t contacts; // all contacts associated in this entity + Types::UUIDvec_t locations; // all locations associated in this entity + Types::UUID_t managementPolicy; + Types::UUIDvec_t deviceConfiguration; + Types::UUIDvec_t devices; + DeviceRules deviceRules; + Types::StringVec sourceIP; + Types::UUIDvec_t variables; + Types::UUIDvec_t managementPolicies; + Types::UUIDvec_t managementRoles; + Types::UUIDvec_t maps; + Types::UUIDvec_t configurations; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector EntityVec; + + struct DiGraphEntry { + Types::UUID_t parent; + Types::UUID_t child; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector DiGraph; + + struct Venue { + ObjectInfo info; + Types::UUID_t entity; + Types::UUID_t parent; + Types::UUIDvec_t children; + Types::UUID_t managementPolicy; + Types::UUIDvec_t devices; + DiGraph topology; + std::string design; + Types::UUIDvec_t deviceConfiguration; + Types::UUIDvec_t contacts; + std::string location; + DeviceRules deviceRules; + Types::StringVec sourceIP; + Types::UUIDvec_t variables; + Types::UUIDvec_t configurations; + Types::UUIDvec_t maps; + Types::UUIDvec_t managementPolicies; + Types::UUIDvec_t managementRoles; + Types::UUIDvec_t boards; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector VenueVec; + + struct UserInfoDigest { + std::string id; + std::string loginId; + std::string userType; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ManagementRole { + ObjectInfo info; + Types::UUID_t managementPolicy; + Types::UUIDvec_t users; + Types::StringVec inUse; + Types::UUID_t entity; + Types::UUID_t venue; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector ManagementRoleVec; + + enum LocationType { + LT_SERVICE, + LT_EQUIPMENT, + LT_AUTO, + LT_MANUAL, + LT_SPECIAL, + LT_UNKNOWN, + LT_CORPORATE + }; + + inline std::string to_string(LocationType L) { + switch (L) { + case LT_SERVICE: + return "SERVICE"; + case LT_EQUIPMENT: + return "EQUIPMENT"; + case LT_AUTO: + return "AUTO"; + case LT_MANUAL: + return "MANUAL"; + case LT_SPECIAL: + return "SPECIAL"; + case LT_UNKNOWN: + return "UNKNOWN"; + case LT_CORPORATE: + return "CORPORATE"; + default: + return "UNKNOWN"; + } + } + + inline LocationType location_from_string(const std::string &S) { + if (!Poco::icompare(S, "SERVICE")) + return LT_SERVICE; + else if (!Poco::icompare(S, "EQUIPMENT")) + return LT_EQUIPMENT; + else if (!Poco::icompare(S, "AUTO")) + return LT_AUTO; + else if (!Poco::icompare(S, "MANUAL")) + return LT_MANUAL; + else if (!Poco::icompare(S, "SPECIAL")) + return LT_SPECIAL; + else if (!Poco::icompare(S, "UNKNOWN")) + return LT_UNKNOWN; + else if (!Poco::icompare(S, "CORPORATE")) + return LT_CORPORATE; + return LT_UNKNOWN; + } + + struct Location { + ObjectInfo info; + LocationType type; + std::string buildingName; + Types::StringVec addressLines; + std::string city; + std::string state; + std::string postal; + std::string country; + Types::StringVec phones; + Types::StringVec mobiles; + std::string geoCode; + Types::StringVec inUse; + Types::UUID_t entity; + Types::UUID_t managementPolicy; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector LocationVec; + + struct OperatorLocation { + ObjectInfo info; + std::string type; + std::string buildingName; + Types::StringVec addressLines; + std::string city; + std::string state; + std::string postal; + std::string country; + Types::StringVec phones; + Types::StringVec mobiles; + std::string geoCode; + Types::UUID_t operatorId; + Types::UUID_t subscriberDeviceId; + Types::UUID_t managementPolicy; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector LocationVec; + + struct SubLocation { + std::string type; + std::string buildingName; + Types::StringVec addressLines; + std::string city; + std::string state; + std::string postal; + std::string country; + Types::StringVec phones; + Types::StringVec mobiles; + std::string geoCode; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct OperatorLocationList { + std::vector locations; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + enum ContactType { + CT_SUBSCRIBER, + CT_USER, + CT_INSTALLER, + CT_CSR, + CT_MANAGER, + CT_BUSINESSOWNER, + CT_TECHNICIAN, + CT_CORPORATE, + CT_UNKNOWN + }; + + inline std::string to_string(ContactType L) { + switch (L) { + case CT_SUBSCRIBER: + return "SUBSCRIBER"; + case CT_USER: + return "USER"; + case CT_INSTALLER: + return "INSTALLER"; + case CT_CSR: + return "CSR"; + case CT_MANAGER: + return "MANAGER"; + case CT_BUSINESSOWNER: + return "BUSINESSOWNER"; + case CT_TECHNICIAN: + return "TECHNICIAN"; + case CT_CORPORATE: + return "CORPORATE"; + case CT_UNKNOWN: + return "UNKNOWN"; + default: + return "UNKNOWN"; + } + } + + inline ContactType contact_from_string(const std::string &S) { + if (!Poco::icompare(S, "SUBSCRIBER")) + return CT_SUBSCRIBER; + else if (!Poco::icompare(S, "USER")) + return CT_USER; + else if (!Poco::icompare(S, "INSTALLER")) + return CT_INSTALLER; + else if (!Poco::icompare(S, "CSR")) + return CT_CSR; + else if (!Poco::icompare(S, "BUSINESSOWNER")) + return CT_BUSINESSOWNER; + else if (!Poco::icompare(S, "TECHNICIAN")) + return CT_TECHNICIAN; + else if (!Poco::icompare(S, "CORPORATE")) + return CT_CORPORATE; + else if (!Poco::icompare(S, "UNKNOWN")) + return CT_UNKNOWN; + return CT_UNKNOWN; + } + + struct Contact { + ObjectInfo info; + ContactType type = CT_USER; + std::string title; + std::string salutation; + std::string firstname; + std::string lastname; + std::string initials; + std::string visual; + Types::StringVec mobiles; + Types::StringVec phones; + std::string primaryEmail; + std::string secondaryEmail; + std::string accessPIN; + Types::StringVec inUse; + Types::UUID_t entity; + Types::UUID_t managementPolicy; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector ContactVec; + + struct OperatorContact { + ObjectInfo info; + std::string type; + std::string title; + std::string salutation; + std::string firstname; + std::string lastname; + std::string initials; + std::string visual; + Types::StringVec mobiles; + Types::StringVec phones; + std::string primaryEmail; + std::string secondaryEmail; + std::string accessPIN; + Types::UUID_t operatorId; + Types::UUID_t subscriberDeviceId; + Types::UUID_t managementPolicy; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct SubContact { + std::string type; + std::string title; + std::string salutation; + std::string firstname; + std::string lastname; + std::string initials; + std::string visual; + Types::StringVec mobiles; + Types::StringVec phones; + std::string primaryEmail; + std::string secondaryEmail; + std::string accessPIN; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct OperatorContactList { + std::vector contacts; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector OperatorContactVec; + + struct DeviceConfigurationElement { + std::string name; + std::string description; + uint64_t weight; + std::string configuration; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector DeviceConfigurationElementVec; + + struct DeviceConfiguration { + ObjectInfo info; + Types::UUID_t managementPolicy; + Types::StringVec deviceTypes; + DeviceConfigurationElementVec configuration; + Types::StringVec inUse; + Types::UUIDvec_t variables; + DeviceRules deviceRules; + bool subscriberOnly = false; + std::string venue; + std::string entity; + std::string subscriber; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector DeviceConfigurationVec; + + struct InventoryTag { + ObjectInfo info; + std::string serialNumber; + std::string venue; + std::string entity; + std::string subscriber; + std::string deviceType; + std::string qrCode; + std::string geoCode; + std::string location; + std::string contact; + std::string deviceConfiguration; + DeviceRules deviceRules; + Types::UUID_t managementPolicy; + std::string state; + std::string devClass; + std::string locale; + std::string realMacAddress; + bool doNotAllowOverrides = false; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + typedef std::vector InventoryTagVec; + + struct InventoryTagList { + InventoryTagVec taglist; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct InventoryConfigApplyResult { + std::string appliedConfiguration; + Types::StringVec errors; + Types::StringVec warnings; + uint64_t errorCode; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct Report { + uint64_t snapShot = 0; + Types::CountedMap tenants; + + void reset(); + + void to_json(Poco::JSON::Object &Obj) const; + }; + + struct ExpandedUseEntry { + std::string uuid; + std::string name; + std::string description; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ExpandedUseEntryList { + std::string type; + std::vector entries; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ExpandedUseEntryMapList { + std::vector entries; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct UuidList { + Types::UUIDvec_t list; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + enum ACLACCESS { + NONE = 0, READ = 1, MODIFY = 2, CREATE = 3, DELETE = 4 + }; + + struct ObjectACL { + UuidList users; + UuidList roles; + uint64_t access = (uint64_t) NONE; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ObjectACLList { + std::vector list; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct Map { + ObjectInfo info; + std::string data; + std::string entity; + std::string creator; + std::string visibility{"private"}; + ObjectACLList access; + Types::UUID_t managementPolicy; + std::string venue; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct MapList { + std::vector list; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + enum SignupStatusCodes { + SignupCreated = 0, + SignupWaitingForEmail, + SignupWaitingForDevice, + SignupSuccess, + SignupFailure, + SignupCanceled, + SignupTimedOut + }; + + struct SignupEntry { + ObjectInfo info; + std::string email; + std::string userId; + std::string macAddress; + std::string serialNumber; + uint64_t submitted = 0; + uint64_t completed = 0; + std::string status; + uint64_t error = 0; + uint64_t statusCode = 0; + std::string deviceID; + std::string registrationId; + std::string operatorId; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct Variable { + std::string type; + uint64_t weight = 0; + std::string prefix; + std::string value; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct VariableList { + std::vector variables; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct VariableBlock { + ObjectInfo info; + std::vector variables; + std::string entity; + std::string venue; + std::string subscriber; + std::string inventory; + Types::UUIDvec_t configurations; + Types::UUID_t managementPolicy; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct VariableBlockList { + std::vector variableBlocks; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct Operator { + ObjectInfo info; + Types::UUID_t managementPolicy; + Types::UUIDvec_t managementRoles; + DeviceRules deviceRules; + std::vector variables; + bool defaultOperator = false; + Types::StringVec sourceIP; + std::string registrationId; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct OperatorList { + std::vector operators; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct VenueDeviceList { + std::string id; + std::string name; + std::string description; + Types::UUIDvec_t devices; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ServiceClass { + ObjectInfo info; + Types::UUID_t operatorId; + Types::UUID_t managementPolicy; + double cost = 0.0; + std::string currency; + std::string period; + std::string billingCode; + std::vector variables; + bool defaultService = false; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ServiceClassList { + std::vector serviceClasses; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ConfigurationDetails { + DeviceConfigurationElementVec configuration; + std::string rrm{"inherit"}; + std::string firmwareUpgrade{"inherit"}; + std::string firmwareRCOnly{"inherit"}; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct SubscriberDevice { + ObjectInfo info; + std::string serialNumber; + std::string deviceType; + Types::UUID_t operatorId; + Types::UUID_t subscriberId; + SubLocation location; + SubContact contact; + Types::UUID_t managementPolicy; + Types::UUID_t serviceClass; + std::string qrCode; + std::string geoCode; + DeviceRules deviceRules; + std::string state; + std::string locale; + std::string billingCode; + DeviceConfigurationElementVec configuration; + bool suspended = false; + std::string realMacAddress; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct SubscriberDeviceList { + std::vector subscriberDevices; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ConfigurationOverride { + std::string source; + std::string reason; + std::string parameterName; + std::string parameterType; + std::string parameterValue; + std::uint64_t modified; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct ConfigurationOverrideList { + std::string serialNumber; + Types::UUID_t managementPolicy; + std::vector overrides; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, + ObjectInfo &I); + + bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, + ObjectInfo &I); + + bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I); + + struct GLBLRAccountInfo { + ObjectInfo info; + std::string privateKey; + std::string country, province, city, organization, commonName; + std::string CSR, CSRPrivateKey, CSRPublicKey; + std::string GlobalReachAcctId; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct GLBLRCertificateInfo { + std::string id; + std::string name; + std::string accountId; + std::string csr; + std::string certificate; + std::string certificateChain; + std::string certificateId; + std::uint64_t expiresAt = 0; + std::uint64_t created = 0; + + void to_json(Poco::JSON::Object &Obj) const; + + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct GooglOrionAccountInfo { + ObjectInfo info; + std::string privateKey; + std::string certificate; + std::vector cacerts; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct RADIUSServer { + std::string Hostname; + std::string IP; + std::uint64_t Port=0; + std::string Secret; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct RADIUSEndPointRadiusType { + std::vector Authentication; + std::vector Accounting; + std::vector CoA; + std::uint64_t AccountingInterval = 60; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct RADIUSEndPointRadsecType { + std::string Hostname; + std::string IP; + std::uint64_t Port=2083; + std::string Secret{"radsec"}; + std::string OpenRoamingType; + std::string UseOpenRoamingAccount; + std::uint64_t Weight=0; + std::string Certificate; + std::string PrivateKey; + std::vector CaCerts; + bool AllowSelfSigned=false; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct RADIUSEndPoint { + ObjectInfo info; + std::string Type{"radius"}; + std::string PoolStrategy{"none"}; + bool UseGWProxy=true; + std::string Index; + std::vector UsedBy; + std::vector RadiusServers; + std::vector RadsecServers; + std::string NasIdentifier; + std::uint64_t AccountingInterval=600; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; + + struct RADIUSEndpointUpdateStatus { + std::uint64_t lastUpdate=0; + std::uint64_t lastConfigurationChange=0; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + bool Read(); + bool Save(); + bool ChangeConfiguration(); + }; + + }; // namespace OpenWifi::ProvObjects diff --git a/src/framework/ow_constants.h b/src/framework/ow_constants.h index 33f8819..ed4e246 100644 --- a/src/framework/ow_constants.h +++ b/src/framework/ow_constants.h @@ -431,6 +431,8 @@ namespace OpenWifi::RESTAPI::Errors { static const struct msg InvalidRadsecSecret { 1190, "Invalid Radsec Secret." }; static const struct msg InvalidRadiusServer { 1191, "Invalid Radius Server." }; + static const struct msg InvalidRRMAction { 1192, "Invalid RRM Action." }; + static const struct msg SimulationDoesNotExist { 7000, "Simulation Instance ID does not exist." }; @@ -561,6 +563,10 @@ namespace OpenWifi::RESTAPI::Protocol { static const char *CONTENTDISPOSITION = "Content-Disposition"; static const char *CONTENTTYPE = "Content-Type"; + static const char *TRANSFER = "transfer"; + static const char *CERTUPDATE = "certupdate"; + static const char *RRM = "rrm"; + static const char *REQUIREMENTS = "requirements"; static const char *PASSWORDPATTERN = "passwordPattern"; static const char *ACCESSPOLICY = "accessPolicy"; @@ -678,6 +684,12 @@ namespace OpenWifi::uCentralProtocol { static const char *RADIUSCOA = "coa"; static const char *RADIUSDST = "dst"; static const char *IES = "ies"; + + static const char *TRANSFER = "transfer"; + static const char *CERTUPDATE = "certupdate"; + static const char *RRM = "rrm"; + static const char *ACTIONS = "actions"; + } // namespace OpenWifi::uCentralProtocol namespace OpenWifi::uCentralProtocol::Events { @@ -770,6 +782,9 @@ namespace OpenWifi::APCommands { telemetry, ping, script, + rrm, + certupdate, + transfer, unknown }; @@ -782,7 +797,10 @@ namespace OpenWifi::APCommands { RESTAPI::Protocol::LEDS, RESTAPI::Protocol::TRACE, RESTAPI::Protocol::REQUEST, RESTAPI::Protocol::WIFISCAN, RESTAPI::Protocol::EVENTQUEUE, RESTAPI::Protocol::TELEMETRY, - RESTAPI::Protocol::PING, RESTAPI::Protocol::SCRIPT}; + RESTAPI::Protocol::PING, RESTAPI::Protocol::SCRIPT, + RESTAPI::Protocol::RRM, RESTAPI::Protocol::CERTUPDATE, + RESTAPI::Protocol::TRANSFER + }; inline const char *to_string(Commands Cmd) { return uCentralAPCommands[(uint8_t)Cmd]; }