Changeset 4994 for trunk/reader-dre.c


Ignore:
Timestamp:
Apr 13, 2011, 11:19:59 PM (9 years ago)
Author:
Admin
Message:

I noticed that monitor encryption is not working on 64bit plattforms due to other sizes of long on this plattform. This patch converts all numeric types like long to portable types like uint32_t. This is not complete yet (only base folder up to r4987, changes thereafter might be incompletely converted). If you encounter problems through this patch please report in forum.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/reader-dre.c

    r4904 r4994  
    55#define CMD_BYTE 0x59
    66
    7 static uchar xor (const uchar * cmd, int cmdlen)
    8 {
    9   int i;
     7static uchar xor (const uchar * cmd, int32_t cmdlen)
     8{
     9  int32_t i;
    1010  uchar checksum = 0x00;
    1111  for (i = 0; i < cmdlen; i++)
     
    1414}
    1515
    16 static int dre_command (struct s_reader * reader, const uchar * cmd, int cmdlen, unsigned char * cta_res, unsigned short * p_cta_lr)    //attention: inputcommand will be changed!!!! answer will be in cta_res, length cta_lr ; returning 1 = no error, return ERROR = err
     16static int32_t dre_command (struct s_reader * reader, const uchar * cmd, int32_t cmdlen, unsigned char * cta_res, uint16_t * p_cta_lr)  //attention: inputcommand will be changed!!!! answer will be in cta_res, length cta_lr ; returning 1 = no error, return ERROR = err
    1717{
    1818  uchar startcmd[] = { 0x80, 0xFF, 0x10, 0x01, 0x05 };  //any command starts with this,
     
    2323  //last byte must be nr. of bytes that card has reported to send
    2424  uchar command[256];
    25   int headerlen = sizeof (startcmd);
     25  int32_t headerlen = sizeof (startcmd);
    2626  startcmd[4] = cmdlen + 3; //commandlength + type + len + checksum bytes
    2727  memcpy (command, startcmd, headerlen);
     
    6969    return ERROR;           //error
    7070  }
    71   int length_excl_leader = *p_cta_lr;
     71  int32_t length_excl_leader = *p_cta_lr;
    7272  if ((cta_res[*p_cta_lr - 2] == 0x90) && (cta_res[*p_cta_lr - 1] == 0x00))
    7373    length_excl_leader -= 2;
     
    8888}
    8989
    90 static int dre_set_provider_info (struct s_reader * reader)
     90static int32_t dre_set_provider_info (struct s_reader * reader)
    9191{
    9292  def_resp;
    93   int i;
     93  int32_t i;
    9494  uchar cmd59[] = { 0x59, 0x14 };   // subscriptions
    9595  uchar cmd5b[] = { 0x5b, 0x00, 0x14 }; //validity dates
     
    118118
    119119      localtime_r (&start, &temp);
    120       int startyear = temp.tm_year + 1900;
    121       int startmonth = temp.tm_mon + 1;
    122       int startday = temp.tm_mday;
     120      int32_t startyear = temp.tm_year + 1900;
     121      int32_t startmonth = temp.tm_mon + 1;
     122      int32_t startday = temp.tm_mday;
    123123      localtime_r (&end, &temp);
    124       int endyear = temp.tm_year + 1900;
    125       int endmonth = temp.tm_mon + 1;
    126       int endday = temp.tm_mday;
     124      int32_t endyear = temp.tm_year + 1900;
     125      int32_t endmonth = temp.tm_mon + 1;
     126      int32_t endday = temp.tm_mday;
    127127      cs_ri_log (reader, "[dre-reader] active package %i valid from %04i/%02i/%02i to %04i/%02i/%02i", i, startyear, startmonth, startday,
    128128          endyear, endmonth, endday);
     
    132132}
    133133
    134 static int dre_card_init (struct s_reader * reader, ATR newatr)
     134static int32_t dre_card_init (struct s_reader * reader, ATR newatr)
    135135{
    136136    get_atr;
     
    138138  uchar ua[] = { 0x43, 0x15 };  // get serial number (UA)
    139139  uchar providers[] = { 0x49, 0x15 };   // get providers
    140   int i;
     140  int32_t i;
    141141    char *card;
    142142
     
    202202      break;
    203203  }
    204   int major_version = cta_res[3];
    205   int minor_version = cta_res[4];
     204  int32_t major_version = cta_res[3];
     205  int32_t minor_version = cta_res[4];
    206206
    207207  ua[1] = reader->provider;
    208208  dre_cmd (ua);         //error would not be fatal
    209209
    210   int hexlength = cta_res[1] - 2;   //discard first and last byte, last byte is always checksum, first is answer code
     210  int32_t hexlength = cta_res[1] - 2;   //discard first and last byte, last byte is always checksum, first is answer code
    211211
    212212  reader->hexserial[0] = 0;
     
    214214  memcpy (reader->hexserial + 2, cta_res + 3, hexlength);
    215215
    216   int low_dre_id = ((cta_res[4] << 16) | (cta_res[5] << 8) | cta_res[6]) - 48608;
    217   int dre_chksum = 0;
     216  int32_t low_dre_id = ((cta_res[4] << 16) | (cta_res[5] << 8) | cta_res[6]) - 48608;
     217  int32_t dre_chksum = 0;
    218218  uchar buf[32];
    219219  snprintf ((char *)buf, sizeof(buf), "%i%i%08i", reader->provider - 16, major_version + 1, low_dre_id);
     
    280280};
    281281
    282 static int dre_do_ecm (struct s_reader * reader, ECM_REQUEST * er)
     282static int32_t dre_do_ecm (struct s_reader * reader, ECM_REQUEST * er)
    283283{
    284284  def_resp;
     
    330330}
    331331
    332 static int dre_get_emm_type(EMM_PACKET *ep, struct s_reader * rdr)
     332static int32_t dre_get_emm_type(EMM_PACKET *ep, struct s_reader * rdr)
    333333{
    334334  switch (ep->emm[0]) {
     
    355355void dre_get_emm_filter(struct s_reader * rdr, uchar *filter)
    356356{
    357     int idx = 2;
     357    int32_t idx = 2;
    358358
    359359    filter[0]=0xFF;
     
    391391}
    392392
    393 static int dre_do_emm (struct s_reader * reader, EMM_PACKET * ep)
     393static int32_t dre_do_emm (struct s_reader * reader, EMM_PACKET * ep)
    394394{
    395395  def_resp;
     
    412412        uchar emmcmd52[0x3a];
    413413        emmcmd52[0] = 0x52;
    414         int i;
     414        int32_t i;
    415415        for (i = 0; i < 2; i++) {
    416416            memcpy (emmcmd52 + 1, ep->emm + 5 + 32 + i * 56, 56);
     
    433433      0x56, 0x58, 0x11
    434434    };
    435         int i;
     435        int32_t i;
    436436        switch (ep->type) {
    437437            case UNIQUE:
     
    478478}
    479479
    480 static int dre_card_info (void)
     480static int32_t dre_card_info (void)
    481481{
    482482  return OK;
Note: See TracChangeset for help on using the changeset viewer.