예제 #1
0
LPCTSTR GetAdapterType( UINT uType)
{
	if (IsEthernet( uType))
		return ETHERNET_ADAPTER;
	if (IsTokenRing( uType))
		return TOKENRING_ADAPTER;
	if (IsTokenBus( uType))
		return TOKENBUS_ADAPTER;
	if (IsATM( uType))
		return ATM_ADAPTER;
	if (IsDialup( uType))
		return DIALUP_ADAPTER;
	if (IsLoopback( uType))
		return LOOPBACK_ADAPTER;
	return OTHER_ADAPTER;
}
예제 #2
0
int ProcessingRestrictions::CheckUsageControl()
{
    DataObject dob_auc; // Application Usage Control
    int res;

    if (InitStatus == EMV_DATA_ERROR)
        return initError;
    if (InitStatus == EMV_DATA_NOT_INITIALIZED)
    {
        if (initData() != SUCCESS)
            return initError;
    }

    res = EnvContext.getTagValue (0x9f07, &dob_auc, true);
    if (res == SUCCESS && dob_auc.len > 0)
    {
        // DO checking according to section 6.4.2, EMV book 3 -
        //  Application Usage Control)

        // Get Terminal Type and additional terminal capabilities
        DataObject dob_termType;
        DataObject dob_addTermCap;
        if ((res = EnvContext.getTagValue (0x9f35, &dob_termType, false))
                != SUCCESS)
            return EMV_MISSING_MANDATORY_DATA;

        if ((res = EnvContext.getTagValue (0x9f40, &dob_addTermCap, false))
                != SUCCESS)
            return EMV_MISSING_MANDATORY_DATA;

        // Check condition 1 (section 6.4.2, EMV book 3)
        if (IsATM(&dob_termType, &dob_addTermCap))
        {
            // Terminal type is ATM
            if (!check_bit(dob_auc.Data[0], 0x02))
            {
                //Appl Usage Control doesn't have 'Valid for ATMs' bit set
                updateDataObject (0x95, &dob_TVR, 2, 0x10);
            }
        }
        else
        {
            // Terminal is not an ATM
            // Check condition 2 (section 6.4.2, EMV book 3)
            if (!check_bit(dob_auc.Data[0], 0x01))
            {
                // Appl Usage Control doesn't have 'Valid for terminals
                // other than ATMs' bit set
                updateDataObject (0x95, &dob_TVR, 2, 0x10);
            }
        }

        // Get Issuer Country Code
        DataObject dob_issCntryCode;
        if ((res = EnvContext.getTagValue (0x5f28, &dob_issCntryCode, true))
                != SUCCESS)
        {
            // Issuer Country code is conditional if Application Usage Control is
            // present. Since it is not found, do not continue with additional
            // checking
            return SUCCESS;
            //return EMV_MISSING_MANDATORY_DATA;
        }

        // Get Transaction Info (tag '60000001' in TransactionTypes). This data type
        // must be initialized during TransactionType initialization
        DataObject dob_transInfo;
        if ((res = EnvContext.getTagValue (0x60000001, &dob_transInfo, true))
                != SUCCESS)
        {
            // Transaction Info is mandatory.
            //Since it is not found, exit the transaction
            return EMV_MISSING_MANDATORY_DATA;
        }

        byte cash = 0x20;
        byte goods = 0x04;
        byte services = 0x08;
        byte cashback = 0x02;

        byte dom_cash = 0x80;
        byte int_cash = 0x40;
        byte dom_goods = 0x20;
        byte int_goods = 0x10;
        byte dom_serv = 0x08;
        byte int_serv = 0x04;
        byte dom_csh_back = 0x80;
        byte int_csh_back = 0x40;

        bool IsCountryCodeMatch = CompareByteArr (dob_issCntryCode.Data,
                                  dob_issCntryCode.len,
                                  dob_TermCountryCode.Data,
                                  dob_TermCountryCode.len);

        if (checkTransaction (dob_transInfo.Data [0],
                              cash, dom_cash, int_cash,
                              dob_auc.Data[0], IsCountryCodeMatch) != SUCCESS)
            return updateDataObject (0x95, &dob_TVR, 2, 0x10);
        if (checkTransaction (dob_transInfo.Data [0],
                              goods, dom_goods, int_goods,
                              dob_auc.Data[0], IsCountryCodeMatch) != SUCCESS)
            return updateDataObject (0x95, &dob_TVR, 2, 0x10);
        if (checkTransaction (dob_transInfo.Data [0],
                              services, dom_serv, int_serv,
                              dob_auc.Data[0], IsCountryCodeMatch) != SUCCESS)
            return updateDataObject (0x95, &dob_TVR, 2, 0x10);
        // Check if cashback amount (Amount Other, tag '9F03') is present
        DataObject dob_cashBack;
        if ((res = EnvContext.getTagValue (0x9f03, &dob_cashBack, true))
                == SUCCESS)
        {
            if (checkTransaction (dob_transInfo.Data [0],
                                  cashback, dom_csh_back,
                                  int_csh_back, dob_auc.Data[1],
                                  IsCountryCodeMatch) != SUCCESS)
                return updateDataObject (0x95, &dob_TVR, 2, 0x10);
        }
    }
    return SUCCESS;

}