⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iso8583.cpp

📁 ISO 8583 implementation.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    // Status [7..9=3] {"000"=ok,..."127","199"=security violation}
	if(!isdigit(chMsg[7]) || !isdigit(chMsg[8]) || !isdigit(chMsg[9]))
	   return (FALSE);

	// Originator [10..10=1]
	if((memcmp((PBYTE)&chMsg[10], "0", 1) != 0) && // Base/Propietary
	   (memcmp((PBYTE)&chMsg[10], "1", 1) != 0) && // B24 Device
	   (memcmp((PBYTE)&chMsg[10], "2", 1) != 0) && // Device Handler
	   (memcmp((PBYTE)&chMsg[10], "3", 1) != 0) && // Authorization
	   (memcmp((PBYTE)&chMsg[10], "4", 1) != 0) && // Host Interface Process
	   (memcmp((PBYTE)&chMsg[10], "5", 1) != 0) && // Host
	   (memcmp((PBYTE)&chMsg[10], "6", 1) != 0) && // Switch Interface Process
	   (memcmp((PBYTE)&chMsg[10], "7", 1) != 0))   // Switch
		return (FALSE);

	// Responder [11..11=1]
	if((memcmp((PBYTE)&chMsg[11], "0", 1) != 0) && // Base/Propietary
	   (memcmp((PBYTE)&chMsg[11], "1", 1) != 0) && // B24 Device
	   (memcmp((PBYTE)&chMsg[11], "2", 1) != 0) && // Device Handler
	   (memcmp((PBYTE)&chMsg[11], "3", 1) != 0) && // Authorization
	   (memcmp((PBYTE)&chMsg[11], "4", 1) != 0) && // Host Interface Process
	   (memcmp((PBYTE)&chMsg[11], "5", 1) != 0) && // Host
	   (memcmp((PBYTE)&chMsg[11], "6", 1) != 0) && // Switch Interface Process
	   (memcmp((PBYTE)&chMsg[11], "7", 1) != 0) && // Switch
	   (memcmp((PBYTE)&chMsg[11], "8", 1) != 0))   // Host Maintenance
		return (FALSE);

	// Message-Type-Identifier [12..15=4]
	if(!IsValidMsgTypeId())
		return (FALSE);

	// Ok
	return (TRUE);
	}

// Es Financial Trx Request valida? 
 BOOL ISO8583MSG::IsValid200(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]		
	if(memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_FINANCIAL_RQST, 4) == 0) // Trx Requirement
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml200.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml200.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}

// Es Statement Print Request valido?
 BOOL ISO8583MSG::IsValid205(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    	
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_STMT_PRINT_RQST, 4) == 0) // StmtPrnt Requirement
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml205.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml205.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}

// Es Financial Trx Response valida?
 BOOL ISO8583MSG::IsValid210(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    	
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_FINANCIAL_RESP, 4) == 0) // Trx Response
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml210.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml210.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}

// Es Satement Print Response valido?
 BOOL ISO8583MSG::IsValid215(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    	
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_STMT_PRINT_RESP, 4) == 0) // Stmtprnt Response
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml215.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml215.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}

// Es Financial Trx Completion/SAF Advice valida?
 BOOL ISO8583MSG::IsValid220(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    	
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_SAF_ADV, 4) == 0) // SAF Requirement-Advice
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml220.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml220.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}

// Es Financial Trx Dup Completion?
 BOOL ISO8583MSG::IsValid221(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    	
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_SAF_ADV_REP, 4) == 0) // Dup Completion?
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml220.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml220.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}

// Es Financial Trx Completion Ack?
 BOOL ISO8583MSG::IsValid230(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    	
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_SAF_ACK, 4) == 0) // Completion Ack?
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml230.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml230.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}


// Es Reversal valido?
 BOOL ISO8583MSG::IsValid420(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_REVERSAL, 4) == 0) // Reverse Trx Requirement
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml420.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml420.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}

// Es Reversal Repeat valido?
 BOOL ISO8583MSG::IsValid421(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_REVERSAL_REP, 4) == 0) // Reverse Repeat Trx Req
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml420.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml420.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}


// Es Reversal Ack valido?
 BOOL ISO8583MSG::IsValid430(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    
	if (memcmp((PBYTE)&chMsg[12], CISO_MSGTYPE_REVERSAL_ACK, 4) == 0) // Reverse Trx Response
		{
			// Precondicion: Verificacion habilitada?
			if(!bCheckMessage) 
				return (TRUE);
			return (
				// Primary-Bitmap [16..31=16]	
				(bml430.Find((PSTR)&chMsg[16], 16) == TRUE)
				&&
				// Optional-Secondary-Bitmap [32..47=16]
				(bml430.Find((PSTR)&chMsg[32], 16) == TRUE)			
				) ? TRUE : FALSE;
		}
	else
		return FALSE;
	}

