|
SASC-NG
DVBSoftCAM
|
00001 /* 00002 * Softcam plugin to VDR (C++) 00003 * 00004 * This code is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This code is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 00018 */ 00019 00020 #ifndef ___SYSTEM_CC_H 00021 #define ___SYSTEM_CC_H 00022 00023 #include <vdr/thread.h> 00024 #include "system.h" 00025 #include "network.h" 00026 #include "misc.h" 00027 #include "log.h" 00028 00029 #define L_CC 6 00030 #define L_CC_CORE LCLASS(L_CC,0x2) 00031 #define L_CC_LOGIN LCLASS(L_CC,0x4) 00032 #define L_CC_ECM LCLASS(L_CC,0x8) 00033 #define L_CC_EMM LCLASS(L_CC,0x10) 00034 #define L_CC_CAMD LCLASS(L_CC,0x20) 00035 #define L_CC_CAMD35 LCLASS(L_CC,0x40) 00036 #define L_CC_CAMDEXTR LCLASS(L_CC,0x80) 00037 #define L_CC_RDGD LCLASS(L_CC,0x100) 00038 #define L_CC_NEWCAMD LCLASS(L_CC,0x200) 00039 #define L_CC_GBOX LCLASS(L_CC,0x400) 00040 #define L_CC_CCCAM LCLASS(L_CC,0x800) 00041 #define L_CC_CCCAM2 LCLASS(L_CC,0x1000) 00042 #define L_CC_CCCAM2DT LCLASS(L_CC,0x2000) 00043 #define L_CC_CCCAM2SH LCLASS(L_CC,0x4000) 00044 #define L_CC_CCCAM2EX LCLASS(L_CC,0x8000) 00045 00046 #define L_CC_ALL LALL(L_CC_CCCAM2EX) 00047 00048 // ---------------------------------------------------------------- 00049 00050 class cEcmInfo; 00051 class cNetSocket; 00052 class cCardClients; 00053 class cSystemCardClient; 00054 00055 // ---------------------------------------------------------------- 00056 00057 #define MAX_CC_CAID 16 00058 00059 class cCardClient : public cStructItem, protected cMutex { 00060 friend class cSystemCardClient; 00061 protected: 00062 cNetSocket so; 00063 const char *name; 00064 char hostname[64]; 00065 int port; 00066 int emmAllowed; 00067 int emmCaid[MAX_CC_CAID], emmMask[MAX_CC_CAID], numCaid; 00068 cMsgCache msECM, msEMM; 00069 // 00070 bool ParseStdConfig(const char *config, int *num=0); 00071 virtual bool SendMsg(const unsigned char *data, int len); 00072 virtual int RecvMsg(unsigned char *data, int len, int to=-1); 00073 virtual void Logout(void); 00074 void CaidsChanged(void); 00075 public: 00076 cCardClient(const char *Name); 00077 virtual bool Init(const char *config)=0; 00078 virtual bool Login(void)=0; 00079 virtual bool Immediate(void); 00080 virtual bool CanHandle(unsigned short SysId); 00081 virtual bool ProcessECM(const cEcmInfo *ecm, const unsigned char *data, unsigned char *cw)=0; 00082 virtual bool ProcessEMM(int caSys, const unsigned char *data) { return false; } 00083 const char *Name(void) { return name; } 00084 }; 00085 00086 // ---------------------------------------------------------------- 00087 00088 class cCardClientLink { 00089 friend class cCardClients; 00090 private: 00091 cCardClientLink *next; 00092 protected: 00093 const char *name; 00094 public: 00095 cCardClientLink(const char *Name); 00096 virtual ~cCardClientLink() {}; 00097 virtual cCardClient *Create(void)=0; 00098 }; 00099 00100 // ---------------------------------------------------------------- 00101 00102 template<class CC> class cCardClientLinkReg : public cCardClientLink { 00103 public: 00104 cCardClientLinkReg(const char *Name):cCardClientLink(Name) {} 00105 virtual cCardClient *Create(void) { return new CC(name); } 00106 }; 00107 00108 #endif //___SYSTEM_CC_H