From de97e2e49061ea051e87a8e151b28117d251b91a Mon Sep 17 00:00:00 2001 From: leslie Date: Mon, 24 Aug 2009 14:48:36 +0800 Subject: [PATCH] fix creating tag length in CAM msg --- cam.c | 26 ++++++++++++++++++++------ systems/cardclient/cccam2.c | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cam.c b/cam.c index 910eb43..165771e 100644 --- a/cam.c +++ b/cam.c @@ -2127,6 +2127,8 @@ private: cCiFrame frame; // int GetLength(const unsigned char * &data); + int LengthSize(int n); + void SetSize(int n, unsigned char * &p); void CaInfo(int tcid, int cid); bool Check(void); public: @@ -2206,20 +2208,32 @@ int cScCamSlot::GetLength(const unsigned char * &data) return len; } +int cScCamSlot::LengthSize(int n) +{ + return n>8; *p++=n&0xFF; } +} + void cScCamSlot::CaInfo(int tcid, int cid) { - int n=9; - for(int i=0; caids[i]; i++) n+=2; + int cn=0; + for(int i=0; caids[i]; i++) cn+=2; + int n=cn+8+LengthSize(cn); +PRINTF(L_CORE_CI,"n=%d cn=%d",n,cn); unsigned char *p; - if(!(p=frame.GetBuff(n+(n>8; *p++=n&0xFF; } + SetSize(n,p); *p++=tcid; *p++=0x90; *p++=0x02; *p++=cid>>8; *p++=cid&0xff; *p++=0x9f; *p++=0x80; *p++=0x31; // AOT_CA_INFO - *p++=n-9; + SetSize(cn,p); for(int i=0; caids[i]; i++) { *p++=caids[i]>>8; *p++=caids[i]&0xff; } frame.Put(); PRINTF(L_CORE_CI,"%d.%d sending CA info",cardIndex,slot); diff --git a/systems/cardclient/cccam2.c b/systems/cardclient/cccam2.c index 5d6c607..6589cc4 100644 --- a/systems/cardclient/cccam2.c +++ b/systems/cardclient/cccam2.c @@ -505,7 +505,7 @@ void cCardClientCCcam2::PacketAnalyzer(const struct CmdHeader *hdr, int length) for(cShare *s=shares.First(); s;) { cShare *n=shares.Next(s); if(s->ShareID()==shareid) { - PRINTF(L_CC_CCCAM2SH,"REMOVE share %08x caid: %04x",s->ShareID(),s->CaID()); + PRINTF(L_CC_CCCAM2SH,"REMOVE share %08x caid: %04x (count %d)",s->ShareID(),s->CaID(),shares.Count()); int caid=s->CaID(); shares.Del(s); if(!shares.HasCaid(caid)) CaidsChanged(); -- 2.39.5