// Es Network Management valido?
 BOOL ISO8583MSG::IsValid800(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    	
	return((memcmp((PBYTE)&chMsg[12], 
		           CISO_MSGTYPE_NETMGMT_RQST, 4) == 0) // Network Mgm Requirement
		   &&
		   // Primary-Bitmap [16..31=16]	
	       (bml800.Find((PSTR)&chMsg[16], 16) == TRUE)
		   &&
		   // Optional-Secondary-Bitmap [32..47=16]
	       (bml800.Find((PSTR)&chMsg[32], 16) == TRUE)
		   &&
		   // Transmision-Date-Time [48..57=10]		   
		   (isdigit(chMsg[48]) && isdigit(chMsg[49]) &&
		    isdigit(chMsg[50]) && isdigit(chMsg[51]) &&
			isdigit(chMsg[52]) && isdigit(chMsg[53]) &&
			isdigit(chMsg[54]) && isdigit(chMsg[55]) &&
			isdigit(chMsg[56]) && isdigit(chMsg[57]))			
		   &&
		   // Trace-Number [58..63=6]
		   (isdigit(chMsg[58]) && isdigit(chMsg[59]) &&
		    isdigit(chMsg[60]) && isdigit(chMsg[61]) &&
			isdigit(chMsg[62]) && isdigit(chMsg[58]))
		   &&		   
		   // Network-Managment-Information-Code [64..66=3]
	       ((memcmp((PBYTE)&chMsg[64], "001", 3) == 0) || // Logon
		    (memcmp((PBYTE)&chMsg[64], "002", 3) == 0) || // Logoff
	        (memcmp((PBYTE)&chMsg[64], "301", 3) == 0))   // Echo
	      ) ? TRUE : FALSE;		
	}	   

// Es Network Management Response valido?
 BOOL ISO8583MSG::IsValid810(void)
	{
	// Precondicion: Mensaje existente
	if(!cbMsgLen) 
		return (FALSE);

	// Message-Type-Identifier [12..15=4]    
	return((memcmp((PBYTE)&chMsg[12], 
		            CISO_MSGTYPE_NETMGMT_RESP, 4) == 0) // Network Mgm Response
		   &&
		   // Primary-Bitmap [16..31=16]	
	       (bml810.Find((PSTR)&chMsg[16], 16) == TRUE)
		   &&
		   // Optional-Secondary-Bitmap [32..47=16]
	       (bml810.Find((PSTR)&chMsg[32], 16) == TRUE)
		   &&
		   // Transmision-Date-Time [48..57=10]		   
		   (isdigit(chMsg[48]) && isdigit(chMsg[49]) &&
		    isdigit(chMsg[50]) && isdigit(chMsg[51]) &&
			isdigit(chMsg[52]) && isdigit(chMsg[53]) &&
			isdigit(chMsg[54]) && isdigit(chMsg[55]) &&
			isdigit(chMsg[56]) && isdigit(chMsg[57]))			
		   &&
		   // Trace-Number [58..63=6]
		   (isdigit(chMsg[58]) && isdigit(chMsg[59]) &&
		    isdigit(chMsg[60]) && isdigit(chMsg[61]) &&
			isdigit(chMsg[62]) && isdigit(chMsg[58]))
		   &&		   
		   // Response-Code [64..65=2]
	       ((memcmp((PBYTE)&chMsg[64], "00", 2) == 0) || // Approved
		    (memcmp((PBYTE)&chMsg[64], "01", 2) == 0) || // Denied
	        (memcmp((PBYTE)&chMsg[64], "90", 2) == 0))   // Host Down
		   &&		   
		   // Network-Managment-Information-Code [66..68=3]
	       ((memcmp((PBYTE)&chMsg[66], "001", 3) == 0) || // Logon
		    (memcmp((PBYTE)&chMsg[66], "002", 3) == 0) || // Logoff
	        (memcmp((PBYTE)&chMsg[66], "301", 3) == 0))   // Echo
	      ) ? TRUE : FALSE;		
	}

// Son validos los datos de usuario?
 BOOL ISO8583MSG::IsValidUserData(void)
	{
	/////////////////////////////////////////
	// Precondicion: Verificacion habilitada?
	if(!bCheckMessage) 
		return (TRUE);
	/////////////////////////////////////////
	// Ok por default
	return (TRUE);
	}

// Offset de Campo en el Mensaje
 WORD ISO8583MSG::FieldOffset(WORD wField)  // Offset 
	{
	// Offset de campo especifico
	return(wField >= 1 && wField <= CISOFIELDS)
		? fdFields[wField-1].wOffset
		: 0;
	}

// Longitud de Campo en el Mensaje
 WORD ISO8583MSG::FieldLength(WORD wField)  // Length

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -