Esempio n. 1
0
static void camd35_process_ecm(uchar *buf, int buflen) {
    ECM_REQUEST er;
    if (!buf || buflen < 23)
        return;
    uint16_t ecmlen = (((buf[21] & 0x0f)<< 8) | buf[22])+3;
    if (ecmlen + 20 > buflen)
        return;
    er.ecmlen = ecmlen;
    er.srvid = b2i(2, buf+ 8);
    er.caid = b2i(2, buf+10);
    er.prid = b2i(4, buf+12);
    memcpy(er.ecm, buf + 20, er.ecmlen);

    if (!ProcessECM(er.caid,er.ecm,er.cw)) {
        er.rc = E_FOUND;
    } else er.rc = E_NOTFOUND;

    if (er.rc == E_NOTFOUND) {
        buf[0] = 0x08;
        buf[1] = 2;
        memset(buf + 20, 0, buf[1]);
        buf[22] = er.rc; //put rc in byte 22 - hopefully don't break legacy camd3
    } else {
        if (buf[0]==3)
            memmove(buf + 20 + 16, buf + 20 + buf[1], 0x34);
        buf[0]++;
        buf[1] = 16;
        memcpy(buf+20, er.cw, buf[1]);
    }
    camd35_send(buf, 0);
}
Esempio n. 2
0
static void camd35_process_ecm(uchar *buf, int buflen){
	ECM_REQUEST er;
	if (!buf || buflen < 23)
		return;
	uint16_t ecmlen = (((buf[21] & 0x0f)<< 8) | buf[22])+3;
	if (ecmlen + 20 > buflen)
		return;
	er.ecmlen = ecmlen;
	er.srvid = b2i(2, buf+ 8);
	er.caid = b2i(2, buf+10);
	er.prid = b2i(4, buf+12);
	er.rc = buf[3];
	
	ProcessECM(er.caid,buf + 20,er.cw);

	if (er.rc == E_STOPPED) {
		buf[0] = 0x08;
		buf[1] = 2;
		buf[20] = 0;
		/*
		* the second Databyte should be forseen for a sleeptime in minutes
		* whoever knows the camd3 protocol related to CMD08 - please help!
		* on tests this don't work with native camd3
		*/
		buf[21] = 0;
	}
	if ((er.rc == E_NOTFOUND) || (er.rc == E_INVALID)) {
		buf[0] = 0x08;
		buf[1] = 2;
		memset(buf + 20, 0, buf[1]);
		buf[22] = er.rc; //put rc in byte 22 - hopefully don't break legacy camd3
	} else {
		if (buf[0]==3)
			memmove(buf + 20 + 16, buf + 20 + buf[1], 0x34);
		buf[0]++;
		buf[1] = 16;
		memcpy(buf+20, er.cw, buf[1]);
	}
	camd35_send(buf, 0);
}
Esempio n. 3
0
static void camd35_process_ecm(uchar *buf, int buflen)
{
	ECM_REQUEST er;
	uint16_t ecmlen = 0;
	
	if(!buf || buflen < 23)
		{ return; }
	
	ecmlen = (((buf[21] & 0x0f) << 8) | buf[22]) + 3;
	if(ecmlen + 20 > buflen)
		{ return; }
	
	memset(&er, 0, sizeof(ECM_REQUEST));
    er.rc = E_UNHANDLED;
	er.ecmlen = ecmlen;
	er.srvid = b2i(2, buf + 8);
	er.caid = b2i(2, buf + 10);
	er.prid = b2i(4, buf + 12);
	
	cs_log_debug("ProcessECM CAID: %X", er.caid);
	cs_log_hexdump("ProcessECM: ", buf+20, ecmlen);
	
	if(ProcessECM(er.caid,buf+20,er.cw)) {
	  er.rc = E_NOTFOUND;
	  cs_log_debug("CW not found");
	}
	else {
	  er.rc = E_FOUND;
	  cs_log_hexdump("Found CW: ", er.cw, 16);
    }
    
	if((er.rc == E_NOTFOUND || (er.rc == E_INVALID)) && !suppresscmd08)
	{
		buf[0] = 0x08;
		buf[1] = 2;
		memset(buf + 20, 0, buf[1]);
		buf[22] = er.rc; //put rc in byte 22 - hopefully don't break legacy camd3
	}
	else if(er.rc == E_STOPPED)
	{
		buf[0] = 0x08;
		buf[1] = 2;
		buf[20] = 0;
		/*
		 * the second Databyte should be forseen for a sleeptime in minutes
		 * whoever knows the camd3 protocol related to CMD08 - please help!
		 * on tests this don't work with native camd3
		 */
		buf[21] = 0;
		cs_log("client stop request send");
	}
	else
	{
		// Send CW
		if((er.rc < E_NOTFOUND) || (er.rc == E_FAKE))
		{
			if(buf[0] == 3)
				{ memmove(buf + 20 + 16, buf + 20 + buf[1], 0x34); }
			buf[0]++;
			buf[1] = 16;
			memcpy(buf + 20, er.cw, buf[1]);
		}
		else
		{
			// Send old CMD44 to prevent cascading problems with older mpcs/oscam versions
			buf[0] = 0x44;
			buf[1] = 0;
		}
	}
	camd35_send(buf, 0);
}