| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973 | #include <iostream>#include "httppost.h"#include "cwmp.nsmap"#include "soapcwmpService.h"#include "plugin/threads.h"#include <vector>#include <algorithm>#include <signal.h>#include <thread>#include <fstream>#include "json.hpp"#include <mysql++/mysql++.h>#include <zdb.h>#define HOST "localhost"#define USER "acs"#define PASSWORD "159753"#define DATABASE "ACS"#define PORT 3306using json = nlohmann::json;int port = 7547;//int port = 8001;int POST_handler(struct soap *soap);struct http_post_handlers http_post_handlers[] = {        {"POST", POST_handler},        {NULL}};std::string currentISO8601TimeUTC() {    std::time_t t = std::time(nullptr);    std::ostringstream ss;    ss << std::put_time(std::localtime(&t), "%FT%T %Z");    return ss.str();}void handler(int s) {    printf("Sassan Caught SIGPIPE ...\n");}void *process_request(void *arg) {    cwmpService *service = (cwmpService *) arg;    THREAD_DETACH(THREAD_ID);    if (service) {        service->serve();        service->destroy(); /* clean up */        delete service;    }    return NULL;}//<editor-fold desc="zbx_keys">//TODO: Read keys from config file and remap them to zbx_keysstd::string zbx_keys[] = {"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.Uptime",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.UL_MCS",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.TX_Power",                          "InternetGatewayDevice.DeviceInfo.SoftwareVersion",                          "InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.SINR2",                          "InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.SINR1",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.RSRP2",                          "InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.RSRQ",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.RSRQ",                          "InternetGatewayDevice.LANDevice.1.LANHostConfigManagement.DHCPServerEnable",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Setting.Status",                          "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.RSRP1",                          "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress",                          "InternetGatewayDevice.WEB_GUI.Overview.DeviceInfo.IMSI",                          "InternetGatewayDevice.WEB_GUI.Overview.DeviceInfo.IMEI",                          "InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.EnodeBId",                          "InternetGatewayDevice.DeviceInfo.MemoryStatus.Free",                          "InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.EnodeBId",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.DL_MCS",                          "InternetGatewayDevice.Time.CurrentLocalTime",                          "InternetGatewayDevice.DeviceInfo.ProcessStatus.CPUUsage",                          "InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.CellId",                          "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Stats.BytesSent",                          "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Stats.BytesReceived",                          "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Stats.PacketsReceived",                          "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Stats.PacketsSent",                          "InternetGatewayDevice.DeviceInfo.UpTime",                          "InternetGatewayDevice.DeviceInfo.X_TGT_IMSI",                          "InternetGatewayDevice.WEB_GUI.Network.Network_Mode.WANIPAddress",                          "InternetGatewayDevice.WEB_GUI.Network.ScanMode.Settings.PCILock",                          "InternetGatewayDevice.WEB_GUI.Overview.LTEStatus.DnsServer",                          "InternetGatewayDevice.DeviceInfo.HardwareVersion",                          "InternetGatewayDevice.DeviceInfo.Manufacturer",                          "InternetGatewayDevice.DeviceInfo.ManufacturerOUI",                          "InternetGatewayDevice.DeviceInfo.ModelName",                          "InternetGatewayDevice.DeviceInfo.ModelNumber",                          "InternetGatewayDevice.DeviceInfo.Description",                          "InternetGatewayDevice.DeviceInfo.ProductClass",                          "InternetGatewayDevice.DeviceInfo.SerialNumber",                          "InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.1.Enable",                          "InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.2.Enable",                          "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Enable",                          "InternetGatewayDevice.WEB_GUI.Overview.LTEStatus.DL_DataRate_Current",                          "InternetGatewayDevice.WEB_GUI.Overview.LTEStatus.UL_DataRate_Current",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.PCI",                          "InternetGatewayDevice.WEB_GUI.Overview.LANStatus.MacAddress",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.DL_Frequency",                          "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.UL_Frequency",                          "InternetGatewayDevice.ManagementServer.ConnectionRequestURL",                          "InternetGatewayDevice.ManagementServer.PeriodicInformInterval",                          "InternetGatewayDevice.LANDevice.1.LANHostConfigManagement.IPInterface.1.IPInterfaceIPAddress",        //ESM                          "InternetGatewayDevice.DeviceInfo.SpecVersion",                          "InternetGatewayDevice.DeviceInfo.ProvisioningCode",//                          "InternetGatewayDevice.DeviceInfo.Manufacturer",                          "InternetGatewayDevice.DeviceInfo.ManufacturerOUI",                          "InternetGatewayDevice.DeviceInfo.ProductClass",                          "InternetGatewayDevice.DeviceInfo.SerialNumber",                          "InternetGatewayDevice.DeviceInfo.ModelName",                          "InternetGatewayDevice.DeviceInfo.RSRP0",                          "InternetGatewayDevice.DeviceInfo.RSRP1",                          "InternetGatewayDevice.DeviceInfo.CINR0",                          "InternetGatewayDevice.DeviceInfo.CINR1",                          "InternetGatewayDevice.DeviceInfo.RSRQ",                          "InternetGatewayDevice.DeviceInfo.TAC",                          "InternetGatewayDevice.DeviceInfo.PCID",                          "InternetGatewayDevice.DeviceInfo.EARFCN",                          "InternetGatewayDevice.DeviceInfo.PWR",                          "InternetGatewayDevice.DeviceInfo.IMEI",                          "InternetGatewayDevice.DeviceInfo.IMSI",                          "InternetGatewayDevice.DeviceInfo.IPV4",                          "InternetGatewayDevice.DeviceInfo.RSSI",                          "InternetGatewayDevice.DeviceInfo.ENODBID",                          "InternetGatewayDevice.DeviceInfo.CELLID",                          "InternetGatewayDevice.DeviceInfo.DLBAND",                          "InternetGatewayDevice.DeviceInfo.ULBAND",                          "InternetGatewayDevice.DeviceInfo.TXMODE",                          "InternetGatewayDevice.DeviceInfo.FREQUANCE",                          "InternetGatewayDevice.DeviceInfo.SINR0",                          "InternetGatewayDevice.DeviceInfo.SINR1",                          "InternetGatewayDevice.DeviceInfo.NOISE0",                          "InternetGatewayDevice.DeviceInfo.NOISE1",                          "InternetGatewayDevice.DeviceInfo.MODAL",                          "InternetGatewayDevice.DeviceInfo.CAR",                          "InternetGatewayDevice.DeviceInfo.BAND",                          "InternetGatewayDevice.DeviceInfo.PLMN",                          "InternetGatewayDevice.DeviceInfo.WANUPTIME",                          "InternetGatewayDevice.DeviceInfo.SYSUPTIME",                          "InternetGatewayDevice.DeviceInfo.BITRECIEVED",                          "InternetGatewayDevice.DeviceInfo.BITSENT",                          "InternetGatewayDevice.DeviceInfo.CPUUSAGE",                          "InternetGatewayDevice.DeviceInfo.MEMORYFREE",                          "InternetGatewayDevice.DeviceInfo.TXPOWER",                          "InternetGatewayDevice.DeviceInfo.PCILOCK",                          "InternetGatewayDevice.DeviceInfo.ULMCS",                          "InternetGatewayDevice.DeviceInfo.DLMCS",                          "InternetGatewayDevice.DeviceInfo.CURRENTTIME",                          "InternetGatewayDevice.DeviceInfo.HardwareVersion",                          "InternetGatewayDevice.DeviceInfo.SoftwareVersion",                          "InternetGatewayDevice.ManagementServer.ConnectionRequestURL",                          "InternetGatewayDevice.ManagementServer.ParameterKey",                          "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"};//</editor-fold>void ZBX_Send(char **Name, char **Value, char **imsi) {    if (!strcmp(*Name, "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.DL_MCS") == 0 or        !strcmp(*Name, "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.UL_MCS") == 0) {        if (!strcmp(*Value, "QPSK")) {            *Value = "4";        } else if (!strcmp(*Value, "QAM8")) {            *Value = "8";        } else if (!strcmp(*Value, "QAM16")) {            *Value = "16";        } else if (!strcmp(*Value, "QAM32")) {            *Value = "32";        } else if (!strcmp(*Value, "QAM64")) {            *Value = "64";        }        std::ofstream zbx_data;        std::string _time{};        time_t second;        second = time(NULL);        std::stringstream strstream;        strstream << second;        strstream >> _time;        zbx_data.open("/var/tmp/zbx_sender-" + _time, std::ios_base::app);        zbx_data << "IMSI-" << *imsi << " " << *Name << " " << second << " \"" << *Value << "\"" << std::endl;    }}std::string url_encode(const std::string &value) {    std::ostringstream escaped;    escaped.fill('0');    escaped << std::hex;    for (std::string::const_iterator i = value.begin(), n = value.end(); i != n; ++i) {        std::string::value_type c = (*i);        // Keep alphanumeric and other accepted characters intact        if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {            escaped << c;            continue;        }        // Any other characters are percent-encoded        escaped << std::uppercase;        escaped << '%' << std::setw(2) << int((unsigned char) c);        escaped << std::nouppercase;    }    return escaped.str();}int main() {    signal(SIGPIPE, handler);    std::cout << "TR069 Server Started on Port " << port << "(1.3)...\n" << std::endl;    cwmpService service(SOAP_XML_INDENT);    service.soap->send_timeout = service.soap->recv_timeout = 5;    service.soap->transfer_timeout = 60;    service.soap->keep_alive = 20;    service.soap->tcp_keep_alive = 1;    service.soap->bind_flags |= SO_REUSEADDR;    service.soap->bind_flags |= SO_REUSEPORT;    service.soap->bind_flags |= MSG_NOSIGNAL;    soap_init2(service.soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);    SOAP_SOCKET m = service.bind(NULL, port, 100);              /* master socket */    if (soap_valid_socket(m)) {        while (soap_valid_socket(service.accept())) {            THREAD_TYPE tid;            void *arg = (void *) service.copy();            if (arg)                while (THREAD_CREATE(&tid, (void *(*)(void *)) process_request, arg))                    sleep(1);        }    }    service.soap_stream_fault(std::cerr);    service.destroy(); /* clean up */    return 0;}int POST_handler(struct soap *soap) {    const char *buf;    size_t len;    buf = soap_http_get_body(soap, &len);    if (len == 0) {        std::cerr << "Sassan 204...: " << buf << std::endl;        return 204; // HTTP 400 Bad Request    }}int cwmpService::GetParameterNames(struct _cwmp__GetParameterNames *cwmp__GetParameterNames,                                   struct _cwmp__GetParameterNamesResponse *cwmp__GetParameterNamesResponse) { return SOAP_OK; }int cwmpService::GetParameterValues(struct _cwmp__GetParameterValues *cwmp__GetParameterValues,                                    struct _cwmp__GetParameterValuesResponse *cwmp__GetParameterValuesResponse) { return SOAP_OK; }int cwmpService::SetParameterValues(struct _cwmp__SetParameterValues *cwmp__SetParameterValues,                                    struct _cwmp__SetParameterValuesResponse *cwmp__SetParameterValuesResponse) {    return SOAP_OK;}int cwmpService::SetParameterAttributes(        struct _cwmp__SetParameterAttributes *cwmp__SetParameterAttributes,        struct _cwmp__SetParameterAttributesResponse *cwmp__SetParameterAttributesResponse) { return SOAP_OK; }int cwmpService::GetParameterAttributes(struct _cwmp__GetParameterAttributes *cwmp__GetParameterAttributes,                                        struct _cwmp__GetParameterAttributesResponse *cwmp__GetParameterAttributesResponse) { return SOAP_OK; }int cwmpService::Download(struct _cwmp__Download *cwmp__Download,                          struct _cwmp__DownloadResponse *cwmp__DownloadResponse) { return SOAP_OK; }int cwmpService::Upload(        struct _cwmp__Upload *cwmp__Upload,        struct _cwmp__UploadResponse *cwmp__UploadResponse) { return SOAP_OK; }int cwmpService::AddObject(        struct _cwmp__AddObject *cwmp__AddObject,        struct _cwmp__AddObjectResponse *cwmp__AddObjectResponse) { return SOAP_OK; }int cwmpService::DeleteObject(        struct _cwmp__DeleteObject *cwmp__DeleteObject,        struct _cwmp__DeleteObjectResponse *cwmp__DeleteObjectResponse) { return SOAP_OK; }int cwmpService::GetRPCMethods(        struct _cwmp__GetRPCMethods *cwmp__GetRPCMethods,        struct _cwmp__GetRPCMethodsResponse *cwmp__GetRPCMethodsResponse) { return SOAP_OK; }int cwmpService::GetParameterValuesResponse(        struct _cwmp__GetParameterValuesResponse *cwmp__GetParameterValuesResponse) { return SOAP_OK; }int cwmpService::Inform(struct _cwmp__Inform *cwmp__Inform, struct _cwmp__InformResponse *cwmp__InformResponse,                        struct soap *soap) {    std::string _id = std::string(cwmp__Inform->DeviceId->OUI) + "-" + std::string(cwmp__Inform->DeviceId->ProductClass)                      + "-" + std::string(cwmp__Inform->DeviceId->SerialNumber);    std::cerr << "Inform Recieved from: " << url_encode(_id) << " at " << time(NULL) << std::endl;    char *imsi;    char *ip;    auto timestamp = std::chrono::high_resolution_clock::now();    std::vector<std::thread> th;    std::vector<std::thread> th_acs;//    int indexes[24];    std::vector<int> ind;    std::ofstream outfile;    outfile.open("/var/tmp/tr069/" + url_encode(_id), std::ios::out | std::ios::trunc);    std::ofstream mongoData;    time_t second;    std::string _time;    std::map<std::string, std::string> tr069{};    second = time(NULL);    std::stringstream strstream;    strstream << second;    strstream >> _time;    ip = soap->host;    for (int i = 0; i < cwmp__Inform->ParameterList->__size; ++i) {        char *_Name = cwmp__Inform->ParameterList->__ptrParameterValueStruct[i]->Name;        char *_Value = cwmp__Inform->ParameterList->__ptrParameterValueStruct[i]->Value;        if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.X_TGT_IMSI") == 0 or            std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.IMSI") == 0) {            imsi = _Value;            break;        }    }    for (int i = 0; i < cwmp__Inform->ParameterList->__size; ++i) {        char *_Name = cwmp__Inform->ParameterList->__ptrParameterValueStruct[i]->Name;        char *_Value = cwmp__Inform->ParameterList->__ptrParameterValueStruct[i]->Value;        outfile << _Name << ": " << _Value << std::endl;//        if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.X_TGT_IMSI") == 0) {//            imsi = _Value;//        }//        if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.Network_Mode.WANIPAddress") == 0) {//            ip = _Value;//        }        std::string cpe = cwmp__Inform->DeviceId->SerialNumber;        auto j = std::find(std::begin(zbx_keys), std::end(zbx_keys), _Name);        if (j != std::end(zbx_keys)) {            if (                    !strcmp(_Name, "InternetGatewayDevice.DeviceInfo.MODAL") == 0 or                    !strcmp(_Name, "InternetGatewayDevice.DeviceInfo.ULMCS") == 0 or                    !strcmp(_Name, "InternetGatewayDevice.DeviceInfo.DLMCS") == 0 or                    !strcmp(_Name, "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.DL_MCS") == 0 or                    !strcmp(_Name, "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.UL_MCS") == 0) {                if (!strcmp(_Value, "QPSK")) {                    _Value = "4";                } else if (!strcmp(_Value, "QAM8")) {                    _Value = "8";                } else if (!strcmp(_Value, "QAM16")) {                    _Value = "16";                } else if (!strcmp(_Value, "QAM32")) {                    _Value = "32";                } else if (!strcmp(_Value, "QAM64")) {                    _Value = "64";                }                std::ofstream zbx_data;                std::string _time{};                time_t second;                second = time(NULL);                std::stringstream strstream;                strstream << second;                strstream >> _time;                zbx_data.open("/var/tmp/zbx_sender-" + _time, std::ios_base::app);                zbx_data << "IMSI-" << imsi << " " << _Name << " " << second << " \"" << _Value << "\"" << std::endl;            }//<editor-fold desc="Map Filler">            if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.HardwareVersion") == 0)                tr069.insert({"HardwareVersion", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.SoftwareVersion") == 0)                tr069.insert({"SoftwareVersion", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.UpTime") == 0)                tr069.insert({"UpTime", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Overview.DeviceInfo.IMEI") == 0)                tr069.insert({"IMEI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.X_TGT_IMSI") == 0)                tr069.insert({"IMSI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.MemoryStatus.Free") == 0)                tr069.insert({"Free", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ProcessStatus.CPUUsage") == 0)                tr069.insert({"CPUUsage", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.Time.CurrentLocalTime") == 0)                tr069.insert({"CurrentLocalTime", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.1.Enable") == 0)                tr069.insert({"LAN1Enable", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.2.Enable") == 0)                tr069.insert({"LAN2Enable", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.SINR1") == 0)                tr069.insert({"SINR1", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.SINR2") == 0)                tr069.insert({"SINR2", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.EnodeBId") ==                     0)                tr069.insert({"EnodeBId", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.CellId") == 0)                tr069.insert({"CellId", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Stats.BytesSent") == 0)                tr069.insert({"BytesSent", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Stats.BytesReceived") == 0)                tr069.insert({"BytesReceived", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Stats.PacketsSent") == 0)                tr069.insert({"PacketsSent", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Stats.PacketsReceived") == 0)                tr069.insert({"PacketsReceived", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus") == 0)                tr069.insert({"ConnectionStatus", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.Uptime") == 0)                tr069.insert({"Uptime", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress") == 0)                tr069.insert({"ExternalIPAddress", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.RSRP1") == 0)                tr069.insert({"RSRP1", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.RSRP2") == 0)                tr069.insert({"RSRP2", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.TX_Power") ==                     0)                tr069.insert({"TX_Power", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.DL_MCS") == 0)                tr069.insert({"DL_MCS", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.UL_MCS") == 0)                tr069.insert({"UL_MCS", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Setting.Status") ==                     0)                tr069.insert({"LTEStatus", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.ScanMode.Settings.PCILock") == 0)                tr069.insert({"PCILock", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.Network_Mode.WANIPAddress") == 0)                tr069.insert({"WANIPAddress", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval") == 0)                tr069.insert({"PeriodicInformInterval", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Overview.LTEStatus.DnsServer") == 0)                tr069.insert({"DnsServer", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Overview.DeviceInfo.IMSI") == 0)                tr069.insert({"IMSI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.Manufacturer") == 0)                tr069.insert({"Manufacturer", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ManufacturerOUI") == 0)                tr069.insert({"OUI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ModelName") == 0)                tr069.insert({"ModelName", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ModelNumber") == 0)                tr069.insert({"ModelNumber", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.Description") == 0)                tr069.insert({"Description", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ProductClass") == 0)                tr069.insert({"ProductClass", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.SerialNumber") == 0)                tr069.insert({"SerialNumber", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WANDevice.1.X_TGT_WANNetConfigInfo.RSRQ") == 0)                tr069.insert({"RSRQ", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.LANDevice.1.LANHostConfigManagement.DHCPServerEnable") == 0)                tr069.insert({"DHCPServerEnable", _Value});            else if (                    std::string(_Name).compare("InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.Enable") ==                    0)                tr069.insert({"WANEthernetInterfaceConfigEnable", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.ManagementServer.ConnectionRequestURL") == 0)                tr069.insert({"ConnectionRequestURL", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WEB_GUI.Overview.LTEStatus.DL_DataRate_Current") == 0)                tr069.insert({"DL_DataRate_Current", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WEB_GUI.Overview.LTEStatus.UL_DataRate_Current") == 0)                tr069.insert({"UL_DataRate_Current", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.PCI") == 0)                tr069.insert({"PCI", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.UL_Frequency") == 0)                tr069.insert({"UL_Frequency", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.WEB_GUI.Network.LTE_Setting.Status.DL_Frequency") == 0)                tr069.insert({"DL_Frequency", _Value});            else if (std::string(_Name).compare(                    "InternetGatewayDevice.LANDevice.1.LANHostConfigManagement.IPInterface.1.IPInterfaceIPAddress") ==                     0)                tr069.insert({"IPInterfaceIPAddress", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.WEB_GUI.Overview.LANStatus.MacAddress") == 0)                tr069.insert({"MacAddress", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ManufacturerOUI") == 0)                tr069.insert({"ManufacturerOUI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.SpecVersion") == 0)                tr069.insert({"SpecVersion", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ProvisioningCode") == 0)                tr069.insert({"ProvisioningCode", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.Manufacturer") == 0)                tr069.insert({"Manufacturer", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ManufacturerOUI") == 0)                tr069.insert({"ManufacturerOUI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ProductClass") == 0)                tr069.insert({"ProductClass", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.SerialNumber") == 0)                tr069.insert({"SerialNumber", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ModelName") == 0)                tr069.insert({"ModelName", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.RSRP0") == 0)                tr069.insert({"RSRP0", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.RSRP1") == 0)                tr069.insert({"RSRP1", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.CINR0") == 0)                tr069.insert({"CINR0", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.CINR1") == 0)                tr069.insert({"CINR1", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.RSRQ") == 0)                tr069.insert({"RSRQ", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.TAC") == 0)                tr069.insert({"TAC", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.PCID") == 0)                tr069.insert({"PCID", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.EARFCN") == 0)                tr069.insert({"EARFCN", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.PWR") == 0)                tr069.insert({"PWR", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.IMEI") == 0)                tr069.insert({"IMEI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.IMSI") == 0)                tr069.insert({"IMSI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.IPV4") == 0)                tr069.insert({"IPV4", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.RSSI") == 0)                tr069.insert({"RSSI", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ENODBID") == 0)                tr069.insert({"ENODBID", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.CELLID") == 0)                tr069.insert({"CELLID", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.DLBAND") == 0)                tr069.insert({"DLBAND", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ULBAND") == 0)                tr069.insert({"ULBAND", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.TXMODE") == 0)                tr069.insert({"TXMODE", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.FREQUANCE") == 0)                tr069.insert({"FREQUANCE", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.SINR0") == 0)                tr069.insert({"SINR0", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.SINR1") == 0)                tr069.insert({"SINR1", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.NOISE0") == 0)                tr069.insert({"NOISE0", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.NOISE1") == 0)                tr069.insert({"NOISE1", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.MODAL") == 0)                tr069.insert({"MODAL", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.CAR") == 0)                tr069.insert({"CAR", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.BAND") == 0)                tr069.insert({"BAND", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.PLMN") == 0)                tr069.insert({"PLMN", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.WANUPTIME") == 0)                tr069.insert({"WANUPTIME", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.SYSUPTIME") == 0)                tr069.insert({"SYSUPTIME", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.BITRECIEVED") == 0)                tr069.insert({"BITRECIEVED", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.BITSENT") == 0)                tr069.insert({"BITSENT", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.CPUUSAGE") == 0)                tr069.insert({"CPUUSAGE", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.MEMORYFREE") == 0)                tr069.insert({"MEMORYFREE", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.TXPOWER") == 0)                tr069.insert({"TXPOWER", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.PCILOCK") == 0)                tr069.insert({"PCILOCK", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ULMCS") == 0)                tr069.insert({"ULMCS", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.DLMCS") == 0)                tr069.insert({"DLMCS", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.CURRENTTIME") == 0)                tr069.insert({"CURRENTTIME", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.HardwareVersion") == 0)                tr069.insert({"HardwareVersion", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.SoftwareVersion") == 0)                tr069.insert({"SoftwareVersion", _Value});            else if (std::string(_Name).compare("InternetGatewayDevice.DeviceInfo.ConnectionRequestURL") == 0)                tr069.insert({"ConnectionRequestURL", _Value});//</editor-fold>        }    }    std::ofstream zbx_data;    zbx_data.open("/var/tmp/zbx_sender-" + _time, std::ios_base::app);    zbx_data << "IMSI-" << imsi << " " << "BytsReceived" << " " << second << " \"" << tr069["BytesReceived"] << "\""             << std::endl;    zbx_data << "IMSI-" << imsi << " " << "BytsSent" << " " << second << " \"" << tr069["BytesSent"] << "\""             << std::endl;//<editor-fold desc="Json">    std::string ISOTime = currentISO8601TimeUTC();    json tr069_json{};    tr069_json["_id"] = url_encode(_id);    tr069_json["_deviceId"]["_Manufacturer"] = cwmp__Inform->DeviceId->Manufacturer;    tr069_json["_deviceId"]["_OUI"] = cwmp__Inform->DeviceId->OUI;    tr069_json["_deviceId"]["_ProductClass"] = cwmp__Inform->DeviceId->ProductClass;    tr069_json["_deviceId"]["_SerialNumber"] = cwmp__Inform->DeviceId->SerialNumber;    tr069_json["_lastInform"] = ISOTime;    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANConnectionDevice"]["1"]["WANIPConnection"]["1"]["Uptime"]["_value"] = tr069["Uptime"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["UL_MCS"]["_value"] = tr069["UL_MCS"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["TX_Power"]["_value"] = tr069["TX_Power"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SoftwareVersion"]["_value"] = tr069["SoftwareVersion"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["SINR2"]["_value"] = tr069["SINR2"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["SINR1"]["_value"] = tr069["SINR1"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["RSRP2"]["_value"] = tr069["RSRP2"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["RSRQ"]["_value"] = tr069["RSRQ"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["RSRQ"]["_value"] = tr069["RSRQ"];    tr069_json["InternetGatewayDevice"]["LANDevice"]["1"]["LANHostConfigManagement"]["DHCPServerEnable"]["_value"] = tr069["DHCPServerEnable"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Setting"]["Status"]["_value"] = tr069["LTEStatus"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANConnectionDevice"]["1"]["WANIPConnection"]["1"]["ConnectionStatus"]["_value"] = tr069["ConnectionStatus"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["RSRP1"]["_value"] = tr069["RSRP1"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANConnectionDevice"]["1"]["WANIPConnection"]["1"]["ExternalIPAddress"]["_value"] = tr069["ExternalIPAddress"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["DeviceInfo"]["IMSI"]["_value"] = tr069["IMSI"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["DeviceInfo"]["IMEI"]["_value"] = tr069["IMEI"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["EnodeBId"]["_value"] = tr069["EnodeBId"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["MemoryStatus"]["Free"]["_value"] = tr069["Free"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["EnodeBId"]["_value"] = tr069["EnodeBId"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["DL_MCS"]["_value"] = tr069["DL_MCS"];    tr069_json["InternetGatewayDevice"]["Time"]["CurrentLocalTime"]["_value"] = tr069["CurrentLocalTime"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ProcessStatus"]["CPUUsage"]["_value"] = tr069["CPUUsage"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["CellId"]["_value"] = tr069["CellId"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANEthernetInterfaceConfig"]["Stats"]["BytesSent"]["_value"] = tr069["BytesSent"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANEthernetInterfaceConfig"]["Stats"]["BytesReceived"]["_value"] = tr069["BytesReceived"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANEthernetInterfaceConfig"]["Stats"]["PacketsReceived"]["_value"] = tr069["PacketsReceived"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANEthernetInterfaceConfig"]["Stats"]["PacketsSent"]["_value"] = tr069["PacketsSent"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["UpTime"]["_value"] = tr069["UpTime"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["X_TGT_IMSI"]["_value"] = tr069["IMSI"];    tr069_json["InternetGatewayDevice"]["LANDevice"]["1"]["LANEthernetInterfaceConfig"]["1"]["Enable"]["_value"] = tr069["Enable"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["Network_Mode"]["WANIPAddress"]["_value"] = tr069["WANIPAddress"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["ScanMode"]["Settings"]["PCILock"]["_value"] = tr069["PCILock"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["LTEStatus"]["DnsServer"]["_value"] = tr069["DnsServer"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["HardwareVersion"]["_value"] = tr069["HardwareVersion"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["Manufacturer"]["_value"] = cwmp__Inform->DeviceId->Manufacturer;    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ManufacturerOUI"]["_value"] = cwmp__Inform->DeviceId->OUI;    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ModelName"]["_value"] = tr069["ModelName"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ModelNumber"]["_value"] = tr069["ModelNumber"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["Description"]["_value"] = tr069["Description"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ProductClass"]["_value"] = cwmp__Inform->DeviceId->ProductClass;    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SerialNumber"]["_value"] = cwmp__Inform->DeviceId->SerialNumber;    tr069_json["InternetGatewayDevice"]["LANDevice"]["1"]["LANEthernetInterfaceConfig"]["1"]["Enable"]["_value"] = tr069["LAN1Enable"];    tr069_json["InternetGatewayDevice"]["LANDevice"]["1"]["LANEthernetInterfaceConfig"]["2"]["Enable"]["_value"] = tr069["LAN2Enable"];    tr069_json["InternetGatewayDevice"]["ManagementServer"]["ConnectionRequestURL"]["_value"] = tr069["ConnectionRequestURL"];    tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANEthernetInterfaceConfig"]["Enable"]["_value"] = tr069["WANEthernetInterfaceConfigEnable"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["LTEStatus"]["DL_DataRate_Current"]["_value"] = tr069["DL_DataRate_Current"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["LTEStatus"]["UL_DataRate_Current"]["_value"] = tr069["UL_DataRate_Current"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["PCI"]["_value"] = tr069["PCI"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["LANStatus"]["MacAddress"]["_value"] = tr069["MacAddress"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["DL_Frequency"]["_value"] = tr069["DL_Frequency"];    tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["UL_Frequency"]["_value"] = tr069["UL_Frequency"];    tr069_json["InternetGatewayDevice"]["LANDevice"]["1"]["IPInterface"]["1"]["IPInterfaceIPAddress"]["_value"] = tr069["IPInterfaceIPAddress"];    tr069_json["InternetGatewayDevice"]["ManagementServer"]["PeriodicInformInterval"]["_value"] = tr069["PeriodicInformInterval"];    //ESM    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ManufacturerOUI"]["_value"] = cwmp__Inform->DeviceId->OUI;//    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["Manufacturer"]["_value"] = tr069["Manufacturer"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["RSRP0"]["_value"] = tr069["RSRP0"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["RSRP1"]["_value"] = tr069["RSRP1"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["CINR0"]["_value"] = tr069["CINR0"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["CINR1"]["_value"] = tr069["CINR1"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["RSRQ"]["_value"] = tr069["RSRQ"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["TAC"]["_value"] = tr069["TAC"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["PCID"]["_value"] = tr069["PCID"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["EARFCN"]["_value"] = tr069["EARFCN"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["PWR"]["_value"] = tr069["PWR"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["IMEI"]["_value"] = tr069["IMEI"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["IMSI"]["_value"] = tr069["IMSI"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["IPV4"]["_value"] = tr069["IPV4"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["RSSI"]["_value"] = tr069["RSSI"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ENODBID"]["_value"] = tr069["ENODBID"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["CELLID"]["_value"] = tr069["CELLID"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["DLBAND"]["_value"] = tr069["DLBAND"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ULBAND"]["_value"] = tr069["ULBAND"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["TXMODE"]["_value"] = tr069["TXMODE"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["FREQUANCE"]["_value"] = tr069["FREQUANCE"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SINR0"]["_value"] = tr069["SINR0"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SINR1"]["_value"] = tr069["SINR1"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["NOISE0"]["_value"] = tr069["NOISE0"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["NOISE1"]["_value"] = tr069["NOISE1"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["MODAL"]["_value"] = tr069["MODAL"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["CAR"]["_value"] = tr069["CAR"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["BAND"]["_value"] = tr069["BAND"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["PLMN"]["_value"] = tr069["PLMN"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["WANUPTIME"]["_value"] = tr069["WANUPTIME"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SYSUPTIME"]["_value"] = tr069["SYSUPTIME"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["BITRECIEVED"]["_value"] = tr069["BITRECIEVED"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["BITSENT"]["_value"] = tr069["BITSENT"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["CPUUSAGE"]["_value"] = tr069["CPUUSAGE"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["MEMORYFREE"]["_value"] = tr069["MEMORYFREE"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["TXPOWER"]["_value"] = tr069["TXPOWER"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["PCILOCK"]["_value"] = tr069["PCILOCK"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ULMCS"]["_value"] = tr069["ULMCS"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["DLMCS"]["_value"] = tr069["DLMCS"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["CURRENTTIME"]["_value"] = tr069["CURRENTTIME"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["HardwareVersion"]["_value"] = tr069["HardwareVersion"];    tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SoftwareVersion"]["_value"] = tr069["SoftwareVersion"];//</editor-fold>    std::ofstream json_data;    second = time(NULL);    strstream << second;    strstream >> _time;    json_data.open("/var/tmp/json_data/json-" + _time, std::ios_base::app);//    json_data.open("/var/tmp/json_data/" + url_encode(_id) + "_" + _time, std::ios_base::app);    json_data << tr069_json.dump(4);    mysqlpp::Connection conn(false);    mysqlpp::Query query = conn.query();    try {        conn.connect(DATABASE, HOST, USER, PASSWORD, PORT);        if (cwmp__Inform->DeviceId->OUI == "D8D866") {            //<editor-fold desc="Mysql-Query">            query <<                  "replace into Device_List (IP,IMSI,`datetime`,update_interval,enodeb_id,cell_id,softwareversion,pcilock,description,IMEI,"                  "rsrp1,rsrp2,rsrq,sinr1,sinr2,U_mcs,d_mcs,txpower,dhcp,ethernet_status,uptime,hardwareversion,upload_rate,download_rate,"                  "DNS) values ('" +                  std::string(ip) + "','" + imsi + "',NOW()" + "," +                  tr069_json["InternetGatewayDevice"]["ManagementServer"]["PeriodicInformInterval"]["_value"].dump() +                  "," +                  tr069["EnodeBId"] + "," + tr069["CellId"] +                  ",'" + tr069["SoftwareVersion"] + "','" + tr069["PCILock"] + "'," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["Description"]["_value"].dump() + "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["DeviceInfo"]["IMEI"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["RSRP1"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["RSRP2"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["RSRQ"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["SINR1"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["X_TGT_WANNetConfigInfo"]["SINR2"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["DL_MCS"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["UL_MCS"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Network"]["LTE_Setting"]["Status"]["TX_Power"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["LANDevice"]["1"]["LANHostConfigManagement"]["DHCPServerEnable"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WANDevice"]["1"]["WANEthernetInterfaceConfig"]["Enable"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["UpTime"]["_value"].dump() + "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["HardwareVersion"]["_value"].dump() + "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["LTEStatus"]["UL_DataRate_Current"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["LTEStatus"]["DL_DataRate_Current"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["WEB_GUI"]["Overview"]["LTEStatus"]["DnsServer"]["_value"].dump() +                  ");";//</editor-fold>            //<editor-fold desc="Mysql-Query">        } else if (cwmp__Inform->DeviceId->OUI == "2020") {            query <<                  "replace into Device_List (IP,IMSI,`datetime`,update_interval,enodeb_id,cell_id,softwareversion,pcilock,description,IMEI,"                  "rsrp1,rsrp2,rsrq,sinr1,sinr2,U_mcs,d_mcs,txpower,dhcp,ethernet_status,uptime,hardwareversion,upload_rate,download_rate,"                  "DNS) values ('" +                  std::string(ip) + "','" + imsi + "',NOW()" + "," +                  "60" +                  "," +                  tr069["ENODBID"] + "," + tr069["CELLID"] +                  ",'" + tr069["SoftwareVersion"] + "','" + tr069["PCILOCK"] + "'," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["Manufacturer"]["_value"].dump() + "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["IMEI"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["RSRP0"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["RSRP1"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["RSRQ"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SINR0"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SINR0"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["ULMCS"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["DLMCS"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["TXPOWER"]["_value"].dump() +                  "," +                  "-" +                  "," +                  "-" +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["SYSUPTIME"]["_value"].dump() +                  "," +                  tr069_json["InternetGatewayDevice"]["DeviceInfo"]["HardwareVersion"]["_value"].dump() +                  "," +                  "-" +                  "," +                  "-" +                  "," +                  "-" +                  ");";//</editor-fold>        }//        std::cout << "Query: " << imsi << " :" << query << std::endl;        query.execute();    } catch (mysqlpp::BadQuery er) { // handle any connection or        std::cerr << "Error on IMSI-" << imsi << " :" << er.what() << std::endl;    }    conn.disconnect();    return SOAP_OK;}int cwmpService::FactoryReset(struct _cwmp__FactoryReset *cwmp__factoryReset,                              struct _cwmp__FactoryResetResponse *cwmp__factoryResetResponse) { return SOAP_OK; }int cwmpService::Reboot(struct _cwmp__Reboot *cwmp__Reboot,                        struct _cwmp__RebootResponse *cwmp__RebootResponse) { return SOAP_OK; }int cwmpService::CheckQueue(struct soap *soap, cwmpService *cwmpService1) {//    std::cerr << "IP: " << soap->host << std::endl;    soap->error = 0;    std::string IMSI{}, s, id;    const char *_actionParameters = "";    int action{0};    /*     * {   "FileType":"1",   "URL":"http://172.20.9.24:808/ZLT_P11S_P13-NO_LOGO-P11PLUS-EN_48.3_update_file-all_2019_12_19_20_21_02.zip",   "FilesSize":"4367707",   "SuccessURL":null,   "FailureURL":null}     */    std::stringstream strValue;    json actionParameters = {};    mysqlpp::Connection conn(false);    mysqlpp::Query query = conn.query();    mysqlpp::Query _query = conn.query();    try {        conn.connect(DATABASE, HOST, USER, PASSWORD, PORT);        query                << "select t.id, d.IMSI , t.action , t.ActionParameters from TaskList as t join Device_List as d on t.IMSI=d.IMSI where d.IP='"                << soap->host                << "' and t.response is null and t.Active=0 and t.`datetime` < NOW() order by id limit 1;";        mysqlpp::StoreQueryResult result = query.store();        if (result.size() == 0)            return soap->error = 204;        mysqlpp::StoreQueryResult::const_iterator it;        for (it = result.begin(); it != result.end(); ++it) {            mysqlpp::Row row = *it;            strValue << row["id"];            strValue >> id;            strValue << row["IMSI"];            strValue >> IMSI;            action = row["action"];            _actionParameters = row["ActionParameters"];        }//        std::cerr<<"Size of result+: "<<result.size()<<std::endl;        s = std::string(_actionParameters);        _query << "update TaskList set Active=1 where id='" << id << "';";        _query.execute();    } catch (mysqlpp::BadQuery er) { // handle any connection or        std::cerr << "Error on CPE with IP: " << soap->host << " :" << er.what() << std::endl;    }    conn.disconnect();    actionParameters = json::parse(s);    if (action == 1) {        try {            std::cerr << "sending download request for " << soap->host << std::endl;            int DelaySeconds = 1;            std::string str = actionParameters["FileType"];            char *FileType = new char[str.length() + 1];            strcpy(FileType, str.c_str());            str = actionParameters["URL"];            char *URL = new char[str.length() + 1];            strcpy(URL, str.c_str());            char *Username = NULL;            char *Password = NULL;            int FileSize = std::stoi(std::string(actionParameters["FilesSize"]));            char *TargetFileName = NULL;            str = actionParameters["SuccessURL"];            char *SuccessURL = new char[str.length() + 1];            strcpy(SuccessURL, str.c_str());            str = actionParameters["FailureURL"];            char *FailureURL = new char[str.length() + 1];            strcpy(FailureURL, str.c_str());            return CustomeDownload(soap, this, DelaySeconds, FileType, URL, Username, Password, FileSize,                                   TargetFileName,                                   SuccessURL, FailureURL);        } catch (std::exception ex) { // handle any connection or            std::cerr << "Error on CPE with IP: " << soap->host << " :" << ex.what() << std::endl;        }    }////    return CustomeDownload(soap, this, std::__cxx11::string(), std::__cxx11::string(), std::__cxx11::string(),//    std::__cxx11::string(), std::__cxx11::string(), std::__cxx11::string(),//                           std::__cxx11::string(),//                           std::__cxx11::string(), std::__cxx11::string());//    return soap_closesock(soap);    return soap->error = 204;}int cwmpService::CustomeDownloadResponse(struct soap *pSoap, cwmpService *pService) {    std::cerr << "Upgrade Response received." << std::endl;    std::stringstream strValue;    std::string IMSI{}, s, id;    soap->error = 0;    mysqlpp::Connection conn(false);    mysqlpp::Query query = conn.query();    mysqlpp::Query _query = conn.query();    try {        conn.connect(DATABASE, HOST, USER, PASSWORD, PORT);        query                << "select t.id  from TaskList as t join Device_List as d on t.IMSI=d.IMSI where d.IP='"                << soap->host << "' and t.response is  null and t.Active=1 order by id limit 1;";        mysqlpp::StoreQueryResult result = query.store();        if (result.size() == 0)            return soap->error = 204;        mysqlpp::StoreQueryResult::const_iterator it;        for (it = result.begin(); it != result.end(); ++it) {            mysqlpp::Row row = *it;            strValue << row["id"];            strValue >> id;        }    } catch (mysqlpp::BadQuery er) { // handle any connection or        std::cerr << "Error on CPE with IP: " << soap->host << " :" << er.what() << std::endl;    }    _query << "update TaskList set Response='Done' where id='" << id << "';";    _query.execute();    conn.disconnect();//    struct _cwmp__DownloadResponse cwmp__downloadResponse;//    if ((soap->mode & SOAP_IO_LENGTH)) {//        if (soap_envelope_begin_out(soap)//            || soap_putheader(soap)//            || soap_body_begin_out(soap)//            || soap_put__cwmp__DownloadResponse(soap, &cwmp__downloadResponse, "cwmp:DownloadResponse", "")//            || soap_body_end_out(soap)//            || soap_envelope_end_out(soap))//            return soap->error;//    };//    if (soap_end_count(soap)//        || soap_response(soap, SOAP_OK)//        || soap_envelope_begin_out(soap)//        || soap_putheader(soap)//        || soap_body_begin_out(soap)//        || soap_put__cwmp__DownloadResponse(soap, &cwmp__downloadResponse, "cwmp:DownloadResponse", "")//        || soap_body_end_out(soap)//        || soap_envelope_end_out(soap)//        || soap_end_send(soap))//        return soap->error;    soap->keep_alive = 0;    return soap_closesock(soap);}
 |