Changeset 1856


Ignore:
Timestamp:
Mar 20, 2010, 10:00:54 PM (10 years ago)
Author:
_network
Message:

modular: fix nagra emm-s/u dvbapi filter

Location:
branches/modular
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/modular/cscrypt/cscrypt.h

    r712 r1856  
    3737unsigned char *MD5(const unsigned char *, unsigned long, unsigned char *);
    3838unsigned long crc32(unsigned long, const unsigned char *, unsigned int);
     39const u_int32_t MD5_C[256];
    3940
    4041#ifdef  __cplusplus
  • branches/modular/cscrypt/md5.c

    r70 r1856  
    277277
    278278/* MD5 basic transformation. Transforms state based on block. */
    279 
    280 static void
    281 __md5_Transform (state, block)
    282     u_int32_t state[4];
    283     const unsigned char block[64];
    284 {
    285     u_int32_t a, b, c, d, x[16];
    286 
    287 #if MD5_SIZE_OVER_SPEED > 1
    288     u_int32_t temp;
    289     const char *ps;
    290 
    291     static const char S[] = {
    292         7, 12, 17, 22,
    293         5, 9, 14, 20,
    294         4, 11, 16, 23,
    295         6, 10, 15, 21
    296     };
    297 #endif /* MD5_SIZE_OVER_SPEED > 1 */
    298 
    299 #if MD5_SIZE_OVER_SPEED > 0
    300     const u_int32_t *pc;
    301     const char *pp;
    302     int i;
    303 
    304     static const u_int32_t C[] = {
     279    const u_int32_t MD5_C[] = {
    305280                                /* round 1 */
    306281        0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
     
    325300    };
    326301
     302static void
     303__md5_Transform (state, block)
     304    u_int32_t state[4];
     305    const unsigned char block[64];
     306{
     307    u_int32_t a, b, c, d, x[16];
     308
     309#if MD5_SIZE_OVER_SPEED > 1
     310    u_int32_t temp;
     311    const char *ps;
     312
     313    static const char S[] = {
     314        7, 12, 17, 22,
     315        5, 9, 14, 20,
     316        4, 11, 16, 23,
     317        6, 10, 15, 21
     318    };
     319#endif /* MD5_SIZE_OVER_SPEED > 1 */
     320
     321#if MD5_SIZE_OVER_SPEED > 0
     322    const u_int32_t *pc;
     323    const char *pp;
     324    int i;
     325
     326
     327
    327328    static const char P[] = {
    328329        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */
     
    339340
    340341#if MD5_SIZE_OVER_SPEED > 2
    341     pc = C; pp = P; ps = S - 4;
     342    pc = MD5_C; pp = P; ps = S - 4;
    342343
    343344    for ( i = 0 ; i < 64 ; i++ ) {
     
    364365    }
    365366#elif MD5_SIZE_OVER_SPEED > 1
    366     pc = C; pp = P; ps = S;
     367    pc = MD5_C; pp = P; ps = S;
    367368
    368369    /* Round 1 */
     
    392393    }
    393394#elif MD5_SIZE_OVER_SPEED > 0
    394     pc = C; pp = P;
     395    pc = MD5_C; pp = P;
    395396
    396397    /* Round 1 */
  • branches/modular/module-dvbapi.c

    r1853 r1856  
    151151int selected_api=-1;
    152152
     153int emm_count[]={0,0,0,0};
     154
    153155extern uchar *nagra2_get_emm_filter(struct s_reader*, int);
    154 
    155 int dvbapi_set_filter(int dmx_fd, int api, unsigned short pid, unsigned char *filt, unsigned char *mask, int timeout) {
     156extern uchar *irdeto_get_emm_filter(struct s_reader*, int);
     157
     158int dvbapi_set_filter(int dmx_fd, int api, unsigned short pid, uchar *filt, uchar *mask, int timeout) {
    156159    int ret=-1;
    157160
     
    320323void dvbapi_start_filter(int demux_index, ushort caid, unsigned short pid, uchar table, uchar mask, int type) {
    321324    int dmx_fd,i,n=-1;
    322     uchar filter[16], filtermask[16];
     325    uchar filter[32];
    323326
    324327    for (i=0;i<MAX_FILTER;i++) {
     
    341344    demux[demux_index].demux_fd[n].type=type;
    342345
    343     memset(filter,0,16);
    344     memset(filtermask,0,16);
     346    memset(filter,0,32);
    345347
    346348    filter[0]=table;
    347     filtermask[0]=mask;
    348 
    349     dvbapi_set_filter(dmx_fd, selected_api, pid, filter, filtermask, 4000);
     349    filter[16]=mask;
     350
     351    dvbapi_set_filter(dmx_fd, selected_api, pid, filter, filter+16, 4000);
    350352}
    351353
     
    369371
    370372#ifdef NOT_MODULAR
    371     switch(caid >> 8) {
    372         case 0x17:
    373         case 0x18: // NAGRA EMM
     373#define SC_IRDETO 1 //reader-common.c
     374#define SC_NAGRA 8
     375    switch(reader[client[cs_idx].au].card_system) {
     376        case SC_IRDETO:
     377            i=0;
     378            uchar *filter1 = irdeto_get_emm_filter(&reader[client[cs_idx].au], emmtype);
     379            memcpy(filter,filter1,32);
     380            break;
     381        case SC_NAGRA:
    374382            i=0;
    375383            uchar *filter1 = nagra2_get_emm_filter(&reader[client[cs_idx].au], emmtype);
     
    414422    demux[demux_index].demux_fd[n].type=type;
    415423
    416     cs_dump(filter, 32, "demux filter:");
    417     dvbapi_set_filter(dmx_fd, selected_api, pid, filter, filter+16, 4000);
     424    cs_ddump(filter, 32, "demux filter:");
     425    dvbapi_set_filter(dmx_fd, selected_api, pid, filter, filter+16, 0);
    418426}
    419427
     
    479487}
    480488
    481 void dvbapi_stop_descrambling_all(int demux_index) {
    482     int j;
    483     for (j=0;j<MAX_DEMUX;j++) {
    484         if (demux[j].demux_index != demux_index)
    485             continue;
    486 
    487         dvbapi_stop_descrambling(j);
    488     }
    489 
    490     return;
    491 }
    492 
    493 void dvbapi_start_descrambling(int demux_index, unsigned short caid, unsigned short capid, unsigned long provider_id) {
     489void dvbapi_start_descrambling(int demux_index, unsigned short caid) {
    494490    int i,n;
    495491
     
    498494    for (n=0; n<demux[demux_index].ECMpidcount; n++) {
    499495        if (demux[demux_index].ECMpids[n].CA_System_ID==caid) {
    500             break;
    501         }
    502     }
    503 
    504     demux[demux_index].pidindex=n;
     496            demux[demux_index].pidindex=n;
     497            break;
     498        }
     499    }
    505500
    506501    demux[demux_index].ca_fd = dvbapi_open_device(demux_index,1);
     
    526521
    527522    if (demux[demux_index].pidindex==-1) return;
    528     cs_ddump(buffer, len, "emm:");
     523    cs_ddump(buffer, 16, "emm:");
    529524
    530525    //force emm output
     
    557552        }
    558553    }
    559     if (found==1 && reader[client[cs_idx].au].card_system>0)
     554
     555    if (found==1 && reader[client[cs_idx].au].card_system>0) {
     556        cardsystem[reader[client[cs_idx].au].card_system-1].get_emm_type(&epg, &reader[client[cs_idx].au]);
     557        char *typtext[]={"UNKNOWN", "UNIQUE", "SHARED", "GLOBAL"};
     558        emm_count[epg.type]++;
     559        cs_debug("dvbapi: %s emm (unk/g/s/u) (%d/%d/%d/%d)", typtext[epg.type], emm_count[UNKNOWN], emm_count[GLOBAL], emm_count[SHARED], emm_count[UNIQUE]);
    560560        do_emm(&epg);
     561    }
     562
    561563}
    562564
     
    570572    for (i=0;i<CS_MAXREADER;i++) {
    571573        for (j=0;j<CS_MAXREADER;j++) {
    572             if (reader[i].caid[j] != 0) {
     574            if (reader[i].caid[j] != 0 && reader[i].card_system > 0) {
    573575                if (k+1>=MAX_CAID) break;
    574576                global_caid_list[k++]=reader[i].caid[j];   
     
    806808    uchar inhalt[200], dest[200];
    807809    int len;
     810    signal=signal;
    808811    int pmt_fd = open("/tmp/pmt.tmp", O_RDONLY);
    809812    if(pmt_fd>0) {
     
    952955
    953956        for (i = 0; i < pfdcount; i++) {
     957            if (pfd2[i].revents > 3)
     958                cs_debug("dvbapi: event %d on fd %d", pfd2[i].revents, pfd2[i].fd);
     959           
    954960            if (pfd2[i].revents & (POLLHUP | POLLNVAL)) {
    955961                if (type[i]==1) {
     
    10501056                                dvbapi_start_emm_filter(demux_index, SHARED, TYPE_EMM);
    10511057                                dvbapi_start_emm_filter(demux_index, GLOBAL, TYPE_EMM);
    1052                                                                                                    
     1058                                //dvbapi_start_emm_filter(demux_index, UNIQUE, TYPE_EMM);
    10531059                                continue;
    10541060                            }
     1061                            cs_debug("EMM Filter fd %d", demux[demux_index].demux_fd[n].fd);
    10551062                            dvbapi_process_emm(demux_index, mbuf, len);
    10561063                        }
     
    10771084        if (demux[i].program_number==er->srvid) {
    10781085            if (er->rc<=2 && demux[i].pidindex==-1 && er->caid!=0) {
    1079                 dvbapi_start_descrambling(i, er->caid, er->pid, er->prid);
     1086                dvbapi_start_descrambling(i, er->caid);
    10801087            }
    10811088
    10821089            if (er->rc==4 && cfg->dvbapi_au==1 && dvbapi_check_array(global_caid_list, MAX_CAID, er->caid)>=0) {
    10831090                //local card and not found -> maybe card need emm
    1084                 dvbapi_start_descrambling(i, er->caid, er->pid, er->prid);
     1091                dvbapi_start_descrambling(i, er->caid);
    10851092            }
    10861093
     
    10901097                for (n=0; n<demux[i].ECMpidcount; n++) {
    10911098                    if (demux[i].ECMpids[n].checked==0) {
    1092                         dvbapi_stop_filter(i, 0);
     1099                        dvbapi_stop_filter(i, TYPE_ECM);
    10931100                        cs_debug("dvbapi: trying CA_System_ID: %04x CA_PID: %04x", demux[i].ECMpids[n].CA_System_ID, demux[i].ECMpids[n].CA_PID);
    10941101
     
    11391146            ecmtxt = fopen("/tmp/ecm.info", "w");
    11401147            if(ecmtxt != NULL) {
    1141                 fprintf(ecmtxt, "caid: 0x%04X\npid: 0x%04X\nprov: %06X\n", er->caid, er->pid, (uint) er->prid);
     1148                fprintf(ecmtxt, "caid 0x%04X\npid 0x%04X\nprov 0x%06X\n", er->caid, er->pid, (uint) er->prid);
    11421149                fprintf(ecmtxt, "reader: %s\n", reader[er->reader[0]].label);
    11431150                if (reader[er->reader[0]].typ & R_IS_CASCADING)
    11441151                    fprintf(ecmtxt, "from: %s\n", reader[er->reader[0]].device);
    11451152                fprintf(ecmtxt, "ecm time: %.3f\n", (float) client[cs_idx].cwlastresptime/1000);
    1146                 fprintf(ecmtxt, "cw0 : %s\n", cs_hexdump(1,demux[i].lastcw0,8));
    1147                 fprintf(ecmtxt, "cw1 : %s\n", cs_hexdump(1,demux[i].lastcw1,8));
     1153                fprintf(ecmtxt, "cw0: %s\n", cs_hexdump(1,demux[i].lastcw0,8));
     1154                fprintf(ecmtxt, "cw1: %s\n", cs_hexdump(1,demux[i].lastcw1,8));
    11481155                fclose(ecmtxt);
    11491156                ecmtxt = NULL;
  • branches/modular/oscam-config.c

    r1839 r1856  
    15881588    fprintf_conf(f, CONFVARWIDTH, "bindwait", "%d\n", cfg->bindwait);
    15891589    fprintf_conf(f, CONFVARWIDTH, "netprio", "%ld\n", cfg->netprio);
     1590    fprintf_conf(f, CONFVARWIDTH, "clientdyndns", "%d\n", cfg->clientdyndns);
    15901591    fprintf_conf(f, CONFVARWIDTH, "resolvedelay", "%d\n", cfg->resolvedelay);
    15911592    if (cfg->tosleep) fprintf_conf(f, CONFVARWIDTH, "sleep", "%d\n", cfg->tosleep);
  • branches/modular/oscam.c

    r1853 r1856  
    21222122    cs_ddump_mask(D_EMM, ep->hexserial, 8, "emm UA/SA:");
    21232123
     2124    char *typtext[]={"UNKNOWN", "UNIQUE", "SHARED", "GLOBAL"};
     2125    cs_debug_mask(D_EMM, "emmtype %s. Reader %s has serial %s.", typtext[ep->type], reader[au].label, cs_hexdump(0, reader[au].hexserial, 8));
     2126
    21242127    switch (ep->type) {
    21252128        case UNKNOWN:
    2126             cs_debug_mask(D_EMM, "emmtype UNKNOWN. Reader %s has serial %s.", reader[au].label, cs_hexdump(0, reader[au].hexserial, 8));
    21272129            if (reader[au].blockemm_unknown) return;
    21282130            break;
    21292131
    21302132        case UNIQUE:
    2131             cs_debug_mask(D_EMM, "emmtype UNIQUE. Reader %s has serial %s.", reader[au].label, cs_hexdump(0, reader[au].hexserial, 8));
    21322133            if (reader[au].blockemm_u) return;
    21332134            break;
    21342135
    21352136        case SHARED:
    2136             cs_debug_mask(D_EMM, "emmtype SHARED. Reader %s has serial %s.", reader[au].label, cs_hexdump(0, reader[au].hexserial, 8));
    21372137            if (reader[au].blockemm_s) return;
    21382138            break;
     
    21412141        // cardreader hexserial in; reader_get_emm_type overwrites this with real SA value if known!
    21422142        case GLOBAL:
    2143             cs_debug_mask(D_EMM, "emmtype GLOBAL. Reader %s has serial %s.", reader[au].label, cs_hexdump(0, reader[au].hexserial, 8));
    21442143            if (reader[au].blockemm_g) return;
    21452144            break;
  • branches/modular/reader-cryptoworks.c

    r1832 r1856  
    459459int cryptoworks_get_emm_type(EMM_PACKET *ep, struct s_reader * rdr) //returns TRUE if shared emm matches SA, unique emm matches serial, or global or unknown
    460460{
     461  rdr=rdr;
    461462  switch (ep->emm[0]) {
    462463        case 0x82:
  • branches/modular/reader-dre.c

    r1776 r1856  
    304304int dre_get_emm_type(EMM_PACKET *ep, struct s_reader * rdr)
    305305{
     306  rdr=rdr;
    306307  switch (ep->emm[0]) {
    307308        case 0x87:
  • branches/modular/reader-irdeto.c

    r1832 r1856  
    290290}
    291291
     292uchar *irdeto_get_emm_filter(struct s_reader * rdr, int type)
     293{
     294    static uint8_t filter[32];
     295    memset(filter, 0x00, 32);
     296
     297    switch (type) {
     298        case GLOBAL:
     299            filter[1]    = 0x00;
     300            filter[1+16] = 0x2F;
     301            break;
     302        case SHARED:
     303        case UNIQUE:
     304            filter[1]    = 0xD2;
     305            filter[1+16] = 0xFE;
     306            memcpy(filter+2, rdr->hexserial, 2);
     307            memset(filter+2+16, 0xFF, 2);
     308
     309            break;
     310    }
     311
     312    return filter;
     313}
     314
    292315int irdeto_get_emm_type(EMM_PACKET *ep, struct s_reader * rdr) {
    293316
     
    437460    ph->card_init=irdeto_card_init;
    438461    ph->get_emm_type=irdeto_get_emm_type;
    439 }
     462    ph->get_emm_filter=irdeto_get_emm_filter;
     463}
  • branches/modular/reader-nagra.c

    r1839 r1856  
    747747uchar *nagra2_get_emm_filter(struct s_reader * rdr, int type)
    748748{
    749     static uchar filter[32];
    750     memset(filter, 0, 32);
     749    static uint8_t filter[32];
     750    memset(filter, 0x00, 32);
    751751
    752752    switch (type) {
     
    759759            filter[0]    = 0x83;
    760760            filter[0+16] = 0xFF;
    761             filter[3]    = rdr->hexserial[4];
     761            //filter[1]    = rdr->hexserial[4] & 0xFF;
     762            //filter[1+16] = 0xFF;
     763            filter[2]    = rdr->hexserial[3] & 0xFF;
     764            filter[2+16] = 0xFF;
     765            filter[3]    = rdr->hexserial[2] & 0xFF;
    762766            filter[3+16] = 0xFF;
    763             filter[4]    = rdr->hexserial[3];
    764             filter[4+16] = 0xFF;
    765             filter[5]    = rdr->hexserial[2];
    766             filter[5+16] = 0xFF;
    767767            break;
    768768    }
  • branches/modular/reader-viaccess.c

    r1776 r1856  
    357357int viaccess_get_emm_type(EMM_PACKET *ep, struct s_reader * rdr) //returns TRUE if shared emm matches SA, unique emm matches serial, or global or unknown
    358358{
    359     ep->type=UNKNOWN; //FIXME not sure how this maps onto global, unique and shared!
    360     return TRUE; //FIXME let it all pass without checking serial or SA, without filling ep->hexserial
     359    rdr=rdr;
     360    switch (ep->emm[0]) {
     361        case 0x8C:
     362        case 0x8D:
     363            ep->type=GLOBAL;
     364            break;
     365        case 0x8E:
     366            ep->type=SHARED;
     367            break;
     368        case 0x88:
     369            ep->type=UNIQUE; // ?
     370            break;
     371        default:
     372            ep->type=UNKNOWN;
     373            break;
     374    }
     375    return TRUE;
    361376}
    362377
  • branches/modular/reader-videoguard2.c

    r1853 r1856  
    4343  return ERROR;
    4444}
    45 
     45/*
    4646unsigned short NdTabB001[0x4][0x20]= {
    4747    { 0xEAF1,0x0237,0x29D0,0xBAD2,0xE9D3,0x8BAE,0x2D6D,0xCD1B,
     
    6565unsigned short Hash3[] = {0x0123,0x4567,0x89AB,0xCDEF,0xF861,0xCB52};
    6666unsigned char Hash4[] = {0x0B,0x04,0x07,0x08,0x05,0x09,0x0B,0x0A,0x07,0x02,0x0A,0x05,0x04,0x08,0x0D,0x0F};
    67 /*
     67
    6868static void postprocess_cw(unsigned char *cw, int nTableIdx)
    6969{
     
    10271027
    10281028
    1029 
     1029/*
    10301030
    10311031    int MD5_C[] = {
     
    10521052    };
    10531053
    1054 
     1054*/
    10551055
    10561056    unsigned char S[] = {7, 12, 17, 22,
     
    13191319int videoguard_get_emm_type(EMM_PACKET *ep, struct s_reader * rdr) //returns TRUE if shared emm matches SA, unique emm matches serial, or global or unknown
    13201320{
     1321    rdr=rdr;
    13211322    ep->type=UNKNOWN; //FIXME not sure how this maps onto global, unique and shared!
    13221323    return TRUE; //FIXME let it all pass without checking serial or SA, without filling ep->hexserial
Note: See TracChangeset for help on using the changeset viewer.