|
|
@@ -686,125 +686,6 @@ void SpSecureClient::OnAuthPass()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-bool SpSecureClient::OnAuthRequest(CConnAuthReq *pReq)
|
|
|
-{
|
|
|
- ErrorCodeEnum Error = Error_Unexpect;
|
|
|
-
|
|
|
- // prepare verify info
|
|
|
- CSystemStaticInfo si;
|
|
|
- m_pEntity->GetFunction()->GetSystemStaticInfo(si);
|
|
|
- CVerifyInfo info;
|
|
|
- memset(&info, 0, sizeof(info));
|
|
|
- strncpy(info.m_arrTerminalNo, (LPCSTR)si.strTerminalID, sizeof(info.m_arrTerminalNo)-1);
|
|
|
- strcpy(info.m_arrServiceType, "CMBRVC");
|
|
|
- {
|
|
|
-
|
|
|
- //TODO: CrossPlaform [Gifur@2025729]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- hostent *ent = _gethostbyname(NULL);
|
|
|
- if (ent && ent->h_addr_list[0] != NULL)
|
|
|
- {
|
|
|
- int i = 0;
|
|
|
- for (; ent->h_addr_list[i] != NULL; ++i) {
|
|
|
- struct in_addr* in = (struct in_addr*)ent->h_addr_list[i];
|
|
|
- if (in->S_un.S_un_b.s_b1 == 99 || in->S_un.S_un_b.s_b1 == 10)
|
|
|
- break;
|
|
|
- }
|
|
|
- if (ent->h_addr_list[i] == NULL)
|
|
|
- i = 0;
|
|
|
-
|
|
|
- auto in = (struct in_addr*)ent->h_addr_list[i];
|
|
|
- info.m_arrIP[0] = in->S_un.S_un_b.s_b1;
|
|
|
- info.m_arrIP[1] = in->S_un.S_un_b.s_b2;
|
|
|
- info.m_arrIP[2] = in->S_un.S_un_b.s_b3;
|
|
|
- info.m_arrIP[3] = in->S_un.S_un_b.s_b4;
|
|
|
- }
|
|
|
-#else
|
|
|
- char buf[512];
|
|
|
- toolkit_interface_address_t* addr;
|
|
|
- int count, i, aim = -1, backup = -1, third = -1;
|
|
|
- toolkit_interface_addresses(&addr, &count);
|
|
|
- i = count;
|
|
|
- WLog_DBG(TAG, "Number of interfaces: %d", count);
|
|
|
- while (i--) {
|
|
|
- toolkit_interface_address_t interface = addr[i];
|
|
|
- WLog_DBG(TAG, "Name: %s", interface.name);
|
|
|
- WLog_DBG(TAG, "Internal? %s", interface.is_internal ? "Yes" : "No");
|
|
|
- if (interface.address.address4.sin_family == AF_INET) {
|
|
|
- third = i;
|
|
|
- toolkit_ip4_name(&interface.address.address4, buf, sizeof(buf));
|
|
|
- WLog_DBG(TAG, "IPv4 address: %s", buf);
|
|
|
- CSimpleStringA s(buf);
|
|
|
- if (s.IsStartWith("99.") || s.IsStartWith("10.")) {
|
|
|
- aim = i;
|
|
|
- break;
|
|
|
- }
|
|
|
- if (!interface.is_internal && backup != -1) {
|
|
|
- backup = i;
|
|
|
- }
|
|
|
- } else if (interface.address.address4.sin_family == AF_INET6) {
|
|
|
- toolkit_ip6_name(&interface.address.address6, buf, sizeof(buf));
|
|
|
- WLog_DBG(TAG, "IPv6 address: %s", buf);
|
|
|
- }
|
|
|
- }
|
|
|
- if (aim == -1 && backup != -1) {
|
|
|
- aim = backup;
|
|
|
- }
|
|
|
- if (aim == -1 && third != -1)
|
|
|
- aim = third;
|
|
|
- memset(info.m_arrIP, 0, sizeof(info.m_arrIP));
|
|
|
- if (aim != -1) {
|
|
|
- char ipStr[32];
|
|
|
- int b1, b2, b3, b4;
|
|
|
- b1 = b2 = b3 = b4 = 0;
|
|
|
- toolkit_ip4_name(&addr[aim].address.address4, ipStr, sizeof(ipStr));
|
|
|
- WLog_DBG(TAG, "specified local ip: %s", ipStr);
|
|
|
- sscanf(ipStr, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
|
|
|
- info.m_arrIP[0] = (BYTE)b1;
|
|
|
- info.m_arrIP[1] = (BYTE)b2;
|
|
|
- info.m_arrIP[2] = (BYTE)b3;
|
|
|
- info.m_arrIP[3] = (BYTE)b4;
|
|
|
- }
|
|
|
- toolkit_free_interface_addresses(addr, count);
|
|
|
-#endif
|
|
|
- }
|
|
|
- if (pReq != NULL)
|
|
|
- {
|
|
|
- // call token service to encrypt verify info
|
|
|
- int nDestLen = sizeof(pReq->m_arrVerifyInfo);
|
|
|
- TokenService_ClientBase *client = new TokenService_ClientBase(m_pEntity);
|
|
|
- Error = client->Connect();
|
|
|
- if (Error == Error_Succeed) {
|
|
|
- TokenService_EncryptWithPubKey_Req Req;
|
|
|
- TokenService_EncryptWithPubKey_Ans Ans;
|
|
|
- Req.raw_data.m_pData = (char*)&info;
|
|
|
- Req.raw_data.m_iLength = sizeof(info); //28
|
|
|
-
|
|
|
- Error = client->EncryptWithPubKey(Req, Ans, -1);
|
|
|
- if (Error != Error_Succeed) {
|
|
|
- LOG_TRACE("EncryptWithPriKey for VerifyInfo failed! Error = %s", SpStrError(Error));
|
|
|
- } else {
|
|
|
- memcpy_s(pReq->m_arrVerifyInfo, sizeof(pReq->m_arrVerifyInfo), Ans.enc_data.m_pData, Ans.enc_data.m_iLength);
|
|
|
- // get token
|
|
|
- TokenService_GetToken_Req Req1;
|
|
|
- TokenService_GetToken_Ans Ans1;
|
|
|
- Error = client-> GetToken(Req1, Ans1, -1);
|
|
|
- if (Error != Error_Succeed) {
|
|
|
- LOG_TRACE("GetToken for VerifyInfo failed! Error = %s", SpStrError(Error));
|
|
|
- } else {
|
|
|
- memcpy_s(pReq->m_arrVerifyToken, sizeof(pReq->m_arrVerifyToken), Ans1.token.m_pData, Ans1.token.m_iLength);
|
|
|
- }
|
|
|
- }
|
|
|
- client->GetFunction()->CloseSession();
|
|
|
- } else {
|
|
|
- LOG_TRACE("connect to tokenservice failed! Error = %s", SpStrError(Error));
|
|
|
- client->SafeDelete();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return Error == Error_Succeed;
|
|
|
-}
|
|
|
-
|
|
|
bool SpSecureClient::OnAuthRequestSM(CConnAuthSMReq* pReq)
|
|
|
{
|
|
|
ErrorCodeEnum Error = Error_Unexpect;
|
|
|
@@ -816,7 +697,7 @@ bool SpSecureClient::OnAuthRequestSM(CConnAuthSMReq* pReq)
|
|
|
strncpy(info.m_arrTerminalNo, (LPCSTR)si.strTerminalID, sizeof(info.m_arrTerminalNo) - 1);
|
|
|
strcpy(info.m_arrServiceType, "CMBRVC");
|
|
|
{
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
+ //TODO: CrossPlaform IP [Gifur@2025730]
|
|
|
#ifdef RVC_OS_LINUX
|
|
|
char buf[512];
|
|
|
toolkit_interface_address_t* addr;
|