Changeset 1926 for trunk/reader-dre.c


Ignore:
Timestamp:
Apr 2, 2010, 4:21:14 PM (10 years ago)
Author:
merek
Message:

Merge UMP r1944-1969: - Adding SC8in1 support, thanks to dingo35

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/reader-dre.c

    r1858 r1926  
    1919}
    2020
    21 static int dre_command (uchar * cmd, int cmdlen)    //attention: inputcommand will be changed!!!! answer will be in cta_res, length cta_lr ; returning 1 = no error, return ERROR = err
     21static int dre_command (struct s_reader * reader, uchar * cmd, int cmdlen)  //attention: inputcommand will be changed!!!! answer will be in cta_res, length cta_lr ; returning 1 = no error, return ERROR = err
    2222{
    2323  static uchar startcmd[] = { 0x80, 0xFF, 0x10, 0x01, 0x05 };   //any command starts with this,
     
    4040  command[cmdlen++] = checksum;
    4141
    42   reader_cmd2icc (command, cmdlen);
     42  reader_cmd2icc (reader, command, cmdlen);
    4343
    4444  if ((cta_lr != 2) || (cta_res[0] != OK_RESPONSE)) {
     
    4848
    4949  reqans[4] = cta_res[1];   //adapt length byte
    50   reader_cmd2icc (reqans, 5);
     50  reader_cmd2icc (reader, reqans, 5);
    5151
    5252  if (cta_res[0] != CMD_BYTE) {
     
    9090#define dre_cmd(cmd) \
    9191{ \
    92     dre_command(cmd, sizeof(cmd)); \
    93 }
    94 
    95 static int dre_set_provider_info (void)
     92    dre_command(reader, cmd, sizeof(cmd)); \
     93}
     94
     95static int dre_set_provider_info (struct s_reader * reader)
    9696{
    9797  int i;
     
    106106
    107107    if (pbm[0] == 0xff)
    108       cs_ri_log ("[dre-reader] no active packages");
     108      cs_ri_log (reader, "[dre-reader] no active packages");
    109109    else
    110110      for (i = 0; i < 32; i++)
     
    129129      int endmonth = temp->tm_mon + 1;
    130130      int endday = temp->tm_mday;
    131       cs_ri_log ("[dre-reader] active package %i valid from %04i/%02i/%02i to %04i/%02i/%02i", i, startyear, startmonth, startday,
     131      cs_ri_log (reader, "[dre-reader] active package %i valid from %04i/%02i/%02i to %04i/%02i/%02i", i, startyear, startmonth, startday,
    132132          endyear, endmonth, endday);
    133133    }
     
    136136}
    137137
    138 int dre_card_init (ATR newatr)
     138int dre_card_init (struct s_reader * reader, ATR newatr)
    139139{
    140140    get_atr;
     
    156156  case 0x11:
    157157    card = "Tricolor Centr";
    158     reader[ridx].caid[0] = 0x4ae0;
     158    reader->caid[0] = 0x4ae0;
    159159    mode = 41;
    160160    break;          //59 type card = MSP (74 type = ATMEL)
    161161  case 0x12:
    162162    card = "Cable TV";
    163     reader[ridx].caid[0] = 0x4ae0;  //TODO not sure about this one
     163    reader->caid[0] = 0x4ae0;   //TODO not sure about this one
    164164    mode = 41;          //TODO not sure
    165165    break;
    166166  case 0x14:
    167167    card = "Tricolor Syberia / Platforma HD new";
    168     reader[ridx].caid[0] = 0x4ae1;
     168    reader->caid[0] = 0x4ae1;
    169169    mode = 51;
    170170    break;          //59 type card
    171171  case 0x15:
    172172    card = "Platforma HD / DW old";
    173     reader[ridx].caid[0] = 0x4ae1;
     173    reader->caid[0] = 0x4ae1;
    174174    mode = 51;
    175175    break;          //59 type card
    176176  default:
    177177    card = "Unknown";
    178     reader[ridx].caid[0] = 0x4ae1;
     178    reader->caid[0] = 0x4ae1;
    179179    mode = 51;
    180180    break;
    181181  }
    182182
    183   memset (reader[ridx].prid, 0x00, 8);
     183  memset (reader->prid, 0x00, 8);
    184184
    185185  static uchar cmd30[] =
     
    218218  int hexlength = cta_res[1] - 2;   //discard first and last byte, last byte is always checksum, first is answer code
    219219
    220   reader[ridx].hexserial[0] = 0;
    221   reader[ridx].hexserial[1] = 0;
    222   memcpy (reader[ridx].hexserial + 2, cta_res + 3, hexlength);
     220  reader->hexserial[0] = 0;
     221  reader->hexserial[1] = 0;
     222  memcpy (reader->hexserial + 2, cta_res + 3, hexlength);
    223223
    224224  int low_dre_id = ((cta_res[4] << 16) | (cta_res[5] << 8) | cta_res[6]) - 48608;
     
    233233
    234234  //cs_ri_log("[dre-reader] type: DRE Crypt, caid: %04X, serial: %llu, card: v%x",
    235   cs_ri_log ("[dre-reader] type: DRE Crypt, caid: %04X, serial: %s, dre id: %i%i%i%08i, geocode %i, card: %s v%i.%i",
    236       reader[ridx].caid[0], cs_hexdump (0, reader[ridx].hexserial + 2, 4), dre_chksum, provider - 16,
     235  cs_ri_log (reader, "[dre-reader] type: DRE Crypt, caid: %04X, serial: %s, dre id: %i%i%i%08i, geocode %i, card: %s v%i.%i",
     236      reader->caid[0], cs_hexdump (0, reader->hexserial + 2, 4), dre_chksum, provider - 16,
    237237      major_version + 1, low_dre_id, geocode, card, major_version, minor_version);
    238   cs_ri_log ("[dre-reader] Provider name:%s.", provname);
    239 
    240 
    241   memset (reader[ridx].sa, 0, sizeof (reader[ridx].sa));
    242   memcpy (reader[ridx].sa[0], reader[ridx].hexserial + 2, 1);   //copy first byte of unique address also in shared address, because we dont know what it is...
    243 
    244   cs_ri_log ("[dre-reader] SA = %02X%02X%02X%02X, UA = %s", reader[ridx].sa[0][0], reader[ridx].sa[0][1], reader[ridx].sa[0][2],
    245       reader[ridx].sa[0][3], cs_hexdump (0, reader[ridx].hexserial + 2, 4));
    246 
    247   reader[ridx].nprov = 1;
    248 
    249   if (!dre_set_provider_info ())
     238  cs_ri_log (reader, "[dre-reader] Provider name:%s.", provname);
     239
     240
     241  memset (reader->sa, 0, sizeof (reader->sa));
     242  memcpy (reader->sa[0], reader->hexserial + 2, 1); //copy first byte of unique address also in shared address, because we dont know what it is...
     243
     244  cs_ri_log (reader, "[dre-reader] SA = %02X%02X%02X%02X, UA = %s", reader->sa[0][0], reader->sa[0][1], reader->sa[0][2],
     245      reader->sa[0][3], cs_hexdump (0, reader->hexserial + 2, 4));
     246
     247  reader->nprov = 1;
     248
     249  if (!dre_set_provider_info (reader))
    250250    return ERROR;           //fatal error
    251251
     
    254254}
    255255
    256 int dre_do_ecm (ECM_REQUEST * er)
     256int dre_do_ecm (struct s_reader * reader, ECM_REQUEST * er)
    257257{
    258258  if (mode == 41) {
     
    319319   
    320320
    321 int dre_do_emm (EMM_PACKET * ep)
     321int dre_do_emm (struct s_reader * reader, EMM_PACKET * ep)
    322322{
    323323
     
    334334      memcpy (emmcmd52 + 1, ep->emm + 5 + 32 + i * 56, 56);
    335335      // check for shared address
    336       if(ep->emm[3]!=reader[ridx].sa[0][0])
     336      if(ep->emm[3]!=reader->sa[0][0])
    337337        return OK; // ignore, wrong address
    338338      emmcmd52[0x39] = provider;
Note: See TracChangeset for help on using the changeset viewer.