void AvFormatDecoderDVD::PostProcessTracks(void) { if (!ringBuffer) return; if (!ringBuffer->IsDVD()) return; if (tracks[kTrackTypeAudio].size() > 1) { stable_sort(tracks[kTrackTypeAudio].begin(), tracks[kTrackTypeAudio].end()); sinfo_vec_t::iterator it = tracks[kTrackTypeAudio].begin(); for (; it != tracks[kTrackTypeAudio].end(); ++it) { LOG(VB_PLAYBACK, LOG_INFO, QString("DVD Audio Track Map Stream id #%1, MPEG stream %2") .arg(it->stream_id) .arg(ic->streams[it->av_stream_index]->id)); } int trackNo = ringBuffer->DVD()->GetTrack(kTrackTypeAudio); if (trackNo >= (int)GetTrackCount(kTrackTypeAudio)) trackNo = GetTrackCount(kTrackTypeAudio) - 1; SetTrack(kTrackTypeAudio, trackNo); } if (tracks[kTrackTypeSubtitle].size() > 0) { stable_sort(tracks[kTrackTypeSubtitle].begin(), tracks[kTrackTypeSubtitle].end()); sinfo_vec_t::iterator it = tracks[kTrackTypeSubtitle].begin(); for(; it != tracks[kTrackTypeSubtitle].end(); ++it) { LOG(VB_PLAYBACK, LOG_INFO, QString("DVD Subtitle Track Map Stream id #%1 ") .arg(it->stream_id)); } stable_sort(tracks[kTrackTypeSubtitle].begin(), tracks[kTrackTypeSubtitle].end()); int trackNo = ringBuffer->DVD()->GetTrack(kTrackTypeSubtitle); uint captionmode = m_parent->GetCaptionMode(); int trackcount = (int)GetTrackCount(kTrackTypeSubtitle); if (captionmode == kDisplayAVSubtitle && (trackNo < 0 || trackNo >= trackcount)) { m_parent->EnableSubtitles(false); } else if (trackNo >= 0 && trackNo < trackcount && !ringBuffer->IsInDiscMenuOrStillFrame()) { SetTrack(kTrackTypeSubtitle, trackNo); m_parent->EnableSubtitles(true); } } }
// Unarchive status_t TrackProperties::Unarchive(const BMessage* from) { if (from == NULL) return B_BAD_VALUE; // restore track, error is not acceptable uint32 track; if (from->FindUInt32("track", &track) < B_OK) return B_ERROR; SetTrack(track); // restore enabled bool enabled; if (from->FindBool("enabled", &enabled) != B_OK) enabled = true; SetEnabled(enabled); // restore name const char* name; if (from->FindString("name", &name) != B_OK) name = ""; SetName(name); // restore alpha uint8 alpha; if (from->FindUInt8("alpha", &alpha) != B_OK) alpha = 255; SetAlpha(alpha); return B_OK; }
//----------------------------------------------------------------------------- // Purpose: // Input : *pInitData - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CDemoActionCDTrackStart::Init( KeyValues *pInitData ) { if ( !BaseClass::Init( pInitData ) ) return false; SetTrack( pInitData->GetInt( "track", -1 ) ); return true; }
void AvFormatDecoderDVD::PostProcessTracks(void) { if (!ringBuffer) return; if (!ringBuffer->IsDVD()) return; if (tracks[kTrackTypeAudio].size() > 1) { stable_sort(tracks[kTrackTypeAudio].begin(), tracks[kTrackTypeAudio].end()); int trackNo = -1; int dvdTrack = ringBuffer->DVD()->GetTrack(kTrackTypeAudio); for (uint i = 0; i < GetTrackCount(kTrackTypeAudio); i++) { LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("DVD Audio Track Map Stream id #%1, av_stream_idx %2, MPEG stream 0x%3, lang %4") .arg(tracks[kTrackTypeAudio][i].stream_id) .arg(tracks[kTrackTypeAudio][i].av_stream_index) .arg(ic->streams[tracks[kTrackTypeAudio][i].av_stream_index]->id,0,16) .arg(iso639_key_toName(tracks[kTrackTypeAudio][i].language))); // Find the audio track in our list that maps to the // selected track in the ringbuffer (the ringbuffer's // list should be in the same order but can have gaps, // so we look for the track with the same index) if (tracks[kTrackTypeAudio][i].stream_id == dvdTrack) trackNo = i; } if (trackNo < 0 && GetTrackCount(kTrackTypeAudio) > 0) { // Take the first track trackNo = 0; } if (trackNo >= 0) SetTrack(kTrackTypeAudio, trackNo); } if (tracks[kTrackTypeSubtitle].size() > 0) { map<int,uint> lang_sub_cnt; map<int,int> stream2idx; // First, create a map containing stream id -> track index // of the subtitle streams that have been found so far. for (uint n = 0; n < GetTrackCount(kTrackTypeSubtitle); n++) { int stream_id = tracks[kTrackTypeSubtitle][n].stream_id & 0x1f; stream2idx[stream_id] = n; } // Get all subtitle tracks from the DVD and filter out any that // are not mapped in the current program chain. sinfo_vec_t filteredTracks; if (!ringBuffer->DVD()->IsInMenu()) { for (uint i = 0; i < 32; ++i) { int streamid = ringBuffer->DVD()->GetSubtitleTrackNum(i); if (streamid >= 0) { // This stream is mapped in the current program chain int lang = ringBuffer->DVD()->GetSubtitleLanguage(i); int lang_indx = lang_sub_cnt[lang]++; int trackNo = -1; if (stream2idx.count(streamid) != 0) trackNo = stream2idx[streamid]; if (trackNo == -1) { // Create a dummy track if the physical stream has not // yet been seen. filteredTracks.push_back(StreamInfo(-1, lang, lang_indx, streamid, 0, 0, false, false, false)); } else { // Otherwise use the real data filteredTracks.push_back(tracks[kTrackTypeSubtitle][trackNo]); filteredTracks.back().stream_id &= 0x1f; filteredTracks.back().language = lang; filteredTracks.back().language_index = lang_indx; } } } } tracks[kTrackTypeSubtitle] = filteredTracks; stable_sort(tracks[kTrackTypeSubtitle].begin(), tracks[kTrackTypeSubtitle].end()); int trackNo = -1; int selectedStream = ringBuffer->DVD()->GetTrack(kTrackTypeSubtitle); // Now iterate over the sorted list and try to find the index of the // currently selected track. for (uint idx = 0; idx < GetTrackCount(kTrackTypeSubtitle); idx++) { const StreamInfo& stream = tracks[kTrackTypeSubtitle][idx]; int avidx = stream.av_stream_index; QString mpegstream; if (avidx >= 0) mpegstream = QString( "0x%1").arg(ic->streams[avidx]->id,0,16); else mpegstream = "n/a"; LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("DVD Subtitle Track Map Stream id #%1, av_stream_idx %2, MPEG #%3, lang %4") .arg(stream.stream_id) .arg(stream.av_stream_index) .arg(mpegstream) .arg(iso639_key_toName(stream.language))); if ((selectedStream != -1) && (stream.stream_id == selectedStream)) trackNo = (int)idx; } uint captionmode = m_parent->GetCaptionMode(); int trackcount = (int)GetTrackCount(kTrackTypeSubtitle); if (captionmode == kDisplayAVSubtitle && (trackNo < 0 || trackNo >= trackcount)) { m_parent->EnableSubtitles(false); } else if (trackNo >= 0 && trackNo < trackcount) { SetTrack(kTrackTypeSubtitle, trackNo); m_parent->EnableSubtitles(true); } } }
//预授权完成 int CTradePreAuthCptReq::DoPack(SAConnection *saConn, void * pNode, unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----PreAuthCptReq-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cICData[256]={0}; unsigned char bFieldData[FIELD_MAXLEN] = {0}; int iFieldDataLen; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; BYTE bTmpData[FIELD_MAXLEN]={0}; //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); //2账号 bFlag &= sndObj.SetValueByStr(2 , pData->TransData.HeadData.Account); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "003000"); //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); //14卡有效期 iFieldDataLen=0; memset(bFieldData, 0, sizeof(bFieldData)); iFieldDataLen = tlvObj.GetTLVItemByHex(TAG_INPUTEXPDATE, bFieldData, sizeof(bFieldData)); if(iFieldDataLen > 0) { char cExpDate[5]={0}; BcdToAsc((BYTE *)cExpDate,bFieldData,iFieldDataLen); bFlag &= sndObj.SetValueByStr(14, cExpDate); } //F23 卡片序列号 nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(23, cICNO+1); } //32 受理机构代码 bFlag &= sndObj.SetValueByStr(32, pData->RcvBrchCode); //33 发送机构代码 bFlag &= sndObj.SetValueByStr(33, pData->SndBrchCode); /**< 磁道处理*/ if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; }else{ trace_log(DBG, "SetTrack SUCCESS"); } //37系统参考号 bFlag &= sndObj.SetValueByStr(37, pData->TransData.HeadData.SysRefNo); //38授权码 bFlag &= sndObj.SetValueByStr(38, pData->TransData.HeadData.OrigAuthCode); //41终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); /**< 52密码*/ if(SetPinKey(pData, tlvObj,bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; }else{ trace_log(DBG, "SetPinKey SUCCESS"); } //55 C卡数据域 nTlvLen= tlvObj.GetTLVItemByHex(TAG_FIELD55_RSP, (BYTE *)cICData, sizeof(cICData)); if(nTlvLen>0) { bFlag &= sndObj.SetValueByHex(55, (BYTE *)cICData,nTlvLen); } /**< 22服务点输入方式码*/ bFlag &= sndObj.SetValueByStr(22,(char*)pData->TransData.HeadData.SvrPointCode); //60 应用版本 bFlag &= sndObj.SetValueByStr(60, "310"); //62 凭证号批次号 memset(bTmpData, 0, sizeof(bTmpData)); sprintf((char *)bTmpData, "%s%s", pData->VouchNo, pData->BatchNo); bFlag &= sndObj.SetValueByStr(62, (char *)bTmpData); //64MAC bFlag &= sndObj.SetValueByHex(64, (unsigned char*)"00000000", 8); /**< 组包*/ iBufLen = PACK_MAXLEN; bFlag &= sndObj.Pack(pBuffer, iBufLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 计算Mac */ BYTE bMac[9] = {0},bMab[512]={0}; int nMacLen = 8,nMabLen=0; nMabLen=iBufLen-7-nMacLen; memcpy(bMab,pBuffer+7,nMabLen); GenMacData(pData,bMab,nMabLen,bMac); memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); return RET_SUCCESS; }
int CTradeRepeal::DoPack(SAConnection *saConn, void * pNode, unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----Repeal-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cICData[256]={0},cLField60[18]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; BYTE bTmpData[FIELD_MAXLEN]={0}; //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); //2账号 bFlag &= sndObj.SetValueByStr(2 , pData->TransData.HeadData.Account); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "200000"); //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); SetDateTime(); /**< 设置时间12域和日期13域 */ //F23 卡片序列号 /*nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(23, cICNO+1); }*/ //NII bFlag &= sndObj.SetValueByStr(24,"009"); //服务点条件码 bFlag &= sndObj.SetValueByStr(25,"14"); //32 受理机构代码 bFlag &= sndObj.SetValueByStr(32, pData->RcvBrchCode); //33 发送机构代码 if(strlen(pData->SndBrchCode) > 0) bFlag &= sndObj.SetValueByStr(33, pData->SndBrchCode); /**< 磁道处理*/ if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; }else{ trace_log(DBG, "SetTrack SUCCESS"); } //38授权码 if(strlen(pData->TransData.HeadData.OrigAuthCode) > 0) { bFlag &= sndObj.SetValueByStr(38, pData->TransData.HeadData.OrigAuthCode); } //终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); /**< 52密码*/ if(SetPinKey(pData, tlvObj,bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; }else{ trace_log(DBG, "SetPinKey SUCCESS"); } /* //55 IC卡数据域 nTlvLen= tlvObj.GetTLVItemByHex(TAG_FIELD55_RSP, (BYTE *)cICData, sizeof(cICData)); if(nTlvLen>0) { // bFlag &= sndObj.SetValueByHex(55, (BYTE *)cICData,nTlvLen); }else{ char cTrace[128]={0}; tlvObj.GetTLVItemByHex(TAG_TRACK2,(unsigned char*) cTrace, sizeof(cTrace)); int i=0; for(i=0;i<strlen(cTrace);i++) { if(0==memcmp(cTrace+i,"D",1)) { if((0==memcmp(cTrace+i+5,"2",1)||0==memcmp(cTrace+i+5,"6",1))) { memcpy(pData->TransData.HeadData.RspCode,"45",2); strcpy(pData->TransData.HeadData.RspDecs,"不允许降级交易"); return RET_PACK; }else{ break; } } } } */ /**< 22服务点输入方式码*/ bFlag &= sndObj.SetValueByStr(22,"021");//(char*)pData->TransData.HeadData.SvrPointCode //61凭证号批次号 nTlvLen= tlvObj.GetTLVItemByHex(TAG_RESERVED1, (BYTE *)cLField60, sizeof(cLField60)); memset(bTmpData, 0, sizeof(bTmpData)); if(nTlvLen>=6) { char cF60[18]={0}; BcdToAsc((BYTE *)cF60,(BYTE *)cLField60,nTlvLen); sprintf((char *)bTmpData, "%s%s%s%s%s", pData->BatchNo, "001","000000","00","0000000000"); memcpy(bTmpData+27,cF60+11,2); }else{ sprintf((char *)bTmpData, "%s%s%s", pData->BatchNo, "001","000000"); } bFlag &= sndObj.SetValueByStr(61, (char *)bTmpData); //62原始交易信息(信息类型码,系统跟踪号,交易日期和时间) memset(bTmpData, 0, sizeof(bTmpData)); sprintf((char *)bTmpData, "%s%s%s","0200", pData->TransData.HeadData.OrigLPosSeq, pData->cOri_DateTime); bFlag &= sndObj.SetValueByStr(62, (char *)bTmpData); //64MAC bFlag &= sndObj.SetValueByHex(64, (unsigned char*)"00000000", 8); /**< 组包*/ iBufLen = PACK_MAXLEN; if(!sndObj.Pack(pBuffer, iBufLen)) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 计算Mac */ BYTE bMac[9] = {0}; int nMacLen = 8; GenMacData(pData,sndObj,bMac); memcpy(pBuffer + iBufLen - nMacLen, bMac, nMacLen); return RET_SUCCESS; }
//预授权完成 int CTradePreAuthCptReq::DoPack(SAConnection *saConn, void * pNode, unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----PreAuthCptReq-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cICData[256]={0},cLField60[18]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; BYTE bTmpData[FIELD_MAXLEN]={0}; //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); //2账号 bFlag &= sndObj.SetValueByStr(2 , pData->TransData.HeadData.Account); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "000000"); //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); //SetDateTime(); /**< 设置时间12域和日期13域 */ //F22服务点输入码 bFlag &= sndObj.SetValueByStr(22, (char *)pData->TransData.HeadData.SvrPointCode); //F23 卡片序列号 nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(23, cICNO+1); } //NII //bFlag &= sndObj.SetValueByStr(24,"009"); //服务点条件码 bFlag &= sndObj.SetValueByStr(25,"06"); //32 受理机构代码 bFlag &= sndObj.SetValueByStr(32, g_Cfg.RcvBrchCode); //33 发送机构代码 //bFlag &= sndObj.SetValueByStr(33, pData->SndBrchCode); /**< 磁道处理*/ if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; }else{ trace_log(DBG, "SetTrack SUCCESS"); } //38授权码 if(strlen(pData->TransData.HeadData.OrigAuthCode) > 0) { bFlag &= sndObj.SetValueByStr(38, pData->TransData.HeadData.OrigAuthCode); } //终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); /**< 52密码*/ if(SetPinKey(pData, tlvObj,bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; }else{ trace_log(DBG, "SetPinKey SUCCESS"); } //53安全控制信息 bFlag &= sndObj.SetValueByStr(53, "2610000000000000"); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //55 C卡数据域 nTlvLen= tlvObj.GetTLVItemByHex(TAG_FIELD55_RSP, (BYTE *)cICData, sizeof(cICData)); if(nTlvLen>0) { bFlag &= sndObj.SetValueByHex(55, (BYTE *)cICData,nTlvLen); } //60自定义域 memset(cLField60,0x00,sizeof(cLField60)); memcpy(cLField60,"20",2); strcat((char *)cLField60,(char *)pData->BatchNo); strcat((char *)cLField60,(char *)"000"); //strcat((char *)cLField60,(char *)"501"); bFlag &= sndObj.SetValueByStr(60, (char *)cLField60); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //62原始交易信息(信息类型码,系统跟踪号,交易日期和时间) memset(bTmpData, 0, sizeof(bTmpData)); sprintf((char *)bTmpData, "%s%s%s",pData->TransData.HeadData.OrigLBatchNo, pData->TransData.HeadData.OrigLPosSeq,pData->cOri_DateTime); bFlag &= sndObj.SetValueByStr(61, (char *)bTmpData); //64MAC bFlag &= sndObj.SetValueByHex(64, (unsigned char*)"00000000", 8); /**< 组包*/ iBufLen = PACK_MAXLEN; bFlag &= sndObj.Pack(pBuffer, iBufLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 计算Mac */ BYTE bMac[9] = {0}; int nMacLen = 8,iRet = 0; BYTE bMab[512] = {0}; memcpy(bMab,pBuffer+13,iBufLen-21); iRet = GenMacData(pData,bMab,iBufLen-21,bMac); if(iRet != 0) return -1; memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); return RET_SUCCESS; }
int CTradeConsume::DoPack(SAConnection *saConn, void * pNode,unsigned char * pBuffer, unsigned & iBufLen) { if( NULL == saConn || NULL == pNode || NULL == pBuffer ) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----Consume-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cICData[256]={0},cLField60[18]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); //银联--消费:0200 //2账号 bFlag &= sndObj.SetValueByStr(2 , pData->TransData.HeadData.Account); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "000000"); //银联--消费:000000 --未选卡种 //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); //7 交易传输时间 bFlag &= sndObj.SetValueByHex(7 ,(unsigned char*) (pData->cDateTime+4),10); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); //12本地交易时间 bFlag &= sndObj.SetValueByHex(12,(unsigned char*) (pData->cDateTime+8),6); //13本地交易日期 bFlag &= sndObj.SetValueByHex(13, (unsigned char*) (pData->cDateTime+4),4); //18 商户类型 n4 bFlag &=sndObj.SetValueByStr(18,pData->cMcc); //25服务点条件码 bFlag &= sndObj.SetValueByStr(25, "00"); //00 正常提交 //32 受理机构标识码 bFlag &=sndObj.SetValueByStr(32,pData->RcvBrchCode); //33 发送机构标识码 bFlag &=sndObj.SetValueByStr(33,pData->SndBrchCode); //F37 检索参考号 bFlag &= sndObj.SetValueByStr(37, pData->cReference); //41终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); //43收卡方名称地址 bFlag &=sndObj.SetValueByStr(43,pData->TransData.HeadData.RPrintMerName); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); //F22服务点输入码 n3 即持卡人数据(如PAN和PIN)的输入方式 如:020 021 050 051 bFlag &= sndObj.SetValueByStr(22, (char *)pData->TransData.HeadData.SvrPointCode); ///F23 卡片序列号 nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(23, cICNO+1); } bool bIC = false; ///55 IC卡数据域 nTlvLen= tlvObj.GetTLVItemByHex(TAG_FIELD55_RSP, (BYTE *)cICData, sizeof(cICData)); if(nTlvLen>0) { bFlag &= sndObj.SetValueByHex(55, (BYTE *)cICData,nTlvLen); bIC=true; } else { char cTrace[128]={0}; tlvObj.GetTLVItemByHex(TAG_TRACK2,(unsigned char*) cTrace, sizeof(cTrace)); int i=0; for(i=0;i<strlen(cTrace);i++) { if(0==memcmp(cTrace+i,"D",1)) { if((0==memcmp(cTrace+i+5,"2",1)||0==memcmp(cTrace+i+5,"6",1))) { memcpy(pData->TransData.HeadData.RspCode,"45",2); strcpy(pData->TransData.HeadData.RspDecs,"不允许降级交易"); return RET_PACK; }else{ break; } } } } // 35 36磁道处理 if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; } trace_log(DBG, "SetTrack SUCCESS"); // 52密码 trace_log(DBG, "pData->TransData.HeadData.SvrPointCode[2]==%c",pData->TransData.HeadData.SvrPointCode[2]); if(0==memcmp((char *)&(pData->TransData.HeadData.SvrPointCode[2]),"1",1)) { if(SetPinKey(pData, tlvObj, bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; } trace_log(DBG, "SetPinKey SUCCESS"); //53安全控制信息 bFlag &= sndObj.SetValueByStr(53, "2600000000000000"); //26服务点PIN获取码 该域描述了服务点设备所能接受的PIN所能容纳的最多字符数 bFlag &= sndObj.SetValueByStr(26, "06"); } //60 域 BYTE F60[101]={0}; int iLen=0; memcpy(F60,"0000",4); //60.1 交易类型为 0200 时 填充 0000 iLen+=4; memcpy(F60+iLen,"0",1);//60.2.1 //保留使用,填充“0” iLen+=1; memcpy(F60+iLen,"5",1);//60.2.2 // 0 终端读取能力不可知 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.3 //0 未使用或后续子域存在 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.4 //保留使用,填充“0” iLen+=1; memcpy(F60+iLen,"03",2);//60.2.5 //03 销售点终端 11 移动POS iLen+=2; memcpy(F60+iLen,"0",1);//60.2.6 //保留使用,填充“0” iLen+=1; memcpy(F60+iLen,"0",1);//60.2.7 //第8位或后继位存在时的填充值 iLen+=1; memcpy(F60+iLen,"00",2);//60.2.8 //保留使用 iLen+=2; memcpy(F60+iLen,"00",2);//60.3 //60.3 业务种类定义 iLen+=2; memcpy(F60+iLen,"0000",4);//60.4 //60.4 行业卡种类 iLen+=4; bFlag &=sndObj.SetValueByStr(60,(char *)F60); //128MAC bFlag &= sndObj.SetValueByHex(128, (unsigned char*)"00000000", 8); // 组包 iBufLen = PACK_MAXLEN; bFlag &= sndObj.Pack(pBuffer, iBufLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } // 计算Mac // BYTE bMac[9] = {0}; int nMacLen = 8; if( 0 != GenMacData(pData,sndObj,bMac) ) { return RET_GETMACERR; } memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); //trace_log(DBG,"pBuffer[%d]=",iBufLen); //trace_mem(pBuffer,iBufLen); return RET_SUCCESS; }
int CTradeRepeal::DoPack(SAConnection *saConn, void * pNode, unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----Repeal-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cLField60[18]={0},cLField61[20]={0},cLField62[32]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); //2账号 bFlag &= sndObj.SetValueByStr(2 , pData->TransData.HeadData.Account); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "200000"); //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); //f14 卡有效期 BYTE field14[6]={0}; BYTE field14ASC[6]={0}; nTlvLen=tlvObj.GetTLVItemByHex(TAG_EXPDATE,(BYTE *)field14,sizeof(field14)); BcdToAsc((BYTE *)field14,(BYTE *)field14ASC,nTlvLen); if(nTlvLen>0) { bFlag &=sndObj.SetValueByStr(14,(char *)field14ASC); } else { bFlag &=sndObj.SetValueByStr(14,"0000"); } /**< 22服务点输入方式码*/ bFlag &= sndObj.SetValueByStr(22,(char*)pData->TransData.HeadData.SvrPointCode); //SetDateTime(); /**< 设置时间12域和日期13域 */ //F23 卡片序列号 nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(23, cICNO+1); } //服务点条件码 bFlag &= sndObj.SetValueByStr(25,"00"); //26服务点PIN获取码 bFlag &= sndObj.SetValueByStr(26, "06"); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //32 受理方标识码 //bFlag &=sndObj.SetValueByStr(32,"90000118"); /**< 磁道处理*/ if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; }else{ trace_log(DBG, "SetTrack SUCCESS"); } //37参考号 bFlag &= sndObj.SetValueByStr(37, pData->TransData.HeadData.SysRefNo); //38授权码 if(strlen(pData->TransData.HeadData.OrigAuthCode) > 0) { bFlag &= sndObj.SetValueByStr(38, pData->TransData.HeadData.OrigAuthCode); } //终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); /**< 52密码*/ if(SetPinKey(pData, tlvObj,bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; }else{ trace_log(DBG, "SetPinKey SUCCESS"); } //60自定义域 memset(cLField60,0x00,sizeof(cLField60)); strcpy((char *)cLField60,(char *)"23"); strcat((char *)cLField60,(char *)pData->BatchNo); strcat((char *)cLField60,(char *)"000"); strcat((char *)cLField60,(char *)"501"); bFlag &= sndObj.SetValueByStr(60, (char *)cLField60); //61自定义域 memset(cLField61,0x00,sizeof(cLField61)); strcpy((char *)cLField61,(char *)pData->TransData.HeadData.OrigLBatchNo); strcat((char *)cLField61,(char *)pData->TransData.HeadData.OrigLPosSeq); bFlag &= sndObj.SetValueByStr(61, (char *)cLField61); //62域 memset(cLField62,0x00,sizeof(cLField62)); memcpy(cLField62,"SD=",3); strcat((char *)cLField62,g_Cfg.RcvBrchCode); bFlag &= sndObj.SetValueByStr(62, (char *)cLField62); //63 自定义域 //bFlag &= sndObj.SetValueByStr(63, (char *)"999"); //64MAC bFlag &= sndObj.SetValueByHex(64, (unsigned char*)"00000000", 8); /**< 组包*/ iBufLen = PACK_MAXLEN; if(!sndObj.Pack(pBuffer, iBufLen)) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 计算Mac */ BYTE bMac[9] = {0}; int nMacLen = 8; int iRet = 0; BYTE bMab[512] = {0}; memcpy(bMab,pBuffer+13,iBufLen-21); iRet = GenMacData(pData,bMab,iBufLen-21,bMac); if(iRet != 0) return iRet; memcpy(pBuffer + iBufLen - nMacLen, bMac, nMacLen); return RET_SUCCESS; }
int CTradeDoReset::DoPack(SAConnection *saConn, void * pNode, unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----DoReset-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cLField60[18]={0},cICData[256]={0},cLField61[20]={0}; bool bHasTrack = false; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } //冲正的时候不能隔批次 if(strcmp(pData->BatchNo, pData->TransData.HeadData.OrigLBatchNo)) { trace_log(ERR, "The original BatchNo is different with the current one"); return RET_SYSEXP; } //获取冲正数据并打包 if(COperateDB::GetResetData(saConn, pData,&sndObj)!=0) { trace_log(ERR, "GetResetData faile"); return RET_SYSEXP; } bool bFlag = true; //打包冲正剩余数据 //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0400"); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "000000"); //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); //11原交易流水 bFlag &= sndObj.SetValueByStr(11 , (char *)pData->TransData.HeadData.OrigLPosSeq); //14卡有效期 nTlvLen= tlvObj.GetTLVItemByHex(TAG_INPUTEXPDATE, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(14, cICNO); } //22服务点输入代码 bFlag &= sndObj.SetValueByStr(22, (const char *)pData->TransData.HeadData.SvrPointCode); //F23 卡片序列号 nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(23, cICNO+1); } //25服务点条件码 bFlag &= sndObj.SetValueByStr(25,"00"); //32 受理机构标识码 bFlag &=sndObj.SetValueByStr(32,pData->RcvBrchCode); // 35 36磁道处理 if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; } trace_log(DBG, "SetTrack SUCCESS"); //F37 检索参考号 bFlag &= sndObj.SetValueByStr(37, pData->TransData.HeadData.SysRefNo); //F39 应答码 bFlag &= sndObj.SetValueByStr(39, "98"); //41终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); ///55 IC卡数据域 bool bIC = false; nTlvLen= tlvObj.GetTLVItemByHex(TAG_FIELD55_RSP, (BYTE *)cICData, sizeof(cICData)); if(nTlvLen>0) { bFlag &= sndObj.SetValueByHex(55, (BYTE *)cICData,nTlvLen); bIC=true; } else { char cTrace[128]={0}; tlvObj.GetTLVItemByHex(TAG_TRACK2,(unsigned char*) cTrace, sizeof(cTrace)); int i=0; for(i=0;i<strlen(cTrace);i++) { if(0==memcmp(cTrace+i,"D",1)) { if((0==memcmp(cTrace+i+5,"2",1)||0==memcmp(cTrace+i+5,"6",1))) { memcpy(pData->TransData.HeadData.RspCode,"45",2); strcpy(pData->TransData.HeadData.RspDecs,"不允许降级交易"); return RET_PACK; }else{ break; } } } } //60 域 BYTE F60[101]={0}; int iLen=0; if(0==memcmp((char *)&(pData->cOrgTradeType),"q",1)) { trace_log(DBG,"消费撤销"); memcpy(F60,"23",2); //—— 60.1 消息类型码 N2 iLen+=2; memcpy(F60+iLen,pData->BatchNo,6); //—— 60.2 批次号 N6 iLen+=6; //61自定义域 memset(cLField61,0x00,sizeof(cLField61)); strcpy((char *)cLField61,(char *)pData->TransData.HeadData.OrigLBatchNo); strcat((char *)cLField61,(char *)pData->TransData.HeadData.OrigLPosSeq); strcat((char *)cLField61,(char *)pData->cOri_DateTime); bFlag &= sndObj.SetValueByStr(61, (char *)cLField61); } else { trace_log(DBG,"原类型为消费"); memcpy(F60,"22",2); //—— 60.1 消息类型码 N2 iLen+=2; memcpy(F60+iLen,pData->BatchNo,6); //—— 60.2 批次号 N6 iLen+=6; } bFlag &= sndObj.SetValueByStr(60, (char *)F60); //64MAC bFlag &= sndObj.SetValueByHex(64, (unsigned char*)"00000000", 8); /**< 组包*/ iBufLen = PACK_MAXLEN; bFlag &= sndObj.Pack(pBuffer, iBufLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 计算Mac */ BYTE bMac[9] = {0}; int nMacLen = 8; BYTE bMab[512] = {0}; memcpy(bMab,pBuffer+13,iBufLen-13-nMacLen); if(GenMacData(pData,bMab,iBufLen-13-nMacLen,bMac)) { return RET_GETMACERR; } memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); return RET_SUCCESS; }
int CTradeConsume::DoPack(SAConnection *saConn, void * pNode,unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----Consume-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cICData[256]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //2账号 bFlag &= sndObj.SetValueByStr(2 ,pData->TransData.HeadData.Account ); trace_log(DBG,"pData->TransData.HeadData.Account2:%s",pData->TransData.HeadData.Account); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //3处理码 bFlag &= sndObj.SetValueByStr(3 , "190000"); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //7交易金额 bFlag &= sndObj.SetValueByHex(7 ,(unsigned char*) (pData->cDateTime+4),10); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //本地交易时间 bFlag &= sndObj.SetValueByHex(12,(unsigned char*) (pData->cDateTime+8),6); //本地交易日期 bFlag &= sndObj.SetValueByHex(13, (unsigned char*) (pData->cDateTime+4),4); //F22服务点输入码 bFlag &= sndObj.SetValueByStr(22,(char *)pData->TransData.HeadData.SvrPointCode );//"022" if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //F23 卡片序列号 nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(23, cICNO+1); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } } //F25 服务点条件码 bFlag &= sndObj.SetValueByStr(25, "82"); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //F26 服务点PIN获取码 if('1'==pData->TransData.HeadData.SvrPointCode[2]) { bFlag &= sndObj.SetValueByStr(26, "12"); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } } //F32 受理机构标识码 bFlag &= sndObj.SetValueByStr(32, pData->RcvBrchCode); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //F33 发送机构标识码 bFlag &= sndObj.SetValueByStr(33, pData->SndBrchCode); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 磁道处理*/ if(SetTrack(pData, tlvObj, bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; }else{ trace_log(DBG, "SetTrack SUCCESS"); } //F37 检索参考号 bFlag &= sndObj.SetValueByStr(37, pData->cReference); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //41终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //42商户号 bFlag &= sndObj.SetValueByStr(42,pData->TransData.HeadData.arrRMerchNo); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //43受卡方名称地址 char cDest[41]={0}; GBK2UTF8(pData->TransData.HeadData.RPrintMerName,cDest); bFlag &= sndObj.SetValueByStr(43, cDest);//"ME31S" if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 52密码*/ trace_log(DBG,"pData->TransData.HeadData.Account3:%s",pData->TransData.HeadData.Account); if(SetPinKey(pData, tlvObj, bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; }else{ trace_log(DBG, "SetPinKey SUCCESS"); } //53安全控制信息 bFlag &= sndObj.SetValueByStr(53, "2600000000000000"); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } //55 C卡数据域 nTlvLen= tlvObj.GetTLVItemByHex(TAG_FIELD55_RSP, (BYTE *)cICData, sizeof(cICData)); if(nTlvLen>0) { bFlag &= sndObj.SetValueByHex(55, (BYTE *)cICData,nTlvLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } } //128MAC bFlag &= sndObj.SetValueByHex(128, (unsigned char*)"00000000", 8); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 组包*/ iBufLen = PACK_MAXLEN; bFlag &= sndObj.Pack(pBuffer, iBufLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } trace_log(DBG,"sndObj.Pack:"); trace_mem(pBuffer, iBufLen); /**< 计算Mac */ BYTE bMac[9] = {0}; int nMacLen = 8; if(0!=GenMacData(pData,sndObj,bMac)) { return RET_GETMACERR; } memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); return RET_SUCCESS; }
int CTradePreAuthCptRpl::DoPack(SAConnection *saConn, void * pNode, unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----PreAuthCptRpl-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cICData[256]={0},cLField60[18]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; BYTE bTmpData[FIELD_MAXLEN]={0}; memset(&checkData,0,sizeof(checkData)); //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); memcpy(checkData.cMsgType,"0210",4); //2账号 bFlag &= sndObj.SetValueByStr(2 , pData->TransData.HeadData.Account); memcpy(checkData.cAccount,pData->TransData.HeadData.Account,strlen(pData->TransData.HeadData.Account)); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "200000"); //预授权完成撤销:200000 //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); memcpy(checkData.cAmount,pData->TransData.HeadData.ReqAmount,strlen(pData->TransData.HeadData.ReqAmount)); //7交易传输时间 bFlag &= sndObj.SetValueByHex(7 ,(unsigned char*) (pData->cDateTime+4),10); memcpy(checkData.cTransTime,(unsigned char*) (pData->cDateTime+4),10); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); memcpy(checkData.cTraceNo,pData->VouchNo,strlen(pData->VouchNo)); /**< 设置时间12域和日期13域 */ //本地交易时间 bFlag &= sndObj.SetValueByHex(12,(unsigned char*) (pData->cDateTime+8),6); //本地交易日期 bFlag &= sndObj.SetValueByHex(13, (unsigned char*) (pData->cDateTime+4),4); //18 商户类型 bFlag &=sndObj.SetValueByStr(18,pData->cMcc); //25服务点条件码 bFlag &= sndObj.SetValueByStr(25,"06"); //预授权完成撤销:06---预授权请求 //26服务点PIN获取码 //bFlag &= sndObj.SetValueByStr(26, "06"); //32 受理机构代码 bFlag &= sndObj.SetValueByStr(32, pData->RcvBrchCode); //33 发送机构代码 bFlag &= sndObj.SetValueByStr(33, pData->SndBrchCode); /**< 磁道处理*/ if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; }else{ trace_log(DBG, "SetTrack SUCCESS"); } //37参考号 bFlag &= sndObj.SetValueByStr(37, pData->cReference); //38授权码 if(strlen(pData->TransData.HeadData.OrigAuthCode) > 0) { bFlag &= sndObj.SetValueByStr(38, pData->TransData.HeadData.OrigAuthCode); } //41终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); memcpy(checkData.cTermNo,pData->TransData.HeadData.arrRTermNo,strlen(pData->TransData.HeadData.arrRTermNo)); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); memcpy(checkData.cMerchNo, pData->TransData.HeadData.arrRMerchNo,strlen( pData->TransData.HeadData.arrRMerchNo)); //43收卡方名称地址 bFlag &=sndObj.SetValueByStr(43,pData->TransData.HeadData.RPrintMerName); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); /**< 22服务点输入方式码*/ bFlag &= sndObj.SetValueByStr(22, (char *)pData->TransData.HeadData.SvrPointCode); if(0==memcmp((char *)&(pData->TransData.HeadData.SvrPointCode[2]),"1",1)) { // 52密码 if(SetPinKey(pData, tlvObj,bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; }else{ trace_log(DBG, "SetPinKey SUCCESS"); } //53安全控制信息 bFlag &= sndObj.SetValueByStr(53, "2600000000000000"); //26服务点PIN获取码 该域描述了服务点设备所能接受的PIN所能容纳的最多字符数 bFlag &= sndObj.SetValueByStr(26, "06"); } //60 域 BYTE F60[101]={0}; int iLen=0; memcpy(F60,"0000",4); //60.1 交易类型为 0200 时 填充 0000 iLen+=4; memcpy(F60+iLen,"0",1);//60.2.1 //0 个人卡账户 iLen+=1; memcpy(F60+iLen,"5",1);//60.2.2 // 0 终端读取能力不可知 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.3 //0 未使用或后续子域存在 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.4 iLen+=1; memcpy(F60+iLen,"03",2);//60.2.5 iLen+=2; memcpy(F60+iLen,"0",1);//60.2.6 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.7 iLen+=1; memcpy(F60+iLen,"00",1);//60.2.8 //ans2 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.9 // iLen+=1; memcpy(F60+iLen,"00",2);//60.3.1 iLen+=2; memcpy(F60+iLen,"0",1);//60.3.2 iLen+=1; memcpy(F60+iLen,"000",3);//60.3.3 iLen+=3; memcpy(F60+iLen,"0",1);//60.3.4 iLen+=1; memcpy(F60+iLen,"1",1);//60.3.5 //现场 iLen+=1; memcpy(F60+iLen,"1",1);//60.3.6 iLen+=1; memcpy(F60+iLen,"0",1);//60.3.7 iLen+=1; memcpy(F60+iLen,"00",1);//60.3.8 //ans2 iLen+=1; memcpy(F60+iLen,"0",1);//60.3.9 iLen+=1; memcpy(F60+iLen,"00",2);//60.3.10 iLen+=2; bFlag &=sndObj.SetValueByStr(60,(char *)F60); //域90 原始数据元 char f90[43]={0}; int iL=0; memcpy(f90+iL,"0200",4); //90.01 n4 原始交易类型 iL+=4; memcpy(f90+iL,pData->TransData.HeadData.OrigLPosSeq,6); //90.02 n6 原始系统跟踪号 即原始请求报文的域11 iL+=6; memcpy(f90+iL,pData->cOri_DateTime,10); //90.03 n10 原始系统日期时间 即原始请求报文的域7 iL+=10; memcpy(f90+iL,"00000000000",11); memcpy(f90+iL+11-strlen(pData->RcvBrchCode),pData->RcvBrchCode,strlen(pData->RcvBrchCode)); //90.04 n11 原始受理机构标识码 即原始请求报文的域32 右对齐,前补零 iL+=11; memcpy(f90+iL,"00000000000",11); memcpy(f90+iL+11-strlen(pData->SndBrchCode),pData->SndBrchCode,strlen(pData->SndBrchCode)); //90.05 n11 原始发送机构标识码 即原始请求报文的域33 右对齐,前补零 bFlag &=sndObj.SetValueByStr(90,f90); //128MAC bFlag &= sndObj.SetValueByHex(128, (unsigned char*)"00000000", 8); /**< 组包*/ iBufLen = PACK_MAXLEN; bFlag &= sndObj.Pack(pBuffer, iBufLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 计算Mac */ BYTE bMac[9] = {0}; int nMacLen = 8; if(0!=GenMacData(pData,sndObj,bMac)) { return RET_GETMACERR; } memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); return RET_SUCCESS; }
TLSpotify::TTrack::TTrack(sp_track& Track) : m_pTrack ( NULL ), m_Loaded ( SyncWait ) { SetTrack( Track ); }
int CTradeRepeal::DoPack(SAConnection *saConn, void * pNode,unsigned char * pBuffer, unsigned & iBufLen) { if(NULL == saConn || NULL == pNode || NULL == pBuffer) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----Repeal-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cICData[256]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); //2账号 bFlag &= sndObj.SetValueByStr(2 , pData->TransData.HeadData.Account); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "200000"); //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); //7交易传输时间 bFlag &= sndObj.SetValueByHex(7 ,(unsigned char*) (pData->cDateTime+4),10); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); //12本地交易时间 bFlag &= sndObj.SetValueByHex(12,(unsigned char*) (pData->cDateTime+8),6); //13本地交易日期 bFlag &= sndObj.SetValueByHex(13, (unsigned char*) (pData->cDateTime+4),4); //18 商户类型 bFlag &= sndObj.SetValueByStr(18 , pData->cMcc); //25服务点条件码 bFlag &= sndObj.SetValueByStr(25,"00"); //32 受理机构标识码 bFlag &=sndObj.SetValueByStr(32,pData->RcvBrchCode); //33 发送机构标识码 bFlag &=sndObj.SetValueByStr(33,pData->SndBrchCode); //37参考号 bFlag &= sndObj.SetValueByStr(37, pData->TransData.HeadData.SysRefNo); //pData->cReference //38授权码 if(strlen(pData->TransData.HeadData.OrigAuthCode) > 0) { bFlag &= sndObj.SetValueByStr(38, pData->TransData.HeadData.OrigAuthCode); } //41终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); //43收卡方名称地址 bFlag &=sndObj.SetValueByStr(43,pData->TransData.HeadData.RPrintMerName); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); //F22服务点输入码 n3 即持卡人数据(如PAN和PIN)的输入方式 如:020 021 050 051 bFlag &= sndObj.SetValueByStr(22,(char*)pData->TransData.HeadData.SvrPointCode); //F23 卡片序列号 //nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); //if(nTlvLen>0) //{ // char cICNO[5]={0}; // BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); // bFlag &= sndObj.SetValueByStr(23, cICNO+1); //} // 35、36磁道处理 if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; } trace_log(DBG, "SetTrack SUCCESS"); // 52密码 trace_log(DBG, "pData->TransData.HeadData.SvrPointCode[2]==%c",pData->TransData.HeadData.SvrPointCode[2]); if(0==memcmp((char *)&(pData->TransData.HeadData.SvrPointCode[2]),"1",1)) { if(SetPinKey(pData, tlvObj,bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; } trace_log(DBG, "SetPinKey SUCCESS"); //53安全控制信息 bFlag &= sndObj.SetValueByStr(53, "2600000000000000"); //26服务点PIN获取码 bFlag &= sndObj.SetValueByStr(26, "06"); } //60 域 BYTE F60[101]={0}; int iLen=0; memcpy(F60,"0000",4); //60.1 交易类型为 0200 时 填充 0000 iLen+=4; memcpy(F60+iLen,"0",1);//60.2.1 //保留使用,填充“0” iLen+=1; memcpy(F60+iLen,"5",1);//60.2.2 // 0 终端读取能力不可知 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.3 //0 未使用或后续子域存在 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.4 //保留使用,填充“0” iLen+=1; memcpy(F60+iLen,"03",2);//60.2.5 //03 销售点终端 11 移动POS iLen+=2; memcpy(F60+iLen,"0",1);//60.2.6 //保留使用,填充“0” iLen+=1; memcpy(F60+iLen,"0",1);//60.2.7 //第8位或后继位存在时的填充值 iLen+=1; memcpy(F60+iLen,"00",2);//60.2.8 //保留使用 iLen+=2; memcpy(F60+iLen,"00",2);//60.3 //60.3 业务种类定义 iLen+=2; memcpy(F60+iLen,"0000",4);//60.4 //60.4 行业卡种类 iLen+=4; bFlag &=sndObj.SetValueByStr(60,(char *)F60); //域90 原始数据元n42 char f90[43]={0}; int iL=0; memcpy(f90+iL,"0200",4); //90.01 n4 原始交易类型 iL+=4; memcpy(f90+iL,pData->TransData.HeadData.OrigLPosSeq,6); //90.02 n6 原始系统跟踪号 即原始请求报文的域11 iL+=6; memcpy(f90+iL,pData->cOri_DateTime,10); //90.03 n10 原始系统日期时间 即原始请求报文的域7 iL+=10; memcpy(f90+iL,"00000000000",11); memcpy(f90+iL+11-strlen(pData->RcvBrchCode),pData->RcvBrchCode,strlen(pData->RcvBrchCode)); //90.04 n11 原始受理机构标识码 即原始请求报文的域32 右对齐,前补零 iL+=11; memcpy(f90+iL,"00000000000",11); memcpy(f90+iL+11-strlen(pData->SndBrchCode),pData->SndBrchCode,strlen(pData->SndBrchCode)); //90.05 n11 原始发送机构标识码 即原始请求报文的域33 右对齐,前补零 iL+=11; bFlag &=sndObj.SetValueByStr(90, f90); //128MAC bFlag &= sndObj.SetValueByHex(128, (unsigned char*)"00000000", 8); // 组包 iBufLen = PACK_MAXLEN; bFlag &= sndObj.Pack(pBuffer, iBufLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } // 计算Mac BYTE bMac[9] = {0}; int nMacLen = 8; if(0!=GenMacData(pData,sndObj, bMac)) { return RET_GETMACERR; } memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); return RET_SUCCESS; }
int CTradeBalanceQry::DoPack(SAConnection *saConn, void * pNode, unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----BalanceQry-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char /*cICCID[4]={0},*/cICData[256]={0};//cLField60[18]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; memset(&checkData,0,sizeof(checkData)); //0消息类型 bFlag &= sndObj.SetValueByStr(0, "0200"); memcpy(checkData.cMsgType,"0210",4); //2账号 bFlag &= sndObj.SetValueByStr(2, pData->TransData.HeadData.Account); memcpy(checkData.cAccount,pData->TransData.HeadData.Account,strlen(pData->TransData.HeadData.Account)); //3处理码 bFlag &= sndObj.SetValueByStr(3, "300000"); //7交易传输时间 bFlag &= sndObj.SetValueByHex(7 ,(unsigned char*) (pData->cDateTime+4),10); memcpy(checkData.cTransTime,(unsigned char*) (pData->cDateTime+4),10); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); memcpy(checkData.cTraceNo,pData->VouchNo,strlen(pData->VouchNo)); //12和13 //本地交易时间 bFlag &= sndObj.SetValueByHex(12,(unsigned char*) (pData->cDateTime+8),6); //本地交易日期 bFlag &= sndObj.SetValueByHex(13, (unsigned char*) (pData->cDateTime+4),4); //18 商户类型 bFlag &=sndObj.SetValueByStr(18,pData->cMcc); //22服务点输入代码 //bFlag &= sndObj.SetValueByStr(22, (const char *)pData->TransData.HeadData.SvrPointCode); bFlag &= sndObj.SetValueByStr(22,"021"); //25服务点条件码 bFlag &= sndObj.SetValueByStr(25,"00"); //26服务点PIN获取码 bFlag &= sndObj.SetValueByStr(26, "06"); //32 受理机构标识码 bFlag &=sndObj.SetValueByStr(32,pData->RcvBrchCode); //33 发送机构标识码 bFlag &=sndObj.SetValueByStr(33,pData->SndBrchCode); /**< 磁道处理*/ // if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; }else{ trace_log(DBG, "SetTrack SUCCESS"); } //37 检索参考号 bFlag &= sndObj.SetValueByStr(37, pData->cReference); //41终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); memcpy(checkData.cTermNo,pData->TransData.HeadData.arrRTermNo,strlen(pData->TransData.HeadData.arrRTermNo)); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); memcpy(checkData.cMerchNo, pData->TransData.HeadData.arrRMerchNo,strlen( pData->TransData.HeadData.arrRMerchNo)); //43收卡方名称地址 bFlag &=sndObj.SetValueByStr(43,pData->TransData.HeadData.RPrintMerName); //48 附加数据[0] bFlag &=sndObj.SetValueByStr(43,"0"); //49交易货币代码[0] bFlag &=sndObj.SetValueByStr(49,"156"); /**< 52密码*/ if(SetPinKey(pData, tlvObj,bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; }else{ trace_log(DBG, "SetPinKey SUCCESS"); } //53安全控制信息 bFlag &= sndObj.SetValueByStr(53, "2600000000000000"); //55 C卡数据域 nTlvLen= tlvObj.GetTLVItemByHex(TAG_FIELD55_RSP, (BYTE *)cICData, sizeof(cICData)); if(nTlvLen>0) { bFlag &= sndObj.SetValueByHex(55, (BYTE *)cICData,nTlvLen); } //60 域 BYTE F60[101]={0}; int iLen=0; memcpy(F60,"0000",4); //60.1 交易类型为 0200 时 填充 0000 iLen+=4; memcpy(F60+iLen,"0",1);//60.2.1 //0 个人卡账户 iLen+=1; memcpy(F60+iLen,"5",1);//60.2.2 // 0 终端读取能力不可知 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.3 //0 未使用或后续子域存在 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.4 iLen+=1; memcpy(F60+iLen,"03",2);//60.2.5 iLen+=2; memcpy(F60+iLen,"0",1);//60.2.6 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.7 iLen+=1; memcpy(F60+iLen,"00",1);//60.2.8 //ans2 iLen+=1; memcpy(F60+iLen,"0",1);//60.2.9 // iLen+=1; memcpy(F60+iLen,"00",2);//60.3.1 iLen+=2; memcpy(F60+iLen,"0",1);//60.3.2 iLen+=1; memcpy(F60+iLen,"000",3);//60.3.3 iLen+=3; memcpy(F60+iLen,"0",1);//60.3.4 iLen+=1; memcpy(F60+iLen,"1",1);//60.3.5 //现场 iLen+=1; memcpy(F60+iLen,"1",1);//60.3.6 iLen+=1; memcpy(F60+iLen,"0",1);//60.3.7 iLen+=1; memcpy(F60+iLen,"00",1);//60.3.8 //ans2 iLen+=1; memcpy(F60+iLen,"0",1);//60.3.9 iLen+=1; memcpy(F60+iLen,"00",2);//60.3.10 iLen+=2; bFlag &=sndObj.SetValueByStr(60,(char *)F60); //122[0] bFlag &=sndObj.SetValueByStr(122,"0"); //128MAC bFlag &= sndObj.SetValueByHex(128, (unsigned char*)"00000000", 8); /**< 组包*/ iBufLen = PACK_MAXLEN; bFlag &= sndObj.Pack(pBuffer, iBufLen); if(!bFlag) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 计算Mac */ BYTE bMac[9] = {0}; int nMacLen = 8; if(0!=GenMacData(pData,sndObj,bMac)) { return RET_GETMACERR; } memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); return RET_SUCCESS; }
int CTradeRepeal::DoPack(SAConnection *saConn, void * pNode, unsigned char * pBuffer, unsigned & iBufLen) { if(saConn == NULL || pNode == NULL || pBuffer == NULL) { trace_log(ERR, "Paramter error!"); return RET_SYSEXP; } trace_log(DBG,"-----Repeal-----"); TRADEDATA * pData = (TRADEDATA *)pNode; int nTlvLen=0; char cICCID[4]={0},cLField61[20]={0},cICData[256]={0}; CTLVTemplet tlvObj; if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData)) { trace_log(ERR, "UnPackTLVData fail!"); return RET_SYSEXP; } bool bFlag = true; bool bHasPin = false, bHasTrack = false; //0消息类型 bFlag &= sndObj.SetValueByStr(0 , "0200"); //2账号 bFlag &= sndObj.SetValueByStr(2 , pData->TransData.HeadData.Account); //3处理码 bFlag &= sndObj.SetValueByStr(3 , "280000"); //4交易金额 bFlag &= sndObj.SetValueByStr(4 , pData->TransData.HeadData.ReqAmount); //11流水号 bFlag &= sndObj.SetValueByStr(11, pData->VouchNo); /**< 22服务点输入方式码*/ bFlag &= sndObj.SetValueByStr(22,(char*)pData->TransData.HeadData.SvrPointCode); //F23 卡片序列号 nTlvLen= tlvObj.GetTLVItemByHex(TAG_ICCID, (BYTE *)cICCID, sizeof(cICCID)); if(nTlvLen>0) { char cICNO[5]={0}; BcdToAsc((BYTE *)cICNO,(BYTE *)cICCID,nTlvLen); bFlag &= sndObj.SetValueByStr(23, cICNO+1); } //25服务点条件码 bFlag &= sndObj.SetValueByStr(25,"82"); // 35 36磁道处理 if(SetTrack(pData,tlvObj,bHasTrack)!=0) { trace_log(ERR, "SetTrack faile"); return -1; } trace_log(DBG, "SetTrack SUCCESS"); //37参考号 bFlag &= sndObj.SetValueByStr(37, pData->TransData.HeadData.SysRefNo); //41终端号 bFlag &= sndObj.SetValueByStr(41, pData->TransData.HeadData.arrRTermNo); //42商户号 bFlag &= sndObj.SetValueByStr(42, pData->TransData.HeadData.arrRMerchNo); //49货币代码 bFlag &= sndObj.SetValueByStr(49, "156"); // 52 53密码 安全信息控制 trace_log(DBG, "pData->TransData.HeadData.SvrPointCode[2]==%c",pData->TransData.HeadData.SvrPointCode[2]); if(0==memcmp((char *)&(pData->TransData.HeadData.SvrPointCode[2]),"1",1)) { if(SetPinKey(pData, tlvObj, bHasPin)!=0) { trace_log(ERR, "SetPinKey faile"); return -1; } trace_log(DBG, "SetPinKey SUCCESS"); //53安全控制信息 bFlag &= sndObj.SetValueByStr(53, "2600000000000000"); //26服务点PIN获取码 该域描述了服务点设备所能接受的PIN所能容纳的最多字符数 bFlag &= sndObj.SetValueByStr(26, "06"); } trace_log(DBG, "SetPinKey SUCCESS"); /* bool bIC = false; ///55 IC卡数据域 nTlvLen= tlvObj.GetTLVItemByHex(TAG_FIELD55_RSP, (BYTE *)cICData, sizeof(cICData)); if(nTlvLen>0) { bFlag &= sndObj.SetValueByHex(55, (BYTE *)cICData,nTlvLen); bIC=true; } else { char cTrace[128]={0}; tlvObj.GetTLVItemByHex(TAG_TRACK2,(unsigned char*) cTrace, sizeof(cTrace)); int i=0; for(i=0;i<strlen(cTrace);i++) { if(0==memcmp(cTrace+i,"D",1)) { if((0==memcmp(cTrace+i+5,"2",1)||0==memcmp(cTrace+i+5,"6",1))) { memcpy(pData->TransData.HeadData.RspCode,"45",2); strcpy(pData->TransData.HeadData.RspDecs,"不允许降级交易"); return RET_PACK; }else{ break; } } } } */ //60 域 BYTE F60[101]={0}; int iLen=0; memcpy(F60,"22",2); //—— 60.1 消息类型码 N2 iLen+=2; memcpy(F60+iLen,pData->BatchNo,6); //—— 60.2 批次号 N6 iLen+=6; memcpy(F60+iLen,"000",3); //—— 60.3 网络管理信息码 N3 iLen+=3; memcpy(F60+iLen,"0",1); //—— 60.4 保留 N2 iLen+=1; memcpy(F60+iLen,"00",2); //—— 60.6 支持部分扣款和返回余额标志 N1 iLen+=2; memcpy(F60+iLen,"5",1); //—— 60.6 终端读取能力 N1 iLen+=1; memcpy(F60+iLen,"0",1); //—— 60.7 基于PBOC借/贷记标准的IC卡条件代码 N1 iLen+=1; bFlag &=sndObj.SetValueByStr(60,(char *)F60); //61自定义域 char cOri_Date[4]; memset(cLField61,0x00,sizeof(cLField61)); strcpy((char *)cLField61,(char *)pData->TransData.HeadData.OrigLBatchNo); strcat((char *)cLField61,(char *)pData->TransData.HeadData.OrigLPosSeq); memcpy(cOri_Date,pData->cOri_DateTime,4); trace_log(DBG,"cOri_Date=%s",cOri_Date); strcat((char *)cLField61,(char *)cOri_Date); bFlag &= sndObj.SetValueByStr(61, (char *)cLField61); //64MAC bFlag &= sndObj.SetValueByHex(64, (unsigned char*)"00000000", 8); /**< 组包*/ iBufLen = PACK_MAXLEN; if(!sndObj.Pack(pBuffer, iBufLen)) { trace_log(ERR, "Pack right CUPS8583 fail!"); return RET_PACK; } /**< 计算Mac */ BYTE bMac[9] = {0}; int nMacLen = 8; BYTE bMab[512] = {0}; memcpy(bMab,pBuffer+13,iBufLen-13-nMacLen); if(GenMacData(pData,bMab,iBufLen-13-nMacLen,bMac)) { return RET_GETMACERR; } memcpy(pBuffer + iBufLen -nMacLen, bMac, nMacLen); return RET_SUCCESS; }