fix debug output
[enigma2.git] / lib / dvb_ci / dvbci_camgr.cpp
1 /* DVB CI CA Manager */
2
3 #include <lib/dvb_ci/dvbci_camgr.h>
4
5 eDVBCICAManagerSession::eDVBCICAManagerSession(eDVBCISlot *tslot)
6 {
7         slot = tslot;
8         slot->setCAManager(this);
9 }
10
11 eDVBCICAManagerSession::~eDVBCICAManagerSession()
12 {
13         slot->setCAManager(NULL);
14 }
15
16 int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
17 {
18         printf("SESSION(%d)/CA %02x %02x %02x: ", session_nb, tag[0], tag[1],tag[2]);
19         for (int i=0; i<len; i++)
20                 printf("%02x ", ((const unsigned char*)data)[i]);
21         printf("\n");
22
23         if ((tag[0]==0x9f) && (tag[1]==0x80))
24         {
25                 switch (tag[2])
26                 {
27                 case 0x31:
28                         printf("ca info:\n");
29                         for (int i=0; i<len; i+=2)
30                         {
31                                 printf("%04x ", (((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
32                                 caids.push_back((((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
33                         }
34                         printf("\n");
35                         slot->resendCAPMT();
36                         break;
37                 default:
38                         printf("unknown APDU tag 9F 80 %02x\n", tag[2]);
39                         break;
40                 }
41         }
42         return 0;
43 }
44
45 int eDVBCICAManagerSession::doAction()
46 {
47         switch (state)
48         {
49         case stateStarted:
50         {
51                 const unsigned char tag[3]={0x9F, 0x80, 0x30}; // ca info enq
52                 sendAPDU(tag);
53                 state=stateFinal;
54                 return 0;
55         }
56         case stateFinal:
57                 printf("stateFinal und action! kann doch garnicht sein ;)\n");
58         default:
59                 return 0;
60         }
61 }
62
63 int eDVBCICAManagerSession::sendCAPMT(unsigned char *data, int len)
64 {
65         const unsigned char tag[3]={0x9F, 0x80, 0x32}; // ca_pmt
66
67   sendAPDU(tag, data, len);
68         
69         return 0;
70 }
71