Changeset 37987


Ignore:
Timestamp:
07/26/16 23:23:53 (8 years ago)
Author:
obi
Message:

reset ca

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/ca.h

    r37986 r37987  
    622622                                        tmpstr1 = ostrcat(tmpstr1, casession->mmibottom, 1, 0);
    623623                                        if(getconfigint("nocamsg", NULL) == 0)
    624                                                 textbox(_(tmpstr), _(tmpstr1), NULL, getrcconfigint("rcok", NULL), NULL, getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 300, 7, 0);
     624                                                textbox(_(tmpstr), _(tmpstr1), NULL, getrcconfigint("rcok", NULL), NULL, getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 300, 7, 0);
    625625                                        free(tmpstr); tmpstr = NULL;
    626626                                        free(tmpstr1); tmpstr1 = NULL;
     
    735735}
    736736
     737//cc functions
     738int caccaction(struct dvbdev* dvbnode, int sessionnr)
     739{
     740        struct casession* casession = NULL;
     741        if(dvbnode == NULL || dvbnode->caslot == NULL) return 0;
     742                casession = dvbnode->caslot->casession;
     743
     744        debug(620, "caccaction nr %d, stat %d", sessionnr, casession[sessionnr].state);
     745
     746        switch (casession[sessionnr].state)
     747        {
     748                case CASESSIONSTART:
     749                {
     750                        casession[sessionnr].state = CASESSIONFINAL;
     751                        return 0;
     752                }
     753                case CASESSIONFINAL:
     754                        printf("stateFinal und action! kann doch garnicht sein ;)\n");
     755                default:
     756                        return 0;
     757        }
     758}
     759
     760int caccAPDU(struct dvbdev* dvbnode, int sessionnr, unsigned char *tag, void *data, int len)
     761{
     762        debug(620, "cc manager caccAPDU start");
     763
     764        int i = 0;
     765        struct casession* casession = NULL;
     766
     767        if(dvbnode == NULL || dvbnode->caslot == NULL) return 0;
     768        casession = dvbnode->caslot->casession;
     769
     770        debug(620, "cc manager %02x %02x %02x", tag[0], tag[1], tag[2]);
     771
     772        if(debug_level == 620)
     773        {
     774                i = 0;
     775                printf("CC manager data (len %d): > ", len);
     776                for(i = 0; i < len; i++)
     777                        printf("%02x ", ((unsigned char*)data)[i]);
     778                printf("\n");
     779        }
     780
     781        if(tag[0] == 0x9f && tag[1] == 0x90)
     782        {
     783                switch(tag[2])
     784                {
     785                        case 0x01: ci_ccmgr_cc_open_cnf(dvbnode, sessionnr); break;
     786                        case 0x03: ci_ccmgr_cc_data_req(dvbnode, sessionnr, (uint8_t*)data, len); break;
     787                        case 0x05: ci_ccmgr_cc_sync_req(dvbnode, sessionnr); break;
     788                        case 0x07: ci_ccmgr_cc_sac_data_req(dvbnode, sessionnr, (uint8_t*)data, len); break;
     789                        case 0x09: ci_ccmgr_cc_sac_sync_req(dvbnode, sessionnr, (uint8_t*)data, len); break;
     790                        default:
     791                                debug(620, "unknown APDU tag 9F 80 %02x\n", tag[2]);
     792                                break;
     793                }
     794        }
     795        return 0;
     796}
     797
    737798//datetime functions
    738799
     
    818879                        debug(620, "state cares sessionstart");
    819880                        unsigned char tag[3] = {0x9F, 0x80, 0x10}; //profile enquiry
     881                        checkcerts();
    820882                        sendAPDU(dvbnode, sessionnr, tag, NULL, 0);
    821883                        casession[sessionnr].state = CARESFIRSTENQUIRY;
     
    839901                        debug(620, "state caresenquiry");
    840902                        unsigned char tag[3] = {0x9F, 0x80, 0x11};
    841                         unsigned char data[][4]=
    842                         {
    843                                 {0x00, 0x01, 0x00, 0x41},
    844                                 {0x00, 0x02, 0x00, 0x41},
    845                                 {0x00, 0x03, 0x00, 0x41},
    846                                 //{0x00, 0x20, 0x00, 0x41}, //host control
    847                                 {0x00, 0x24, 0x00, 0x41},
    848                                 {0x00, 0x40, 0x00, 0x41}
    849                                 //{0x00, 0x10, 0x00, 0x41} //auth.
     903
     904                        if(checkcerts() == 1)
     905                        {
     906                                unsigned char data[][4]=
     907                                {
     908                                        {0x00, 0x01, 0x00, 0x41},       // resource
     909                                        {0x00, 0x02, 0x00, 0x41},       // application V1
     910                                        {0x00, 0x02, 0x00, 0x43},       // application V3
     911                                        {0x00, 0x03, 0x00, 0x41},       // conditional access
     912//                                      {0x00, 0x20, 0x00, 0x41},       // host control
     913                                        {0x00, 0x40, 0x00, 0x41},       // mmi
     914                                        {0x00, 0x24, 0x00, 0x41},       // date-time
     915                                        {0x00, 0x8c, 0x10, 0x01}        // content control
     916//                                      {0x00, 0x10, 0x00, 0x41}        // auth.
     917                                };
     918                                sendAPDU(dvbnode, sessionnr, tag, data, sizeof(data));
     919                        }
     920                        else
     921                        {                       
     922                                unsigned char data[][4]=
     923                                {
     924                                        {0x00, 0x01, 0x00, 0x41},
     925                                        {0x00, 0x02, 0x00, 0x41},
     926                                        {0x00, 0x03, 0x00, 0x41},
     927                                        //{0x00, 0x20, 0x00, 0x41}, //host control
     928                                        {0x00, 0x24, 0x00, 0x41},
     929                                        {0x00, 0x40, 0x00, 0x41}
     930                                        //{0x00, 0x10, 0x00, 0x41} //auth.
     931                                };
     932                                sendAPDU(dvbnode, sessionnr, tag, data, sizeof(data));
    850933                        };
    851                         sendAPDU(dvbnode, sessionnr, tag, data, sizeof(data));
    852934                        casession[sessionnr].state = CASESSIONFINAL;
    853935                        return 0;
     
    10621144                                return i;
    10631145                        }
     1146                        if(type == 5 && dvbnode->caslot->casession[i].ccmanager == 1 && dvbnode->caslot->casession[i].inuse == 1) //ccmanager
     1147                        {
     1148                                dvbnode->caslot->casession[i].inuse = value;
     1149                                return i;
     1150                        }
    10641151                }
    10651152        }
     
    11121199                                else if(casession[sessionnr].appmanager == 1)
    11131200                                        casession[sessionnr].action = caappaction(dvbnode, sessionnr);
     1201                                else if(casession[sessionnr].ccmanager == 1)
     1202                                        casession[sessionnr].action = caccaction(dvbnode, sessionnr);
    11141203                                else if(casession[sessionnr].camanager == 1)
    11151204                                        casession[sessionnr].action = cacaaction(dvbnode, sessionnr);
     
    11641253                        break;
    11651254                case 0x00020041:
     1255                case 0x00020043:
    11661256                        casession[sessionnr].inuse = 1;
    11671257                        casession[sessionnr].appmanager = 1;
     
    11811271                        casession[sessionnr].inuse = 1;
    11821272                        casession[sessionnr].mmimanager = 1;
     1273                        //neutrino sessions[session_nb - 1] = new eDVBCIMMISession(slot);
    11831274                        debug(620, "create session mmi manager");
     1275                        break;
     1276                case 0x008c1001:
     1277                        if(checkcerts())
     1278                        {
     1279                                casession[sessionnr].inuse = 1;
     1280                                casession[sessionnr].ccmanager = 1;
     1281                                //neutrino [session_nb - 1] = new eDVBCIContentControlManagerSession(slot);
     1282                                debug(620, "create session cc manager");
     1283                        }
    11841284                        break;
    11851285                case 0x00100041:
     
    13301430                                        casession->action = 1;
    13311431                        }
     1432                        else if(casession->ccmanager == 1)
     1433                        {
     1434                                if(caccAPDU(dvbnode, sessionnr, tag, pkt, alen))
     1435                                        casession->action = 1;
     1436                        }
    13321437                        else if(casession->camanager == 1)
    13331438                        {
     
    13451450                                        casession->action = 1;
    13461451                        }
     1452
    13471453                        pkt += alen;
    13481454                        len -= alen;
     
    15681674                                        debug(620, "cam (slot %d) status changed, cam now present", dvbnode->devnr);
    15691675                                        canode->connid = dvbnode->devnr + 1;
     1676                                        // cacc start
     1677                                        dvbnode->caslot->ccmgr_ready = 0;
     1678                                        debug(620, "set ccmgr_ready=%d", dvbnode->caslot->ccmgr_ready);
     1679                                        // cacc end
    15701680                                        if(cacreatetc(dvbnode) == 5)
    15711681                                        {
     
    18011911        if(node == NULL && dvbnode == NULL) return 1;
    18021912
     1913        // cacc
     1914        dvbnode->caslot->scrambled = 0;
     1915        debug(620, "set scrambled=%d", dvbnode->caslot->scrambled);
     1916
    18031917        if(dvbnode->type == CIDEV && dvbnode->fd > -1 && dvbnode->caslot != NULL && dvbnode->caslot->status == 2 && dvbnode->caslot->caids != NULL)
    18041918        {
     
    18151929                int foundcaid = 0;
    18161930               
    1817     //check if channel used this slot
     1931            //check if channel used this slot
    18181932                if(node->channel != NULL)
    18191933                {
     
    18231937                                if(channelslotnode->transponderid == node->channel->transponderid && channelslotnode->serviceid == node->channel->serviceid)
    18241938                                {
    1825           if(channelslotnode->slot == dvbnode->devnr)
    1826           {
     1939                                        if(channelslotnode->slot == dvbnode->devnr)
     1940                                        {
    18271941                                                debug(620, "channel support cam (channelslot=%d, slot=%d)", channelslotnode->slot, dvbnode->devnr);
    18281942                                                foundcaid = 1;
    18291943                                                break;
    1830           }
    1831           else
    1832           {
    1833                 debug(620, "channel not support cam (channelslot=%d, slot=%d)", channelslotnode->slot, dvbnode->devnr);
     1944                                        }
     1945                                        else
     1946                                        {
     1947                                        debug(620, "channel not support cam (channelslot=%d, slot=%d)", channelslotnode->slot, dvbnode->devnr);
    18341948                                                return 1;
    18351949                                        }
     
    18531967                                        debug(620, "videopid=%d, audiopid=%d, ac3pid=%d, capid=%d, caid=%d", node->channel->videopid, node->channel->audiopid, node->channel->ac3audiopid, nodecadesc->pid, nodecadesc->systemid);
    18541968                                        tmpstr = oitoa(nodecadesc->systemid);
     1969                                       
    18551970                                        if(ostrstr(dvbnode->caslot->caids, tmpstr) != NULL)
    18561971                                        {
     
    18651980                                        }
    18661981                                        free(tmpstr); tmpstr = NULL;
    1867                         nodecadesc = nodecadesc->next;
     1982                                nodecadesc = nodecadesc->next;
    18681983                                }
    18691984                        }
     
    19132028                                        usleep(30000);
    19142029                                }
    1915                 if(status.checkcamdecrypt == -2)
     2030                                if(status.checkcamdecrypt == -2)
    19162031                                {
    19172032                                        dvbnode->caslot->casession[caservice[caservicenr].camanager].inuse = 1;
     
    19862101                        }
    19872102                        debug(620, "found cam for decrypt (slot=%d)", dvbnode->devnr);
     2103                        // cacc
     2104                        dvbnode->caslot->scrambled = 1;
     2105                        debug(620, "set scrambled=%d", dvbnode->caslot->scrambled);
     2106                        debug(620, "scrambled=%d ccmgr_ready=%d camanager=%d caservicenr=%d", dvbnode->caslot->scrambled, dvbnode->caslot->ccmgr_ready, caservice[caservicenr].camanager, caservicenr);
     2107                        if(dvbnode->caslot->ccmgr_ready == 1 && caservice[caservicenr].camanager == 5)
     2108                        {
     2109#ifdef MIPSEL
     2110                                /*for (i = 0; i < 8192; i++)
     2111                                        descrambler_set_pid(0, 1, i); //workaround... activate all pids
     2112                                       
     2113                                descrambler_set_pid(0, 1, status.aktservice->channel->pmtpid);*/       
     2114                               
     2115                                struct esinfo* esinfonode = status.aktservice->channel->esinfo;
     2116                                for (i = 0; i < 8192; i++)
     2117                                        descrambler_set_pid(0, 0, i);
     2118                                       
     2119                                while(esinfonode != NULL)
     2120                                {
     2121                                        descrambler_set_pid(0, 1,esinfonode->pid);
     2122                                        esinfonode = esinfonode->next;
     2123                                }
     2124                               
     2125#endif
     2126
     2127                                resendKey(dvbnode);
     2128                        }
     2129 
    19882130                        return 0;
    19892131                }
Note: See TracChangeset for help on using the changeset viewer.