|
@@ -18,14 +18,16 @@
|
|
|
#include <Winsock2.h>
|
|
|
#include <algorithm>
|
|
|
#pragma comment(lib, "IPHLPAPI.lib")
|
|
|
-
|
|
|
-
|
|
|
+#include "..\mod_pinpad\PinPad_client_g.h"
|
|
|
+using namespace PinPad;
|
|
|
#define ALLOW_MULTI_NETWORKD_CARDS
|
|
|
|
|
|
#else
|
|
|
#include "CommEntityRestful.hpp"
|
|
|
#include "SpUtility.h"
|
|
|
#include "comm.h"
|
|
|
+#include "PinPad_client_g.h"
|
|
|
+using namespace PinPad;
|
|
|
#endif // RVC_OS_WIN
|
|
|
|
|
|
int HexBuf2StrBuf(PBYTE hexBuf, char** strBuf, DWORD len)
|
|
@@ -308,11 +310,41 @@ struct UpdateWKTask : ITaskSp
|
|
|
CAccessAuthUpdateWKReq updateWKReq;
|
|
|
updateWKReq.terminalNo = si.strTerminalID.GetData();
|
|
|
auto tmkpair = m_entity->GenerateTmkToKMC();//first是加密的,seconde是没加密的
|
|
|
-
|
|
|
updateWKReq.encRandom = tmkpair.first;
|
|
|
+
|
|
|
+ PinPadService_ClientBase* pPinPad = new PinPadService_ClientBase(this->m_entity);
|
|
|
+ auto errRc = pPinPad->Connect();
|
|
|
+ if (errRc == Error_Succeed)
|
|
|
+ {
|
|
|
+ PinPadService_GetCheckCode_Req req = {};
|
|
|
+ PinPadService_GetCheckCode_Ans ans = {};
|
|
|
+
|
|
|
+ req.mSN.Init(1);
|
|
|
+ req.wSN.Init(1);
|
|
|
+ req.mSN[0] = 1;
|
|
|
+ req.wSN[0] = 0;
|
|
|
+ errRc = (*pPinPad)(EntityResource::getLink().upgradeLink())->GetCheckCode(req, ans, 10000);
|
|
|
+ if (errRc == Error_Succeed)
|
|
|
+ {
|
|
|
+ updateWKReq.tpkKeyCheck = ans.checkcode[0].GetData();
|
|
|
+ updateWKReq.keyIndex = ans.index[0].GetData();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex suc.");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex failed.");
|
|
|
+ }
|
|
|
+
|
|
|
+ pPinPad->GetFunction()->CloseSession();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("connect to pinpad failed.error code:%d", errRc);
|
|
|
+ }
|
|
|
+
|
|
|
CAccessAuthUpdateWKRet updateWKRet;
|
|
|
updateWKReq.m_url = m_fsm->GetmAccessAuthHost();
|
|
|
- updateWKReq.m_url += "/api/v3/wkupdate";
|
|
|
+ updateWKReq.m_url += "/api/v5/wkupdate";
|
|
|
long beg = GetTickCount();
|
|
|
bool ret = client->Post(updateWKReq, updateWKRet);
|
|
|
long end = GetTickCount();
|
|
@@ -333,7 +365,7 @@ struct UpdateWKTask : ITaskSp
|
|
|
|
|
|
|
|
|
ErrorCodeEnum eLoadErr = m_entity->LoadKeysToPinPadACS(tmkpair.second, updateWKRet.tpk,
|
|
|
- updateWKRet.edk, updateWKRet.index);
|
|
|
+ updateWKRet.edk, updateWKRet.keyIndex);
|
|
|
if (eLoadErr == Error_Succeed) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("LoadKeysToPinPadNew")
|
|
|
("UpdateWKTask LoadKeysToPinPadNew Success");
|
|
@@ -362,9 +394,12 @@ struct UpdateWKTask : ITaskSp
|
|
|
#else
|
|
|
struct UpdateWKReq
|
|
|
{
|
|
|
- std::string terminalNo;
|
|
|
- std::string encRandom;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, encRandom)
|
|
|
+ string terminalNo;
|
|
|
+ string encRandom;
|
|
|
+ string tpkKeyCheck; //tpk密钥校验值
|
|
|
+ string edkKeyCheck; //edk密钥校验值
|
|
|
+ string keyIndex; //密钥序号
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, encRandom, tpkKeyCheck, edkKeyCheck, keyIndex)
|
|
|
} updateWKReq;
|
|
|
|
|
|
struct UpdateWKAns
|
|
@@ -372,17 +407,49 @@ struct UpdateWKTask : ITaskSp
|
|
|
string tmk;
|
|
|
string tpk;
|
|
|
string edk;
|
|
|
- string index;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(tmk, tpk, edk, index)
|
|
|
+ string tpkKeyCheck; //密钥校验值
|
|
|
+ string edkKeyCheck; //edk密钥校验值
|
|
|
+ string keyIndex; //密钥序号
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(tmk, tpk, edk, tpkKeyCheck, edkKeyCheck, keyIndex)
|
|
|
} updateWKAns;
|
|
|
|
|
|
updateWKReq.terminalNo = si.strTerminalID.GetData();
|
|
|
auto tmkpair = m_entity->GenerateTmkToKMC();//first是加密的,seconde是没加密的
|
|
|
updateWKReq.encRandom = tmkpair.first;
|
|
|
|
|
|
+ PinPadService_ClientBase* pPinPad = new PinPadService_ClientBase(this->m_entity);
|
|
|
+ auto errRc = pPinPad->Connect();
|
|
|
+ if (errRc == Error_Succeed)
|
|
|
+ {
|
|
|
+ PinPadService_GetCheckCode_Req req = {};
|
|
|
+ PinPadService_GetCheckCode_Ans ans = {};
|
|
|
+
|
|
|
+ req.mSN.Init(1);
|
|
|
+ req.wSN.Init(1);
|
|
|
+ req.mSN[0] = 1;
|
|
|
+ req.wSN[0] = 0;
|
|
|
+ errRc = (*pPinPad)(EntityResource::getLink().upgradeLink())->GetCheckCode(req, ans, 10000);
|
|
|
+ if (errRc == Error_Succeed)
|
|
|
+ {
|
|
|
+ updateWKReq.tpkKeyCheck = ans.checkcode[0].GetData();
|
|
|
+ updateWKReq.keyIndex = ans.index[0].GetData();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex suc.");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex failed.");
|
|
|
+ }
|
|
|
+
|
|
|
+ pPinPad->GetFunction()->CloseSession();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("connect to pinpad failed.error code:%d", errRc);
|
|
|
+ }
|
|
|
+
|
|
|
HttpClientResponseResult result;
|
|
|
HttpClientRequestConfig config(HttpRequestMethod::POST, m_fsm->GetmAccessAuthHost().GetData());
|
|
|
- config.SetChildUri("/api/v3/wkupdate");
|
|
|
+ config.SetChildUri("/api/v5/wkupdate");
|
|
|
|
|
|
SP::Module::Restful::FulfillRequestJsonBody(&config, updateWKReq);
|
|
|
|
|
@@ -407,9 +474,11 @@ struct UpdateWKTask : ITaskSp
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tmk=%s %d", updateWKAns.tmk.c_str(), updateWKAns.tmk.size());
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tpk=%s %d", updateWKAns.tpk.c_str(), updateWKAns.tpk.size());
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("edk=%s %d", updateWKAns.edk.c_str(), updateWKAns.edk.size());
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("index=%s %d", updateWKAns.index.c_str(), updateWKAns.index.size());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tpkKeyCheck=%s %d", updateWKAns.tpkKeyCheck.c_str(), updateWKAns.tpkKeyCheck.size());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("edkKeyCheck=%s %d", updateWKAns.edkKeyCheck.c_str(), updateWKAns.edkKeyCheck.size());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("index=%s %d", updateWKAns.keyIndex.c_str(), updateWKAns.keyIndex.size());
|
|
|
|
|
|
- DWORD rc = m_entity->LoadKeysToPinPadACS(tmkpair.second, updateWKAns.tpk, updateWKAns.edk, updateWKAns.index);
|
|
|
+ DWORD rc = m_entity->LoadKeysToPinPadACS(tmkpair.second, updateWKAns.tpk, updateWKAns.edk, updateWKAns.keyIndex);
|
|
|
if (rc == Error_Succeed) {
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("UpdateWKTask LoadKeysToPinPadNew Success");
|
|
|
/*FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_UpdateWKSucc);
|
|
@@ -1524,83 +1593,73 @@ void CAccessAuthFSM::AuthLogWarn(const T& ret, const string& url, const string&
|
|
|
|
|
|
void CAccessAuthFSM::GetNetMsg(SpReqAnsContext<AccessAuthService_GetNetMsg_Req, AccessAuthService_GetNetMsg_Ans>::Pointer& ctx)
|
|
|
{
|
|
|
-// CSimpleStringA tmp;
|
|
|
-//#ifdef RVC_OS_WIN
|
|
|
-// ErrorCodeEnum errCode = GetDNS(tmp);
|
|
|
-// Dbg("网卡状态:%d, 网卡信息为:%s.", errCode, tmp.GetData());
|
|
|
-// ctx->Ans.netMsg = tmp;
|
|
|
-// if (errCode == Error_Succeed)
|
|
|
-// {
|
|
|
-// ctx->Ans.netStatus = 1; //成功
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// ctx->Ans.netStatus = 0; //失败
|
|
|
-// }
|
|
|
-//#else
|
|
|
-// ErrorCodeEnum ec = Error_Succeed;
|
|
|
-// int netType = 0; //默认未知
|
|
|
-//
|
|
|
-// CSimpleStringA tmpVendor(""), tmpDevSN(""), tmpDLLVersion("");
|
|
|
-// GetEntityBase()->GetFunction()->GetSysVar("FWBVendor", tmpVendor);
|
|
|
-// GetEntityBase()->GetFunction()->GetSysVar("FWBDevSN", tmpDevSN);
|
|
|
-// GetEntityBase()->GetFunction()->GetSysVar("FWBVersion", tmpDLLVersion);
|
|
|
-//
|
|
|
-//
|
|
|
-// if (tmpDLLVersion.GetLength() < 2)
|
|
|
-// tmpDLLVersion = "8.1";
|
|
|
-// if (tmpDevSN.GetLength() > 12 && tmpDevSN.IndexOf("FWB") > 2)
|
|
|
-// {
|
|
|
-// Dbg("This is fwb device.");
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// int i = 0;
|
|
|
-// int sockfd;
|
|
|
-// struct ifconf ifconf;
|
|
|
-// struct ifreq* ifreq;
|
|
|
-// char buf[1024];
|
|
|
-//
|
|
|
-// //初始化ifconf
|
|
|
-// ifconf.ifc_len = 1024;
|
|
|
-// ifconf.ifc_buf = buf;
|
|
|
-//
|
|
|
-// if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
|
|
-// {
|
|
|
-// perror("socket error");
|
|
|
-// exit(1);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //获取所有接口信息
|
|
|
-// ioctl(sockfd, SIOCGIFCONF, &ifconf);
|
|
|
-//
|
|
|
-// //逐个获取Ip地址
|
|
|
-// int size = ifconf.ifc_len / sizeof(struct ifreq);
|
|
|
-// ifreq = (struct ifreq*)buf;
|
|
|
-// string netName(ifreq->ifr_name);
|
|
|
-//
|
|
|
-// if (size == 1 && netName == "lo") //只有逻辑地址 -- 网线被拔出
|
|
|
-// {
|
|
|
-// netType = 0;
|
|
|
-// tmp = "无网络";
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// for (i = size; i > 0; i--)
|
|
|
-// {
|
|
|
-// string netName(ifreq->ifr_name); //有其他网卡 -- 有线
|
|
|
-// if (netName != "lo")
|
|
|
-// {
|
|
|
-// netType = 1;
|
|
|
-// tmp = "网络已连接";
|
|
|
-// }
|
|
|
-// ifreq++;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// ctx->Ans.netStatus = netType;
|
|
|
-// }
|
|
|
-// ctx->Ans.netMsg = tmp;
|
|
|
-//#endif // RVC_OS_WIN
|
|
|
+ CSimpleStringA tmp;
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ ctx->Ans.netStatus = 1; //成功
|
|
|
+#else
|
|
|
+ ErrorCodeEnum ec = Error_Succeed;
|
|
|
+ int netType = 0; //默认未知
|
|
|
+
|
|
|
+ CSimpleStringA tmpVendor(""), tmpDevSN(""), tmpDLLVersion("");
|
|
|
+ GetEntityBase()->GetFunction()->GetSysVar("FWBVendor", tmpVendor);
|
|
|
+ GetEntityBase()->GetFunction()->GetSysVar("FWBDevSN", tmpDevSN);
|
|
|
+ GetEntityBase()->GetFunction()->GetSysVar("FWBVersion", tmpDLLVersion);
|
|
|
+
|
|
|
+
|
|
|
+ if (tmpDLLVersion.GetLength() < 2)
|
|
|
+ tmpDLLVersion = "8.1";
|
|
|
+ if (tmpDevSN.GetLength() > 12 && tmpDevSN.IndexOf("FWB") > 2)
|
|
|
+ {
|
|
|
+ Dbg("This is fwb device.");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int i = 0;
|
|
|
+ int sockfd;
|
|
|
+ struct ifconf ifconf;
|
|
|
+ struct ifreq* ifreq;
|
|
|
+ char buf[1024];
|
|
|
+
|
|
|
+ //初始化ifconf
|
|
|
+ ifconf.ifc_len = 1024;
|
|
|
+ ifconf.ifc_buf = buf;
|
|
|
+
|
|
|
+ if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
|
|
+ {
|
|
|
+ perror("socket error");
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取所有接口信息
|
|
|
+ ioctl(sockfd, SIOCGIFCONF, &ifconf);
|
|
|
+
|
|
|
+ //逐个获取Ip地址
|
|
|
+ int size = ifconf.ifc_len / sizeof(struct ifreq);
|
|
|
+ ifreq = (struct ifreq*)buf;
|
|
|
+ string netName(ifreq->ifr_name);
|
|
|
+
|
|
|
+ if (size == 1 && netName == "lo") //只有逻辑地址 -- 网线被拔出
|
|
|
+ {
|
|
|
+ netType = 0;
|
|
|
+ tmp = "无网络";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (i = size; i > 0; i--)
|
|
|
+ {
|
|
|
+ string netName(ifreq->ifr_name); //有其他网卡 -- 有线
|
|
|
+ if (netName != "lo")
|
|
|
+ {
|
|
|
+ netType = 1;
|
|
|
+ tmp = "网络已连接";
|
|
|
+ }
|
|
|
+ ifreq++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ctx->Ans.netStatus = netType;
|
|
|
+ }
|
|
|
+ ctx->Ans.netMsg = tmp;
|
|
|
+#endif // RVC_OS_WIN
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
}
|