From: leslie Date: Mon, 14 Sep 2009 03:34:04 +0000 (+0800) Subject: cardclient-cccam2: cmd 05 handling (poor) X-Git-Tag: upstream/620~168 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=4e79c144b06490600d1dfc76401c978379dc4bbf;p=sasc-ng.git cardclient-cccam2: cmd 05 handling (poor) --- diff --git a/systems/cardclient/cccam2.c b/systems/cardclient/cccam2.c index 6a010c2..7564159 100644 --- a/systems/cardclient/cccam2.c +++ b/systems/cardclient/cccam2.c @@ -19,7 +19,7 @@ // initialy written by anetwolf anetwolf@hotmail.com // based on crypto & protocol information from _silencer -// EMM handling based on contribution from appiemulder +// EMM & cmd 05 handling based on contribution from appiemulder #include #include @@ -528,7 +528,7 @@ private: char username[21], password[64]; bool login, emmProcessing; cTimeMs lastsend; - int pendingDCW; + int pendingDCW, keymaskpos; // bool newcw; unsigned char cw[16]; @@ -558,7 +558,7 @@ cCardClientCCcam2::cCardClientCCcam2(const char *Name) :cCardClient(Name) ,cThread("CCcam2 reader") { - shareid=0; readerTid=0; pendingDCW=0; newcw=login=emmProcessing=false; + shareid=0; readerTid=0; pendingDCW=keymaskpos=0; newcw=login=emmProcessing=false; so.SetRWTimeout(10*1000); } @@ -591,6 +591,10 @@ void cCardClientCCcam2::PacketAnalyzer(const struct CmdHeader *hdr, int length) cwwait.Broadcast(); cwmutex.Unlock(); decr.Decrypt(tempcw,tempcw,16); + if(keymaskpos>0 && --keymaskpos<=2) { + PRINTF(L_CC_CCCAM2,"disconnecting due to key limit..."); + Logout(); + } break; } case 2: @@ -625,6 +629,14 @@ void cCardClientCCcam2::PacketAnalyzer(const struct CmdHeader *hdr, int length) shares.Unlock(); break; } + case 5: + { + static const struct CmdHeader resp = { 0,5,0 }; + if(CryptSend((unsigned char *)&resp,sizeof(resp))<0) + PRINTF(L_CC_CCCAM2,"failed to send cmd 05 response"); + keymaskpos=60; + break; + } case 6: PRINTF(L_CC_CCCAM2,"server PONG"); break; @@ -725,7 +737,7 @@ void cCardClientCCcam2::Logout(void) shares.Clear(); emmProcessing=false; shares.Unlock(); - pendingDCW=0; + pendingDCW=keymaskpos=0; } bool cCardClientCCcam2::Login(void)