Changeset 3172 for trunk/module-camd35.c


Ignore:
Timestamp:
09/22/10 21:36:20 (10 years ago)
Author:
_network
Message:

remove global mbuf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module-camd35.c

    r3168 r3172  
    140140    int i, au;
    141141    time_t now;
     142    uchar mbuf[1024];
    142143
    143144    au = client[cs_idx].au;
     
    163164            client[cs_idx].disable_counter++;
    164165
    165     memset(client[cs_idx].mbuf, 0, sizeof(client[cs_idx].mbuf));
    166     client[cs_idx].mbuf[2] = client[cs_idx].mbuf[3] = 0xff;         // must not be zero
    167     memcpy(client[cs_idx].mbuf + 8, i2b(2, er->srvid), 2);
     166    memset(mbuf, 0, sizeof(mbuf));
     167    mbuf[2] = mbuf[3] = 0xff;           // must not be zero
     168    memcpy(mbuf + 8, i2b(2, er->srvid), 2);
    168169
    169170    //override request provid with auprovid if set in CMD05
    170171    if(reader[au].auprovid) {
    171172        if(reader[au].auprovid != er->prid)
    172             memcpy(client[cs_idx].mbuf + 12, i2b(4, reader[au].auprovid), 4);
     173            memcpy(mbuf + 12, i2b(4, reader[au].auprovid), 4);
    173174        else
    174             memcpy(client[cs_idx].mbuf + 12, i2b(4, er->prid), 4);
     175            memcpy(mbuf + 12, i2b(4, er->prid), 4);
    175176    } else {
    176         memcpy(client[cs_idx].mbuf + 12, i2b(4, er->prid), 4);
    177     }
    178 
    179     memcpy(client[cs_idx].mbuf + 16, i2b(2, er->pid), 2);
    180     client[cs_idx].mbuf[0] = 5;
    181     client[cs_idx].mbuf[1] = 111;
     177        memcpy(mbuf + 12, i2b(4, er->prid), 4);
     178    }
     179
     180    memcpy(mbuf + 16, i2b(2, er->pid), 2);
     181    mbuf[0] = 5;
     182    mbuf[1] = 111;
    182183    if (reader[au].caid[0])
    183184    {
    184         client[cs_idx].mbuf[39] = 1;                            // no. caids
    185         client[cs_idx].mbuf[20] = reader[au].caid[0]>>8;        // caid's (max 8)
    186         client[cs_idx].mbuf[21] = reader[au].caid[0]&0xff;
    187         memcpy(client[cs_idx].mbuf + 40, reader[au].hexserial, 6);  // serial now 6 bytes
    188         client[cs_idx].mbuf[47] = reader[au].nprov;
     185        mbuf[39] = 1;                           // no. caids
     186        mbuf[20] = reader[au].caid[0]>>8;       // caid's (max 8)
     187        mbuf[21] = reader[au].caid[0]&0xff;
     188        memcpy(mbuf + 40, reader[au].hexserial, 6); // serial now 6 bytes
     189        mbuf[47] = reader[au].nprov;
    189190        for (i = 0; i < reader[au].nprov; i++)
    190191        {
     
    192193                    ((reader[au].caid[0] >= 0x0600) && (reader[au].caid[0] <= 0x0699)))    // Irdeto (don't know if this is correct, cause I don't own a IRDETO-Card)
    193194            {
    194                 client[cs_idx].mbuf[48 + (i*5)] = reader[au].prid[i][0];
    195                 memcpy(&client[cs_idx].mbuf[50 + (i*5)], &reader[au].prid[i][1], 3);
     195                mbuf[48 + (i*5)] = reader[au].prid[i][0];
     196                memcpy(&mbuf[50 + (i*5)], &reader[au].prid[i][1], 3);
    196197            }
    197198            else
    198199            {
    199                 client[cs_idx].mbuf[48 + (i * 5)] = reader[au].prid[i][2];
    200                 client[cs_idx].mbuf[49 + (i * 5)] =reader[au].prid[i][3];
    201                 memcpy(&client[cs_idx].mbuf[50 + (i * 5)], &reader[au].sa[i][0],4); // for conax we need at least 4 Bytes
     200                mbuf[48 + (i * 5)] = reader[au].prid[i][2];
     201                mbuf[49 + (i * 5)] =reader[au].prid[i][3];
     202                memcpy(&mbuf[50 + (i * 5)], &reader[au].sa[i][0],4); // for conax we need at least 4 Bytes
    202203            }
    203204        }
    204205        //we think client/server protocols should deliver all information, and only readers should discard EMM
    205         client[cs_idx].mbuf[128] = (reader[au].blockemm_g == 1) ? 0: 1;
    206         client[cs_idx].mbuf[129] = (reader[au].blockemm_s == 1) ? 0: 1;
    207         client[cs_idx].mbuf[130] = (reader[au].blockemm_u == 1) ? 0: 1;
    208         //client[cs_idx].mbuf[131] = reader[au].card_system; //Cardsystem for Oscam client
     206        mbuf[128] = (reader[au].blockemm_g == 1) ? 0: 1;
     207        mbuf[129] = (reader[au].blockemm_s == 1) ? 0: 1;
     208        mbuf[130] = (reader[au].blockemm_u == 1) ? 0: 1;
     209        //mbuf[131] = reader[au].card_system; //Cardsystem for Oscam client
    209210    }
    210211    else        // disable emm
    211         client[cs_idx].mbuf[20] = client[cs_idx].mbuf[39] = client[cs_idx].mbuf[40] = client[cs_idx].mbuf[47] = client[cs_idx].mbuf[49] = 1;
    212 
    213     memcpy(client[cs_idx].mbuf + 10, client[cs_idx].mbuf + 20, 2);
    214     camd35_send(client[cs_idx].mbuf);       // send with data-len 111 for camd3 > 3.890
    215     client[cs_idx].mbuf[1]++;
    216     camd35_send(client[cs_idx].mbuf);       // send with data-len 112 for camd3 < 3.890
     212        mbuf[20] = mbuf[39] = mbuf[40] = mbuf[47] = mbuf[49] = 1;
     213
     214    memcpy(mbuf + 10, mbuf + 20, 2);
     215    camd35_send(mbuf);      // send with data-len 111 for camd3 > 3.890
     216    mbuf[1]++;
     217    camd35_send(mbuf);      // send with data-len 112 for camd3 < 3.890
    217218}
    218219
     
    295296{
    296297  int n;
     298  uchar mbuf[1024];
    297299
    298300  int cidx=(int)idx;
     
    309311  client[cs_idx].is_udp = (ph[client[cs_idx].ctyp].type == MOD_CONN_UDP);
    310312
    311   while ((n=process_input(client[cs_idx].mbuf, sizeof(client[cs_idx].mbuf), cfg->cmaxidle))>0)
    312   {
    313     switch(client[cs_idx].mbuf[0])
     313  while ((n=process_input(mbuf, sizeof(mbuf), cfg->cmaxidle))>0)
     314  {
     315    switch(mbuf[0])
    314316    {
    315317      case  0:  // ECM
    316318      case  3:  // ECM (cascading)
    317         camd35_process_ecm(client[cs_idx].mbuf);
     319        camd35_process_ecm(mbuf);
    318320        break;
    319321      case  6:  // EMM
    320322      case 19:  // EMM
    321         camd35_process_emm(client[cs_idx].mbuf);
     323        camd35_process_emm(mbuf);
    322324        break;
    323325      default:
    324         cs_log("unknown camd35 command! (%d)", client[cs_idx].mbuf[0]);
     326        cs_log("unknown camd35 command! (%d)", mbuf[0]);
    325327    }
    326328  }
Note: See TracChangeset for help on using the changeset viewer.