add stuff
[enigma2.git] / lib / dvb_ci / dvbci_camgr.cpp
1 /* DVB CI CA Manager */
2
3 #include <lib/dvb_ci/dvbci_camgr.h>
4
5 int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
6 {
7         printf("SESSION(%d)/CA %02x %02x %02x: ", session_nb, tag[0], tag[1],tag[2]);
8         for (int i=0; i<len; i++)
9                 printf("%02x ", ((const unsigned char*)data)[i]);
10         printf("\n");
11
12         if ((tag[0]==0x9f) && (tag[1]==0x80))
13         {
14                 switch (tag[2])
15                 {
16                 case 0x31:
17                         printf("ca info:\n");
18                         for (int i=0; i<len; i+=2)
19                         {
20                                 printf("%04x ", (((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
21                                 caids.insert((((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
22                         }
23                         printf("\n");
24                         break;
25                 default:
26                         printf("unknown APDU tag 9F 80 %02x\n", tag[2]);
27                         break;
28                 }
29         }
30         return 0;
31 }
32
33 int eDVBCICAManagerSession::doAction()
34 {
35         switch (state)
36         {
37         case stateStarted:
38         {
39                 const unsigned char tag[3]={0x9F, 0x80, 0x30}; // ca info enq
40                 sendAPDU(tag);
41                 state=stateFinal;
42                 return 0;
43         }
44         case stateFinal:
45                 printf("stateFinal und action! kann doch garnicht sein ;)\n");
46         default:
47                 return 0;
48         }
49 }