|
|
@@ -497,25 +497,9 @@ bool CHeartBeatFSM::HandShakeHttp(IHttpFunc* client,bool &isHeartBeatOk) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-string CHeartBeatFSM::HandShakeJsonStr() {
|
|
|
- //LOG_FUNCTION();
|
|
|
- string jsonStr = "";
|
|
|
- Json::Value root;
|
|
|
- Json::FastWriter fw;//写入对象
|
|
|
- Json::Value obj1, obj2, obj3;
|
|
|
-
|
|
|
- //写入shakehandvo对象
|
|
|
- CSystemStaticInfo sysSInfo;
|
|
|
- m_pEntity->GetFunction()->GetSystemStaticInfo(sysSInfo);
|
|
|
- CSimpleStringA warningLevel("w"), runState("O"), customerHandle("c"), callState("s"),
|
|
|
- localMaintain("l"), remoteMaintain("m"), termStage("U");
|
|
|
- //m_pEntity->GetFunction()->GetSysVar("RunState", runState);
|
|
|
- m_pEntity->GetFunction()->GetSysVar("CustomerHandle", customerHandle);
|
|
|
- m_pEntity->GetFunction()->GetSysVar("CallState", callState);
|
|
|
- m_pEntity->GetFunction()->GetSysVar("TerminalStage", termStage);
|
|
|
-
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
+/** 提取出来 [Gifur@202585]*/
|
|
|
+static unsigned long GetLocalIP()
|
|
|
+{
|
|
|
#ifdef RVC_OS_WIN
|
|
|
char tmp[256];
|
|
|
gethostname(tmp, sizeof(tmp));
|
|
|
@@ -535,13 +519,33 @@ string CHeartBeatFSM::HandShakeJsonStr() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ return ip;
|
|
|
+#else
|
|
|
+ //oiltest
|
|
|
+ return 0x0;
|
|
|
#endif //RVC_OS_WIN
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+string CHeartBeatFSM::HandShakeJsonStr() {
|
|
|
+ //LOG_FUNCTION();
|
|
|
+ string jsonStr = "";
|
|
|
+ Json::Value root;
|
|
|
+ Json::FastWriter fw;//写入对象
|
|
|
+ Json::Value obj1, obj2, obj3;
|
|
|
+
|
|
|
+ //写入shakehandvo对象
|
|
|
+ CSystemStaticInfo sysSInfo;
|
|
|
+ m_pEntity->GetFunction()->GetSystemStaticInfo(sysSInfo);
|
|
|
+ CSimpleStringA warningLevel("w"), runState("O"), customerHandle("c"), callState("s"),
|
|
|
+ localMaintain("l"), remoteMaintain("m"), termStage("U");
|
|
|
+ //m_pEntity->GetFunction()->GetSysVar("RunState", runState);
|
|
|
+ m_pEntity->GetFunction()->GetSysVar("CustomerHandle", customerHandle);
|
|
|
+ m_pEntity->GetFunction()->GetSysVar("CallState", callState);
|
|
|
+ m_pEntity->GetFunction()->GetSysVar("TerminalStage", termStage);
|
|
|
obj1["terminalNo"] = sysSInfo.strTerminalID.GetData();
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- obj1["ip"] = (unsigned int)ip;
|
|
|
-#else
|
|
|
- obj1["ip"] = 0;//默认不获取
|
|
|
-#endif
|
|
|
+ obj1["ip"] = (unsigned int)GetLocalIP();
|
|
|
obj1["warningLevel"] = warningLevel.GetData();
|
|
|
obj1["runState"] = runState.GetData();
|
|
|
obj1["customerHandle"] = customerHandle.GetData();
|
|
|
@@ -1124,11 +1128,6 @@ void HeartBeatConnection::OnPkgAnswer(const CSmartPointer<IPackage> &pRecvPkg)
|
|
|
void HeartBeatConnection::SendHandShake()
|
|
|
{
|
|
|
HandReq req = {0};
|
|
|
-
|
|
|
- //oiltest
|
|
|
- //strcpy(req.TerminalNo,"75500000002");
|
|
|
-
|
|
|
- //Dbg("get sysvar");
|
|
|
//oiltest set default value
|
|
|
CSimpleStringA warningLevel("w"),runState("O"),customerHandle("c"),callState("s"),
|
|
|
localMaintain("l"),remoteMaintain("m"),termStage("U");
|
|
|
@@ -1144,32 +1143,7 @@ void HeartBeatConnection::SendHandShake()
|
|
|
//Dbg("ts[%s]",(LPCTSTR)termStage);
|
|
|
//oiltest byteorder
|
|
|
|
|
|
- //TODO: CrossPlaform [Gifur@2025729]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- char tmp[256];
|
|
|
- gethostname(tmp, sizeof(tmp));
|
|
|
- hostent *ent = gethostbyname(tmp);
|
|
|
- unsigned long ip = 0xffffffff;
|
|
|
- if (ent) {
|
|
|
- for (int i = 0; ent->h_addr_list[i]; ++i) {
|
|
|
- if (ent->h_addrtype == AF_INET) {
|
|
|
- struct in_addr *in = (struct in_addr*)ent->h_addr_list[i];
|
|
|
- if (in->S_un.S_un_b.s_b1 != 0) {
|
|
|
- if (in->S_un.S_un_b.s_b1 == 192)
|
|
|
- continue;
|
|
|
- ip = (in->S_un.S_un_b.s_b1<<24)+(in->S_un.S_un_b.s_b2<<16)
|
|
|
- +(in->S_un.S_un_b.s_b3<<8)+in->S_un.S_un_b.s_b4;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- req.ip = ip;
|
|
|
-#else
|
|
|
- //oiltest
|
|
|
- req.ip = 0x0;
|
|
|
-#endif //RVC_OS_WIN
|
|
|
+ req.ip = GetLocalIP();
|
|
|
req.WarningLevel = warningLevel[0];
|
|
|
req.RunState = runState[0];
|
|
|
req.CustomerHandle = customerHandle[0];
|
|
|
@@ -1194,61 +1168,8 @@ void HeartBeatConnection::SendHandShake()
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Get Terminal Performance Information failed !!!");
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- //oilyang@20171122 数量太多,暂时去掉
|
|
|
- //Dbg("Get Terminal Performance Information suc");
|
|
|
- }
|
|
|
- //const char* szIP = m_pFSM->GetRealIP();
|
|
|
- //memset(tmp, 0, sizeof(tmp));
|
|
|
- //strcpy_s(tmp, 256, szIP);
|
|
|
- //Dbg("Calling gethostbyname with %s %s", tmp, szIP);
|
|
|
- //ent = gethostbyname(tmp);
|
|
|
- //ip = 0xffffffff;
|
|
|
- //if (ent == NULL)
|
|
|
- //{
|
|
|
- // DWORD dwError = WSAGetLastError();
|
|
|
- // if (dwError != 0)
|
|
|
- // {
|
|
|
- // if (dwError == WSAHOST_NOT_FOUND)
|
|
|
- // {
|
|
|
- // Dbg("Host not found");
|
|
|
- // } else if (dwError == WSANO_DATA)
|
|
|
- // {
|
|
|
- // Dbg("No data record found");
|
|
|
- // } else
|
|
|
- // {
|
|
|
- // Dbg("Function failed with error: %ld", dwError);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // counter.serverIP = 0xffffffff;
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // //unsigned long ulIP = ((struct in_addr*)ent->h_addr)->S_un.S_addr;
|
|
|
- // for (int i = 0; ent->h_addr_list[i]; ++i)
|
|
|
- // {
|
|
|
- // if (ent->h_addrtype == AF_INET)
|
|
|
- // {
|
|
|
- // struct in_addr *in = (struct in_addr*)ent->h_addr_list[i];
|
|
|
- // if (in->S_un.S_un_b.s_b1 != 0)
|
|
|
- // {
|
|
|
- // if (in->S_un.S_un_b.s_b1 == 192)
|
|
|
- // continue;
|
|
|
- // ip = (in->S_un.S_un_b.s_b1<<24)+(in->S_un.S_un_b.s_b2<<16)
|
|
|
- // +(in->S_un.S_un_b.s_b3<<8)+in->S_un.S_un_b.s_b4;
|
|
|
- // // test for ip with S_addr [Josephus in 11:15:43 2016/4/22]
|
|
|
- // unsigned long ulIP = in->S_un.S_addr;
|
|
|
- // unsigned long ul2IP = inet_addr(tmp);
|
|
|
- // Dbg("joseph-test2: ip=0x%x, ulIp=0x%x, ul2IP=0x%x", ip, ulIP, ul2IP);
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
|
|
|
counter.serverIP = m_pFSM->m_dwServIP;
|
|
|
- //Dbg("dwServIP 0x%x", counter.serverIP);
|
|
|
#ifdef RVC_OS_WIN
|
|
|
const char* diskPath = m_pFSM->GetRunDiskPath();
|
|
|
ULARGE_INTEGER uliFreeBytesAvailable;
|