static int ReadPemFile(uchar *pszAppFileName, uchar *psCA, uchar *psCert, uchar *psPrivatekey) { int fd, iRet, iTempLen; uchar *ptr1, *ptr2 ; uchar ucBuf[MAX_PEM_ELN+1]; uchar pos_ca_buf[2048]; uchar pos_cer_buf[2048]; uchar pos_privatekey_buf[2048]; if (pszAppFileName == NULL) { return -1; } //打开文件 fd = open(pszAppFileName, O_RDWR); if (fd < 0) { return fd; } //读取文件 memset(ucBuf, 0, sizeof(ucBuf)); iRet = read(fd, ucBuf, MAX_PEM_ELN); if (iRet < 0) { ScrClrLine(6,9); ScrPrint(0, 6, 1, "READ FILE ERR:%d", iRet); PubWaitKey(30); close(fd); return iRet; } close(fd); //Get CERTIFICATE if ((ptr1 = strstr(ucBuf, "-----BEGIN CERTIFICATE-----")) && (ptr2 = strstr(ucBuf, "-----END CERTIFICATE-----")) ) { memset(pos_cer_buf, 0, sizeof(pos_cer_buf)); iTempLen = strlen(ptr1) - strlen(ptr2) - strlen("-----BEGIN CERTIFICATE-----\n"); memcpy(pos_cer_buf, ptr1+strlen("-----BEGIN CERTIFICATE-----\n"), iTempLen); } else { ScrClrLine(6,9); ScrPrint(0, 6, 1, "UNFOUND CERT"); PubWaitKey(30); return -2; } memset(pos_privatekey_buf, 0, sizeof(pos_privatekey_buf)); memset(pos_ca_buf, 0, sizeof(pos_ca_buf)); //out data memcpy(psCA, pos_ca_buf, strlen(pos_ca_buf)); memcpy(psCert, pos_cer_buf, strlen(pos_cer_buf)); memcpy(psPrivatekey, pos_privatekey_buf, strlen(pos_privatekey_buf)); return 0; }
//连接WIFI int WifiConfig(void) //add by wuc 2014.9.9 { int iRet; /* iRet = SelectWifiMode(); if(iRet) { return iRet; } */ while(1) { //linzhao iRet = SelectWifiMode(); if(iRet) { break; } iRet = SetWifiLocalIpPara(); if(iRet) { break; } if(glConfiged) { glConfiged = 0; } else { iRet = ManualWifiAps(); if (iRet) { break; } } ScrCls(); PubDispString(_T("CONNECT..."), DISP_LINE_CENTER|3); //CONNECTING iRet = WifiApLogin(); if(iRet == 0) { ScrCls(); PubDispString(_T("WIFI CONNECTED"), DISP_LINE_CENTER|3); PubWaitKey(3); break; } else { ScrCls(); PubDispString(_T("CONNECT FAIL"), DISP_LINE_CENTER|3); //CONNECT FAIL PubWaitKey(3); continue; } } return iRet; }
//选择WIFI打开模式, 是扫描周围的热点,还是手工输入SSID int SelectWifiMode(void) { int iRet = 0; uchar ucKey; while(1) { kbflush(); ScrCls(); PubDispString(_T("WIFI"), DISP_LINE_CENTER|0); ScrPrint(0, 1, 0, _T("1 - SEARCH NETWORK")); ScrPrint(0, 2, 0, _T("2 - MANUAL")); ucKey = PubWaitKey(USER_OPER_TIMEOUT); if (ucKey == KEY1) { iRet = ScanWifiAps(); if (iRet) { //add by wuc 2014.3.24 if(WIFI_ERR_SCAN == iRet) { WifiClose(); iRet = WifiOpen(); if(iRet) { ScrClrBelow(1); ScrPrint(0, 2, 0, "OpenWifi err=%d", iRet); PubWaitKey(5); break; } } continue; } break; } if (ucKey == KEY2) { iRet = ManualWifiAps(); if (iRet) { continue; } break; } if (ucKey == KEYCANCEL || ucKey == NOKEY) { return ucKey; } } return iRet; }
//1.RSA 2,TMK 3,Active TMK void KeyDownload(void) { int iRet; memcpy(&glCurAcq, &glSysParam.stAcqList[1], sizeof(ACQUIRER)); //set the default Acq by richard 20170223 iRet = RsaKeyDownload(); if(iRet !=0) { ScrClrLine(2, 7); PubDispString(_T("RSA DOWN ERR"), 3 | DISP_LINE_CENTER); PubWaitKey(3); return; } iRet = TmkDownload(); if(iRet !=0) { ScrClrLine(2, 7); PubDispString(_T("TMK DOWN ERR"), 3 | DISP_LINE_CENTER); PubWaitKey(3); return; } iRet = TmkActivation(); if(iRet !=0) { ScrClrLine(2, 7); PubDispString(_T("TMK ACTIVE ERR"), 3 | DISP_LINE_CENTER); PubWaitKey(3); } else { PubBeepOk(); ScrClrLine(2, 7); PubDispString(_T("DOWNLOAD SUCCESS!"), 3 | DISP_LINE_CENTER); PubWaitKey(3); } }
//设置WIFI 本地IP参数 int SetWifiLocalIpPara(void) { int iRet = 0; uchar ucKey; while(1) { kbflush(); ScrCls(); PubDispString(_T("PROTOCOL"), DISP_LINE_CENTER|0); ScrPrint(0, 1, 0, _T("1 - DHCP")); ScrPrint(0, 2, 0, _T("2 - MANUAL")); ucKey = PubWaitKey(USER_OPER_TIMEOUT); if (ucKey == KEY1) { glSysCtrl.stAppWifiPara.DhcpEnable= 1; glConfiged = 1; break; } if (ucKey == KEY2) { glSysCtrl.stAppWifiPara.DhcpEnable = 0; iRet = ManualWifiIps(); if (iRet) { return iRet; } iRet = ConfirmConfig(); if(iRet) { return iRet; } break; } if (ucKey == KEYCANCEL || ucKey == NOKEY) { return ucKey; } /*if(ucKey == KEYENTER) { break; }*/ } return iRet; }
// Modified by Kim_LinHB 2014-7-8 int CheckInitTerminal(void) { uchar szCurTime[16+1], szLastTime[16+1]; uchar ucKey; uchar szBuff[50]; if( !(glSysParam.ucTermStatus & INIT_MODE) ) { return 0; } TimerSet(0, 0); memset(szCurTime, 0, sizeof(szCurTime)); memset(szLastTime, 0, sizeof(szLastTime)); while( glSysParam.ucTermStatus & INIT_MODE ) { Gui_UpdateKey(XUI_KEYFUNC, _T("FUNC"), NULL, NULL); Gui_SetVirtualButton(1, 0); if( TimerCheck(0)==0 ) { TimerSet(0, 10); GetEngTime(szCurTime); if (strcmp(szCurTime, szLastTime)!=0) { Gui_ClearScr(); sprintf(szBuff, "%s\n[%.14s]", _T("PLEASE INIT"), AppInfo.AppName); Gui_UpdateTitle(szCurTime, gl_stTitleAttr); Gui_DrawText(szBuff, gl_stCenterAttr, 0, 50); memcpy(szLastTime, szCurTime, sizeof(szLastTime)); } } ucKey = PubWaitKey(10); if( (ucKey==KEYF1 && ChkTermEx(_TERMINAL_D200_)) || (ucKey==KEYFN && !ChkTermEx(_TERMINAL_D200_)) ) { InitTransInfo(); FunctionInit(); TimerSet(0, 0); memset(szLastTime, 0, sizeof(szLastTime)); } } return 0; }
void UnLockTerminal(void) { if( ChkEdcOption(EDC_NOT_KEYBOARD_LOCKED) ) { return; } while( !ChkEdcOption(EDC_NOT_KEYBOARD_LOCKED) ) { PubShowTitle(TRUE, (uchar *)_T("TERMINAL LOCKED")); PubDispString(_T("MERCHANT PWD"), 4|DISP_LINE_LEFT); PubWaitKey(-1); if( PasswordMerchant()==0 ) { glSysParam.stEdcInfo.sOption[EDC_NOT_KEYBOARD_LOCKED>>8] |= (EDC_NOT_KEYBOARD_LOCKED & 0xFF); SaveEdcParam(); PubBeepOk(); } }
//输入WIFI 加密方式 int GetWifiSecMode(uchar *psName, uchar *psOut) { uchar ucKey; ScrCls(); PubDispString(_T("ENCRYPTION"), DISP_LINE_CENTER|1); ScrPrint(0, 3, 0, _T("1 - NONE")); ScrPrint(0, 4, 0, _T("2 - WEP")); ScrPrint(0, 5, 0, _T("3 - WPA/WPA2")); ScrPrint(0, 6, 0, _T("4 - WPA-PSK/WPA2-PSK")); do { ucKey = PubWaitKey(USER_OPER_TIMEOUT); } while(ucKey!=KEY1 && ucKey!=KEY2 && ucKey!=KEY3 && ucKey!=KEY4 && ucKey!=KEYCANCEL); if (ucKey == KEY1) { *psOut = 0; } if (ucKey == KEY2) { *psOut = 1; } if (ucKey == KEY3) { *psOut = 2; } if (ucKey == KEY4) { *psOut = 3; } if (ucKey == KEYCANCEL || ucKey == NOKEY) { return ucKey; } return 0; }
////发送数据 int WifiNetTcpTxd(uchar *psTxdData, ushort usDataLen, ushort uiTimeOutSec) { int iRet; int iSendLen; int iSumLen; uchar sBuff[128]; #ifdef DEBUG_USE DelayMs(500); return 0; #endif // Netioctl(wnet_socket_id, CMD_TO_SET, uiTimeOutSec*1000); // 系统默认为2秒 iSumLen = 0; while(1) { if (usDataLen > TCPMAXSENDLEN) { iSendLen = TCPMAXSENDLEN; usDataLen = usDataLen - TCPMAXSENDLEN; } else { iSendLen = usDataLen; } iRet = NetSend(wnet_socket_id, psTxdData+iSumLen, iSendLen, 0); { DebugOutput("%s--%d--%s, netsend : iRet = %d\n", __FILE__, __LINE__, __FUNCTION__, iRet); }//linzhao if (iRet < 0) { memset(sBuff, 0, sizeof(sBuff)); switch (iRet) { case NET_ERR_MEM: strcpy(sBuff,_T("MEM ERROR")); break; case NET_ERR_BUF: strcpy(sBuff,_T("BUF ERROR")); break; case NET_ERR_CLSD: strcpy(sBuff,_T("CONNE CLOSED")); break; case NET_ERR_CONN: strcpy(sBuff,_T("CONNE NOT EST")); break; case NET_ERR_LINKDOWN: strcpy(sBuff,_T("LINK DOWN")); break; default: sprintf(sBuff,"ret_send=%d",iRet); break; } DxxScrClrLine(2, 7); PubDispString(sBuff,4|DISP_LINE_CENTER); PubWaitKey(5); return iRet; } iSumLen = iSumLen + iSendLen; if (iSendLen <= TCPMAXSENDLEN) { break; } } return 0; }
int wifiConnect(uchar *inIp, uchar *inPort) { int i = 0; int ret; int trans_port; int event; int ret_num; char sBuff[33]; ST_WIFI_AP WifiAp; struct net_sockaddr server_addr; for (i = 0;i < 1; i++) // change 5 to 1 by wuc 2014.9.2 { ret = WifiCheck(&WifiAp); if (ret < 0) { ret = WifiApLogin(); if (ret != 0 && i != 4) { continue; } else if (ret != 0 && i == 4) { return ret; } else { break; } } else if (ret == 0) { DelayMs(500); continue; } else { break; } } trans_port = atoi(inPort); //如果TCP仍然连接,就不用再连接 if(wnet_socket_id >= 0) { event = Netioctl(wnet_socket_id, CMD_EVENT_GET, 0); if(event&(SOCK_EVENT_CONN|SOCK_EVENT_WRITE|SOCK_EVENT_READ)) { return 0; } } if(wnet_socket_id >= 0) { NetCloseSocket(wnet_socket_id); wnet_socket_id = -1; } ret = NetSocket(NET_AF_INET, NET_SOCK_STREAM, 0); if(ret < 0) { return -1; } wnet_socket_id = ret; /*ret = Netioctl(wnet_socket_id, CMD_TO_SET, 30*1000);//advice from S/W department if (ret != 0) { DebugOutput("ret = [%d]", ret); return ret; }*/ SockAddrSet(&server_addr, (char*)inIp, (short)trans_port); ret_num = NetConnect(wnet_socket_id, &server_addr, sizeof(server_addr)); if(ret_num < 0) { switch (ret_num) { case NET_ERR_ABRT: case NET_ERR_CONN: case NET_ERR_IF://linzhao strcpy(sBuff,_T("CONN FAIL")); break; case NET_ERR_RST: strcpy(sBuff,_T("CONN RESET")); break; case NET_ERR_CLSD: strcpy(sBuff,_T("CONN CLOSE")); break; case NET_ERR_RTE: strcpy(sBuff,_T("ROUTE ERR")); break; case NET_ERR_ISCONN: strcpy(sBuff,_T("CONN EXIST")); break; case NET_ERR_TIMEOUT: strcpy(sBuff,_T("CONN TIMOUT")); break; case NET_ERR_PASSWD: strcpy(sBuff,_T("PASSWORD ERR")); break; case NET_ERR_MODEM: strcpy(sBuff,_T("PPP FAIL")); break; case NET_ERR_LINKDOWN: case NET_ERR_LOGOUT: case NET_ERR_PPP: strcpy(sBuff,_T("RETRY PPP")); break; default: strcpy(sBuff,_T("UNKNOW ERR")); break; } ScrClrBelow(2); PubDispString(sBuff, DISP_LINE_LEFT|2); //Cielo要求去除返回码, linzhao // sprintf(sBuff, _T("code=%d "), ret_num); // PubDispString(sBuff, DISP_LINE_LEFT|3); PubWaitKey(2); NetCloseSocket(wnet_socket_id); wnet_socket_id = -1; return -1; } else return 0; }
//输入WIFI 密码 int GetWifiKey(uchar *psName, int iSecMode, uchar *psOut) { uchar ucRet; uchar ucTempBuf[100]; uchar ucWEPMode; if (iSecMode < 1 || iSecMode > 3) { return 0; } ScrCls(); PubDispString(psName, DISP_LINE_CENTER|1); if(iSecMode == 1) { PubDispString(_T("SELECT WEP MODE"), DISP_LINE_CENTER|2); ScrPrint(0, 3, 0, _T("1. ASCII")); ScrPrint(0, 4, 0, _T("2. HEX")); while(1) { ucRet = PubWaitKey(USER_OPER_TIMEOUT); if(ucRet == KEY1) { ucWEPMode = 0; break; } else if(ucRet == KEY2) { ucWEPMode = 1; break; } else if(ucRet == KEYCANCEL || ucRet == NOKEY) { return ucRet; } } ScrClrBelow(2); } PubDispString(_T("TYPE PASSWORD:"), DISP_LINE_CENTER|2); ScrGotoxyEx (0, 96); memset(ucTempBuf, 0, sizeof(ucTempBuf)); if (iSecMode == 1) //WEP { if(glSysCtrl.ucWepMode == 0) //ascii { strcpy(ucTempBuf, glSysCtrl.stAppWifiPara.Wep); } else //hex { PubBcd2Asc0(glSysCtrl.stAppWifiPara.Wep, 5, ucTempBuf); } ucRet = GetString(ucTempBuf, 0xF5, (uchar)(ucWEPMode==0 ? 5:10), (uchar)(ucWEPMode==0 ? 5:10)); glSysCtrl.ucWepMode = ucWEPMode; } else //WPA { strcpy(ucTempBuf, glSysCtrl.stAppWifiPara.Wpa); ucRet = GetString(ucTempBuf, 0xF5, 1, KEY_WPA_MAXLEN); } if (ucRet == 0x00) { if((iSecMode == 1) && (ucWEPMode == 1)) { PubAsc2Bcd(&ucTempBuf[1], ucTempBuf[0], psOut); } else { memcpy(psOut, &ucTempBuf[1], ucTempBuf[0]); } return 0; } if (ucRet == 0x0D) { return 0; } return ucRet; }
//扫描周围的热点 int ScanWifiAps(void) { int i, iRet, iApCount; uchar ucKey, ucTempBuf[100]; ST_WIFI_AP stWifiAps[16]; ScrClrBelow(1); ScrPrint(0, 1, 0, _T("SCANNING AP...")); //scanning ap if(strlen(glSysCtrl.stAppWifiPara.Ssid) != 0) { WifiDisconAp(); } iApCount = 8; memset(&stWifiAps, 0, sizeof(stWifiAps)); iRet = WifiScanAps(&stWifiAps[0], iApCount); if(iRet == 0) { ScrClrBelow(1); ScrPrint(0, 2, 0, _T("NO AVAILABLE AP")); getkey(); return WIFI_ERR_NULL; } if(iRet < 0) { ScrClrBelow(1); ScrPrint(0, 2, 0, "ScanAps err=%d", iRet); getkey(); return WIFI_ERR_SCAN; } ScrCls(); PubDispString(_T("SEARCH NETWORK"), DISP_LINE_CENTER|0); //please select //显示搜索到的热点 for (i=0; i<iRet; i++) { ScrPrint(0, (uchar)(i + 1), 0, "%d - %s",i, stWifiAps[i].Ssid); } while (1) { kbflush(); ucKey = PubWaitKey(USER_OPER_TIMEOUT); if (ucKey == KEYCANCEL || ucKey == NOKEY) { return ucKey; //modify by wuc 2014.4.1 } i = ucKey - 0x30; if(i<0 || i>iRet) { continue; } break; } strcpy(glSysCtrl.stAppWifiPara.Ssid, stWifiAps[i].Ssid); //判断是否需要密码 if(stWifiAps[i].SecMode == 0) //无加密 { glSysCtrl.stAppWifiPara.SecMode = 0; } else if(stWifiAps[i].SecMode == 1) //WEP加密 { glSysCtrl.stAppWifiPara.SecMode = 1; memset(ucTempBuf, 0, sizeof(ucTempBuf)); iRet = GetWifiKey(stWifiAps[i].Ssid, stWifiAps[i].SecMode, ucTempBuf); if(iRet) { return iRet; } strcpy(glSysCtrl.stAppWifiPara.Wep, ucTempBuf); } else if(stWifiAps[i].SecMode == 2) //WPA/WPA2加密 TKIP { glSysCtrl.stAppWifiPara.SecMode = 2; memset(ucTempBuf, 0, sizeof(ucTempBuf)); iRet = GetWifiKey(stWifiAps[i].Ssid, stWifiAps[i].SecMode, ucTempBuf); if(iRet) { return iRet; } strcpy(glSysCtrl.stAppWifiPara.Wpa, ucTempBuf); } else if(stWifiAps[i].SecMode == 3) //WPA-PSK/WPA2-PSK加密 AES { glSysCtrl.stAppWifiPara.SecMode = 3; memset(ucTempBuf, 0, sizeof(ucTempBuf)); iRet = GetWifiKey(stWifiAps[i].Ssid, stWifiAps[i].SecMode, ucTempBuf); if(iRet) { return iRet; } strcpy(glSysCtrl.stAppWifiPara.Wpa, ucTempBuf); } else { ScrClrRect(0, 24, 319, 215); ScrGotoxyEx(0, 24); Lcdprintf("%s\n", stWifiAps[i].Ssid); Lcdprintf(_T("UNSUPPORTED MODE\n")); getkey(); return WIFI_ERR_CANCEL; } return 0; }
int ShowLastAP(void) //add by wuc 2014.9.9 { int iRet; //读取参数并显示 kbflush(); ScrCls(); //add by wuc 2014.1.10 PubDispString(_T("CONFIGURATIONS"), DISP_LINE_CENTER|0); if(strlen(glSysCtrl.stAppWifiPara.Ssid) == 0) { ScrPrint(0, 1, 0, _T("NO AP CONNECTED")); } else { ScrPrint(0, 1, 0, _T("NETWORK: %s\n"), glSysCtrl.stAppWifiPara.Ssid); if (glSysCtrl.stAppWifiPara.SecMode == 1) { if(glSysCtrl.ucWepMode == 0) { ScrPrint(0, 2, 0, _T("MODE:WEP(ASCII)")); ScrPrint(0, 3, 0, _T("PASSWORD:%s\n"), glSysCtrl.stAppWifiPara.Wep); } else { ScrPrint(0, 2, 0, _T("MODE:WEP(HEX)")); ScrPrint(0, 3, 0, _T("PASSWORD:%02x%02x%02x%02x%02x\n"), glSysCtrl.stAppWifiPara.Wep[0], glSysCtrl.stAppWifiPara.Wep[1], glSysCtrl.stAppWifiPara.Wep[2], glSysCtrl.stAppWifiPara.Wep[3], glSysCtrl.stAppWifiPara.Wep[4]); } } else if (glSysCtrl.stAppWifiPara.SecMode == 2) { ScrPrint(0, 2, 0, _T("MODE:WPA/WPA2")); ScrPrint(0, 3, 0, _T("PASSWORD:%s\n"), glSysCtrl.stAppWifiPara.Wpa); } else if (glSysCtrl.stAppWifiPara.SecMode == 3) { ScrPrint(0, 2, 0, _T("MODE:WPA-PSK/WPA2-PSK")); ScrPrint(0, 3, 0, _T("PASSWORD:%s\n"), glSysCtrl.stAppWifiPara.Wpa); } else { ScrPrint(0, 2, 0, _T("MODE:NONE")); } if (glSysCtrl.stAppWifiPara.DhcpEnable == 1) { ScrPrint(0, 4, 0, _T("DHCP: OPEN")); } else { ScrPrint(0, 4, 0, _T("DHCP: CLOSE")); } } PubDispString(_T("(PRESS ENTER TO CONTINUE)"), DISP_LINE_CENTER|6); while(1) { iRet = PubWaitKey(USER_OPER_TIMEOUT); if(iRet == KEYCANCEL || iRet == NOKEY) { return iRet; } if(iRet == KEYENTER) { break; } } return 0; }
int Ssl_Connect( char *szRemoteIP, short RemotePort, int TimeOutSec ) { int iRet, iEvent; int length; SSL_BUF_T pos_ca; SSL_BUF_T pos_cert; SSL_BUF_T pos_privatekey; SSL_BUF_T pos_certs[2]; char pos_ca_pem[2048]; char pos_cert_pem[2048]; char pos_privatekey_pem[2048]; // char pos_ca_buf[2048]; char pos_cert_buf[2048]; // char pos_privatekey_buf[2048]; //linzhao 0331 DebugOutput("%s--%d iSSLSocket:%d\n", __FILE__, __LINE__, iSSLSocket); if (iSSLSocket>=0) { /* iEvent = Netioctl(iSSLSocket, CMD_TO_GET, 0); DebugOutput("%s--%d iEvent:%d\n", __FILE__, __LINE__, iEvent); if (iEvent&(SOCK_EVENT_CONN|SOCK_EVENT_READ|SOCK_EVENT_WRITE)) { return 0; } */ return 0; } SslSetNetOps( &stSslNetOps ); //Let SSL module know how to perform TCP/IP operations(open, send, receive and close) DebugOutput("%s--%d,SslSetNetOps\n", __FILE__, __LINE__); memset( &stSslSysOps, 0, sizeof(SSL_SYS_OPS) ); stSslSysOps.ServCertAck = OurServCertAck; SslSetSysOps( &stSslSysOps ); //Define some system related call back functions to use by SSL module //* // begin: 证书验证 length = 0; memset(pos_ca_pem, 0, sizeof(pos_ca_pem)); memset(pos_cert_pem, 0, sizeof(pos_cert_pem)); memset(pos_privatekey_pem, 0, sizeof(pos_privatekey_pem)); iRet = ReadPemFile(CER_FILE, pos_ca_pem, pos_cert_pem, pos_privatekey_pem); DebugOutput("%s--%d--%s, ReadPemFile iRet:%d\n", __FILE__, __LINE__, __FUNCTION__, iRet); if (iRet == 0) { pos_ca.size = 0; pos_ca.ptr = NULL; length = 0; memset(pos_cert_buf, 0, sizeof(pos_cert_buf)); length = SslDecodePem(pos_cert_pem, strlen(pos_cert_pem), pos_cert_buf, sizeof(pos_cert_buf)); if (length <= 0) { ScrPrint(0, 6, 1, _T("ssl Cert wrong!")); PubWaitKey(30); return ERR_NO_DISP; } pos_cert.size = length; pos_cert.ptr = pos_cert_buf; pos_privatekey.size = 0; pos_privatekey.ptr = NULL; } // end: for 证书验证 //*/ iRet = SslCreate(); if ( iRet < 0 ) { return iRet; } iSSLSocket = iRet; DebugOutput("%s--%d--%s, iSSLSocket:%d\n", __FILE__, __LINE__, __FUNCTION__, iSSLSocket); pos_certs[0] = pos_cert; pos_certs[1] = pos_ca; iRet = SslCertsSet(iSSLSocket, 0, 0, NULL, pos_certs, 1, &pos_privatekey); DebugOutput("%s--%d--%s, SslCertsSet iRet:%d\n", __FILE__, __LINE__, __FUNCTION__, iRet); if (iRet < 0) { ScrPrint(0, 6, 1, "SslCertsSet=%d", iRet); PubWaitKey(30); return iRet; } iRet = SslConnect( iSSLSocket, szRemoteIP, RemotePort, 0, 0 ); DebugOutput("%s--%d--%s, sslConnect:[%s:%d]=[%d], iSSLSocket:%d\n", __FILE__, __LINE__, __FUNCTION__, szRemoteIP, RemotePort, iRet, iSSLSocket); //you wen ti if ( iRet != 0 && 0==SslClose( iSSLSocket ))//linzhao { DebugOutput("%s--%d, iSSLSocket:%d, s_iSocket:%d\n", __FILE__, __LINE__, iSSLSocket, s_iSocket); iSSLSocket = -1; s_iSocket = -1;//linzhao } DebugOutput("%s--%d--%s, iSSLSocket:%d\n", __FILE__, __LINE__, __FUNCTION__, iSSLSocket); return iRet; }
void TerminalSignOn(void) { int iRet; ST_KEY_INFO KeyInfoIn = {0}; ST_KCV_INFO KcvInfoIn = {0}; memcpy(&glCurAcq, &glSysParam.stAcqList[1], sizeof(ACQUIRER)); //set the default Acq by richard 20170223 iRet = TransInit(LOGON); if( iRet!=0 ) { return iRet; } SaveRevInfo(FALSE); //for test, TODO need to delete, ScrCls(); PubDispString(_T("TERM SIGNON"), 0 | DISP_LINE_LEFT | DISP_LINE_REVER); SetKeyCommfield(KEY_TYPE_TPK); //set field63 memcpy(glSendPack.sField63, "\x00\x03", 2); memcpy(glSendPack.sField63+2, "000", 3); iRet = SendRecvPacket(); if(iRet!=0) { return iRet; } if( memcmp(glProcInfo.stTranLog.szRspCode, "00", 2)!=0 ) { return -1; } //TODO , deal with other response field data. //get the TPK and check value KeyInfoIn.iDstKeyLen = 16; KcvInfoIn.aucCheckBuf[0] = 0x04; memcpy(KeyInfoIn.aucDstKeyValue, glRecvPack.sField62+2, 16); memcpy(KcvInfoIn.aucCheckBuf+1, glRecvPack.sField62+18, 4); KeyInfoIn.ucSrcKeyType = PED_TMK; KeyInfoIn.ucSrcKeyIdx = CUP_TMK_ID; KeyInfoIn.ucDstKeyType = PED_TPK; KeyInfoIn.ucDstKeyIdx = CUP_TPK_ID; KcvInfoIn.iCheckMode = 0x01; iRet = PedWriteKey(&KeyInfoIn, &KcvInfoIn); if(iRet != 0) { ScrClrLine(2, 7); PubDispString(_T("SignOn Failed!"), 3 | DISP_LINE_CENTER); PubWaitKey(3); } else { PubBeepOk(); ScrClrLine(2, 7); PubDispString(_T("SignOn SUCCESS!"), 3 | DISP_LINE_CENTER); PubWaitKey(3); } }