#define SETCMDLEN(h,l) BYTE2_BE(&(h)->cmdlen,(l)-4)
#define CMDLEN(h) (UINT16_BE(&(h)->cmdlen)+4)
+struct GenericCmd {
+ struct CmdHeader header;
+ unsigned char payload[0];
+ } __attribute__((packed));
+
struct ClientInfo {
struct CmdHeader header;
char username[20];
void cCardClientCCcam2::PacketAnalyzer(const struct CmdHeader *hdr, int length)
{
- if(CMDLEN(hdr)<=length) {
+ int plen=CMDLEN(hdr);
+ if(plen<=length) {
+ plen-=sizeof(struct CmdHeader);
switch(hdr->cmd) {
case 0:
break;
{
struct DcwAnswer *dcw=(struct DcwAnswer *)hdr;
if(pendingDCW>0) pendingDCW--;
- PRINTF(L_CC_CCCAM2,"got CW, current shareid %08x (pending %d, EMM %d)",shareid,pendingDCW,pendingEMM);
+ PRINTF(L_CC_CCCAM2,"got CW, current shareid %08x (pending %d, EMM %d, keymaskpos=%d)",shareid,pendingDCW,pendingEMM,keymaskpos);
unsigned char tempcw[16];
memcpy(tempcw,dcw->cw,16);
LDUMP(L_CC_CCCAM2DT,tempcw,16,"scrambled CW");
}
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;
+ PRINTF(L_CC_CCCAM2,"got CMD 05 (payload length=%d)",plen);
+ if(plen>0) {
+ static const struct CmdHeader resp = { 0,5,0 };
+ LDUMP(L_CC_CCCAM2DT,((struct GenericCmd *)hdr)->payload,plen,"CMD 05 payload");
+ if(CryptSend((unsigned char *)&resp,sizeof(resp))<0)
+ PRINTF(L_CC_CCCAM2,"failed to send cmd 05 response");
+ keymaskpos=60;
+ }
+ else
+ keymaskpos=0;
break;
}
case 6:
}
}
else
- PRINTF(L_CC_CCCAM2,"cmdlen mismatch: cmdlen=%d length=%d",CMDLEN(hdr),length);
+ PRINTF(L_CC_CCCAM2,"cmdlen mismatch: cmdlen=%d length=%d",plen,length);
}
bool cCardClientCCcam2::CanHandle(unsigned short SysId)