diff --git a/cardlist.h b/cardlist.h index 246a1f721..152496d45 100644 --- a/cardlist.h +++ b/cardlist.h @@ -4,7 +4,7 @@ struct known_cards { char providername[32]; -//max atrsize incl. spaces + //max atrsize incl. spaces char atr[80]; int atrsize; } @@ -42,114 +42,114 @@ struct atrlist void findatr(struct s_reader *reader) { - current.found = 0; + current.found = 0; current.ishd03 = 0; current.ishd04 = 0; memset(current.providername, 0, 32); - if ( strncmp(current.atr, hdplus01.atr, hdplus01.atrsize) == 0 ) + if (strncmp(current.atr, hdplus01.atr, hdplus01.atrsize) == 0) { memcpy(current.providername, hdplus01.providername, strlen(hdplus01.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, hdplus02.atr, hdplus02.atrsize) == 0 ) + else if (strncmp(current.atr, hdplus02.atr, hdplus02.atrsize) == 0) { memcpy(current.providername, hdplus02.providername, strlen(hdplus02.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, hdplus03.atr, hdplus03.atrsize) == 0 ) + else if (strncmp(current.atr, hdplus03.atr, hdplus03.atrsize) == 0) { - current.ishd03=1; + current.ishd03 = 1; memcpy(current.providername, hdplus03.providername, strlen(hdplus03.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, hdplus03a.atr, hdplus03a.atrsize) == 0 ) + else if (strncmp(current.atr, hdplus03a.atr, hdplus03a.atrsize) == 0) { - current.ishd03=1; - current.badcard=1; + current.ishd03 = 1; + current.badcard = 1; memcpy(current.providername, hdplus03a.providername, strlen(hdplus03a.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, hdplus03b.atr, hdplus03b.atrsize) == 0 ) + else if (strncmp(current.atr, hdplus03b.atr, hdplus03b.atrsize) == 0) { - current.ishd03=1; + current.ishd03 = 1; memcpy(current.providername, hdplus03b.providername, strlen(hdplus03b.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, hdplus04.atr, hdplus04.atrsize) == 0 ) + else if (strncmp(current.atr, hdplus04.atr, hdplus04.atrsize) == 0) { - current.ishd04=1; + current.ishd04 = 1; memcpy(current.providername, hdplus04.providername, strlen(hdplus04.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, hdplus04a.atr, hdplus04a.atrsize) == 0 ) + else if (strncmp(current.atr, hdplus04a.atr, hdplus04a.atrsize) == 0) { - current.ishd04=1; + current.ishd04 = 1; memcpy(current.providername, hdplus04a.providername, strlen(hdplus04a.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, unity_01.atr, unity_01.atrsize) == 0 ) + else if (strncmp(current.atr, unity_01.atr, unity_01.atrsize) == 0) { memcpy(current.providername, unity_01.providername, strlen(unity_01.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, unity_02.atr, unity_02.atrsize) == 0 ) + else if (strncmp(current.atr, unity_02.atr, unity_02.atrsize) == 0) { memcpy(current.providername, unity_02.providername, strlen(unity_02.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, kdg_02.atr, kdg_02.atrsize) == 0 ) + else if (strncmp(current.atr, kdg_02.atr, kdg_02.atrsize) == 0) { memcpy(current.providername, kdg_02.providername, strlen(kdg_02.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, rlmega.atr, rlmega.atrsize) == 0 ) + else if (strncmp(current.atr, rlmega.atr, rlmega.atrsize) == 0) { memcpy(current.providername, rlmega.providername, strlen(rlmega.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, mtv.atr, mtv.atrsize) == 0 ) + else if (strncmp(current.atr, mtv.atr, mtv.atrsize) == 0) { memcpy(current.providername, mtv.providername, strlen(mtv.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, orfice.atr, orfice.atrsize) == 0 ) + else if (strncmp(current.atr, orfice.atr, orfice.atrsize) == 0) { memcpy(current.providername, orfice.providername, strlen(orfice.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, cdnl.atr, cdnl.atrsize) == 0 ) + else if (strncmp(current.atr, cdnl.atr, cdnl.atrsize) == 0) { memcpy(current.providername, cdnl.providername, strlen(cdnl.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, tivusatd.atr, tivusatd.atrsize) == 0 ) + else if (strncmp(current.atr, tivusatd.atr, tivusatd.atrsize) == 0) { memcpy(current.providername, tivusatd.providername, strlen(tivusatd.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, tivusate.atr, tivusate.atrsize) == 0 ) + else if (strncmp(current.atr, tivusate.atr, tivusate.atrsize) == 0) { memcpy(current.providername, tivusate.providername, strlen(tivusate.providername)); current.found = 1; return; } - else if ( strncmp(current.atr, srg.atr, srg.atrsize) == 0 ) + else if (strncmp(current.atr, srg.atr, srg.atrsize) == 0) { memcpy(current.providername, srg.providername, strlen(srg.providername)); reader->read_old_classes = 0; @@ -158,37 +158,37 @@ void findatr(struct s_reader *reader) } /* test ATR for ins7e11 12,13,14,15 */ - if ( current.found == 0 ) + if (current.found == 0) { int i; char buf[66]; - for( i = 11; i < 16; i++ ) + for(i = 11; i < 16; i++) { - snprintf(buf, skyDEv13.atrsize+1, "3F FF %i 25 03 10 80 41 B0 07 69 FF 4A 50 70 00 00 50 31 01 00 %i", i, i); - if ( strncmp(current.atr, buf, skyDEv13.atrsize) == 0 ) + snprintf(buf, skyDEv13.atrsize + 1, "3F FF %i 25 03 10 80 41 B0 07 69 FF 4A 50 70 00 00 50 31 01 00 %i", i, i); + if (strncmp(current.atr, buf, skyDEv13.atrsize) == 0) { memcpy(current.providername, skyDEv13.providername, strlen(skyDEv13.providername)); reader->caid = 0x09C4; current.found = 1; break; } - snprintf(buf, skyDEv14.atrsize+1, "3F FD %i 25 02 50 80 0F 41 B0 0A 69 FF 4A 50 F0 00 00 50 31 03", i); - if ( strncmp(current.atr, buf, skyDEv14.atrsize) == 0 ) + snprintf(buf, skyDEv14.atrsize + 1, "3F FD %i 25 02 50 80 0F 41 B0 0A 69 FF 4A 50 F0 00 00 50 31 03", i); + if (strncmp(current.atr, buf, skyDEv14.atrsize) == 0) { memcpy(current.providername, skyDEv14.providername, strlen(skyDEv14.providername)); reader->caid = 0x098C; current.found = 1; break; } - snprintf(buf, kbw_v23.atrsize+1, "3F FF %i 25 03 10 80 54 B0 01 69 FF 4A 50 70 00 00 4B 57 01 00 00", i); - if ( strncmp(current.atr, buf, kbw_v23.atrsize) == 0 ) + snprintf(buf, kbw_v23.atrsize + 1, "3F FF %i 25 03 10 80 54 B0 01 69 FF 4A 50 70 00 00 4B 57 01 00 00", i); + if (strncmp(current.atr, buf, kbw_v23.atrsize) == 0) { memcpy(current.providername, kbw_v23.providername, strlen(kbw_v23.providername)); current.found = 1; break; } - snprintf(buf, kdg9.atrsize+1, "3F FD %i 25 02 50 00 03 33 B0 15 69 FF 4A 50 F0 80 03 4B 4C 03", i); - if ( strncmp(current.atr, buf, kdg9.atrsize) == 0 ) + snprintf(buf, kdg9.atrsize + 1, "3F FD %i 25 02 50 00 03 33 B0 15 69 FF 4A 50 F0 80 03 4B 4C 03", i); + if (strncmp(current.atr, buf, kdg9.atrsize) == 0) { memcpy(current.providername, kdg9.providername, strlen(kdg9.providername)); current.found = 1; diff --git a/csctapi/atr.c b/csctapi/atr.c index 3cb38276a..0054e4e65 100644 --- a/csctapi/atr.c +++ b/csctapi/atr.c @@ -191,7 +191,7 @@ int32_t ATR_InitFromArray(ATR *atr, const unsigned char atr_buffer[ATR_MAX_SIZE] // check that TA1, if pn==1 , has a valid value for FI if(atr->pn == 1 && atr->ib[pn][ATR_INTERFACE_BYTE_TA].present == 1) { - uchar FI; + uint8_t FI; cs_log_dbg(D_ATR, "TA1 = %02x", atr->ib[pn][ATR_INTERFACE_BYTE_TA].value); FI = (atr->ib[pn][ATR_INTERFACE_BYTE_TA].value & 0xF0) >> 4; cs_log_dbg(D_ATR, "FI = %02x", FI); diff --git a/csctapi/ifd_drecas.c b/csctapi/ifd_drecas.c index cf01c04c6..fe609a13c 100644 --- a/csctapi/ifd_drecas.c +++ b/csctapi/ifd_drecas.c @@ -45,9 +45,9 @@ int32_t DreCas_Reset(struct s_reader *reader, ATR *atr) int32_t ret; uint8_t buf[ATR_MAX_SIZE]; uint8_t reset_cmd[5] = { 0xDB ,0x03 ,0x00 ,0xC1 ,0xC1 }; - + if(IO_Serial_SetParams(reader, DEFAULT_BAUDRATE, 8, PARITY_NONE, 2, NULL, NULL)) { return ERROR; } - + const struct s_cardreader *crdr_ops = reader->crdr; if (!crdr_ops) return ERROR; @@ -57,19 +57,19 @@ int32_t DreCas_Reset(struct s_reader *reader, ATR *atr) ret = ERROR; IO_Serial_Ioctl_Lock(reader, 1); - + /* Module soft reset */ IO_Serial_Write(reader, 0, 0, (uint32_t)sizeof(reset_cmd), reset_cmd); cs_sleepms(50); - + IO_Serial_Ioctl_Lock(reader, 0); int32_t n = 0; while(n < ATR_MAX_SIZE && !IO_Serial_Read(reader, 50, ATR_TIMEOUT, 1, buf + n)) { n++; } - + if(ATR_InitFromArray(atr, buf, n) != ERROR) { ret = OK; } diff --git a/csctapi/ifd_pcsc.c b/csctapi/ifd_pcsc.c index 4cc588df6..ea7eb1886 100644 --- a/csctapi/ifd_pcsc.c +++ b/csctapi/ifd_pcsc.c @@ -153,7 +153,7 @@ static int32_t pcsc_init(struct s_reader *pcsc_reader) return OK; } -static int32_t pcsc_do_api(struct s_reader *pcsc_reader, const uchar *buf, uchar *cta_res, uint16_t *cta_lr, int32_t l) +static int32_t pcsc_do_api(struct s_reader *pcsc_reader, const uint8_t *buf, uint8_t *cta_res, uint16_t *cta_lr, int32_t l) { LONG rv; DWORD dwSendLength, dwRecvLength; @@ -214,7 +214,7 @@ static int32_t pcsc_do_api(struct s_reader *pcsc_reader, const uchar *buf, uchar } -static int32_t pcsc_activate_card(struct s_reader *pcsc_reader, uchar *atr, uint16_t *atr_size) +static int32_t pcsc_activate_card(struct s_reader *pcsc_reader, uint8_t *atr, uint16_t *atr_size) { struct pcsc_data *crdr_data = pcsc_reader->crdr_data; LONG rv; @@ -246,7 +246,7 @@ static int32_t pcsc_activate_card(struct s_reader *pcsc_reader, uchar *atr, uint memcpy(atr, pbAtr, dwAtrLen); *atr_size = dwAtrLen; - rdr_log(pcsc_reader, "ATR: %s", cs_hexdump(1, (uchar *)pbAtr, dwAtrLen, tmp, sizeof(tmp))); + rdr_log(pcsc_reader, "ATR: %s", cs_hexdump(1, (uint8_t *)pbAtr, dwAtrLen, tmp, sizeof(tmp))); memcpy(pcsc_reader->card_atr, pbAtr, dwAtrLen); pcsc_reader->card_atr_length = dwAtrLen; return OK; diff --git a/csctapi/ifd_sci.c b/csctapi/ifd_sci.c index b3a3db91e..6e0f0512a 100644 --- a/csctapi/ifd_sci.c +++ b/csctapi/ifd_sci.c @@ -22,13 +22,13 @@ struct sr_data { uint8_t old_reset; unsigned char T; - uint32_t fs; + uint32_t fs; uint32_t ETU; - uint32_t WWT; - uint32_t CWT; - uint32_t BWT; - uint32_t EGT; - unsigned char P; + uint32_t WWT; + uint32_t CWT; + uint32_t BWT; + uint32_t EGT; + unsigned char P; unsigned char I; }; @@ -58,9 +58,9 @@ static int32_t Sci_Deactivate(struct s_reader *reader) } } else {return ERROR;} - + return OK; - + } static int32_t Sci_Activate(struct s_reader *reader) @@ -93,7 +93,7 @@ static int32_t Sci_Read_ATR(struct s_reader *reader, ATR *atr) // reads ATR on uint32_t timeout = ATR_TIMEOUT; unsigned char buf[SCI_MAX_ATR_SIZE]; int32_t n = 0, statusreturn = 0; - + if(IO_Serial_Read(reader, 0, timeout, 1, buf + n)) //read first char of atr { rdr_log(reader, "ERROR: no characters found in ATR!"); @@ -121,7 +121,7 @@ static int32_t Sci_Read_ATR(struct s_reader *reader, ATR *atr) // reads ATR on int32_t TDi = T0; // place T0 char into TDi for looped parsing. while(n < SCI_MAX_ATR_SIZE) { - if(TDi & 0x10) //TA Present: //The value of TA(i) is always interpreted as XI || UI if i > 2 and T = 15 ='F'in TD(i–1) + if(TDi & 0x10) //TA Present: //The value of TA(i) is always interpreted as XI || UI if i > 2 and T = 15 ='F'in TD(i�1) { if(IO_Serial_Read(reader, 0, timeout, 1, buf + n)) { break; } //In this case, TA(i) contains the clock stop indicator XI, which indicates the logical //state the clockline must assume when the clock is stopped, and the class indicator UI, @@ -308,7 +308,7 @@ static int32_t Sci_Reset(struct s_reader *reader, ATR *atr) int32_t tries = 0; int32_t max_tries = 0; int32_t pll_start_fs = 0; - if (reader->cardmhz > 2000 && reader->cardmhz != 8300) + if (reader->cardmhz > 2000 && reader->cardmhz != 8300) { max_tries = (((double)(reader->cardmhz/900)) * 2 ) + 1 ; // the higher the maxpll the higher tries needed, to have 9 Mhz or first avb below. pll_start_fs = ((double)(reader->cardmhz/300)) + 1.5 ; // first avbl reader Mhz equal or above 3.0 Mhz @@ -341,8 +341,8 @@ static int32_t Sci_Reset(struct s_reader *reader, ATR *atr) else { ret = Sci_Read_ATR(reader, atr); - if(ret == ERROR) - { + if(ret == ERROR) + { Sci_Deactivate(reader); Sci_Activate(reader); if (reader->cardmhz > 2000 && reader->cardmhz != 8300) @@ -357,12 +357,12 @@ static int32_t Sci_Reset(struct s_reader *reader, ATR *atr) params.fs = (11 - tries); // if 1 Mhz init failed retry with 3.19 Mhz up to 5.188 Mhz rdr_log(reader, "Read ATR fail, attempt %d/5 fs = %d", tries, params.fs); } - else + else { tries++; // increase fs params.fs = (2 + tries); // if 1 Mhz init failed retry with 3.0 Mhz up to 7.0 Mhz rdr_log(reader, "Read ATR fail, attempt %d/5 fs = %d", tries, params.fs); - } + } } else // ATR fetched successfully! { @@ -435,7 +435,7 @@ static int32_t Sci_FastReset(struct s_reader *reader, ATR *atr) } else { - atr_len = reader->card_atr_length + 2; // data buffer has atr lenght + 2 bytes + atr_len = reader->card_atr_length + 2; // data buffer has atr lenght + 2 bytes } Sci_Activate(reader); @@ -467,7 +467,7 @@ static int32_t Sci_FastReset(struct s_reader *reader, ATR *atr) rdr_log(reader,"Error reading ATR"); atr_ok= ERROR; } - + cs_sleepms(150); Sci_WriteSettings(reader, crdr_data->T,crdr_data->fs,crdr_data->ETU, crdr_data->WWT,crdr_data->CWT,crdr_data->BWT,crdr_data->EGT,crdr_data->P,crdr_data->I); cs_sleepms(150); @@ -485,7 +485,7 @@ static int32_t Sci_Init(struct s_reader *reader) rdr_log(reader," Wait On closing before restart %u", i); cs_sleepms(1000); } - + int flags = O_RDWR | O_NOCTTY; #if defined(__SH4__) || defined(STB04SCI) flags |= O_NONBLOCK; @@ -501,7 +501,7 @@ static int32_t Sci_Init(struct s_reader *reader) if(!reader->crdr_data && !cs_malloc(&reader->crdr_data, sizeof(struct sr_data))) { return ERROR; } struct sr_data *crdr_data = reader->crdr_data; - crdr_data->old_reset = 1; + crdr_data->old_reset = 1; reader->handle_nr = reader->handle + 1; return OK; } @@ -534,7 +534,7 @@ static int32_t Sci_Close(struct s_reader *reader) static int32_t sci_write_settings(struct s_reader *reader, struct s_cardreader_settings *s) { - if(reader->cardmhz > 2000) // only for dreambox internal pll readers clockspeed can be set precise others like vu ignore it and work always at 4.5 Mhz + if(reader->cardmhz > 2000) // only for dreambox internal pll readers clockspeed can be set precise others like vu ignore it and work always at 4.5 Mhz { // P fixed at 5V since this is default class A card, and TB is deprecated if(reader->protocol_type != ATR_PROTOCOL_TYPE_T14) // fix VU+ internal reader slow responses on T0/T1 diff --git a/csctapi/ifd_smargo.c b/csctapi/ifd_smargo.c index 8085f6aaa..f52221161 100644 --- a/csctapi/ifd_smargo.c +++ b/csctapi/ifd_smargo.c @@ -45,8 +45,8 @@ static void smargo_set_config_mode_off(struct s_reader *reader) static int32_t smargo_set_settings(struct s_reader *reader, int32_t freq, unsigned char T, unsigned char inv, uint16_t Fi, unsigned char Di, unsigned char Ni) { - uint16_t freqk = (freq * 10); - uchar data[4]; + uint16_t freqk = (freq * 10); + uint8_t data[4]; smargo_set_config_mode_on(reader); @@ -152,7 +152,7 @@ static int32_t smargo_fast_reset_by_atr(struct s_reader *reader, ATR *atr) } else { - atr_len = reader->card_atr_length + 2; // data buffer has atr lenght + 2 bytes + atr_len = reader->card_atr_length + 2; // data buffer has atr lenght + 2 bytes } IO_Serial_Read(reader, 0, 500000, atr_len, buf); @@ -228,7 +228,7 @@ static int32_t smargo_reset(struct s_reader *reader, ATR *atr) // If inverse convention, switch here due to if not PTS will fail if(convention == ATR_CONVENTION_INVERSE) { - uchar data[4]; + uint8_t data[4]; smargo_set_config_mode_on(reader); diff --git a/csctapi/ifd_smartreader.c b/csctapi/ifd_smartreader.c index 367af6ba1..6fefb9756 100644 --- a/csctapi/ifd_smartreader.c +++ b/csctapi/ifd_smartreader.c @@ -38,8 +38,8 @@ static int8_t init_lock = 0; static CS_MUTEX_LOCK sr_lock; // to debug rdrtype and ftdi chip type string value in logs instead off the enumarated value -static const char *const rdrtype_str[6] = {"SR","Infinity", "SRv2", "TripleP1", "TripleP2", "TripleP3"}; -static const char *const type_str[7] = { "TYPE_AM", "TYPE_BM", "TYPE_2232C", "TYPE_R", "TYPE_2232H", "TYPE_4232H", "TYPE_232H"}; +static const char *const rdrtype_str[6] = { "SR","Infinity", "SRv2", "TripleP1", "TripleP2", "TripleP3" }; +static const char *const type_str[7] = { "TYPE_AM", "TYPE_BM", "TYPE_2232C", "TYPE_R", "TYPE_2232H", "TYPE_4232H", "TYPE_232H" }; struct sr_data { @@ -275,7 +275,7 @@ static struct libusb_device *find_smartreader(struct s_reader *rdr, const char * if(out_endpoint == 0x83 && in_endpoint == 0x04 && usbdesc.idProduct == 0x6011) { rdr->smart_type = 4; rdr->smartdev_found = 5; rdr->modemstat = 1;} else if(out_endpoint == 0x85 && in_endpoint == 0x06 && usbdesc.idProduct == 0x6011) { rdr->smart_type = 5; rdr->smartdev_found = 6; rdr->modemstat = 1;} else rdr->smartdev_found = 0; - } + } } } } @@ -291,7 +291,7 @@ static struct libusb_device *find_smartreader(struct s_reader *rdr, const char * if(out_endpoint == 0x83 && in_endpoint == 0x04 && usbdesc.idProduct == 0x6011) { rdr->smart_type = 4; rdr->smartdev_found = 5; rdr->modemstat = 1;} else if(out_endpoint == 0x85 && in_endpoint == 0x06 && usbdesc.idProduct == 0x6011) { rdr->smart_type = 5; rdr->smartdev_found = 6; rdr->modemstat = 1;} else rdr->smartdev_found = 0; - } + } } libusb_close(usb_dev_handle); } @@ -333,7 +333,7 @@ void smartreader_init(struct s_reader *reader) crdr_data->in_ep = reader_types[i].in_ep; crdr_data->out_ep = reader_types[i].out_ep; crdr_data->index = reader_types[i].index; - crdr_data->interface = reader_types[i].interface; + crdr_data->interface = reader_types[i].interface; } } } @@ -422,7 +422,7 @@ static int32_t smartreader_usb_reset(struct s_reader *reader) rdr_log(reader, "Smartreader reset failed"); return (-1); } - + return 0; } @@ -581,7 +581,7 @@ static int smartreader_to_clkbits_AM(int baudrate, unsigned long *encoded_diviso H Type have all features above with {index[8],value[15:14]} is the encoded subdivisor - FT232R, FT2232 and FT232BM have no option for 12 MHz and with + FT232R, FT2232 and FT232BM have no option for 12 MHz and with {index[0],value[15:14]} is the encoded subdivisor AM Type chips have only four fractional subdivisors at value[15:14] @@ -625,7 +625,7 @@ static int smartreader_to_clkbits(int baudrate, int clk, int clk_div, unsigned l *encoded_divisor = (best_divisor >> 3) | (frac_code[best_divisor & 0x7] << 14); } return best_baud; -} +} /** ftdi_convert_baudrate returns nearest supported baud rate to that requested. Function is only used internally @@ -650,7 +650,7 @@ static int smartreader_convert_baudrate(int baudrate, struct s_reader *reader, u if(baudrate*10 > H_CLK /0x3fff) { /* On H Devices, use 12 000 000 Baudrate when possible - We have a 14 bit divisor, a 1 bit divisor switch (10 or 16) + We have a 14 bit divisor, a 1 bit divisor switch (10 or 16) three fractional bits and a 120 MHz clock Assume AN_120 "Sub-integer divisors between 0 and 2 are not allowed" holds for DIV/10 CLK too, so /1, /1.5 and /2 can be handled the same*/ @@ -670,7 +670,7 @@ static int smartreader_convert_baudrate(int baudrate, struct s_reader *reader, u } // Split into "value" and "index" values *value = (unsigned short)(encoded_divisor & 0xFFFF); - if (crdr_data->type == TYPE_2232H || + if (crdr_data->type == TYPE_2232H || crdr_data->type == TYPE_4232H || crdr_data->type == TYPE_232H) { *idx = (unsigned short)(encoded_divisor >> 8); @@ -725,13 +725,13 @@ int smartreader_set_baudrate(struct s_reader *reader, int baudrate) rdr_log(reader, "Unsupported baudrate. Note: bitbang baudrates are automatically multiplied by 4"); return (-1); } - if (libusb_control_transfer(crdr_data->usb_dev_handle, + if (libusb_control_transfer(crdr_data->usb_dev_handle, FTDI_DEVICE_OUT_REQTYPE, - SIO_SET_BAUDRATE_REQUEST, + SIO_SET_BAUDRATE_REQUEST, value, - idx, - NULL, - 0, + idx, + NULL, + 0, crdr_data->usb_write_timeout) < 0) { rdr_log(reader, "Setting new baudrate failed"); return (-2); @@ -955,7 +955,7 @@ static void read_callback(struct libusb_transfer *transfer) { rdr_log(reader, "SR: submit async transfer failed with error %d", ret); } } - else + else { if (!crdr_data->closing && init_count) { rdr_log(reader, "SR: USB bulk read failed with error %d", transfer->status); @@ -1011,7 +1011,7 @@ static int32_t smartreader_usb_open_dev(struct s_reader *reader) smartreader_usb_close_internal(reader); rdr_log(reader, "Couldn't detach interface from kernel. Please unload the FTDI drivers"); return (LIBUSB_ERROR_NOT_SUPPORTED); - } + } #endif ret = libusb_get_device_descriptor(crdr_data->usb_dev, &usbdesc); @@ -1082,7 +1082,7 @@ static int32_t smartreader_usb_open_dev(struct s_reader *reader) else if(usbdesc.bcdDevice == 0x200) { crdr_data->type = TYPE_AM; } else if(usbdesc.bcdDevice == 0x500) - { + { if(usbdesc.idProduct == 0x6011) { crdr_data->type = TYPE_4232H; @@ -1113,7 +1113,7 @@ static int32_t smartreader_usb_open_dev(struct s_reader *reader) smartreader_usb_close_internal(reader); rdr_log(reader, "set baudrate failed"); return (-7); - } + } return (0); } @@ -1128,7 +1128,7 @@ static void EnableSmartReader(struct s_reader *reader, uint32_t baud_temp2, int3 unsigned char Prot[2]; unsigned char Invert[2]; unsigned char temp_T; - + smartreader_set_baudrate(reader, baud_temp2); smartreader_setflowctrl(reader, 0); if (crdr_data->rdrtype >= 2) cs_sleepms(150); // for changing a line setting the V2 and Triple need a delay @@ -1188,17 +1188,17 @@ static void EnableSmartReader(struct s_reader *reader, uint32_t baud_temp2, int3 Invert[1] = inv; smart_write(reader, Invert, sizeof(Invert)); - cs_sleepms(250); // this delay needed for Triple and v2 + cs_sleepms(250); // this delay needed for Triple and v2 smartreader_set_line_property2(reader, BITS_8, STOP_BIT_2, parity, BREAK_ON); - // send break for 350ms, also comes from JoePub debugging.break + // send break for 350ms, also comes from JoePub debugging.break cs_sleepms(350); - + if(temp_T == 1) { smartreader_set_line_property2(reader, BITS_8, STOP_BIT_1, parity, BREAK_OFF); } else { smartreader_set_line_property2(reader, BITS_8, STOP_BIT_2, parity, BREAK_OFF); } - + cs_sleepus(800); smart_flush(reader); cs_sleepus(800); @@ -1301,14 +1301,14 @@ static int32_t SR_Init(struct s_reader *reader) crdr_data->detectstart = 0; crdr_data->tripledelay = 0; if (!strcasecmp(rdrtype, "SR")) { - crdr_data->rdrtype = SR; + crdr_data->rdrtype = SR; } if (!strcasecmp(rdrtype, "Infinity")) { - crdr_data->rdrtype = Infinity; + crdr_data->rdrtype = Infinity; } if (!strcasecmp(rdrtype, "SRv2")) { crdr_data->tripledelay = 0; - crdr_data->rdrtype = SRv2; + crdr_data->rdrtype = SRv2; } if (!strcasecmp(rdrtype, "TripleP1")) { crdr_data->tripledelay = 0; @@ -1322,7 +1322,7 @@ static int32_t SR_Init(struct s_reader *reader) crdr_data->tripledelay = 150; crdr_data->rdrtype = TripleP3; } - + rdr_log_dbg(reader, D_DEVICE, "SR: Looking for device %s on bus %s", dev, busname); cs_writelock(__func__, &sr_lock); smartreader_init(reader); @@ -1385,7 +1385,7 @@ static int32_t SR_Init(struct s_reader *reader) //Set the DTR LOW and RTS LOW ret = smartreader_setdtr_rts(reader, 0, 0); - + //Disable flow control ret = smartreader_setflowctrl(reader, 0); @@ -1423,7 +1423,7 @@ static int32_t SR_Reset(struct s_reader *reader, ATR *atr) // seems to be ok after all if (reader->cardmhz == reader->mhz && reader->cardmhz > 369) - crdr_data->fs = reader->cardmhz * 10000; else + crdr_data->fs = reader->cardmhz * 10000; else crdr_data->fs = 3690000; rdr_log_dbg(reader, D_IFD, " init card at %u mhz", crdr_data->fs / 10000); @@ -1444,7 +1444,7 @@ static int32_t SR_Reset(struct s_reader *reader, ATR *atr) atr_ok = ERROR; memset(data, 0, sizeof(data)); rdr_log_dbg(reader, D_IFD, "SR: Trying with parity %s", parity_str[parity[i]]); - + // special irdeto case if(i == 3) { @@ -1505,11 +1505,11 @@ static int32_t SR_Reset(struct s_reader *reader, ATR *atr) rdr_log_dbg(reader, D_IFD, "SR: Locking F and D for Irdeto mode irdeto = %u", crdr_data->irdeto = 1); } } - + if(atr_ok == OK) {break;} } smart_fastpoll(reader, 0); - + return atr_ok; } @@ -1536,7 +1536,7 @@ static int32_t SR_GetStatus(struct s_reader *reader, int32_t *in) char usb_val[2]; uint32_t state2; - if (crdr_data->usb_dev == NULL) + if (crdr_data->usb_dev == NULL) { rdr_log(reader,"usb device unavailable"); return ERROR; @@ -1618,7 +1618,7 @@ static int32_t SR_Receive(struct s_reader *reader, unsigned char *buffer, uint32 { timeout2 = (double)timeout/1000; } - // Limit the max timeout to 14 seconds to avoid a device read timeout. + // Limit the max timeout to 14 seconds to avoid a device read timeout. timeout2 = MIN(timeout2, 14000); // convert timeout to ms precize if (timeout2 < (double)timeout/1000) { @@ -1649,7 +1649,7 @@ int32_t SR_WriteSettings(struct s_reader *reader, uint16_t F, unsigned char D, return OK; } -static int32_t SR_SetParity(struct s_reader *reader, uchar parity) +static int32_t SR_SetParity(struct s_reader *reader, uint8_t parity) { struct sr_data *crdr_data = reader->crdr_data; int32_t ret; @@ -1746,7 +1746,7 @@ static int32_t SR_FastReset_With_ATR(struct s_reader *reader, ATR *atr) } else { - atr_len = reader->card_atr_length + 2; // data buffer has atr lenght + 2 bytes + atr_len = reader->card_atr_length + 2; // data buffer has atr lenght + 2 bytes } smart_fastpoll(reader, 1); diff --git a/csctapi/ifd_smartreader_types.h b/csctapi/ifd_smartreader_types.h index bc7bdda22..800b70e0f 100644 --- a/csctapi/ifd_smartreader_types.h +++ b/csctapi/ifd_smartreader_types.h @@ -65,7 +65,7 @@ enum smartreader_break_type { BREAK_OFF = 0, BREAK_ON = 1 }; /** Port interface for chips with multiple interfaces */ -enum smartreader_rdrtypename +enum smartreader_rdrtypename { SR = 0, Infinity = 1, diff --git a/csctapi/ifd_stapi.c b/csctapi/ifd_stapi.c index 5a1bf7572..29f4b610a 100644 --- a/csctapi/ifd_stapi.c +++ b/csctapi/ifd_stapi.c @@ -32,11 +32,11 @@ static int32_t stapi_init(struct s_reader *reader) if(!cs_malloc(&reader->crdr_data, sizeof(struct stapi_data))) { return ERROR; } struct stapi_data *crdr_data = reader->crdr_data; - -#ifdef CARDREADER_STAPI5 + +#ifdef CARDREADER_STAPI5 STReader_GetRevision(); #endif - + return STReader_Open(reader->device, &crdr_data->stapi_handle); } diff --git a/csctapi/ifd_stinger.c b/csctapi/ifd_stinger.c index 5df812f29..4018ab1ec 100644 --- a/csctapi/ifd_stinger.c +++ b/csctapi/ifd_stinger.c @@ -290,7 +290,7 @@ int32_t Stinger_Reset(struct s_reader *reader, ATR *atr) cs_sleepms(50); IO_Serial_RTS_Clr(reader); - + cs_sleepms(50); IO_Serial_Ioctl_Lock(reader, 0); diff --git a/csctapi/io_serial.c b/csctapi/io_serial.c index ab65486f5..82c850d1c 100644 --- a/csctapi/io_serial.c +++ b/csctapi/io_serial.c @@ -367,7 +367,7 @@ void IO_Serial_Flush(struct s_reader *reader) struct timeb starttotal, endtotal; struct timeb start, end; cs_ftimeus(&starttotal); - endtotal = starttotal; + endtotal = starttotal; cs_ftimeus(&start); end = start; int64_t gone = 0; diff --git a/module-anticasc.c b/module-anticasc.c index d1b7e85e0..09cb43b10 100644 --- a/module-anticasc.c +++ b/module-anticasc.c @@ -15,7 +15,7 @@ #define cs_ac "oscam.ac" static FILE *ac_log; -static uchar ac_ecmd5[CS_ECMSTORESIZE]; +static uint8_t ac_ecmd5[CS_ECMSTORESIZE]; bool anticasc_logging(char *txt) { diff --git a/module-cacheex.c b/module-cacheex.c index 32e1c0486..9a2b92af8 100644 --- a/module-cacheex.c +++ b/module-cacheex.c @@ -196,13 +196,13 @@ void cacheex_cleanup_hitcache(bool force) { i_next = i->next; cachehit = get_data_from_node(i); - + if(!cachehit) - { + { i = i_next; continue; } - + cs_ftime(&now); gone = comp_timeb(&now, &cachehit->time); gone_max_hitcache_time = comp_timeb(&now, &cachehit->max_hitcache_time); @@ -223,7 +223,7 @@ void cacheex_cleanup_hitcache(bool force) SAFE_RWLOCK_UNLOCK(&hitcache_lock); } -static int32_t cacheex_ecm_hash_calc(uchar *buf, int32_t n) +static int32_t cacheex_ecm_hash_calc(uint8_t *buf, int32_t n) { int32_t i, h = 0; for(i = 0; i < n; i++) @@ -511,7 +511,7 @@ void cacheex_cache_push(ECM_REQUEST *er) && chk_ctab(er->caid, &cl->ctab) //Caid-check && (!checkECMD5(er) || chk_ident_filter(er->caid, er->prid, &cl->ftab)) //Ident-check (not for csp: prid=0 always!) && chk_srvid(cl, er) //Service-check - && chk_csp_ctab(er, &cl->account->cacheex.filter_caidtab) //cacheex_ecm_filter + && chk_csp_ctab(er, &cl->account->cacheex.filter_caidtab) //cacheex_ecm_filter ) { cacheex_cache_push_to_client(cl, er); @@ -540,7 +540,7 @@ void cacheex_cache_push(ECM_REQUEST *er) && chk_ctab(er->caid, &rdr->ctab) //Caid-check && (!checkECMD5(er) || chk_ident_filter(er->caid, er->prid, &rdr->ftab)) //Ident-check (not for csp: prid=0 always!) && chk_srvid(cl, er) //Service-check - && chk_csp_ctab(er, &rdr->cacheex.filter_caidtab) //cacheex_ecm_filter + && chk_csp_ctab(er, &rdr->cacheex.filter_caidtab) //cacheex_ecm_filter ) { cacheex_cache_push_to_client(cl, er); @@ -627,7 +627,7 @@ static void log_cacheex_cw(ECM_REQUEST *er, char *reason) { memcpy(remotenodeid, data, 8); } else { memset(remotenodeid, 0 , 8); } - + char buf_ecm[109]; format_ecm(er, buf_ecm, 109); cs_log_dbg(D_CACHEEX,"got pushed ecm [%s]: %s - odd/even 0x%x - CSP cw: %s - pushed from %s, at hop %d, origin node-id %" PRIu64 "X", @@ -712,7 +712,7 @@ static int32_t cacheex_add_to_cache_int(struct s_client *cl, ECM_REQUEST *er, in return 0; } - if((csp && cfg.csp.block_fakecws) || (cl->reader && cl->reader->cacheex.block_fakecws) + if((csp && cfg.csp.block_fakecws) || (cl->reader && cl->reader->cacheex.block_fakecws) || (!cl->reader && cl->account && cl->account->cacheex.block_fakecws)) { if(chk_is_fakecw(er->cw)) @@ -778,7 +778,7 @@ static struct s_cacheex_matcher *cacheex_matcher_read_int(void) { return NULL; } char token[1024]; - unsigned char type; + uint8_t type; int32_t i, ret, count = 0; struct s_cacheex_matcher *new_cacheex_matcher = NULL, *entry, *last = NULL; uint32_t line = 0; diff --git a/module-camd33.c b/module-camd33.c index 50218bc8f..18844b601 100644 --- a/module-camd33.c +++ b/module-camd33.c @@ -9,7 +9,7 @@ #include "oscam-net.h" #include "oscam-string.h" -#define REQ_SIZE 4 +#define REQ_SIZE 4 static int32_t camd33_send(uchar *buf, int32_t ml) { @@ -128,7 +128,7 @@ static void camd33_send_dcw(struct s_client *UNUSED(client), ECM_REQUEST *er) static void camd33_process_ecm(uchar *buf, int32_t l) { - ECM_REQUEST *er; + ECM_REQUEST *er; if(l < 7) { return; } if(!(er = get_ecmtask())) diff --git a/module-camd35-cacheex.c b/module-camd35-cacheex.c index 92f1a86a4..8a70d9677 100644 --- a/module-camd35-cacheex.c +++ b/module-camd35-cacheex.c @@ -242,7 +242,7 @@ static int32_t camd35_cacheex_push_out(struct s_client *cl, struct ecm_request_t uint32_t size = sizeof(er->ecmd5) + sizeof(er->csp_hash) + sizeof(er->cw) + sizeof(uint8_t) + (ll_count(er->csp_lastnodes) + 1) * 8; - unsigned char *buf; + uint8_t *buf; if(!cs_malloc(&buf, size + 20)) //camd35_send() adds +20 { return -1; } @@ -309,7 +309,7 @@ static int32_t camd35_cacheex_push_out(struct s_client *cl, struct ecm_request_t return res; } -static void camd35_cacheex_push_in(struct s_client *cl, uchar *buf) +static void camd35_cacheex_push_in(struct s_client *cl, uint8_t *buf) { int8_t rc = buf[3]; if(rc != E_FOUND && rc != E_UNHANDLED) //Maybe later we could support other rcs @@ -434,7 +434,7 @@ static void camd35_cacheex_push_in(struct s_client *cl, uchar *buf) cacheex_add_to_cache(cl, er); } -void camd35_cacheex_recv_ce1_cwc_info(struct s_client *cl, uchar *buf, int32_t idx) +void camd35_cacheex_recv_ce1_cwc_info(struct s_client *cl, uint8_t *buf, int32_t idx) { if(!(buf[0] == 0x01 && buf[18] < 0xFF && buf[18] > 0x00)) // cwc info ; normal camd3 ecms send 0xFF but we need no cycletime of 255 ;) return; diff --git a/module-camd35.c b/module-camd35.c index 16eec279d..822f45391 100644 --- a/module-camd35.c +++ b/module-camd35.c @@ -39,10 +39,10 @@ #define REQ_SIZE MAX_ECM_SIZE + 20 + 0x34 -static int32_t __camd35_send(struct s_client *cl, uchar *buf, int32_t buflen, int answer_awaited) +static int32_t __camd35_send(struct s_client *cl, uint8_t *buf, int32_t buflen, int answer_awaited) { int32_t l; - unsigned char rbuf[REQ_SIZE + 15 + 4], *sbuf = rbuf + 4; + uint8_t rbuf[REQ_SIZE + 15 + 4], *sbuf = rbuf + 4; if(!cl->udp_fd || !cl->crypted) { return (-1); } //exit if no fd or aes key not set! @@ -93,31 +93,31 @@ static int32_t __camd35_send(struct s_client *cl, uchar *buf, int32_t buflen, in return status; } -int32_t camd35_send(struct s_client *cl, uchar *buf, int32_t buflen) +int32_t camd35_send(struct s_client *cl, uint8_t *buf, int32_t buflen) { // send command and set sending time because we await response return __camd35_send(cl, buf, buflen, 1); } -int32_t camd35_send_without_timeout(struct s_client *cl, uchar *buf, int32_t buflen) +int32_t camd35_send_without_timeout(struct s_client *cl, uint8_t *buf, int32_t buflen) { // send command and do NOT set sending time because we DON'T await response return __camd35_send(cl, buf, buflen, 0); } -static int32_t camd35_auth_client(struct s_client *cl, uchar *ucrc) +static int32_t camd35_auth_client(struct s_client *cl, uint8_t *ucrc) { int32_t rc = 1, no_delay = 1; uint32_t crc; struct s_auth *account; - unsigned char md5tmp[MD5_DIGEST_LENGTH]; + uint8_t md5tmp[MD5_DIGEST_LENGTH]; if(cl->upwd[0]) { return (memcmp(cl->ucrc, ucrc, 4) ? 1 : 0); } cl->crypted = 1; crc = (((ucrc[0] << 24) | (ucrc[1] << 16) | (ucrc[2] << 8) | ucrc[3]) & 0xffffffffL); for(account = cfg.account; (account) && (!cl->upwd[0]); account = account->next) - if(crc == crc32(0L, MD5((unsigned char *)account->usr, strlen(account->usr), md5tmp), MD5_DIGEST_LENGTH)) + if(crc == crc32(0L, MD5((uint8_t *)account->usr, strlen(account->usr), md5tmp), MD5_DIGEST_LENGTH)) { rc = cs_auth_client(cl, account, NULL); if(!rc) @@ -128,7 +128,7 @@ static int32_t camd35_auth_client(struct s_client *cl, uchar *ucrc) { return 1; } - + #ifdef CS_CACHEEX if(cl->account->cacheex.mode < 2) #endif @@ -137,14 +137,14 @@ static int32_t camd35_auth_client(struct s_client *cl, uchar *ucrc) setsockopt(cl->udp_fd, IPPROTO_TCP, TCP_NODELAY, (void *)&no_delay, sizeof(no_delay)); cl->tcp_nodelay = 1; } - + return 0; } } return (rc); } -static int32_t camd35_recv(struct s_client *client, uchar *buf, int32_t l) +static int32_t camd35_recv(struct s_client *client, uint8_t *buf, int32_t l) { int32_t rc, s, rs, n = 0, buflen = 0, len = 0; for(rc = rs = s = 0; !rc; s++) @@ -198,7 +198,7 @@ static int32_t camd35_recv(struct s_client *client, uchar *buf, int32_t l) } if(rs < 36) - { + { if(rc != -5) { rc = -1; } goto out; @@ -312,7 +312,7 @@ static int32_t camd35_recv(struct s_client *client, uchar *buf, int32_t l) break; case -5: cs_log_dbg(client->typ == 'c' ? D_CLIENT : D_READER, "connection closed"); - break; + break; //default: cs_log_dbg(D_TRACE, "camd35_recv returns rc=%d", rc); break; } @@ -327,7 +327,7 @@ static void camd35_request_emm(ECM_REQUEST *er) { int32_t i; time_t now; - uchar mbuf[1024]; + uint8_t mbuf[1024]; struct s_client *cl = cur_client(); struct s_reader *aureader = NULL, *rdr = NULL; @@ -433,7 +433,7 @@ static void camd35_request_emm(ECM_REQUEST *er) static void camd35_send_dcw(struct s_client *client, ECM_REQUEST *er) { - uchar *buf; + uint8_t *buf; buf = er->src_data; // get orig request if(!buf) @@ -480,26 +480,26 @@ static void camd35_send_dcw(struct s_client *client, ECM_REQUEST *er) camd35_request_emm(er); } -static void camd35_process_ecm(uchar *buf, int buflen) +static void camd35_process_ecm(uint8_t *buf, int buflen) { ECM_REQUEST *er; - + if(!buf || buflen < 23) { return; } - + uint16_t ecmlen = SCT_LEN((&buf[20])); - + if(ecmlen > MAX_ECM_SIZE || ecmlen + 20 > buflen) { return; } - + if(!(er = get_ecmtask())) { return; } er->ecmlen = ecmlen; - + if(!cs_malloc(&er->src_data, 0x34 + 20 + er->ecmlen)) { NULLFREE(er); return; } - + memcpy(er->src_data, buf, 0x34 + 20 + er->ecmlen); // save request er->srvid = b2i(2, buf + 8); er->caid = b2i(2, buf + 10); @@ -509,7 +509,7 @@ static void camd35_process_ecm(uchar *buf, int buflen) get_cw(cur_client(), er); } -static void camd35_process_emm(uchar *buf, int buflen, int emmlen) +static void camd35_process_emm(uint8_t *buf, int buflen, int emmlen) { EMM_PACKET epg; if(!buf || buflen < 20 || emmlen + 20 > buflen) @@ -558,7 +558,7 @@ int32_t camd35_tcp_connect(struct s_client *cl) cl->pfd = cl->udp_fd = handle; } if(!cl->udp_fd) { return (0); } // Check if client has no handle -> error - + // check if client reached timeout if(cl->reader->tcp_rto && (cl->reader->last_s - cl->reader->last_g > cl->reader->tcp_rto)) { @@ -574,7 +574,7 @@ int32_t camd35_tcp_connect(struct s_client *cl) if(!hostResolve(cl->reader)) { network_tcp_connection_close(cl->reader, "no ip"); - return 0; + return 0; } if(!IP_EQUAL(last_ip, cl->ip)) { @@ -583,7 +583,7 @@ int32_t camd35_tcp_connect(struct s_client *cl) } } } - + return (1); // all ok } @@ -629,11 +629,11 @@ static void camd35_send_keepalive_answer(struct s_client *cl) static int32_t camd35_client_init(struct s_client *cl) { - unsigned char md5tmp[MD5_DIGEST_LENGTH]; + uint8_t md5tmp[MD5_DIGEST_LENGTH]; int32_t no_delay = 1; - + cs_strncpy((char *)cl->upwd, cl->reader->r_pwd, sizeof(cl->upwd)); - i2b_buf(4, crc32(0L, MD5((unsigned char *)cl->reader->r_usr, strlen(cl->reader->r_usr), md5tmp), 16), cl->ucrc); + i2b_buf(4, crc32(0L, MD5((uint8_t *)cl->reader->r_usr, strlen(cl->reader->r_usr), md5tmp), 16), cl->ucrc); if (!aes_set_key_alloc(&cl->aes_keys, (char *)MD5(cl->upwd, strlen((char *)cl->upwd), md5tmp))) { return 1; @@ -662,7 +662,7 @@ static void camd35_idle(void) if(!cl->reader) { return; } - if(cl->reader->keepalive) + if(cl->reader->keepalive) { camd35_send_keepalive(cl); } @@ -686,7 +686,7 @@ static void camd35_idle(void) } } -static void *camd35_server(struct s_client *client, uchar *mbuf, int32_t n) +static void *camd35_server(struct s_client *client, uint8_t *mbuf, int32_t n) { if(!client || !mbuf) { return NULL; } @@ -755,7 +755,7 @@ static int32_t camd35_send_ecm(struct s_client *client, ECM_REQUEST *er) uint8_t *buf; if(!cs_malloc(&buf, er->ecmlen + 20 + 15)) { return -1; } - + memset(buf, 0, 20); memset(buf + 20, 0xff, er->ecmlen + 15); buf[1] = er->ecmlen; @@ -767,7 +767,7 @@ static int32_t camd35_send_ecm(struct s_client *client, ECM_REQUEST *er) buf[19] = 0xff; memcpy(buf + 20, er->ecm, er->ecmlen); int32_t rc = ((camd35_send(client, buf, 0) < 1) ? (-1) : 0); - + NULLFREE(buf); return rc; } @@ -782,7 +782,7 @@ static int32_t camd35_send_emm(EMM_PACKET *ep) if(!cs_malloc(&buf, ep->emmlen + 20 + 15)) { return -1; } - + memset(buf, 0, 20); memset(buf + 20, 0xff, ep->emmlen + 15); @@ -793,17 +793,17 @@ static int32_t camd35_send_emm(EMM_PACKET *ep) memcpy(buf + 20, ep->emm, ep->emmlen); int32_t rc = ((camd35_send_without_timeout(cl, buf, 0) < 1) ? 0 : 1); - + NULLFREE(buf); - return rc; + return rc; } -static int32_t camd35_recv_chk(struct s_client *client, uchar *dcw, int32_t *rc, uchar *buf, int32_t rc2 __attribute__((unused))) +static int32_t camd35_recv_chk(struct s_client *client, uint8_t *dcw, int32_t *rc, uint8_t *buf, int32_t rc2 __attribute__((unused))) { uint16_t idx; static const char *typtext[] = {"ok", "invalid", "sleeping"}; struct s_reader *rdr = client->reader; - rdr->last_g = time(NULL); // last receive is now + rdr->last_g = time(NULL); // last receive is now // reading CMD05 Emm request and set serial if(buf[0] == 0x05 && buf[1] == 111) diff --git a/module-camd35.h b/module-camd35.h index e0f602b39..c45ee4a25 100644 --- a/module-camd35.h +++ b/module-camd35.h @@ -1,8 +1,8 @@ #ifndef MODULE_CAMD35_H_ #define MODULE_CAMD35_H_ -int32_t camd35_send(struct s_client *cl, uchar *buf, int32_t buflen); -int32_t camd35_send_without_timeout(struct s_client *cl, uchar *buf, int32_t buflen); +int32_t camd35_send(struct s_client *cl, uint8_t *buf, int32_t buflen); +int32_t camd35_send_without_timeout(struct s_client *cl, uint8_t *buf, int32_t buflen); int32_t camd35_tcp_connect(struct s_client *cl); #endif diff --git a/module-cccam-cacheex.c b/module-cccam-cacheex.c index 7a1a76ea4..75348a860 100644 --- a/module-cccam-cacheex.c +++ b/module-cccam-cacheex.c @@ -91,7 +91,7 @@ void cc_cacheex_filter_out(struct s_client *cl) cc_cmd_send(cl, buf, size, MSG_CACHE_FILTER); } -void cc_cacheex_filter_in(struct s_client *cl, uchar *buf) +void cc_cacheex_filter_in(struct s_client *cl, uint8_t *buf) { struct s_reader *rdr = (cl->typ == 'c') ? NULL : cl->reader; int i = 0, j; @@ -242,8 +242,8 @@ static int32_t cc_cacheex_push_out(struct s_client *cl, struct ecm_request_t *er uint32_t size = sizeof(er->ecmd5) + sizeof(er->csp_hash) + sizeof(er->cw) + sizeof(uint8_t) + (ll_count(er->csp_lastnodes) + 1) * 8; - unsigned char *buf; - if(!cs_malloc(&buf, size + 20)) //camd35_send() adds +20 + uint8_t *buf; + if(!cs_malloc(&buf, size + 20)) // camd35_send() adds +20 { return -1; } // build ecm message @@ -323,7 +323,7 @@ static int32_t cc_cacheex_push_out(struct s_client *cl, struct ecm_request_t *er return res; } -void cc_cacheex_push_in(struct s_client *cl, uchar *buf) +void cc_cacheex_push_in(struct s_client *cl, uint8_t *buf) { struct cc_data *cc = cl->cc; ECM_REQUEST *er; diff --git a/module-cccam-cacheex.h b/module-cccam-cacheex.h index 7702e79a2..0735f0db6 100644 --- a/module-cccam-cacheex.h +++ b/module-cccam-cacheex.h @@ -3,8 +3,8 @@ #ifdef CS_CACHEEX void cc_cacheex_filter_out(struct s_client *cl); -void cc_cacheex_filter_in(struct s_client *cl, uchar *buf); -void cc_cacheex_push_in(struct s_client *cl, uchar *buf); +void cc_cacheex_filter_in(struct s_client *cl, uint8_t *buf); +void cc_cacheex_push_in(struct s_client *cl, uint8_t *buf); void cc_cacheex_module_init(struct s_module *ph); #else static inline void cc_cacheex_filter_out(struct s_client *UNUSED(cl)) { } diff --git a/module-cccam.c b/module-cccam.c index b6a071d20..e31450139 100644 --- a/module-cccam.c +++ b/module-cccam.c @@ -131,14 +131,14 @@ void cc_cw_crypt(struct s_client *cl, uint8_t *cws, uint32_t cardid) } /** swap endianness (int) */ -static void SwapLBi(unsigned char *buff, int32_t len) +static void SwapLBi(uint8_t *buff, int32_t len) { #if __BYTE_ORDER != __BIG_ENDIAN return; #endif int32_t i; - unsigned char swap[4]; + uint8_t swap[4]; for(i = 0; i < len / 4; i++) { memcpy(swap, buff, 4); @@ -166,15 +166,15 @@ void cc_crypt_cmd0c(struct s_client *cl, uint8_t *buf, int32_t len) } case MODE_CMD_0x0C_RC6 : //RC6 { - // buf may be unaligned, + // buf may be unaligned, // so we use malloc() memory for the uint32_t* cast uint8_t *tmp; - int32_t i; - + int32_t i; + if(!cs_malloc(&tmp, len)) { return; } memcpy(tmp, buf, len); - + SwapLBi(tmp, len); for(i = 0; i < len / 16; i++) { rc6_block_decrypt((uint32_t *)(tmp + i * 16), (uint32_t *)(out + i * 16), 1, cc->cmd0c_RC6_cryptkey); } @@ -198,11 +198,11 @@ void cc_crypt_cmd0c(struct s_client *cl, uint8_t *buf, int32_t len) { int32_t i; for(i = 0; i < len / 16; i++) - AES_decrypt((unsigned char *) buf + i * 16, - (unsigned char *) out + i * 16, &cc->cmd0c_AES_key); + AES_decrypt((uint8_t *)buf + i * 16, + (uint8_t *)out + i * 16, &cc->cmd0c_AES_key); break; } - case MODE_CMD_0x0C_IDEA : //IDEA + case MODE_CMD_0x0C_IDEA : // IDEA { int32_t i = 0; int32_t j; @@ -266,7 +266,7 @@ void set_cmd0c_cryptkey(struct s_client *cl, uint8_t *key, uint8_t len) case MODE_CMD_0x0C_AES: //AES { memset(&cc->cmd0c_AES_key, 0, sizeof(cc->cmd0c_AES_key)); - AES_set_decrypt_key((unsigned char *) key_buf, 256, &cc->cmd0c_AES_key); + AES_set_decrypt_key((uint8_t *)key_buf, 256, &cc->cmd0c_AES_key); break; } @@ -352,10 +352,10 @@ void add_sid_block(struct cc_card *card, struct cc_srvid *srvid_blocked, bool te if(!cs_malloc(&srvid, sizeof(struct cc_srvid_block))) { return; } memcpy(srvid, srvid_blocked, sizeof(struct cc_srvid)); - - if(temporary) + + if(temporary) { srvid->blocked_till = time(NULL) + BLOCKING_SECONDS; } - + ll_append(card->badsids, srvid); cs_log_dbg(D_READER, "added sid block %04X(CHID %04X, length %d) for card %08x", srvid_blocked->sid, srvid_blocked->chid, srvid_blocked->ecmlen, card->id); @@ -368,9 +368,9 @@ void remove_sid_block(struct cc_card *card, struct cc_srvid *srvid_blocked) while((srvid = ll_iter_next(&it))) if(sid_eq_nb(srvid_blocked, srvid)) { ll_iter_remove_data(&it); } - + cs_log_dbg(D_READER, "removed sid block %04X(CHID %04X, length %d) for card %08x", - srvid_blocked->sid, srvid_blocked->chid, srvid_blocked->ecmlen, card->id); + srvid_blocked->sid, srvid_blocked->chid, srvid_blocked->ecmlen, card->id); } void add_good_sid(struct cc_card *card, struct cc_srvid *srvid_good) @@ -394,8 +394,8 @@ void remove_good_sid(struct cc_card *card, struct cc_srvid *srvid_good) while((srvid = ll_iter_next(&it))) if(sid_eq(srvid, srvid_good)) { ll_iter_remove_data(&it); } - - cs_log_dbg(D_READER, "removed good sid %04X(%d) for card %08x", srvid_good->sid, srvid_good->ecmlen, card->id); + + cs_log_dbg(D_READER, "removed good sid %04X(%d) for card %08x", srvid_good->sid, srvid_good->ecmlen, card->id); } /** @@ -997,10 +997,10 @@ int32_t send_cmd05_answer(struct s_client *cl) memcpy(aeskey, cc->cmd05_aeskey, 16); memset(&key, 0, sizeof(key)); - AES_set_encrypt_key((unsigned char *) &aeskey, 128, &key); + AES_set_encrypt_key((uint8_t *) &aeskey, 128, &key); int32_t i; for(i = 0; i < 256; i += 16) - AES_encrypt((unsigned char *) data + i, (unsigned char *) &out + AES_encrypt((uint8_t *)data + i, (uint8_t *) &out + i, &key); cc_cmd_send(cl, out, 256, MSG_CMD_05); @@ -1293,15 +1293,15 @@ struct cc_card *get_matching_card(struct s_client *cl, ECM_REQUEST *cur_er, int8 // needed for wantemu || lb_match ) - { + { int32_t goodSidCount = ll_count(ncard->goodsids); int32_t badSidCount = ll_count(ncard->badsids); struct cc_srvid *good_sid; struct cc_srvid_block *blocked_sid; - + // only good sids -> check if sid is good if(goodSidCount && !badSidCount) - { + { good_sid = is_good_sid(ncard, &cur_srvid); if(!good_sid) { continue; } @@ -1312,13 +1312,13 @@ struct cc_card *get_matching_card(struct s_client *cl, ECM_REQUEST *cur_er, int8 blocked_sid = is_sid_blocked(ncard, &cur_srvid); if(blocked_sid && (!chk_only || blocked_sid->blocked_till == 0)) { continue; } - } + } // bad and good sids -> check not blocked and good else if (goodSidCount && badSidCount) { - blocked_sid = is_sid_blocked(ncard, &cur_srvid); + blocked_sid = is_sid_blocked(ncard, &cur_srvid); good_sid = is_good_sid(ncard, &cur_srvid); - + if(blocked_sid && (!chk_only || blocked_sid->blocked_till == 0)) { continue; } if(!good_sid) @@ -2049,7 +2049,7 @@ void cc_idle(void) return; } } - + //check read timeout: int32_t rto = llabs(rdr->last_g - now); //cs_log("last_g - now = %d, rto=%d", rto, rdr->tcp_rto); @@ -2097,16 +2097,16 @@ struct cc_card *read_card(uint8_t *buf, int32_t buflen, int32_t ext) { if(buflen < 23) { cc_free_card(card); return NULL; } - + nassign = buf[21]; nreject = buf[22]; offset += 2; } - + if(buflen < (offset + (nprov*7))) { cc_free_card(card); return NULL; } - + int16_t i; for(i = 0; i < nprov; i++) // providers { @@ -2128,7 +2128,7 @@ struct cc_card *read_card(uint8_t *buf, int32_t buflen, int32_t ext) { if(buflen < (offset + (nassign*2) + (nreject*2))) { cc_free_card(card); return NULL; } - + for(i = 0; i < nassign; i++) { uint16_t sid = b2i(2, buf + offset); @@ -2160,16 +2160,16 @@ struct cc_card *read_card(uint8_t *buf, int32_t buflen, int32_t ext) offset += 2; } } - + if(buflen < (offset + 1)) { return card; } - + int16_t remote_count = buf[offset]; offset++; - + if(buflen < (offset + (remote_count*8))) { cc_free_card(card); return NULL; } - + for(i = 0; i < remote_count; i++) { uint8_t *remote_node; @@ -2312,10 +2312,10 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) cs_log_dbg(cl->typ == 'c' ? D_CLIENT : D_READER, "%s parse_msg=%d", getprefix(), buf[1]); uint8_t *data = buf + 4; - + if(l < 4) { return -1; } - + memcpy(&cc->receive_buffer, data, l - 4); cc->last_msg = buf[1]; switch(buf[1]) @@ -2459,7 +2459,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) { if(l < 16) { break; } - + uint16_t caid = b2i(2, buf + 12); //filter caid==0 and maxhop: if(!caid || buf[14] >= rdr->cc_maxhops + 1) @@ -2588,7 +2588,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) case MSG_CW_NOK2: if(l < 2) { break; } - + if(l > 5) { //Received NOK with payload: @@ -2621,7 +2621,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) strcat(param, "]"); } - uchar token[256]; + uint8_t token[256]; snprintf((char *)token, sizeof(token), "PARTNER: OSCam v%s, build r%s (%s)%s", CS_VERSION, CS_SVN_VERSION, CS_TARGET, param); @@ -2799,7 +2799,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) cc_send_ecm(cl, NULL); break; - + case MSG_CACHE_PUSH: { if((l - 4) >= 18) @@ -2808,7 +2808,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) } break; } - + case MSG_CACHE_FILTER: { if((l - 4) >= 482) @@ -2826,10 +2826,10 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) ECM_REQUEST *er; struct cc_card *server_card; - + if(l < CCMSG_HEADER_LEN) { break; } - + if(!cs_malloc(&server_card, sizeof(struct cc_card))) { break; } server_card->id = buf[10] << 24 | buf[11] << 16 | buf[12] << 8 @@ -2939,7 +2939,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) { if(l < 20) { break; } - + cs_readlock(__func__, &cc->cards_busy); cc->recv_ecmtask = -1; eei = get_extended_ecm_idx(cl, @@ -3057,7 +3057,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) rdr->last_s = time(NULL); rdr_log_dbg(rdr, D_READER, "%s: receive keepalive", __func__); } - + cc->just_logged_in = 0; break; @@ -3068,7 +3068,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) l = l - 4;//Header Length=4 Byte if(l < 0) { break; } - + cs_log_dbg(D_READER, "%s MSG_CMD_05 recvd, payload length=%d mode=%d", getprefix(), l, cc->cmd05_mode); cc->cmd05_active = 1; @@ -3082,7 +3082,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) { if(l < 20) { break; } - + // by Project:Keynation cs_log_dbg(D_READER, "%s MSG_CMD_0B received (payload=%d)!", getprefix(), l - 4); @@ -3097,8 +3097,8 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) //cs_log_dump_dbg(D_READER, aeskey, 16, "%s CMD_0B AES key:", getprefix()); //cs_log_dump_dbg(D_READER, data, 16, "%s CMD_0B received data:", getprefix()); - AES_set_encrypt_key((unsigned char *) &aeskey, 128, &key); - AES_encrypt((unsigned char *) data, (unsigned char *) &out, &key); + AES_set_encrypt_key((uint8_t *) &aeskey, 128, &key); + AES_encrypt((uint8_t *)data, (uint8_t *) &out, &key); cs_log_dbg(D_TRACE, "%s sending CMD_0B! ", getprefix()); //cs_log_dump_dbg(D_READER, out, 16, "%s CMD_0B out:", getprefix()); @@ -3198,7 +3198,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) int32_t len = l - 4; if(len < 0) { break; } - + if(cc->cmd0c_mode == MODE_CMD_0x0C_NONE) { break; } @@ -3214,7 +3214,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) { if(l < 2) { break; } - + cs_log_dbg(D_READER, "cccam 2.2.x commands not implemented: 0x%02X", buf[1]); //Unkwon commands...need workout algo if(cl->typ == 'c') //client connection @@ -3238,9 +3238,9 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) if(cl->typ == 'c') //EMM Request received { cc_cmd_send(cl, NULL, 0, MSG_EMM_ACK); //Send back ACK - + if(l < 16) - { break; } + { break; } cs_log_dbg(D_EMM, "%s EMM Request received!", getprefix()); @@ -3270,10 +3270,10 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) { emm->emmlen = buf[15]; } else { emm->emmlen = MIN(l - 16, (int32_t)sizeof(emm->emm)); } - + if(emm->emmlen < 0 || emm->emmlen > MAX_EMM_SIZE || emm->emmlen+16 > l) { NULLFREE(emm); break;} - + memcpy(emm->emm, buf + 16, emm->emmlen); //emm->type = UNKNOWN; //emm->cidx = cs_idx; @@ -3308,7 +3308,7 @@ int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) /** * Reader: write dcw to receive */ -int32_t cc_recv_chk(struct s_client *cl, uchar *dcw, int32_t *rc, uchar *buf, int32_t UNUSED(n)) +int32_t cc_recv_chk(struct s_client *cl, uint8_t *dcw, int32_t *rc, uint8_t *buf, int32_t UNUSED(n)) { struct cc_data *cc = cl->cc; @@ -3357,7 +3357,7 @@ int32_t cc_recv_chk(struct s_client *cl, uchar *dcw, int32_t *rc, uchar *buf, in */ void cc_send_dcw(struct s_client *cl, ECM_REQUEST *er) { - uchar buf[16]; + uint8_t buf[16]; struct cc_data *cc = cl->cc; memset(buf, 0, sizeof(buf)); @@ -3414,7 +3414,7 @@ void cc_send_dcw(struct s_client *cl, ECM_REQUEST *er) } } -int32_t cc_recv(struct s_client *cl, uchar *buf, int32_t l) +int32_t cc_recv(struct s_client *cl, uint8_t *buf, int32_t l) { int32_t n; struct s_reader *rdr = (cl->typ == 'c') ? NULL : cl->reader; @@ -3526,7 +3526,7 @@ int32_t cc_srv_connect(struct s_client *cl) char usr[21], pwd[65], tmp_dbg[17]; struct s_auth *account; struct cc_data *cc; - + if(!cs_malloc(&cc, sizeof(struct cc_data))) { return -1; } @@ -3720,10 +3720,10 @@ int32_t cc_srv_connect(struct s_client *cl) if(i < 0) { return -1; } cs_log_dump_dbg(D_CLIENT, buf, i, "cccam: cli data:"); - + if(i < 66) { cs_log_dbg(D_CLIENT, "cccam: cli data too small"); return -1; } - + memcpy(cc->peer_node_id, buf + 24, 8); //chk_peer_node_for_oscam(cc); @@ -3803,7 +3803,7 @@ void cc_srv_init2(struct s_client *cl) return; } -void *cc_srv_init(struct s_client *cl, uchar *UNUSED(mbuf), int32_t UNUSED(len)) +void *cc_srv_init(struct s_client *cl, uint8_t *UNUSED(mbuf), int32_t UNUSED(len)) { cc_srv_init2(cl); return NULL; @@ -3867,7 +3867,7 @@ int32_t cc_cli_connect(struct s_client *cl) block_connect(rdr); return -1; } - + int32_t no_delay = 1; if(cacheex_get_rdr_mode(rdr) < 2) setsockopt(cl->udp_fd, IPPROTO_TCP, TCP_NODELAY, (void *)&no_delay, sizeof(no_delay)); diff --git a/module-cccshare.c b/module-cccshare.c index 8eb39f404..11d0e98bb 100644 --- a/module-cccshare.c +++ b/module-cccshare.c @@ -37,7 +37,6 @@ LLIST *get_cardlist(uint16_t caid, LLIST **list) return list[caid]; } - LLIST **get_and_lock_sharelist(void) { cs_readlock(__func__, &cc_shares_lock); @@ -59,10 +58,10 @@ void add_good_sids(struct s_sidtab *ptr, struct cc_card *card) { return; } srvid->sid = ptr->srvid[l]; srvid->chid = 0; - srvid->ecmlen = 0; //0=undefined, also not used with "O" CCcam - + srvid->ecmlen = 0; // 0=undefined, also not used with "O" CCcam + if(!ll_contains_data(card->goodsids, srvid, sizeof(struct cc_srvid))) - { ll_append(card->goodsids, srvid); } + { ll_append(card->goodsids, srvid); } else { NULLFREE(srvid);} } } @@ -77,9 +76,9 @@ void add_bad_sids(struct s_sidtab *ptr, struct cc_card *card) { return; } srvid->sid = ptr->srvid[l]; srvid->chid = 0; - srvid->ecmlen = 0; //0=undefined, also not used with "O" CCcam + srvid->ecmlen = 0; // 0=undefined, also not used with "O" CCcam srvid->blocked_till = 0; - + if(!ll_contains_data(card->badsids, srvid, sizeof(struct cc_srvid_block))) { ll_append(card->badsids, srvid); } else { NULLFREE(srvid); } @@ -111,7 +110,6 @@ void add_good_bad_sids_by_rdr(struct s_reader *rdr, struct cc_card *card) } } - int32_t can_use_ext(struct cc_card *card) { if(card->card_type == CT_REMOTECARD) @@ -142,10 +140,10 @@ int32_t write_card(struct cc_data *cc, uint8_t *buf, struct cc_card *card, int32 if(au_allowed) { memcpy(buf + 12, card->hexserial, 8); } - //with cccam 2.2.0 we have assigned and rejected sids: + // with cccam 2.2.0 we have assigned and rejected sids: int32_t ofs = ext ? 23 : 21; - //write providers: + // write providers: LL_ITER it = ll_iter_create(card->providers); struct cc_provider *prov; while((prov = ll_iter_next(&it))) @@ -160,12 +158,12 @@ int32_t write_card(struct cc_data *cc, uint8_t *buf, struct cc_card *card, int32 ofs += 7; } - //write sids only if cccam 2.2.x: + // write sids only if cccam 2.2.x: if(ext) { if(card->sidtab) { - //good sids: + // good sids: struct s_sidtab *ptr = card->sidtab; int32_t l; for(l = 0; l < ptr->num_srvid; l++) @@ -173,12 +171,12 @@ int32_t write_card(struct cc_data *cc, uint8_t *buf, struct cc_card *card, int32 buf[ofs + 0] = ptr->srvid[l] >> 8; buf[ofs + 1] = ptr->srvid[l] & 0xFF; ofs += 2; - buf[21]++; //nassign + buf[21]++; // nassign if(buf[21] >= 240) { break; } } - //bad sids: + // bad sids: int32_t n; for(n = 0, ptr = cfg.sidtab; ptr; ptr = ptr->next, n++) { @@ -186,7 +184,7 @@ int32_t write_card(struct cc_data *cc, uint8_t *buf, struct cc_card *card, int32 { int32_t m; int32_t ok_caid = 0; - for(m = 0; m < ptr->num_caid; m++) //search bad sids for this caid: + for(m = 0; m < ptr->num_caid; m++) // search bad sids for this caid: { if(ptr->caid[m] == card->caid) { @@ -201,7 +199,7 @@ int32_t write_card(struct cc_data *cc, uint8_t *buf, struct cc_card *card, int32 buf[ofs + 0] = ptr->srvid[l] >> 8; buf[ofs + 1] = ptr->srvid[l] & 0xFF; ofs += 2; - buf[22]++; //nreject + buf[22]++; // nreject if(buf[22] >= 240) { break; } } @@ -214,7 +212,7 @@ int32_t write_card(struct cc_data *cc, uint8_t *buf, struct cc_card *card, int32 } else { - //assigned sids: + // assigned sids: it = ll_iter_create(card->goodsids); struct cc_srvid *srvid; struct cc_srvid_block *srvidblock; @@ -223,30 +221,30 @@ int32_t write_card(struct cc_data *cc, uint8_t *buf, struct cc_card *card, int32 buf[ofs + 0] = srvid->sid >> 8; buf[ofs + 1] = srvid->sid & 0xFF; ofs += 2; - buf[21]++; //nassign + buf[21]++; // nassign if(buf[21] >= 200) { break; } } - //reject sids: + // reject sids: it = ll_iter_create(card->badsids); while((srvidblock = ll_iter_next(&it))) { if(srvidblock->blocked_till > 0) { - continue; + continue; } buf[ofs + 0] = srvidblock->sid >> 8; buf[ofs + 1] = srvidblock->sid & 0xFF; ofs += 2; - buf[22]++; //nreject + buf[22]++; // nreject if(buf[22] >= 200) { break; } } } } - //write remote nodes + // write remote nodes int32_t nremote_ofs = ofs; ofs++; it = ll_iter_create(card->remote_nodes); @@ -272,12 +270,12 @@ static int32_t is_client_au_allowed(struct cc_card *card, struct s_client *cl) { return 0; } - + if(!cl || !cl->aureader_list || !ll_count(cl->aureader_list)) { return 0; } - + struct s_reader *rdr = NULL; LL_ITER itr = ll_iter_create(cl->aureader_list); while((rdr = ll_iter_next(&itr))) @@ -287,7 +285,7 @@ static int32_t is_client_au_allowed(struct cc_card *card, struct s_client *cl) return 1; } } - + return 0; } @@ -358,7 +356,7 @@ int32_t send_card_to_all_clients(struct cc_card *card) cs_readlock(__func__, &clientlist_lock); for(cl = first_client; cl; cl = cl->next) { - if(cl->cc && cl->typ == 'c' && !cl->kill && get_module(cl)->num == R_CCCAM) //CCCam-Client! + if(cl->cc && cl->typ == 'c' && !cl->kill && get_module(cl)->num == R_CCCAM) // CCCam-Client! { count += send_card_to_client(card, cl); } @@ -384,7 +382,7 @@ void send_remove_card_to_clients(struct cc_card *card) for(cl = first_client; cl; cl = cl->next) { struct cc_data *cc = cl->cc; - if(cc && cl->typ == 'c' && !cl->kill && get_module(cl)->num == R_CCCAM) //CCCam-Client! + if(cc && cl->typ == 'c' && !cl->kill && get_module(cl)->num == R_CCCAM) // CCCam-Client! { if(card_valid_for_client(cl, card)) { @@ -422,11 +420,11 @@ int32_t chk_ident(FTAB *ftab, struct cc_card *card) if(ftab->filts[j].caid) { res = 0; - if(ftab->filts[j].caid == card->caid) //caid matches! + if(ftab->filts[j].caid == card->caid) // caid matches! { int32_t nprids = ftab->filts[j].nprids; - if(!nprids) // No Provider ->Ok + if(!nprids) // No Provider ->Ok { return 1; } @@ -438,7 +436,7 @@ int32_t chk_ident(FTAB *ftab, struct cc_card *card) for(k = 0; k < nprids; k++) { uint32_t prid = ftab->filts[j].prids[k]; - if(prid == prov->prov) //Provider matches + if(prid == prov->prov) // Provider matches { return 1; } @@ -451,8 +449,7 @@ int32_t chk_ident(FTAB *ftab, struct cc_card *card) return res; } -int32_t cc_clear_reported_carddata(LLIST *reported_carddatas, LLIST *except, - int32_t send_removed) +int32_t cc_clear_reported_carddata(LLIST *reported_carddatas, LLIST *except, int32_t send_removed) { int32_t i = 0; LL_ITER it = ll_iter_create(reported_carddatas); @@ -470,12 +467,12 @@ int32_t cc_clear_reported_carddata(LLIST *reported_carddatas, LLIST *except, } } - if(!card2 && ll_iter_remove(&it)) //check result of ll_iter_remove, because another thread could removed it + if(!card2 && ll_iter_remove(&it)) // check result of ll_iter_remove, because another thread could removed it { if(send_removed) { cs_log_dbg(D_TRACE, "s-card removed: id %8X remoteid %8X caid %4X hop %d reshare %d originid %8X cardtype %d", - card->id, card->remote_id, card->caid, card->hop, card->reshare, card->origin_id, card->card_type); + card->id, card->remote_id, card->caid, card->hop, card->reshare, card->origin_id, card->card_type); send_remove_card_to_clients(card); } @@ -486,8 +483,7 @@ int32_t cc_clear_reported_carddata(LLIST *reported_carddatas, LLIST *except, return i; } -int32_t cc_free_reported_carddata(LLIST *reported_carddatas, LLIST *except, - int32_t send_removed) +int32_t cc_free_reported_carddata(LLIST *reported_carddatas, LLIST *except, int32_t send_removed) { int32_t i = 0; if(reported_carddatas) @@ -501,19 +497,19 @@ int32_t cc_free_reported_carddata(LLIST *reported_carddatas, LLIST *except, int32_t card_valid_for_client(struct s_client *cl, struct cc_card *card) { - //Check group: + // Check group: if(card->grp && !(card->grp & cl->grp)) { return 0; } - //Check idents: + // Check idents: if(!chk_ident(&cl->ftab, card)) { return 0; } - //Check caids: + // Check caids: if(!chk_ctab(card->caid, &cl->ctab)) { return 0; } - //Check reshare + // Check reshare if(card->card_type == CT_REMOTECARD) { int8_t ignorereshare = cl->account->cccignorereshare; @@ -522,11 +518,11 @@ int32_t card_valid_for_client(struct s_client *cl, struct cc_card *card) { return 0; } } - //Check account maxhops: + // Check account maxhops: if(cl->account->cccmaxhops < card->hop) { return 0; } - //Check remote node id, if card is from there, ignore it! + // Check remote node id, if card is from there, ignore it! LL_ITER it = ll_iter_create(card->remote_nodes); uint8_t *node; struct cc_data *cc = cl->cc; @@ -538,7 +534,7 @@ int32_t card_valid_for_client(struct s_client *cl, struct cc_card *card) } } - //Check Services: + // Check Services: if(ll_count(card->providers)) { it = ll_iter_create(card->providers); @@ -561,15 +557,15 @@ int32_t card_valid_for_client(struct s_client *cl, struct cc_card *card) { return 0; } } - //Check Card created by Service: + // Check Card created by Service: if(card->sidtab) { struct s_sidtab *ptr; int32_t j; - int32_t ok = !cl->sidtabs.ok && !cl->sidtabs.no; //default valid if no positive services and no negative services + int32_t ok = !cl->sidtabs.ok && !cl->sidtabs.no; // default valid if no positive services and no negative services if(!ok) { - if(!cl->sidtabs.ok) // no positive services, so ok by default if no negative found + if(!cl->sidtabs.ok) // no positive services, so ok by default if no negative found { ok = 1; } for(j = 0, ptr = cfg.sidtab; ptr; ptr = ptr->next, j++) @@ -658,12 +654,11 @@ void copy_bad_sids(LLIST *dst, LLIST *src) } } -int32_t add_card_providers(struct cc_card *dest_card, struct cc_card *card, - int32_t copy_remote_nodes) +int32_t add_card_providers(struct cc_card *dest_card, struct cc_card *card, int32_t copy_remote_nodes) { int32_t modified = 0; - //1. Copy nonexisting providers, ignore double: + // 1. Copy nonexisting providers, ignore double: struct cc_provider *prov_info; LL_ITER it_src = ll_iter_create(card->providers); LL_ITER it_dst = ll_iter_create(dest_card->providers); @@ -690,7 +685,7 @@ int32_t add_card_providers(struct cc_card *dest_card, struct cc_card *card, if(copy_remote_nodes) { - //2. Copy nonexisting remote_nodes, ignoring existing: + // 2. Copy nonexisting remote_nodes, ignoring existing: it_src = ll_iter_create(card->remote_nodes); it_dst = ll_iter_create(dest_card->remote_nodes); uint8_t *remote_node; @@ -848,11 +843,11 @@ void merge_sids(struct cc_card *carddst, struct cc_card *cardsrc) LL_ITER it; struct cc_srvid *srvid; struct cc_srvid_block *srvidb; - - int32_t goodSidCountSrc = ll_count(cardsrc->goodsids); - int32_t goodSidCountDst = ll_count(carddst->goodsids); - - if(goodSidCountDst == 0) + + int32_t goodSidCountSrc = ll_count(cardsrc->goodsids); + int32_t goodSidCountDst = ll_count(carddst->goodsids); + + if(goodSidCountDst == 0) { // remove sid blocks good+notbad from src it = ll_iter_create(cardsrc->goodsids); @@ -871,13 +866,13 @@ void merge_sids(struct cc_card *carddst, struct cc_card *cardsrc) // del bads from dst ll_clear(carddst->badsids); - + // add bads from src it = ll_iter_create(cardsrc->badsids); while((srvidb = ll_iter_next(&it))) { { add_sid_block(carddst, (struct cc_srvid*)srvidb, false); } - } + } } else { @@ -887,10 +882,10 @@ void merge_sids(struct cc_card *carddst, struct cc_card *cardsrc) { if(!is_sid_blocked(cardsrc, srvid)) { add_good_sid(carddst, srvid); } - } + } } } - + } /** @@ -906,68 +901,68 @@ int32_t add_card_to_serverlist(LLIST *cardlist, struct cc_card *card, int8_t fre LL_ITER it = ll_iter_create(cardlist); struct cc_card *card2; - //Minimize all, transmit just CAID, merge providers: + // Minimize all, transmit just CAID, merge providers: if(cfg.cc_minimize_cards == MINIMIZE_CAID && !cfg.cc_forward_origin_card) { while((card2 = ll_iter_next(&it))) { - //compare caid, hexserial, cardtype and sidtab (if any): + // compare caid, hexserial, cardtype and sidtab (if any): if(same_card2(card, card2, 0)) { - //Merge cards only if resulting providercount is smaller than CS_MAXPROV + // Merge cards only if resulting providercount is smaller than CS_MAXPROV int32_t nsame, ndiff, nnew; - nsame = num_same_providers(card, card2); //count same cards - ndiff = ll_count(card->providers) - nsame; //cound different cards, this cound will be added - nnew = ndiff + ll_count(card2->providers); //new card count after add. because its limited to CS_MAXPROV, dont add it + nsame = num_same_providers(card, card2); // count same cards + ndiff = ll_count(card->providers) - nsame; // cound different cards, this cound will be added + nnew = ndiff + ll_count(card2->providers); // new card count after add. because its limited to CS_MAXPROV, dont add it if(nnew <= CS_MAXPROV) { break; } } } - if(!card2) //Not found->add it: + if(!card2) // Not found->add it: { - if(free_card) //Use this card + if(free_card) // Use this card { free_card = 0; ll_iter_insert(&it, card); } else { - card2 = create_card(card); //Copy card + card2 = create_card(card); // Copy card if(!card2) { return modified; } card2->hop = 0; ll_iter_insert(&it, card2); - add_card_providers(card2, card, 1); //copy providers to new card. Copy remote nodes to new card + add_card_providers(card2, card, 1); // copy providers to new card. Copy remote nodes to new card } modified = 1; } - else //found, merge providers: + else // found, merge providers: { card_dup_count++; - card2->grp |= card->grp; //add group to the card - add_card_providers(card2, card, 0); //merge all providers - ll_clear_data(card2->remote_nodes); //clear remote nodes + card2->grp |= card->grp; // add group to the card + add_card_providers(card2, card, 0); // merge all providers + ll_clear_data(card2->remote_nodes); // clear remote nodes merge_sids(card2, card); } } - //Removed duplicate cards, keeping card with lower hop: + // Removed duplicate cards, keeping card with lower hop: else if(cfg.cc_minimize_cards == MINIMIZE_HOPS && !cfg.cc_forward_origin_card) { while((card2 = ll_iter_next(&it))) { - //compare caid, hexserial, cardtype, sidtab (if any), providers: + // compare caid, hexserial, cardtype, sidtab (if any), providers: if(same_card2(card, card2, 0) && equal_providers(card, card2)) { break; } } - if(card2 && card2->hop > card->hop) //hop is smaller, drop old card + if(card2 && card2->hop > card->hop) // hop is smaller, drop old card { ll_iter_remove(&it); cc_free_card(card2); @@ -975,24 +970,24 @@ int32_t add_card_to_serverlist(LLIST *cardlist, struct cc_card *card, int8_t fre card_dup_count++; } - if(!card2) //Not found->add it: + if(!card2) // Not found->add it: { - if(free_card) //use this card + if(free_card) // use this card { free_card = 0; ll_iter_insert(&it, card); } else { - card2 = create_card(card); //copy card + card2 = create_card(card); // copy card if(!card2) { return modified; } ll_iter_insert(&it, card2); - add_card_providers(card2, card, 1); //copy providers to new card. Copy remote nodes to new card + add_card_providers(card2, card, 1); // copy providers to new card. Copy remote nodes to new card } modified = 1; } - else //found, merge cards (providers are same!) + else // found, merge cards (providers are same!) { card_dup_count++; card2->grp |= card->grp; //add group to the card @@ -1001,24 +996,24 @@ int32_t add_card_to_serverlist(LLIST *cardlist, struct cc_card *card, int8_t fre } } - //like cccam: - else //just remove duplicate cards (same ids) + // like cccam: + else // just remove duplicate cards (same ids) { while((card2 = ll_iter_next(&it))) { - //compare remote_id, first_node, caid, hexserial, cardtype, sidtab (if any), providers: + // compare remote_id, first_node, caid, hexserial, cardtype, sidtab (if any), providers: if(same_card(card, card2)) { break; } } - if(card2 && card2->hop > card->hop) //same card, if hop greater drop card + if(card2 && card2->hop > card->hop) // same card, if hop greater drop card { ll_iter_remove(&it); cc_free_card(card2); card2 = NULL; card_dup_count++; } - if(!card2) //Not found, add it: + if(!card2) // Not found, add it: { if(free_card) { @@ -1035,7 +1030,7 @@ int32_t add_card_to_serverlist(LLIST *cardlist, struct cc_card *card, int8_t fre } modified = 1; } - else //Found, everything is same (including providers) + else // Found, everything is same (including providers) { card_dup_count++; } @@ -1670,7 +1665,7 @@ void cccam_init_share(void) share_updater_thread = 0; share_updater_thread_active = 1; share_updater_refresh = 0; - + pthread_t temp; int32_t ret = start_thread("share updater", (void *)&share_updater, NULL, &temp, 1, 1); if(!ret) diff --git a/module-constcw.c b/module-constcw.c index 845762fe5..01370c7e6 100644 --- a/module-constcw.c +++ b/module-constcw.c @@ -24,7 +24,7 @@ int32_t constcw_file_available(void) return (1); } -int32_t constcw_analyse_file(uint16_t c_caid, uint32_t c_prid, uint16_t c_sid, uint16_t c_pmtpid, uint32_t c_vpid, uint16_t c_ecmpid, uchar *dcw) +int32_t constcw_analyse_file(uint16_t c_caid, uint32_t c_prid, uint16_t c_sid, uint16_t c_pmtpid, uint32_t c_vpid, uint16_t c_ecmpid, uint8_t *dcw) { //CAID:PROVIDER:SID:PMTPID:ECMPID:VPID:XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX FILE *fp; @@ -48,22 +48,22 @@ int32_t constcw_analyse_file(uint16_t c_caid, uint32_t c_prid, uint16_t c_sid, u int ret = sscanf(token, "%4x:%6x:%4x:%4x:%4x::%2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x", &caid, &provid, &sid, &pmtpid, &ecmpid, &cw[0], &cw[1], &cw[2], &cw[3], &cw[4], &cw[5], &cw[6], &cw[7], &cw[8], &cw[9], &cw[10], &cw[11], &cw[12], &cw[13], &cw[14], &cw[15]); - - if(ret != 21){ + + if(ret != 21){ ret = sscanf(token, "%4x:%6x:%4x:%4x:%4x:%4x:%2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x", &caid, &provid, &sid, &pmtpid, &ecmpid, &vpid, &cw[0], &cw[1], &cw[2], &cw[3], &cw[4], &cw[5], &cw[6], &cw[7], &cw[8], &cw[9], &cw[10], &cw[11], &cw[12], &cw[13], &cw[14], &cw[15]); if(ret != 22) continue; - } + } //cs_log("Line found: %s", token); - if(c_caid == caid && c_sid == sid && (!provid || provid == c_prid) && (!pmtpid || !c_pmtpid || pmtpid == c_pmtpid) && (!vpid || !c_vpid || vpid == c_vpid) + if(c_caid == caid && c_sid == sid && (!provid || provid == c_prid) && (!pmtpid || !c_pmtpid || pmtpid == c_pmtpid) && (!vpid || !c_vpid || vpid == c_vpid) && (!ecmpid || !c_ecmpid || ecmpid == c_ecmpid)) { fclose(fp); int8_t i; for(i = 0; i < 16; ++i) - { dcw[i] = (uchar) cw[i]; } + { dcw[i] = (uint8_t) cw[i]; } cs_log("Entry found: %04X@%06X:%04X:%04X:%04X:%04X:%s", caid, provid, sid, pmtpid, ecmpid, vpid, cs_hexdump(1, dcw, 16, token, sizeof(token))); return 1; } @@ -75,7 +75,7 @@ int32_t constcw_analyse_file(uint16_t c_caid, uint32_t c_prid, uint16_t c_sid, u //************************************************************************************************************************ //* client/server common functions //************************************************************************************************************************ -static int32_t constcw_recv(struct s_client *client, uchar *buf, int32_t l) +static int32_t constcw_recv(struct s_client *client, uint8_t *buf, int32_t l) { int32_t ret; @@ -125,7 +125,7 @@ static int32_t constcw_send_ecm(struct s_client *client, ECM_REQUEST *er) { time_t t; struct s_reader *rdr = client->reader; - uchar cw[16]; + uint8_t cw[16]; t = time(NULL); // Check if DCW exist in the files @@ -145,7 +145,7 @@ static int32_t constcw_send_ecm(struct s_client *client, ECM_REQUEST *er) return (0); } -static int32_t constcw_recv_chk(struct s_client *UNUSED(client), uchar *UNUSED(dcw), int32_t *rc, uchar *UNUSED(buf), int32_t UNUSED(n)) +static int32_t constcw_recv_chk(struct s_client *UNUSED(client), uint8_t *UNUSED(dcw), int32_t *rc, uint8_t *UNUSED(buf), int32_t UNUSED(n)) { //dcw = dcw; //n = n; diff --git a/module-csp.c b/module-csp.c index c46434a7d..468b83562 100644 --- a/module-csp.c +++ b/module-csp.c @@ -29,14 +29,14 @@ #define PING_INTVL 4 -static void *csp_server(struct s_client *client __attribute__((unused)), uchar *mbuf __attribute__((unused)), int32_t n __attribute__((unused))) +static void *csp_server(struct s_client *client __attribute__((unused)), uint8_t *mbuf __attribute__((unused)), int32_t n __attribute__((unused))) { return NULL; } static int32_t csp_send_ping(struct s_client *cl, uint32_t now) { - uchar buf[13] = {0}; + uint8_t buf[13] = {0}; buf[0] = TYPE_PINGREQ; i2b_buf(4, now, buf + 1); @@ -68,7 +68,7 @@ static int32_t csp_cache_push_out(struct s_client *cl, struct ecm_request_t *er) } - uchar *buf; + uint8_t *buf; if(!cs_malloc(&buf, size)) { return -1; } uint16_t onid = er->onid; @@ -109,7 +109,7 @@ static int32_t csp_cache_push_out(struct s_client *cl, struct ecm_request_t *er) return status; } -static uint8_t parse_request(struct ecm_request_t *er, uchar *buf) +static uint8_t parse_request(struct ecm_request_t *er, uint8_t *buf) { uint8_t commandTag = buf[0]; // first ecm byte indicating odd or even (0x80 or 0x81) uint16_t srvid = b2i(2, buf + 1); @@ -127,7 +127,7 @@ static uint8_t parse_request(struct ecm_request_t *er, uchar *buf) return commandTag; } -static int32_t csp_recv(struct s_client *client, uchar *buf, int32_t l) +static int32_t csp_recv(struct s_client *client, uint8_t *buf, int32_t l) { int32_t rs = 0; if(!client->udp_fd) { return (-9); } @@ -160,7 +160,7 @@ static int32_t csp_recv(struct s_client *client, uchar *buf, int32_t l) if(chk_csp_ctab(er, &cfg.csp.filter_caidtab)) { memcpy(er->cw, buf + 13, sizeof(er->cw)); - uchar orgname[32] = {0}; + uint8_t orgname[32] = {0}; if(rs >= 31) { // origin connector name included @@ -201,7 +201,7 @@ static int32_t csp_recv(struct s_client *client, uchar *buf, int32_t l) uint32_t port = b2i(4, buf + 9); SIN_GET_PORT(client->udp_sa) = htons(port); - uchar pingrpl[9]; + uint8_t pingrpl[9]; pingrpl[0] = TYPE_PINGRPL; memcpy(pingrpl + 1, buf + 1, 8); int32_t status = sendto(client->udp_fd, pingrpl, sizeof(pingrpl), 0, (struct sockaddr *) &client->udp_sa, client->udp_sa_len); diff --git a/module-cw-cycle-check.c b/module-cw-cycle-check.c index 499a0494c..c46f9053b 100644 --- a/module-cw-cycle-check.c +++ b/module-cw-cycle-check.c @@ -13,29 +13,29 @@ struct s_cwc_md5 { - uchar md5[CS_ECMSTORESIZE]; - uint32_t csp_hash; - uchar cw[16]; + uint8_t md5[CS_ECMSTORESIZE]; + uint32_t csp_hash; + uint8_t cw[16]; }; struct s_cw_cycle_check { - uchar cw[16]; - time_t time; - time_t locktime; // lock in learning - uint16_t caid; - uint16_t sid; - uint16_t chid; - uint32_t provid; - int16_t ecmlen; - int8_t stage; - int32_t cycletime; - int32_t dyncycletime; - int8_t nextcyclecw; - struct s_cwc_md5 ecm_md5[15]; // max 15 old ecm md5 /csp-hashs - int8_t cwc_hist_entry; - uint8_t old; - int8_t stage4_repeat; + uint8_t cw[16]; + time_t time; + time_t locktime; // lock in learning + uint16_t caid; + uint16_t sid; + uint16_t chid; + uint32_t provid; + int16_t ecmlen; + int8_t stage; + int32_t cycletime; + int32_t dyncycletime; + int8_t nextcyclecw; + struct s_cwc_md5 ecm_md5[15]; // max 15 old ecm md5 /csp-hashs + int8_t cwc_hist_entry; + uint8_t old; + int8_t stage4_repeat; struct s_cw_cycle_check *prev; struct s_cw_cycle_check *next; }; @@ -72,7 +72,7 @@ static uint8_t chk_is_pos_fallback(ECM_REQUEST *er, char *reader) return 0; } -static inline uint8_t checkECMD5CW(uchar *ecmd5_cw) +static inline uint8_t checkECMD5CW(uint8_t *ecmd5_cw) { int8_t i; for(i = 0; i < CS_ECMSTORESIZE; i++) @@ -114,20 +114,20 @@ static uint8_t countCWpart(ECM_REQUEST *er, struct s_cw_cycle_check *cwc) static uint8_t checkvalidCW(ECM_REQUEST *er) { - uint8_t ret = 1; - if(chk_is_null_CW(er->cw) && er->caid !=0x2600) // 0x2600 used by biss and constant cw could be indeed zero + uint8_t ret = 1; + if(chk_is_null_CW(er->cw) && er->caid !=0x2600) // 0x2600 used by biss and constant cw could be indeed zero { er->rc = E_NOTFOUND; } if(er->rc == E_NOTFOUND) - { return 0; } //wrong leave the check + { return 0; } // wrong leave the check if(checkCWpart(er->cw, 0) && checkCWpart(er->cw, 1)) - { return 1; } //cw1 and cw2 is filled -> we can check for cwc + { return 1; } // cw1 and cw2 is filled -> we can check for cwc if((!checkCWpart(er->cw, 0) || !checkCWpart(er->cw, 1)) && caid_is_videoguard(er->caid)) { cs_log("CAID: %04X uses obviously half cycle cw's : NO need to check it with CWC! Remove CAID: %04X from CWC Config!", er->caid, er->caid); - ret = 0; // cw1 or cw2 is null + ret = 0; // cw1 or cw2 is null } return ret; @@ -136,7 +136,7 @@ static uint8_t checkvalidCW(ECM_REQUEST *er) void cleanupcwcycle(void) { time_t now = time(NULL); - if(last_cwcyclecleaning + 120 > now) //only clean once every 2min + if(last_cwcyclecleaning + 120 > now) // only clean once every 2min { return; } last_cwcyclecleaning = now; @@ -145,11 +145,11 @@ void cleanupcwcycle(void) bool bcleanup = false; - //write lock + // write lock cs_writelock(__func__, &cwcycle_lock); for(currentnode = cw_cc_list, prv = NULL; currentnode; prv = currentnode, currentnode = currentnode->next, count++) // First Remove old Entrys { - if((now - currentnode->time) <= kct) // delete Entry which old to hold list small + if((now - currentnode->time) <= kct) // delete Entry which old to hold list small { continue; } @@ -163,7 +163,7 @@ void cleanupcwcycle(void) cw_cc_list = NULL; } bcleanup = true; - break; //we need only once, all follow to old + break; // we need only once, all follow to old } cs_writeunlock(__func__, &cwcycle_lock); while(currentnode != NULL) @@ -178,14 +178,14 @@ void cleanupcwcycle(void) { cs_log_dbg(D_CWC, "cyclecheck [Cleanup] list new size: %d (realsize: %d)", cw_cc_list_size, count); } } -static int32_t checkcwcycle_int(ECM_REQUEST *er, char *er_ecmf , char *user, uchar *cw , char *reader, uint8_t cycletime_fr, uint8_t next_cw_cycle_fr) +static int32_t checkcwcycle_int(ECM_REQUEST *er, char *er_ecmf , char *user, uint8_t *cw , char *reader, uint8_t cycletime_fr, uint8_t next_cw_cycle_fr) { int8_t i, ret = 6; // ret = 6 no checked int8_t cycleok = -1; - time_t now = er->tps.time;//time(NULL); + time_t now = er->tps.time; //time(NULL); uint8_t need_new_entry = 1, upd_entry = 1; - char cwstr[17 * 3]; //cw to check + char cwstr[17 * 3]; // cw to check char cwc_ecmf[ECM_FMT_LEN]; char cwc_md5[17 * 3]; @@ -201,7 +201,7 @@ static int32_t checkcwcycle_int(ECM_REQUEST *er, char *er_ecmf , char *user, uch }*/ if(!checkvalidCW(er)) - { return 3; } //cwc ign + { return 3; } //cwc ign //read lock cs_readlock(__func__, &cwcycle_lock); @@ -264,11 +264,11 @@ static int32_t checkcwcycle_int(ECM_REQUEST *er, char *er_ecmf , char *user, uch ret = cfg.cwcycle_dropold ? 2 : 4; } else - { + { ret = 4; // Return 4 same CW } upd_entry = 0; - } + } break; } } @@ -290,7 +290,7 @@ static int32_t checkcwcycle_int(ECM_REQUEST *er, char *er_ecmf , char *user, uch ret = cfg.cwcycle_dropold ? 2 : 4; } else - { + { ret = 4; // Return 4 same CW } upd_entry = 0; @@ -492,7 +492,7 @@ static int32_t checkcwcycle_int(ECM_REQUEST *er, char *er_ecmf , char *user, uch cwc->stage = 1; } } - else if(cwc->stage == 4) // we got a early learned cycletime.. use this cycletime and check only which cw cycle + else if(cwc->stage == 4) // we got a early learned cycletime.. use this cycletime and check only which cw cycle { n = memcmp(cwc->cw, cw, 8); m = memcmp(cwc->cw + 8, cw + 8, 8); @@ -514,11 +514,11 @@ static int32_t checkcwcycle_int(ECM_REQUEST *er, char *er_ecmf , char *user, uch else { cs_log_dbg(D_CWC, "cyclecheck [Stay on Stage %d] for Entry %s Cycletime: %i no cycle detect!", cwc->stage, cwc_ecmf, cwc->cycletime); - if (cwc->stage4_repeat > 12) - { + if (cwc->stage4_repeat > 12) + { cwc->stage = 1; - cs_log_dbg(D_CWC, "cyclecheck [Back to Stage 1] too much cyclefailure, maybe cycletime not correct %s Cycletime: %i Lockdiff: %ld nextCycleCW = CW%i", cwc_ecmf, cwc->cycletime, now - cwc->locktime, cwc->nextcyclecw); - } + cs_log_dbg(D_CWC, "cyclecheck [Back to Stage 1] too much cyclefailure, maybe cycletime not correct %s Cycletime: %i Lockdiff: %ld nextCycleCW = CW%i", cwc_ecmf, cwc->cycletime, now - cwc->locktime, cwc->nextcyclecw); + } } cwc->stage4_repeat++; ret = ret == 3 ? 3 : 7; // IGN for first stage4 otherwise LEARN @@ -592,7 +592,7 @@ static int32_t checkcwcycle_int(ECM_REQUEST *er, char *er_ecmf , char *user, uch new->cycletime = (cfg.cwcycle_usecwcfromce && cycletime_fr > 0 && next_cw_cycle_fr < 2) ? cycletime_fr : 99; new->nextcyclecw = (cfg.cwcycle_usecwcfromce && cycletime_fr > 0 && next_cw_cycle_fr < 2) ? next_cw_cycle_fr : 2; //2=we dont know which next cw Cycle; 0= next cw Cycle CW0; 1= next cw Cycle CW1; ret = (cycletime_fr > 0 && next_cw_cycle_fr < 2) ? 8 : 6; -// +// new->prev = new->next = NULL; new->old = 0; new->stage4_repeat = 0; @@ -698,7 +698,7 @@ static void count_ign(struct s_client *client) } } -uint8_t checkcwcycle(struct s_client *client, ECM_REQUEST *er, struct s_reader *reader, uchar *cw, int8_t rc, uint8_t cycletime_fr, uint8_t next_cw_cycle_fr) +uint8_t checkcwcycle(struct s_client *client, ECM_REQUEST *er, struct s_reader *reader, uint8_t *cw, int8_t rc, uint8_t cycletime_fr, uint8_t next_cw_cycle_fr) { if(!cfg.cwcycle_check_enable) @@ -792,7 +792,7 @@ uint8_t checkcwcycle(struct s_client *client, ECM_REQUEST *er, struct s_reader * snprintf(er->cwc_msg_log, sizeof(er->cwc_msg_log), "cwc NOK"); if(cfg.onbadcycle > 0) // ignore ECM Request { - cs_log("cyclecheck [Bad CW Cycle already Counted] for: %s %s from: %s -> drop cw (ECM Answer)", user, er_ecmf, c_reader); + cs_log("cyclecheck [Bad CW Cycle already Counted] for: %s %s from: %s -> drop cw (ECM Answer)", user, er_ecmf, c_reader); return 0; } else // only logging diff --git a/module-cw-cycle-check.h b/module-cw-cycle-check.h index 26ac7d0dc..8534e8053 100644 --- a/module-cw-cycle-check.h +++ b/module-cw-cycle-check.h @@ -1,7 +1,7 @@ #ifndef MODULE_CW_CYCLE_CHECK_H_ #define MODULE_CW_CYCLE_CHECK_H_ -uint8_t checkcwcycle(struct s_client *client, ECM_REQUEST *er, struct s_reader *reader, uchar *cw, int8_t rc, uint8_t cycletime_fr, uint8_t next_cw_cycle_fr); +uint8_t checkcwcycle(struct s_client *client, ECM_REQUEST *er, struct s_reader *reader, uint8_t *cw, int8_t rc, uint8_t cycletime_fr, uint8_t next_cw_cycle_fr); #ifdef CW_CYCLE_CHECK void cleanupcwcycle(void); diff --git a/module-dvbapi-azbox.c b/module-dvbapi-azbox.c index d808f734f..bb02e0d37 100644 --- a/module-dvbapi-azbox.c +++ b/module-dvbapi-azbox.c @@ -23,11 +23,11 @@ extern DEMUXTYPE demux[MAX_DEMUX]; int32_t openxcas_provid; uint16_t openxcas_sid, openxcas_caid, openxcas_ecm_pid; -static unsigned char openxcas_cw[16]; +static uint8_t openxcas_cw[16]; static int32_t openxcas_seq, openxcas_filter_idx, openxcas_stream_id, openxcas_cipher_idx, openxcas_busy = 0; static uint16_t openxcas_video_pid, openxcas_audio_pid, openxcas_data_pid; -static void azbox_openxcas_ecm_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t cipher_index, uint32_t UNUSED(caid), unsigned char *ecm_data, int32_t l, uint16_t pid) +static void azbox_openxcas_ecm_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t cipher_index, uint32_t UNUSED(caid), uint8_t *ecm_data, int32_t l, uint16_t pid) { cs_log_dbg(D_DVBAPI, "ecm callback received"); @@ -65,7 +65,7 @@ static void azbox_openxcas_ecm_callback(int32_t stream_id, uint32_t UNUSED(seq), } -static void azbox_openxcas_ex_callback(int32_t stream_id, uint32_t seq, int32_t idx, uint32_t pid, unsigned char *ecm_data, int32_t l) +static void azbox_openxcas_ex_callback(int32_t stream_id, uint32_t seq, int32_t idx, uint32_t pid, uint8_t *ecm_data, int32_t l) { cs_log_dbg(D_DVBAPI, "ex callback received"); @@ -76,7 +76,7 @@ static void azbox_openxcas_ex_callback(int32_t stream_id, uint32_t seq, int32_t if(l < 0 || l > MAX_ECM_SIZE) { return; } - ECM_REQUEST *er; + ECM_REQUEST *er; if(!(er = get_ecmtask())) { return; } @@ -97,8 +97,8 @@ static void azbox_openxcas_ex_callback(int32_t stream_id, uint32_t seq, int32_t - unsigned char mask[12]; - unsigned char comp[12]; + uint8_t mask[12]; + uint8_t comp[12]; memset(&mask, 0x00, sizeof(mask)); memset(&comp, 0x00, sizeof(comp)); @@ -160,7 +160,7 @@ static void *azbox_main_thread(void *cli) cs_log_dbg(D_DVBAPI, "OPENXCAS_START_PMT_ECM"); // parse pmt - uchar *dest; + uint8_t *dest; if(!cs_malloc(&dest, msg.buf_len + 7 - 12 - 4)) { break; } @@ -175,8 +175,8 @@ static void *azbox_main_thread(void *cli) dvbapi_parse_capmt(dest, 7 + msg.buf_len - 12 - 4, -1, NULL, 0, 0, 0, 0); NULLFREE(dest); - unsigned char mask[12]; - unsigned char comp[12]; + uint8_t mask[12]; + uint8_t comp[12]; memset(&mask, 0x00, sizeof(mask)); memset(&comp, 0x00, sizeof(comp)); @@ -241,7 +241,7 @@ void azbox_send_dcw(struct s_client *client, ECM_REQUEST *er) uint32_t delay = 0; cs_log_dbg(D_DVBAPI, "send_dcw"); - + if(delayentry) { if(delayentry->delay < 1000) @@ -255,7 +255,7 @@ void azbox_send_dcw(struct s_client *client, ECM_REQUEST *er) delay = cfg.dvbapi_delayer; cs_log_dbg(D_DVBAPI, "generic delay: write cw %d ms after ecmrequest", delay); } - + delayer(er, delay); dvbapi_write_ecminfo_file(client, er, demux[0].lastcw[0], demux[0].lastcw[1]); @@ -275,8 +275,8 @@ void azbox_send_dcw(struct s_client *client, ECM_REQUEST *er) openxcas_stop_filter(openxcas_stream_id, OPENXCAS_FILTER_ECM); openxcas_remove_filter(openxcas_stream_id, OPENXCAS_FILTER_ECM); - unsigned char mask[12]; - unsigned char comp[12]; + uint8_t mask[12]; + uint8_t comp[12]; memset(&mask, 0x00, sizeof(mask)); memset(&comp, 0x00, sizeof(comp)); @@ -303,7 +303,7 @@ void azbox_send_dcw(struct s_client *client, ECM_REQUEST *er) } } - unsigned char nullcw[8]; + uint8_t nullcw[8]; memset(nullcw, 0, 8); int32_t n; @@ -341,7 +341,7 @@ void azbox_close(void) { cs_log("could not close"); } } -void *azbox_handler(struct s_client *cl, uchar *mbuf, int32_t module_idx) +void *azbox_handler(struct s_client *cl, uint8_t *mbuf, int32_t module_idx) { return dvbapi_start_handler(cl, mbuf, module_idx, azbox_main_thread); } diff --git a/module-dvbapi-azbox.h b/module-dvbapi-azbox.h index 49fe19964..40e9133ff 100644 --- a/module-dvbapi-azbox.h +++ b/module-dvbapi-azbox.h @@ -2,7 +2,7 @@ #define _MODULE_AZBOX_H_ void azbox_send_dcw(struct s_client *client, ECM_REQUEST *er); -void *azbox_handler(struct s_client *cl, uchar *mbuf, int32_t module_idx); +void *azbox_handler(struct s_client *cl, uint8_t *mbuf, int32_t module_idx); #if defined(HAVE_DVBAPI) && defined(WITH_AZBOX) void azbox_init(void); diff --git a/module-dvbapi-chancache.c b/module-dvbapi-chancache.c index 2889e0d7a..d955f5c25 100644 --- a/module-dvbapi-chancache.c +++ b/module-dvbapi-chancache.c @@ -17,7 +17,7 @@ static LLIST *channel_cache; void dvbapi_save_channel_cache(void) { if(boxtype_is("dbox2")) return; // dont save channelcache on these boxes, they lack resources and will crash! - + if (USE_OPENXCAS) // Why? return; @@ -60,7 +60,7 @@ void dvbapi_save_channel_cache(void) void dvbapi_load_channel_cache(void) { if(boxtype_is("dbox2")) return; // dont load channelcache on these boxes, they lack resources and will crash! - + if (USE_OPENXCAS) // Why? return; @@ -76,7 +76,7 @@ void dvbapi_load_channel_cache(void) cs_log_dbg(D_TRACE, "dvbapi channelcache can't read from file %s", fname); return; } - + int32_t i = 1; int32_t valid = 0; char *ptr, *saveptr1 = NULL; diff --git a/module-dvbapi-coolapi-legacy.c b/module-dvbapi-coolapi-legacy.c index 7e39a4b9a..a04589ee8 100644 --- a/module-dvbapi-coolapi-legacy.c +++ b/module-dvbapi-coolapi-legacy.c @@ -19,16 +19,16 @@ typedef struct s_cool_filter int32_t fd; int32_t channel; int32_t pid; - uchar filter16[16]; - uchar mask16[16]; + uint8_t filter16[16]; + uint8_t mask16[16]; } S_COOL_FILTER; typedef struct s_cool_chanhandle { int32_t pid; - void *buffer1; - void *buffer2; - void *channel; + void *buffer1; + void *buffer2; + void *channel; int32_t demux_index; } S_COOL_CHANHANDLE; @@ -36,12 +36,12 @@ struct cool_dmx { int32_t opened; int32_t fd; - uchar buffer[4096]; - void *buffer1; - void *buffer2; - void *channel; - void *filter; - void *device; + uint8_t buffer[4096]; + void *buffer1; + void *buffer2; + void *channel; + void *filter; + void *device; int32_t pid; pthread_mutex_t mutex; int32_t demux_index; @@ -53,7 +53,7 @@ typedef struct cool_dmx dmx_t; typedef struct { - int32_t type; + int32_t type; uint32_t size; int32_t unknown1; int16_t unknown2; @@ -239,7 +239,7 @@ static void dmx_callback(void *UNUSED(unk), dmx_t *dmx, int32_t type, dmx_callba } } -int32_t coolapi_set_filter(int32_t fd, int32_t num, int32_t pid, uchar *flt, uchar *mask, int32_t type) +int32_t coolapi_set_filter(int32_t fd, int32_t num, int32_t pid, uint8_t *flt, uint8_t *mask, int32_t type) { dmx_t *dmx = find_demux(fd, 0); if(!dmx) @@ -582,7 +582,7 @@ static int32_t coolapi_read(dmx_t *dmx, dmx_callback_data_t *data) int32_t result; uint32_t done = 0, toread, len = data->len; - uchar *buff = &dmx->buffer[0]; + uint8_t *buff = &dmx->buffer[0]; uint32_t bytes_used = 0; //cs_log_dbg(D_DVBAPI, "dmx channel %x pid %x len %d", (int) dmx->channel, dmx->pid, len); diff --git a/module-dvbapi-coolapi.c b/module-dvbapi-coolapi.c index bc2ef7648..9f6ea5a91 100644 --- a/module-dvbapi-coolapi.c +++ b/module-dvbapi-coolapi.c @@ -9,37 +9,37 @@ #include "module-dvbapi.h" #include "module-dvbapi-coolapi.h" -#include "oscam-string.h" +#include "oscam-string.h" #define MAX_COOL_DMX 4 -//kronos-Plattform (Coolsterem ZEE²) +//kronos-Plattform (Coolsterem ZEE) //#define MAX_COOL_DMX 3 #define DMX_MAX_FILTERS_PER_CHAN 16 #define DMX_MAX_CHANNELS_PER_DMX 192 //#define MAX_COOL_DMX_FILTERS 128 - + struct s_cool_chanhandle; typedef struct s_cool_filter { - int32_t fd; + int32_t fd; struct s_cool_chanhandle *chanhandle; - void *filter; - int32_t filter_num; - uchar filter16[16]; - uchar mask16[16]; + void *filter; + int32_t filter_num; + uint8_t filter16[16]; + uint8_t mask16[16]; } S_COOL_FILTER; typedef struct s_cool_chanhandle { int32_t pid; - void *buffer1; // filter Cbuf 1 - void *buffer2; // filter Cbuf 2 - void *channel; + void *buffer1; // filter Cbuf 1 + void *buffer2; // filter Cbuf 2 + void *channel; int32_t demux_index; struct s_cool_dmxhandle *dmx_handle; uint32_t allocated_filters; @@ -163,7 +163,7 @@ extern int32_t cnxt_dmx_set_filter(void *handle, filter_set_t *arg, void *); extern int32_t cnxt_dmx_channel_suspend(void *handle, int32_t enable); /* Local coolapi functions */ -static int32_t coolapi_read(dmx_t *dmx, dmx_callback_data_t *dataa, uchar *buffer); +static int32_t coolapi_read(dmx_t *dmx, dmx_callback_data_t *dataa, uint8_t *buffer); static int8_t dmx_opened; int32_t cool_kal_opened = 0; @@ -358,14 +358,14 @@ static void coolapi_read_data(dmx_t *dmx, dmx_callback_data_t *data) } int32_t ret; - uchar buffer[4096]; + uint8_t buffer[4096]; SAFE_SETSPECIFIC(getclient, dvbapi_client); SAFE_MUTEX_LOCK(&dmx->mutex); memset(buffer, 0, sizeof(buffer)); ret = coolapi_read(dmx, data, buffer); SAFE_MUTEX_UNLOCK(&dmx->mutex); - + if(ret > -1) { uint16_t filters = data->num; uint16_t flt; @@ -422,7 +422,7 @@ static void dmx_callback(void *channel, dmx_t *dmx, int32_t type, dmx_callback_d } } -int32_t coolapi_set_filter(int32_t fd, int32_t num, int32_t pid, uchar *flt, uchar *mask, int32_t type) +int32_t coolapi_set_filter(int32_t fd, int32_t num, int32_t pid, uint8_t *flt, uint8_t *mask, int32_t type) { dmx_t *dmx = find_demux(fd, 0); if(!dmx) @@ -470,7 +470,7 @@ int32_t coolapi_set_filter(int32_t fd, int32_t num, int32_t pid, uchar *flt, uch channel_open_arg_t chanarg; memset(&chanarg, 0, sizeof(channel_open_arg_t)); - + chanarg.type = 4; result = cnxt_dmx_channel_open(dmx_handles[COOLDEMUX_DMX_DEV(fd)].handle, &handle_item->channel, &chanarg, dmx_callback, dmx); coolapi_check_error("cnxt_dmx_channel_open", result); @@ -645,7 +645,7 @@ int32_t coolapi_remove_filter(int32_t fd, int32_t num) result = cnxt_dmx_channel_ctrl(channel, 0, 0); coolapi_check_error("cnxt_dmx_channel_ctrl", result); cs_log_dbg(D_DVBAPI, "closing channel %x", (int32_t) channel); - + result = cnxt_dmx_set_channel_pid(channel, 0x1FFF); coolapi_check_error("cnxt_dmx_set_channel_pid", result); @@ -657,7 +657,7 @@ int32_t coolapi_remove_filter(int32_t fd, int32_t num) result = cnxt_cbuf_detach(handle_item->buffer2, 2, channel); coolapi_check_error("cnxt_cbuf_detach", result); - + result = cnxt_dmx_channel_detach(channel, 0xB, 0, handle_item->buffer1); coolapi_check_error("cnxt_dmx_channel_detach", result); @@ -688,7 +688,7 @@ int32_t coolapi_remove_filter(int32_t fd, int32_t num) result = cnxt_dmx_close_filter(filter); coolapi_check_error("cnxt_dmx_close_filter", result); } - + // COOLAPI2 - We don't want to close Channel on no ECM Filters (Makes AU / EMMs work) if(dmx->type != TYPE_ECM) { return 0; } @@ -789,7 +789,7 @@ int32_t coolapi_write_cw(int32_t mask, uint16_t *STREAMpids, int32_t count, ca_d return 0; } -static int32_t coolapi_read(dmx_t *dmx, dmx_callback_data_t *data, uchar *buffer) +static int32_t coolapi_read(dmx_t *dmx, dmx_callback_data_t *data, uint8_t *buffer) { if(!dmx) { diff --git a/module-dvbapi-coolapi.h b/module-dvbapi-coolapi.h index 3a780d868..391e662a8 100644 --- a/module-dvbapi-coolapi.h +++ b/module-dvbapi-coolapi.h @@ -1,7 +1,7 @@ #ifndef _MODULE_COOLAPI_H_ #define _MODULE_COOLAPI_H_ -int32_t coolapi_set_filter(int32_t fd, int32_t num, int32_t pid, uchar *flt, uchar *mask, int32_t type); +int32_t coolapi_set_filter(int32_t fd, int32_t num, int32_t pid, uint8_t *flt, uint8_t *mask, int32_t type); int32_t coolapi_remove_filter(int32_t fd, int32_t num); int32_t coolapi_open_device(int32_t demux_index, int32_t demux_id); int32_t coolapi_close_device(int32_t fd); diff --git a/module-dvbapi-mca.c b/module-dvbapi-mca.c index d0d7ce3f3..3ec59eb2b 100644 --- a/module-dvbapi-mca.c +++ b/module-dvbapi-mca.c @@ -52,7 +52,7 @@ extern DEMUXTYPE demux[MAX_DEMUX]; int32_t openxcas_provid; uint16_t openxcas_sid, openxcas_caid, openxcas_ecm_pid; -static unsigned char openxcas_cw[16]; +static uint8_t openxcas_cw[16]; static int32_t openxcas_seq, openxcas_filter_idx, openxcas_stream_id, openxcas_cipher_idx, openxcas_busy = 0; static uint16_t openxcas_video_pid, openxcas_audio_pid, openxcas_data_pid; static uint8_t found[MAX_DEMUX]; @@ -86,7 +86,7 @@ struct s_ecmpids_matrix int32_t irdeto_cycle; int32_t checked; int32_t status; - unsigned char table; + uint8_t table; int32_t index; uint32_t streams; }; @@ -126,9 +126,9 @@ typedef struct demux_s_matrix int32_t tries; int32_t max_status; uint16_t program_number; - unsigned char lastcw[2][8]; + uint8_t lastcw[2][8]; int32_t emm_filter; - uchar hexserial[8]; + uint8_t hexserial[8]; struct s_reader *rdr; char pmt_file[30]; int32_t pmt_time; @@ -220,7 +220,7 @@ static int mca_write_flt(DEMUXMATRIX *demux_matrix, int timeout) return rval; } -static int mca_set_key(unsigned char *mca_cw) +static int mca_set_key(uint8_t *mca_cw) { int rval = -1; struct pollfd mdesc_poll_fd; @@ -235,7 +235,7 @@ static int mca_set_key(unsigned char *mca_cw) return rval; } -static int mca_capmt_remove_duplicates(uchar *capmt, int len) +static int mca_capmt_remove_duplicates(uint8_t *capmt, int len) { int i, newlen = len; uint16_t descriptor_length = 0; @@ -251,8 +251,8 @@ static int mca_capmt_remove_duplicates(uchar *capmt, int len) } } program_info_length -= (len - newlen); - capmt[4] = (uchar)((capmt[4] & 0xF0) | ((program_info_length & 0xF00) >> 8)); - capmt[5] = (uchar)(program_info_length & 0x0FF); + capmt[4] = (uint8_t)((capmt[4] & 0xF0) | ((program_info_length & 0xF00) >> 8)); + capmt[5] = (uint8_t)(program_info_length & 0x0FF); return newlen; } @@ -284,7 +284,7 @@ static void mca_demux_convert(DEMUXTYPE *demux_orig, DEMUXMATRIX *demux_matrix) demux_matrix->ECMpids[i].irdeto_cycle = (int32_t)demux_orig->ECMpids[i].irdeto_cycle; demux_matrix->ECMpids[i].checked = (int32_t)demux_orig->ECMpids[i].checked; demux_matrix->ECMpids[i].status = (int32_t)demux_orig->ECMpids[i].status; - demux_matrix->ECMpids[i].table = (unsigned char)demux_orig->ECMpids[i].table; + demux_matrix->ECMpids[i].table = (uint8_t)demux_orig->ECMpids[i].table; demux_matrix->ECMpids[i].streams = (uint32_t)demux_orig->ECMpids[i].streams; } demux_matrix->STREAMpidcount = (int32_t)demux->STREAMpidcount; @@ -293,15 +293,15 @@ static void mca_demux_convert(DEMUXTYPE *demux_orig, DEMUXMATRIX *demux_matrix) demux_matrix->curindex = (int32_t)demux_orig->curindex; demux_matrix->max_status = (int32_t)demux_orig->max_status; demux_matrix->program_number = (uint16_t)demux_orig->program_number; - memcpy(&demux_matrix->lastcw, &demux_orig->lastcw, 2 * 8 * sizeof(unsigned char)); + memcpy(&demux_matrix->lastcw, &demux_orig->lastcw, 2 * 8 * sizeof(uint8_t)); demux_matrix->emm_filter = (int32_t)demux_orig->emm_filter; - memcpy(&demux_matrix->hexserial, &demux_orig->hexserial, 8 * sizeof(uchar)); + memcpy(&demux_matrix->hexserial, &demux_orig->hexserial, 8 * sizeof(uint8_t)); demux_matrix->rdr = (struct s_reader *)demux_orig->rdr; memcpy(&demux_matrix->pmt_file, &demux_orig->pmt_file, 30); demux_matrix->pmt_time = (int32_t)demux_orig->pmt_time; } -static void mca_ecm_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t cipher_index, uint32_t caid, unsigned char *ecm_data, int32_t l, uint16_t pid) +static void mca_ecm_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t cipher_index, uint32_t caid, uint8_t *ecm_data, int32_t l, uint16_t pid) { cs_log_dbg(D_DVBAPI, "ecm callback received"); @@ -348,7 +348,7 @@ static void mca_ecm_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t ci } -static void mca_ex_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t idx, uint32_t pid, unsigned char *ecm_data, int32_t l) +static void mca_ex_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t idx, uint32_t pid, uint8_t *ecm_data, int32_t l) { cs_log_dbg(D_DVBAPI, "ex callback received"); @@ -358,7 +358,7 @@ static void mca_ex_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t idx if(l < 0 || l > MAX_ECM_SIZE) { return; } - + ECM_REQUEST *er; if(!(er = get_ecmtask())) { return; } @@ -378,10 +378,8 @@ static void mca_ex_callback(int32_t stream_id, uint32_t UNUSED(seq), int32_t idx else { cs_log_dbg(D_DVBAPI, "ex filter stopped"); } - - - unsigned char mask[12]; - unsigned char comp[12]; + uint8_t mask[12]; + uint8_t comp[12]; memset(&mask, 0x00, sizeof(mask)); memset(&comp, 0x00, sizeof(comp)); @@ -456,9 +454,8 @@ static void *mca_main_thread(void *cli) { cs_log_dump_dbg(D_DVBAPI, msg.buf + 2, new_len, "capmt (duplicates removed):"); } int demux_id = dvbapi_parse_capmt(msg.buf + 2, new_len, -1, NULL, 0, 0, 0, 0); - - unsigned char mask[12]; - unsigned char comp[12]; + uint8_t mask[12]; + uint8_t comp[12]; memset(&mask, 0x00, sizeof(mask)); memset(&comp, 0x00, sizeof(comp)); @@ -501,13 +498,13 @@ static void *mca_main_thread(void *cli) memcpy(&data, msg.buf, msg.buf_len); if(!openxcas_busy) //openxcas_filter_callback(msg.stream_id, msg.sequence, OPENXCAS_FILTER_ECM, &data); - { mca_ecm_callback(msg.stream_id, msg.sequence, data.cipher_index, data.ca_system_id, (unsigned char *)&data.buf, data.len, data.pid); } + { mca_ecm_callback(msg.stream_id, msg.sequence, data.cipher_index, data.ca_system_id, (uint8_t *)&data.buf, data.len, data.pid); } break; case OPENXCAS_PID_FILTER_CALLBACK: cs_log_dbg(D_DVBAPI, "OPENXCAS_PID_FILTER_CALLBACK"); memcpy(&data, msg.buf, msg.buf_len); //openxcas_filter_callback_ex(msg.stream_id, msg.sequence, (struct stOpenXCAS_Data *)msg.buf); - mca_ex_callback(msg.stream_id, msg.sequence, data.cipher_index, data.pid, (unsigned char *)&data.buf, data.len); + mca_ex_callback(msg.stream_id, msg.sequence, data.cipher_index, data.pid, (uuint8_t *)&data.buf, data.len); break; case OPENXCAS_QUIT: cs_log_dbg(D_DVBAPI, "OPENXCAS_QUIT"); @@ -533,7 +530,7 @@ void mca_send_dcw(struct s_client *client, ECM_REQUEST *er) uint32_t delay = 0; cs_log_dbg(D_DVBAPI, "send_dcw"); - + if(delayentry) { if(delayentry->delay < 1000) @@ -547,7 +544,7 @@ void mca_send_dcw(struct s_client *client, ECM_REQUEST *er) delay = cfg.dvbapi_delayer; cs_log_dbg(D_DVBAPI, "generic delay: write cw %d ms after ecmrequest", delay); } - + delayer(er, delay); dvbapi_write_ecminfo_file(client, er, demux[0].lastcw[0], demux[0].lastcw[1]); @@ -568,8 +565,8 @@ void mca_send_dcw(struct s_client *client, ECM_REQUEST *er) openxcas_stop_filter(openxcas_stream_id, OPENXCAS_FILTER_ECM); openxcas_remove_filter(openxcas_stream_id, OPENXCAS_FILTER_ECM); - unsigned char mask[12]; - unsigned char comp[12]; + uint8_t mask[12]; + uint8_t comp[12]; memset(&mask, 0x00, sizeof(mask)); memset(&comp, 0x00, sizeof(comp)); @@ -594,14 +591,14 @@ void mca_send_dcw(struct s_client *client, ECM_REQUEST *er) } } - unsigned char nullcw[8]; + uint8_t nullcw[8]; memset(nullcw, 0, 8); int32_t n; for(n = 0; n < 2; n++) { // 0x2600 used by biss and constant cw could be indeed zero - if((memcmp(er->cw + (n * 8), demux[0].lastcw[0], 8) && memcmp(er->cw + (n * 8), demux[0].lastcw[1], 8)) + if((memcmp(er->cw + (n * 8), demux[0].lastcw[0], 8) && memcmp(er->cw + (n * 8), demux[0].lastcw[1], 8)) && (memcmp(er->cw + (n * 8), nullcw, 8) !=0 || er->caid == 0x2600)) { memcpy(demux[0].lastcw[n], er->cw + (n * 8), 8); @@ -614,7 +611,7 @@ void mca_send_dcw(struct s_client *client, ECM_REQUEST *er) } } -void *mca_handler(struct s_client *cl, uchar *mbuf, int32_t module_idx) +void *mca_handler(struct s_client *cl, uint8_t *mbuf, int32_t module_idx) { return dvbapi_start_handler(cl, mbuf, module_idx, mca_main_thread); } diff --git a/module-dvbapi-mca.h b/module-dvbapi-mca.h index b95413235..d5e820ce5 100644 --- a/module-dvbapi-mca.h +++ b/module-dvbapi-mca.h @@ -2,7 +2,7 @@ #define _MODULE_MCA_H_ void mca_send_dcw(struct s_client *client, ECM_REQUEST *er); -void *mca_handler(struct s_client *cl, uchar *mbuf, int32_t module_idx); +void *mca_handler(struct s_client *cl, uint8_t *mbuf, int32_t module_idx); #if defined(HAVE_DVBAPI) && defined(WITH_MCA) void mca_init(void); diff --git a/module-dvbapi-stapi.c b/module-dvbapi-stapi.c index ef70819b5..817de30cb 100644 --- a/module-dvbapi-stapi.c +++ b/module-dvbapi-stapi.c @@ -38,7 +38,7 @@ extern uint32_t oscam_stapi_Open(char *name, uint32_t *sessionhandle); extern uint32_t oscam_stapi_SignalAllocate(uint32_t sessionhandle, uint32_t *signalhandle); extern uint32_t oscam_stapi_FilterAllocate(uint32_t sessionhandle, uint32_t *filterhandle); extern uint32_t oscam_stapi_SlotInit(uint32_t sessionhandle, uint32_t signalhandle, uint32_t *bufferhandle, uint32_t *slothandle, uint16_t pid); -extern uint32_t oscam_stapi_FilterSet(uint32_t filterhandle, uchar *filt, uchar *mask); +extern uint32_t oscam_stapi_FilterSet(uint32_t filterhandle, uint8_t *filt, uint8_t *mask); extern uint32_t oscam_stapi_FilterAssociate(uint32_t filterhandle, uint32_t slothandle); extern uint32_t oscam_stapi_SlotDeallocate(uint32_t slothandle); extern uint32_t oscam_stapi_BufferDeallocate(uint32_t bufferhandle); @@ -49,9 +49,9 @@ extern uint32_t oscam_stapi_DescramblerAssociate(uint32_t deschandle, uint32_t s extern uint32_t oscam_stapi_DescramblerDisassociate(uint32_t deschandle, uint32_t slot); extern uint32_t oscam_stapi_DescramblerAllocate(uint32_t sessionhandle, uint32_t *deschandle); extern uint32_t oscam_stapi_DescramblerDeallocate(uint32_t deschandle); -extern uint32_t oscam_stapi_DescramblerSet(uint32_t deschandle, int32_t parity, uchar *cw); +extern uint32_t oscam_stapi_DescramblerSet(uint32_t deschandle, int32_t parity, uint8_t *cw); extern uint32_t oscam_stapi_SignalWaitBuffer(uint32_t signalhandle, uint32_t *qbuffer, int32_t timeout); -extern uint32_t oscam_stapi_BufferReadSection(uint32_t bufferhandle, uint32_t *filterlist, int32_t maxfilter, uint32_t *filtercount, int32_t *crc, uchar *buf, int32_t bufsize, uint32_t *size); +extern uint32_t oscam_stapi_BufferReadSection(uint32_t bufferhandle, uint32_t *filterlist, int32_t maxfilter, uint32_t *filtercount, int32_t *crc, uint8_t *buf, int32_t bufsize, uint32_t *size); extern uint32_t oscam_stapi_SignalAbort(uint32_t signalhandle); extern uint32_t oscam_stapi_PidQuery(char *name, uint16_t pid); extern uint32_t oscam_stapi_BufferFlush(uint32_t bufferhandle); @@ -59,7 +59,7 @@ extern uint32_t oscam_stapi_SlotClearPid(uint32_t slot); // Local functions static void *stapi_read_thread(void *); -static int32_t stapi_do_set_filter(int32_t demux_id, FILTERTYPE *filter, uint16_t *pids, int32_t pidcount, uchar *filt, uchar *mask, int32_t dev_id); +static int32_t stapi_do_set_filter(int32_t demux_id, FILTERTYPE *filter, uint16_t *pids, int32_t pidcount, uint8_t *filt, uint8_t *mask, int32_t dev_id); static int32_t stapi_do_remove_filter(int32_t demux_id, FILTERTYPE *filter, int32_t dev_id); // These variables are declared in module-dvbapi.c @@ -226,25 +226,29 @@ int32_t stapi_open(void) return 1; } -int32_t stapi_activate_section_filter(int32_t fd, uchar *filter, uchar *mask) +int32_t stapi_activate_section_filter(int32_t fd, uint8_t *filter, uint8_t *mask) { - int n=0, ret=852049; - while (n<3 && ret==852049) { + int n = 0, ret = 852049; + while(n < 3 && ret == 852049) + { ret = oscam_stapi_FilterSet(fd, filter, mask); - if(ret) { + if(ret) + { cs_log_dbg(D_DVBAPI, "Error: oscam_stapi_FilterSet; %d", ret); cs_sleepms(50); n++; } } - if(ret) { + + if(ret) + { cs_log("Error: stapi_activate_section_filter: %d", ret); - ret = -1; + ret = -1; } return ret; } -int32_t stapi_set_filter(int32_t demux_id, uint16_t pid, uchar *filter, uchar *mask, int32_t num, char *pmtfile) +int32_t stapi_set_filter(int32_t demux_id, uint16_t pid, uint8_t *filter, uint8_t *mask, int32_t num, char *pmtfile) { int32_t i; int32_t ret = -1; @@ -349,7 +353,7 @@ static uint32_t check_slot(int32_t dev_id, uint32_t checkslot, FILTERTYPE *skipf } -static int32_t stapi_do_set_filter(int32_t demux_id, FILTERTYPE *filter, uint16_t *pids, int32_t pidcount, uchar *filt, uchar *mask, int32_t dev_id) +static int32_t stapi_do_set_filter(int32_t demux_id, FILTERTYPE *filter, uint16_t *pids, int32_t pidcount, uint8_t *filt, uint8_t *mask, int32_t dev_id) { uint32_t FilterAssociateError = 0; int32_t k, ret = 0; @@ -466,7 +470,7 @@ static void *stapi_read_thread(void *sparam) { int32_t dev_index, ErrorCode, i, j, CRCValid; uint32_t QueryBufferHandle = 0, DataSize = 0; - uchar buf[BUFFLEN]; + uint8_t buf[BUFFLEN]; struct read_thread_param *para = sparam; dev_index = para->id; @@ -550,9 +554,9 @@ static void *stapi_read_thread(void *sparam) } SAFE_MUTEX_UNLOCK(&filter_lock); } - + pthread_cleanup_pop(0); - + return NULL; } @@ -575,7 +579,7 @@ static void stapi_DescramblerAssociate(int32_t demux_id, uint16_t pid, int32_t m if(demux[demux_id].DescramblerHandle[n] == 0) { return; } if(mode == ASSOCIATE) - { + { int32_t k; for(k = 0; k < SLOTNUM; k++) { @@ -671,10 +675,10 @@ int32_t stapi_set_pid(int32_t demux_id, int32_t UNUSED(num), ca_index_t idx, uin return 1; } -int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_t STREAMpidcount, char *pmtfile) +int32_t stapi_write_cw(int32_t demux_id, uint8_t *cw, uint16_t *STREAMpids, int32_t STREAMpidcount, char *pmtfile) { int32_t ErrorCode, l, n, k; - unsigned char nullcw[8]; + uint8_t nullcw[8]; memset(nullcw, 0, 8); char *text[] = { "even", "odd" }; @@ -702,7 +706,7 @@ int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_ } if(demux[demux_id].DescramblerHandle[n] == 0) { continue; } - + for(k = 0; k < STREAMpidcount; k++) { stapi_DescramblerAssociate(demux_id, STREAMpids[k], ASSOCIATE, n); @@ -711,13 +715,13 @@ int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_ int32_t pidnum = demux[demux_id].pidindex; // get current pidindex used for descrambling ca_index_t idx = demux[demux_id].ECMpids[pidnum].index[0]; - + if(idx == INDEX_INVALID) // if no indexer for this pid get one! { idx = dvbapi_get_descindex(demux_id, pidnum, 0); cs_log_dbg(D_DVBAPI, "Demuxer %d PID: %d CAID: %04X ECMPID: %04X is using index %d", demux_id, pidnum, demux[demux_id].ECMpids[pidnum].CAID, demux[demux_id].ECMpids[pidnum].ECM_PID, idx); - } + } for(l = 0; l < 2; l++) { diff --git a/module-dvbapi-stapi.h b/module-dvbapi-stapi.h index a3aa2cea3..aa76aadc5 100644 --- a/module-dvbapi-stapi.h +++ b/module-dvbapi-stapi.h @@ -2,11 +2,11 @@ #define MODULE_DVBAPI_STAPI_H_ int32_t stapi_open(void); -int32_t stapi_set_filter(int32_t demux_id, uint16_t pid, uchar *filter, uchar *mask, int32_t num, char *pmtfile); +int32_t stapi_set_filter(int32_t demux_id, uint16_t pid, uint8_t *filter, uint8_t *mask, int32_t num, char *pmtfile); int32_t stapi_remove_filter(int32_t demux_id, int32_t num, char *pmtfile); int32_t stapi_set_pid(int32_t demux_id, int32_t num, ca_index_t idx, uint16_t pid, char *pmtfile); -int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *, int32_t, char *pmtfile); -int32_t stapi_activate_section_filter(int32_t fd, uchar *filter, uchar *mask); +int32_t stapi_write_cw(int32_t demux_id, uint8_t *cw, uint16_t *, int32_t, char *pmtfile); +int32_t stapi_activate_section_filter(int32_t fd, uint8_t *filter, uint8_t *mask); #ifdef WITH_STAPI5 diff --git a/module-dvbapi-stapi5.c b/module-dvbapi-stapi5.c index 20a5a7dde..a64354a2a 100644 --- a/module-dvbapi-stapi5.c +++ b/module-dvbapi-stapi5.c @@ -40,7 +40,7 @@ extern uint32_t oscam_stapi5_Open(char *name, uint32_t *sessionhandle); extern uint32_t oscam_stapi5_SignalAllocate(uint32_t sessionhandle, uint32_t *signalhandle); extern uint32_t oscam_stapi5_FilterAllocate(uint32_t sessionhandle, uint32_t *filterhandle); extern uint32_t oscam_stapi5_SlotInit(uint32_t sessionhandle, uint32_t signalhandle, uint32_t *bufferhandle, uint32_t *slothandle, uint16_t pid); -extern uint32_t oscam_stapi5_FilterSet(uint32_t filterhandle, uchar *filt, uchar *mask); +extern uint32_t oscam_stapi5_FilterSet(uint32_t filterhandle, uint8_t *filt, uint8_t *mask); extern uint32_t oscam_stapi5_FilterAssociate(uint32_t filterhandle, uint32_t slothandle); extern uint32_t oscam_stapi5_SlotDeallocate(uint32_t slothandle); extern uint32_t oscam_stapi5_BufferDeallocate(uint32_t bufferhandle); @@ -49,7 +49,7 @@ extern uint32_t oscam_stapi5_Close(uint32_t sessionhandle); extern const char *oscam_stapi5_GetRevision(void); extern uint32_t oscam_stapi5_SignalWaitBuffer(uint32_t signalhandle, uint32_t *qbuffer, int32_t timeout); extern uint32_t oscam_stapi5_SignalDisassociateBuffer(uint32_t signalhandle, uint32_t bufferhandle); -extern uint32_t oscam_stapi5_BufferReadSection(uint32_t bufferhandle, uint32_t *filterlist, int32_t maxfilter, uint32_t *filtercount, int32_t *crc, uchar *buf, int32_t bufsize, uint32_t *size); +extern uint32_t oscam_stapi5_BufferReadSection(uint32_t bufferhandle, uint32_t *filterlist, int32_t maxfilter, uint32_t *filtercount, int32_t *crc, uint8_t *buf, int32_t bufsize, uint32_t *size); extern uint32_t oscam_stapi5_SignalAbort(uint32_t signalhandle); extern uint32_t oscam_stapi5_PidQuery(char *name, uint16_t pid); extern uint32_t oscam_stapi5_BufferFlush(uint32_t bufferhandle); @@ -63,11 +63,11 @@ extern uint32_t oscam_sttkd_Allocate(uint32_t tkdhandle, uint8_t cp, uint32_t *p extern uint32_t oscam_sttkd_Associate(char *name, uint32_t pathhandle, uint16_t Pid); extern uint32_t oscam_sttkd_Deallocate(uint32_t pathhandle, uint32_t Keyhandle); extern uint32_t oscam_sttkd_Disassociate(char *name, uint16_t pid); -extern uint32_t oscam_sttkd_KeyWrite(uint32_t keyhandle, uint8_t pol, const uchar * cw); +extern uint32_t oscam_sttkd_KeyWrite(uint32_t keyhandle, uint8_t pol, const uint8_t *cw); // Local functions static void *stapi_read_thread(void *); -static int32_t stapi_do_set_filter(int32_t demux_id, FILTERTYPE *filter, uint16_t *pids, int32_t pidcount, uchar *filt, uchar *mask, int32_t dev_id); +static int32_t stapi_do_set_filter(int32_t demux_id, FILTERTYPE *filter, uint16_t *pids, int32_t pidcount, uint8_t *filt, uint8_t *mask, int32_t dev_id); static int32_t stapi_do_remove_filter(int32_t demux_id, FILTERTYPE *filter, int32_t dev_id); // These variables are declared in module-dvbapi.c @@ -99,22 +99,22 @@ static void stapi_off(void) for(i = 0; i < MAX_DEMUX; i++) { dvbapi_stop_descrambling(i, 0); - + if (tkd_desc_info[i].path_hndl != 0) { ErrorCode = oscam_sttkd_Deallocate(tkd_desc_info[i].path_hndl, tkd_desc_info[i].key_hndl); if (ErrorCode != 0) { cs_log("oscam_sttkd_Deallocate faild! ErrorCode: %d", ErrorCode); } - } + } } - + uint8_t TKD_InstanceID = 0; for(TKD_InstanceID = 0; TKD_InstanceID < TKD_MAX_NUMBER; TKD_InstanceID++) { ErrorCode = oscam_sttkd_Close(TKDHandle[TKD_InstanceID]); if(ErrorCode != 0) { cs_log("oscam_sttkd_Close: ErrorCode: %d TKDHandle: 0x%08X", ErrorCode, TKDHandle[TKD_InstanceID]); } - } + } for(i = 0; i < PTINUM; i++) { @@ -230,19 +230,19 @@ int32_t stapi_open(void) closedir(dirp); if(i == 0) { return 0; } - + uint8_t TKD_InstanceID = 0; memset(&tkd_desc_info, 0, sizeof(tkd_desc_info[0]) * MAX_DESCRAMBLER); for(TKD_InstanceID = 0; TKD_InstanceID < TKD_MAX_NUMBER; TKD_InstanceID++) - { + { /* Generate the device name dynamically based upon the Instance ID */ snprintf(TKD_DeviceName[TKD_InstanceID], sizeof(TKD_DeviceName), "TKD_%02d", TKD_InstanceID); - + ErrorCode = oscam_sttkd_Open(TKD_DeviceName[TKD_InstanceID], &TKDHandle[TKD_InstanceID]); if(ErrorCode != 0) cs_log("oscam_sttkd_Open: DeviceName: %s, TKDHandle: 0x%08X, ErrorCode: %d", TKD_DeviceName[TKD_InstanceID], TKDHandle[TKD_InstanceID], ErrorCode); - } + } SAFE_MUTEX_INIT(&filter_lock, NULL); @@ -270,7 +270,7 @@ int32_t stapi_open(void) return 1; } -int32_t stapi_activate_section_filter(int32_t fd, uchar *filter, uchar *mask) +int32_t stapi_activate_section_filter(int32_t fd, uint8_t *filter, uint8_t *mask) { uint32_t ErrorCode; @@ -280,11 +280,11 @@ int32_t stapi_activate_section_filter(int32_t fd, uchar *filter, uchar *mask) cs_log_dbg(D_DVBAPI, "Error: oscam_stapi5_FilterSet; %d", ErrorCode); return -1; } - + return ErrorCode; } -int32_t stapi_set_filter(int32_t demux_id, uint16_t pid, uchar *filter, uchar *mask, int32_t num, char *pmtfile) +int32_t stapi_set_filter(int32_t demux_id, uint16_t pid, uint8_t *filter, uint8_t *mask, int32_t num, char *pmtfile) { int32_t i; int32_t ret = -1; @@ -390,7 +390,7 @@ static uint32_t check_slot(int32_t dev_id, uint32_t checkslot, FILTERTYPE *skipf } -static int32_t stapi_do_set_filter(int32_t demux_id, FILTERTYPE *filter, uint16_t *pids, int32_t pidcount, uchar *filt, uchar *mask, int32_t dev_id) +static int32_t stapi_do_set_filter(int32_t demux_id, FILTERTYPE *filter, uint16_t *pids, int32_t pidcount, uint8_t *filt, uint8_t *mask, int32_t dev_id) { uint32_t FilterAssociateError = 0; int32_t k, ret = 0; @@ -473,13 +473,13 @@ static int32_t stapi_do_remove_filter(int32_t UNUSED(demux_id), FILTERTYPE *filt if(checkslot == 0) { FilterDeallocateError = oscam_stapi5_FilterDeallocate(filter->fd, filter->BufferHandle[k], filter->SlotHandle[k]); - + oscam_stapi5_SlotClearPid(filter->SlotHandle[k]); oscam_stapi5_SlotUnlink(filter->SlotHandle[k]); oscam_stapi5_SignalDisassociateBuffer(dev_list[dev_id].SignalHandle, filter->BufferHandle[k]); BufferDeallocateError = oscam_stapi5_BufferDeallocate(filter->BufferHandle[k]); - SlotDeallocateError = oscam_stapi5_SlotDeallocate(filter->SlotHandle[k]); + SlotDeallocateError = oscam_stapi5_SlotDeallocate(filter->SlotHandle[k]); } } @@ -513,7 +513,7 @@ static void *stapi_read_thread(void *sparam) { int32_t dev_index, ErrorCode, i, j, CRCValid; uint32_t QueryBufferHandle = 0, DataSize = 0; - uchar buf[BUFFLEN]; + uint8_t buf[BUFFLEN]; struct read_thread_param *para = sparam; dev_index = para->id; @@ -597,9 +597,9 @@ static void *stapi_read_thread(void *sparam) } SAFE_MUTEX_UNLOCK(&filter_lock); } - + pthread_cleanup_pop(0); - + return NULL; } @@ -633,7 +633,7 @@ int32_t stapi_set_pid(int32_t demux_id, int32_t UNUSED(num), ca_index_t idx, uin uint32_t ErrorCode = oscam_sttkd_Disassociate(dev_list[demux[demux_id].dev_index].name, pid); if (ErrorCode != 0) cs_log("oscam_sttkd_Disassociate faild! ErrorCode: %d", ErrorCode); - + int i; for (i = 0; i < MAX_STREAMPIDS; i++) { @@ -643,22 +643,22 @@ int32_t stapi_set_pid(int32_t demux_id, int32_t UNUSED(num), ca_index_t idx, uin break; } } - + } } return 1; } -int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_t STREAMpidcount, char *UNUSED(pmtfile)) +int32_t stapi_write_cw(int32_t demux_id, uint8_t *cw, uint16_t *STREAMpids, int32_t STREAMpidcount, char *UNUSED(pmtfile)) { int32_t ErrorCode, l, x; - unsigned char nullcw[8]; + uint8_t nullcw[8]; memset(nullcw, 0, 8); char *text[] = { "even", "odd" }; if(dev_list[demux[demux_id].dev_index].SessionHandle == 0) { return 0; } - + // check if descrambler is started for this dev_index if(tkd_desc_info[demux[demux_id].dev_index].path_hndl == 0) { @@ -666,14 +666,14 @@ int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_ { cs_log_dbg(D_DVBAPI, "stapi_write_cw , faild to added descrambler for %s", dev_list[demux[demux_id].dev_index].name); return 0; - } + } } // descrambler started, check each pid for (x = 0; x < STREAMpidcount; x++) { int pid_associated = -1; - + // search STREAMpids if path got associated for (l = 0; l < MAX_STREAMPIDS; l++) { @@ -683,7 +683,7 @@ int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_ break; } } - + // if not associated add the pid if(pid_associated < 0) { @@ -692,8 +692,8 @@ int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_ { cs_log("stapi_write_cw , oscam_sttkd_Associate faild for pid %04X! ErrorCode: %d", STREAMpids[x], ErrorCode); return 0; - } - + } + // add the pid to the next free index for (l = 0; l < MAX_STREAMPIDS; l++) { @@ -704,12 +704,12 @@ int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_ break; } } - + if (pid_associated < 0) { cs_log("stapi_write_cw , faild to associate pid %04X, maximum number of %d pids reached", STREAMpids[x], MAX_STREAMPIDS); return 0; - } + } } } @@ -730,7 +730,7 @@ int32_t stapi_write_cw(int32_t demux_id, uchar *cw, uint16_t *STREAMpids, int32_ if(memcmp(cw + (l * 8), demux[demux_id].lastcw[l], 8) != 0 && (memcmp(cw + (l * 8), nullcw, 8) != 0 || demux[demux_id].ECMpids[pidnum].CAID == 0x2600)) { ErrorCode = oscam_sttkd_KeyWrite(tkd_desc_info[demux[demux_id].dev_index].key_hndl, l, cw + (l * 8)); - + memcpy(demux[demux_id].lastcw[l], cw + (l * 8), 8); cs_log_dbg(D_DVBAPI, "write cw %s index: %d on %s", text[l], demux_id, dev_list[demux[demux_id].dev_index].name); } diff --git a/module-dvbapi.h b/module-dvbapi.h index 31f4d1924..e02c13f67 100644 --- a/module-dvbapi.h +++ b/module-dvbapi.h @@ -31,7 +31,7 @@ #define ECM_PIDS 30 #define MAX_FILTER 32 -#ifdef WITH_EXTENDED_CW +#ifdef WITH_EXTENDED_CW #define MAX_STREAM_INDICES 32 #else #define MAX_STREAM_INDICES 1 @@ -40,20 +40,20 @@ #define BOX_COUNT 7 #define BOXTYPE_DREAMBOX 1 -#define BOXTYPE_DUCKBOX 2 -#define BOXTYPE_UFS910 3 -#define BOXTYPE_DBOX2 4 -#define BOXTYPE_IPBOX 5 +#define BOXTYPE_DUCKBOX 2 +#define BOXTYPE_UFS910 3 +#define BOXTYPE_DBOX2 4 +#define BOXTYPE_IPBOX 5 #define BOXTYPE_IPBOX_PMT 6 -#define BOXTYPE_DM7000 7 -#define BOXTYPE_QBOXHD 8 +#define BOXTYPE_DM7000 7 +#define BOXTYPE_QBOXHD 8 #define BOXTYPE_COOLSTREAM 9 -#define BOXTYPE_NEUMO 10 -#define BOXTYPE_PC 11 -#define BOXTYPE_PC_NODMX 12 -#define BOXTYPE_SAMYGO 13 -#define BOXTYPES 13 -#define DMXMD5HASHSIZE 16 // use MD5() +#define BOXTYPE_NEUMO 10 +#define BOXTYPE_PC 11 +#define BOXTYPE_PC_NODMX 12 +#define BOXTYPE_SAMYGO 13 +#define BOXTYPES 13 +#define DMXMD5HASHSIZE 16 // use MD5() // we store the results of remove_streampid_from_list() // and update_streampid_list() in one variable, so make sure @@ -77,23 +77,23 @@ #define DUMMY_FD 0xFFFF //constants used int socket communication: -#define DVBAPI_PROTOCOL_VERSION 3 +#define DVBAPI_PROTOCOL_VERSION 3 #define DVBAPI_CA_SET_PID 0x40086f87 -#define DVBAPI_CA_SET_DESCR 0x40106f86 +#define DVBAPI_CA_SET_DESCR 0x40106f86 #define DVBAPI_CA_SET_DESCR_MODE 0x400c6f88 #define DVBAPI_DMX_SET_FILTER 0x403c6f2b #define DVBAPI_DMX_STOP 0x00006f2a #define DVBAPI_AOT_CA 0x9F803000 -#define DVBAPI_AOT_CA_PMT 0x9F803200 //least significant byte is length (ignored) +#define DVBAPI_AOT_CA_PMT 0x9F803200 // least significant byte is length (ignored) #define DVBAPI_AOT_CA_STOP 0x9F803F04 #define DVBAPI_FILTER_DATA 0xFFFF0000 #define DVBAPI_CLIENT_INFO 0xFFFF0001 #define DVBAPI_SERVER_INFO 0xFFFF0002 #define DVBAPI_ECM_INFO 0xFFFF0003 -#define DVBAPI_MAX_PACKET_SIZE 262 //maximum possible packet size +#define DVBAPI_MAX_PACKET_SIZE 262 // maximum possible packet size #define DVBAPI_INDEX_DISABLE 0xFFFFFFFF // only used for ca_pid_t @@ -136,7 +136,7 @@ struct s_ecmpids int8_t checked; int8_t status; uint8_t tries; - unsigned char table; + uint8_t table; ca_index_t index[MAX_STREAM_INDICES]; int8_t useMultipleIndices; uint32_t streams; @@ -152,16 +152,16 @@ typedef struct filter_s uint32_t provid; uint16_t type; int32_t count; - uchar filter[16]; - uchar mask[16]; - uchar lastecmd5[CS_ECMSTORESIZE]; // last requested ecm md5 + uint8_t filter[16]; + uint8_t mask[16]; + uint8_t lastecmd5[CS_ECMSTORESIZE]; // last requested ecm md5 int32_t lastresult; - uchar prevecmd5[CS_ECMSTORESIZE]; // previous requested ecm md5 + uint8_t prevecmd5[CS_ECMSTORESIZE]; // previous requested ecm md5 int32_t prevresult; #if defined(WITH_STAPI) || defined(WITH_STAPI5) int32_t NumSlots; - uint32_t SlotHandle[10]; - uint32_t BufferHandle[10]; + uint32_t SlotHandle[10]; + uint32_t BufferHandle[10]; #endif } FILTERTYPE; @@ -202,10 +202,10 @@ typedef struct demux_s uint16_t tsid; uint16_t pmtpid; uint32_t enigma_namespace; - unsigned char lastcw[2][8]; + uint8_t lastcw[2][8]; int8_t emm_filter; int8_t sdt_filter; - uchar hexserial[8]; + uint8_t hexserial[8]; struct s_reader *rdr; char pmt_file[30]; time_t pmt_time; @@ -228,12 +228,12 @@ typedef struct demux_s typedef struct s_streampid { - uint8_t cadevice; // holds ca device - uint16_t streampid; // holds pids - uint64_t activeindexers; // bitmask indexers if streampid enabled for index bit is set - ca_index_t caindex; // holds index that is used to decode on ca device - bool use_des; -}STREAMPIDTYPE; + uint8_t cadevice; // holds ca device + uint16_t streampid; // holds pids + uint64_t activeindexers; // bitmask indexers if streampid enabled for index bit is set + ca_index_t caindex; // holds index that is used to decode on ca device + bool use_des; +} STREAMPIDTYPE; struct s_dvbapi_priority { @@ -258,53 +258,51 @@ struct s_dvbapi_priority struct s_dvbapi_priority *next; }; - #define DMX_FILTER_SIZE 16 - //dvbapi 1 typedef struct dmxFilter { - uint8_t filter[DMX_FILTER_SIZE]; - uint8_t mask[DMX_FILTER_SIZE]; + uint8_t filter[DMX_FILTER_SIZE]; + uint8_t mask[DMX_FILTER_SIZE]; } dmxFilter_t; struct dmxSctFilterParams { - uint16_t pid; - dmxFilter_t filter; - uint32_t timeout; - uint32_t flags; + uint16_t pid; + dmxFilter_t filter; + uint32_t timeout; + uint32_t flags; + #define DMX_CHECK_CRC 1 -#define DMX_ONESHOT 2 +#define DMX_ONESHOT 2 #define DMX_IMMEDIATE_START 4 -#define DMX_BUCKET 0x1000 /* added in 2005.05.18 */ +#define DMX_BUCKET 0x1000 /* added in 2005.05.18 */ #define DMX_KERNEL_CLIENT 0x8000 }; #define DMX_START1 _IOW('o',41,int) #define DMX_STOP1 _IOW('o',42,int) -#define DMX_SET_FILTER1 _IOW('o',43,struct dmxSctFilterParams *) +#define DMX_SET_FILTER1 _IOW('o',43,struct dmxSctFilterParams *) //------------------------------------------------------------------ - //dbox2+ufs typedef struct dmx_filter { - uint8_t filter[DMX_FILTER_SIZE]; - uint8_t mask[DMX_FILTER_SIZE]; - uint8_t mode[DMX_FILTER_SIZE]; + uint8_t filter[DMX_FILTER_SIZE]; + uint8_t mask[DMX_FILTER_SIZE]; + uint8_t mode[DMX_FILTER_SIZE]; } dmx_filter_t; - struct dmx_sct_filter_params { - uint16_t pid; - dmx_filter_t filter; - uint32_t timeout; - uint32_t flags; + uint16_t pid; + dmx_filter_t filter; + uint32_t timeout; + uint32_t flags; + #define DMX_CHECK_CRC 1 -#define DMX_ONESHOT 2 +#define DMX_ONESHOT 2 #define DMX_IMMEDIATE_START 4 #define DMX_KERNEL_CLIENT 0x8000 }; @@ -312,57 +310,60 @@ struct dmx_sct_filter_params typedef struct ca_descr { uint32_t index; - uint32_t parity; /* 0 == even, 1 == odd */ - unsigned char cw[8]; + uint32_t parity; /* 0 == even, 1 == odd */ + uint8_t cw[8]; } ca_descr_t; typedef struct ca_pid { uint32_t pid; - int32_t index; /* -1 == disable*/ + int32_t index; /* -1 == disable*/ } ca_pid_t; -enum ca_descr_algo { +enum ca_descr_algo +{ CA_ALGO_DVBCSA, CA_ALGO_DES, CA_ALGO_AES128, }; - -enum ca_descr_cipher_mode { + +enum ca_descr_cipher_mode +{ CA_MODE_ECB, CA_MODE_CBC, }; -typedef struct ca_descr_mode { +typedef struct ca_descr_mode +{ uint32_t index; enum ca_descr_algo algo; enum ca_descr_cipher_mode cipher_mode; } ca_descr_mode_t; -#define DMX_START _IO('o', 41) -#define DMX_STOP _IO('o', 42) -#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params) +#define DMX_START _IO('o', 41) +#define DMX_STOP _IO('o', 42) +#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params) -#define CA_SET_DESCR _IOW('o', 134, ca_descr_t) -#define CA_SET_PID _IOW('o', 135, ca_pid_t) -#define CA_SET_DESCR_MODE _IOW('o', 136, ca_descr_mode_t) +#define CA_SET_DESCR _IOW('o', 134, ca_descr_t) +#define CA_SET_PID _IOW('o', 135, ca_pid_t) +#define CA_SET_DESCR_MODE _IOW('o', 136, ca_descr_mode_t) // -------------------------------------------------------------------- void dvbapi_stop_descrambling(int32_t demux_id, uint32_t msgid); void dvbapi_stop_all_descrambling(uint32_t msgid); -void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uchar *buffer, int32_t len, uint32_t msgid); +void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uint8_t *buffer, int32_t len, uint32_t msgid); int32_t dvbapi_open_device(int32_t, int32_t, int); int32_t dvbapi_stop_filternum(int32_t demux_index, int32_t num, uint32_t msgid); int32_t dvbapi_stop_filter(int32_t demux_index, int32_t type, uint32_t msgid); struct s_dvbapi_priority *dvbapi_check_prio_match(int32_t demux_id, int32_t pidindex, char type); void dvbapi_send_dcw(struct s_client *client, ECM_REQUEST *er); -void dvbapi_write_cw(int32_t demux_id, uchar *cw, int32_t pid, int32_t stream_id, enum ca_descr_algo algo, enum ca_descr_cipher_mode cipher_mode, uint32_t msgid); -int32_t dvbapi_parse_capmt(unsigned char *buffer, uint32_t length, int32_t connfd, char *pmtfile, int8_t is_real_pmt, uint16_t existing_demux_id, uint16_t client_proto_version, uint32_t msgid); +void dvbapi_write_cw(int32_t demux_id, uint8_t *cw, int32_t pid, int32_t stream_id, enum ca_descr_algo algo, enum ca_descr_cipher_mode cipher_mode, uint32_t msgid); +int32_t dvbapi_parse_capmt(uint8_t *buffer, uint32_t length, int32_t connfd, char *pmtfile, int8_t is_real_pmt, uint16_t existing_demux_id, uint16_t client_proto_version, uint32_t msgid); void request_cw(struct s_client *client, ECM_REQUEST *er, int32_t demux_id, uint8_t delayed_ecm_check); void dvbapi_try_next_caid(int32_t demux_id, int8_t checked, uint32_t msgid); void dvbapi_read_priority(void); int32_t dvbapi_set_section_filter(int32_t demux_index, ECM_REQUEST *er, int32_t n); -int32_t dvbapi_activate_section_filter(int32_t demux_index, int32_t num, int32_t fd, int32_t pid, uchar *filter, uchar *mask, uint32_t msgid); +int32_t dvbapi_activate_section_filter(int32_t demux_index, int32_t num, int32_t fd, int32_t pid, uint8_t *filter, uint8_t *mask, uint32_t msgid); int32_t dvbapi_check_ecm_delayed_delivery(int32_t demux_index, ECM_REQUEST *er); int32_t dvbapi_get_filternum(int32_t demux_index, ECM_REQUEST *er, int32_t type); ca_index_t dvbapi_ca_setpid(int32_t demux_index, int32_t pid, int32_t stream_id, bool use_des, uint32_t msgid); @@ -374,12 +375,12 @@ ca_index_t is_ca_used(uint8_t cadevice, int32_t pid); uint16_t dvbapi_get_client_proto_version(void); const char *dvbapi_get_client_name(void); void rotate_emmfilter(int32_t demux_id); -int32_t filtermatch(uchar *buffer, int32_t filter_num, int32_t demux_id, int32_t len); +int32_t filtermatch(uint8_t *buffer, int32_t filter_num, int32_t demux_id, int32_t len); void delayer(ECM_REQUEST *er, uint32_t delay); -void check_add_emmpid(int32_t demux_index, uchar *filter, int32_t l, int32_t emmtype); -void *dvbapi_start_handler(struct s_client *cl, uchar *mbuf, int32_t module_idx, void * (*_main_func)(void *)); +void check_add_emmpid(int32_t demux_index, uint8_t *filter, int32_t l, int32_t emmtype); +void *dvbapi_start_handler(struct s_client *cl, uint8_t *mbuf, int32_t module_idx, void *(*_main_func)(void *)); ca_index_t dvbapi_get_descindex(int32_t demux_index, int32_t pid, int32_t stream_id); -void dvbapi_write_ecminfo_file(struct s_client *client, ECM_REQUEST *er, uint8_t* lastcw0, uint8_t* lastcw1); +void dvbapi_write_ecminfo_file(struct s_client *client, ECM_REQUEST *er, uint8_t *lastcw0, uint8_t *lastcw1); #if defined(WITH_AZBOX) || defined(WITH_MCA) #define USE_OPENXCAS 1 diff --git a/module-ghttp.c b/module-ghttp.c index fec3197d5..92ff30bbf 100644 --- a/module-ghttp.c +++ b/module-ghttp.c @@ -47,7 +47,7 @@ static bool _ssl_connect(struct s_client *client, int32_t fd) { s_ghttp *context = (s_ghttp *)client->ghttp; - if(context->ssl_handle) // cleanup previous + if(context->ssl_handle) // cleanup previous { SSL_shutdown(context->ssl_handle); SSL_free(context->ssl_handle); @@ -58,10 +58,10 @@ static bool _ssl_connect(struct s_client *client, int32_t fd) context->ssl_handle = SSL_new(ghttp_ssl_context); if(context->ssl_handle == NULL) { - ERR_print_errors_fp(stderr); + ERR_print_errors_fp(stderr); #if OPENSSL_VERSION_NUMBER < 0x1010005fL ERR_remove_state(0); -#endif +#endif return false; } if(!SSL_set_fd(context->ssl_handle, fd)) @@ -69,7 +69,7 @@ static bool _ssl_connect(struct s_client *client, int32_t fd) ERR_print_errors_fp(stderr); #if OPENSSL_VERSION_NUMBER < 0x1010005fL ERR_remove_state(0); -#endif +#endif return false; } if(SSL_connect(context->ssl_handle) != 1) @@ -77,7 +77,7 @@ static bool _ssl_connect(struct s_client *client, int32_t fd) ERR_print_errors_fp(stderr); #if OPENSSL_VERSION_NUMBER < 0x1010005fL ERR_remove_state(0); -#endif +#endif } if(context->ssl_handle) @@ -103,37 +103,47 @@ int32_t ghttp_client_init(struct s_client *cl) ERR_print_errors_fp(stderr); #if OPENSSL_VERSION_NUMBER < 0x1010005fL ERR_remove_state(0); -#endif +#endif } #endif if(cl->reader->r_port == 0) - { cl->reader->r_port = cl->reader->ghttp_use_ssl ? 443 : 80; } + { + cl->reader->r_port = cl->reader->ghttp_use_ssl ? 443 : 80; + } str = strstr(cl->reader->device, "."); if(!str) { char host[128]; cs_strncpy(host, cl->reader->device, sizeof(cl->reader->device)); - snprintf(cl->reader->device, sizeof(cl->reader->device), "%s.appspot.com", host); + snprintf(cl->reader->device, sizeof(cl->reader->device), "%.115s.appspot.com", host); } cs_log("%s: init google cache client %s:%d (fd=%d)", cl->reader->label, cl->reader->device, cl->reader->r_port, cl->udp_fd); - if(cl->udp_fd) { network_tcp_connection_close(cl->reader, "re-init"); } + if(cl->udp_fd) + { + network_tcp_connection_close(cl->reader, "re-init"); + } handle = network_tcp_connection_open(cl->reader); - if(handle < 0) { return -1; } + if(handle < 0) + { + return -1; + } cl->reader->tcp_connected = 2; cl->reader->card_status = CARD_INSERTED; cl->reader->last_g = cl->reader->last_s = time((time_t *)0); cl->pfd = cl->udp_fd; - if(!cl->ghttp) { - if(!cs_malloc(&(cl->ghttp), sizeof(s_ghttp))) { return -1; } + if(!cs_malloc(&(cl->ghttp), sizeof(s_ghttp))) + { + return -1; + } memset(cl->ghttp, 0, sizeof(s_ghttp)); ((s_ghttp *)cl->ghttp)->post_contexts = ll_create("post contexts"); ((s_ghttp *)cl->ghttp)->ecm_q = ll_create("ecm queue"); @@ -150,7 +160,10 @@ int32_t ghttp_client_init(struct s_client *cl) return -1; #endif #ifdef WITH_SSL - if(ghttp_ssl_context == NULL) { return -1; } + if(ghttp_ssl_context == NULL) + { + return -1; + } if(_ssl_connect(cl, handle)) { @@ -190,7 +203,9 @@ static int32_t ghttp_send_int(struct s_client *client, uchar *buf, int32_t l) #ifdef WITH_SSL s_ghttp *context = (s_ghttp *)client->ghttp; if(client->reader->ghttp_use_ssl) - { return SSL_write(context->ssl_handle, buf, l); } + { + return SSL_write(context->ssl_handle, buf, l); + } #endif return send(client->pfd, buf, l, 0); } @@ -221,7 +236,10 @@ static int32_t ghttp_recv_int(struct s_client *client, uchar *buf, int32_t l) n = SSL_read(context->ssl_handle, buf, l); #endif } - else { n = cs_recv(client->pfd, buf, l, 0); } + else + { + n = cs_recv(client->pfd, buf, l, 0); + } if(n > 0) { @@ -265,7 +283,9 @@ static bool _is_post_context(LLIST *ca_contexts, ECM_REQUEST *er, bool remove_da existing = (s_ca_context *)ll_contains_data(ca_contexts, ctx, sizeof(s_ca_context)); if(remove_data) - { ll_remove_data(ca_contexts, existing); } + { + ll_remove_data(ca_contexts, existing); + } NULLFREE(ctx); } return existing != NULL; @@ -277,10 +297,15 @@ static void _add_context(LLIST *ca_contexts, s_ca_context *context) { ll_append(ca_contexts, context); } - else { NULLFREE(context); } + else + { + NULLFREE(context); + } while(ll_count(ca_contexts) > 64) - { ll_remove_first_data(ca_contexts); } + { + ll_remove_first_data(ca_contexts); + } cs_log_dbg(D_CLIENT, "ca contexts size %d", ll_count(ca_contexts)); } @@ -313,7 +338,11 @@ static void _set_pids_status(LLIST *ca_contexts, uint16_t onid, uint16_t tsid, u static bool _swap_hosts(s_ghttp *context) { - if(!context->fallback_id) { return false; } + if(!context->fallback_id) + { + return false; + } + uchar *tmp = context->host_id; context->host_id = context->fallback_id; context->fallback_id = tmp; @@ -326,10 +355,18 @@ static bool _swap_hosts(s_ghttp *context) static char *_get_header_substr(uchar *buf, const char *start, const char *end) { char *data = strstr((char *)buf, start); - if(!data) { return NULL; } + if(!data) + { + return NULL; + } + data += strlen(start); int len = strstr(data, end) - data; - if(len <= 0) { return NULL; } + if(len <= 0) + { + return NULL; + } + char tmp = data[len]; data[len] = '\0'; char *value = cs_strdup(data); @@ -359,7 +396,10 @@ static int32_t ghttp_recv_chk(struct s_client *client, uchar *dcw, int32_t *rc, s_ghttp *context = (s_ghttp *)client->ghttp; ECM_REQUEST *er = NULL; - if(n < 5) { return -1; } + if(n < 5) + { + return -1; + } data = strstr((char *)buf, "HTTP/1.1 "); if(!data || ll_count(context->ecm_q) > 6) @@ -497,7 +537,9 @@ static int32_t ghttp_recv_chk(struct s_client *client, uchar *dcw, int32_t *rc, cs_log_dump_dbg(D_CLIENT, content, clen, "%s: pmt ignore reply - %s (%d pids)", client->reader->label, hdrstr, clen / 2); uint32_t onid = 0, tsid = 0, sid = 0; if(sscanf(hdrstr, "%4x-%4x-%4x", &onid, &tsid, &sid) == 3) - { _set_pids_status(ghttp_ignored_contexts, onid, tsid, sid, content, clen); } + { + _set_pids_status(ghttp_ignored_contexts, onid, tsid, sid, content, clen); + } NULLFREE(hdrstr); return -1; } @@ -518,7 +560,10 @@ static int32_t ghttp_recv_chk(struct s_client *client, uchar *dcw, int32_t *rc, if(data || (client->cwlastresptime > 0 && client->cwlastresptime < 640)) { cs_log_dbg(D_CLIENT, "%s: probably cached cw (%d ms), switching back to cache get for next req", client->reader->label, client->cwlastresptime); - if(er) { _is_post_context(context->post_contexts, er, true); } + if(er) + { + _is_post_context(context->post_contexts, er, true); + } } } @@ -527,13 +572,20 @@ static int32_t ghttp_recv_chk(struct s_client *client, uchar *dcw, int32_t *rc, memcpy(dcw, content, 16); *rc = 1; er = ll_remove_first(context->ecm_q); - if(!er) { return -1; } + if(!er) + { + return -1; + } + cs_log_dump_dbg(D_TRACE, dcw, 16, "%s: cw recv chk for idx %d", client->reader->label, er->idx); return er->idx; } else { - if(clen != 0) { cs_log_dump_dbg(D_CLIENT, content, clen, "%s: recv_chk fail, clen = %d", client->reader->label, clen); } + if(clen != 0) + { + cs_log_dump_dbg(D_CLIENT, content, clen, "%s: recv_chk fail, clen = %d", client->reader->label, clen); + } } return -1; } @@ -563,18 +615,18 @@ static int32_t _ghttp_http_get(struct s_client *client, uint32_t hash, int odd) encauth = _ghttp_basic_auth(client); - if(encauth) // basic auth login + if(encauth) // basic auth login { ret = snprintf((char *)req, sizeof(req), "GET /api/c/%d/%x HTTP/1.1\r\nHost: %s\r\nAuthorization: Basic %s\r\n\r\n", odd ? 81 : 80, hash, context->host_id, encauth); NULLFREE(encauth); } else { - if(context->session_id) // session exists + if(context->session_id) // session exists { ret = snprintf((char *)req, sizeof(req), "GET /api/c/%s/%d/%x HTTP/1.1\r\nHost: %s\r\n\r\n", context->session_id, odd ? 81 : 80, hash, context->host_id); } - else // no credentials configured, assume no session required + else // no credentials configured, assume no session required { ret = snprintf((char *)req, sizeof(req), "GET /api/c/%d/%x HTTP/1.1\r\nHost: %s\r\n\r\n", odd ? 81 : 80, hash, context->host_id); } @@ -595,20 +647,23 @@ static int32_t _ghttp_post_ecmdata(struct s_client *client, ECM_REQUEST *er) encauth = _ghttp_basic_auth(client); - if(encauth) // basic auth login + if(encauth) // basic auth login { - ret = snprintf((char *)req, sizeof(req), "POST /api/e/%x/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s\r\nAuthorization: Basic %s\r\nContent-Length: %d\r\n\r\n", er->onid, er->tsid, er->pid, er->srvid, er->caid, er->prid, context->host_id, encauth, er->ecmlen); + ret = snprintf((char *)req, sizeof(req), "POST /api/e/%x/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s\r\nAuthorization: Basic %s\r\nContent-Length: %d\r\n\r\n", + er->onid, er->tsid, er->pid, er->srvid, er->caid, er->prid, context->host_id, encauth, er->ecmlen); NULLFREE(encauth); } else { if(context->session_id) // session exists { - ret = snprintf((char *)req, sizeof(req), "POST /api/e/%s/%x/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n", context->session_id, er->onid, er->tsid, er->pid, er->srvid, er->caid, er->prid, context->host_id, er->ecmlen); + ret = snprintf((char *)req, sizeof(req), "POST /api/e/%s/%x/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n", + context->session_id, er->onid, er->tsid, er->pid, er->srvid, er->caid, er->prid, context->host_id, er->ecmlen); } else // no credentials configured, assume no session required { - ret = snprintf((char *)req, sizeof(req), "POST /api/e/%x/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n", er->onid, er->tsid, er->pid, er->srvid, er->caid, er->prid, context->host_id, er->ecmlen); + ret = snprintf((char *)req, sizeof(req), "POST /api/e/%x/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n", + er->onid, er->tsid, er->pid, er->srvid, er->caid, er->prid, context->host_id, er->ecmlen); } } end = req + ret; @@ -635,7 +690,10 @@ static bool _is_pid_ignored(ECM_REQUEST *er) NULLFREE(ignore); return true; } - else { NULLFREE(ignore); } + else + { + NULLFREE(ignore); + } } return false; } @@ -655,7 +713,9 @@ static int32_t ghttp_send_ecm(struct s_client *client, ECM_REQUEST *er) ll_append(context->ecm_q, er); if(ll_count(context->ecm_q) > 1) - { cs_log_dbg(D_CLIENT, "%s: %d simultaneous ecms...", client->reader->label, ll_count(context->ecm_q)); } + { + cs_log_dbg(D_CLIENT, "%s: %d simultaneous ecms...", client->reader->label, ll_count(context->ecm_q)); + } if(_is_post_context(context->post_contexts, er, false)) { @@ -708,7 +768,8 @@ static int32_t ghttp_capmt_notify(struct s_client *client, struct demux_s *demux if(!context) { return -1; } - cs_log_dbg(D_CLIENT, "%s: capmt %x-%x-%x %d pids on adapter %d mask %x dmx index %d", client->reader->label, demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->adapter_index, demux->ca_mask, demux->demux_index); + cs_log_dbg(D_CLIENT, "%s: capmt %x-%x-%x %d pids on adapter %d mask %x dmx index %d", + client->reader->label, demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->adapter_index, demux->ca_mask, demux->demux_index); if(demux->ECMpidcount > 0) { @@ -724,27 +785,36 @@ static int32_t ghttp_capmt_notify(struct s_client *client, struct demux_s *demux } snprintf((char *)lenhdr, sizeof(lenhdr), "\r\nContent-Length: %d", pids_len); } - else { return -1; } + else + { + return -1; + } } - if(!context->host_id) { context->host_id = (uchar *)cs_strdup(client->reader->device); } + if(!context->host_id) + { + context->host_id = (uchar *)cs_strdup(client->reader->device); + } encauth = _ghttp_basic_auth(client); - if(encauth) // basic auth login + if(encauth) // basic auth login { - ret = snprintf((char *)req, sizeof(req), "%s /api/p/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s\r\nAuthorization: Basic %s%s\r\n\r\n", ((pids_len > 0) ? "POST" : "GET"), demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->enigma_namespace, context->host_id, encauth, lenhdr); + ret = snprintf((char *)req, sizeof(req), "%s /api/p/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s\r\nAuthorization: Basic %s%s\r\n\r\n", + ((pids_len > 0) ? "POST" : "GET"), demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->enigma_namespace, context->host_id, encauth, lenhdr); NULLFREE(encauth); } else { if(context->session_id) // session exists { - ret = snprintf((char *)req, sizeof(req), "%s /api/p/%s/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s%s\r\n\r\n", ((pids_len > 0) ? "POST" : "GET"), context->session_id, demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->enigma_namespace, context->host_id, lenhdr); + ret = snprintf((char *)req, sizeof(req), "%s /api/p/%s/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s%s\r\n\r\n", + ((pids_len > 0) ? "POST" : "GET"), context->session_id, demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->enigma_namespace, context->host_id, lenhdr); } - else // no credentials configured, assume no session required + else // no credentials configured, assume no session required { - ret = snprintf((char *)req, sizeof(req), "%s /api/p/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s%s\r\n\r\n", ((pids_len > 0) ? "POST" : "GET"), demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->enigma_namespace, context->host_id, lenhdr); + ret = snprintf((char *)req, sizeof(req), "%s /api/p/%x/%x/%x/%x/%x HTTP/1.1\r\nHost: %s%s\r\n\r\n", + ((pids_len > 0) ? "POST" : "GET"), demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->enigma_namespace, context->host_id, lenhdr); } } end = req + ret; @@ -754,11 +824,15 @@ static int32_t ghttp_capmt_notify(struct s_client *client, struct demux_s *demux cs_log_dbg(D_CLIENT, "%s: new unscrambling detected, switching to post", client->reader->label); _set_pid_status(context->post_contexts, demux->onid, demux->tsid, demux->program_number, 0); } - cs_log_dump_dbg(D_CLIENT, pids, pids_len, "%s: sending capmt ecm pids - %s /api/p/%x/%x/%x/%x/%x", client->reader->label, (pids_len > 0) ? "POST" : "GET", demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->enigma_namespace); + cs_log_dump_dbg(D_CLIENT, pids, pids_len, "%s: sending capmt ecm pids - %s /api/p/%x/%x/%x/%x/%x", + client->reader->label, (pids_len > 0) ? "POST" : "GET", demux->onid, demux->tsid, demux->program_number, demux->ECMpidcount, demux->enigma_namespace); ret = ghttp_send(client, req, ret + pids_len); - if(pids_len > 0) { NULLFREE(pids); } + if(pids_len > 0) + { + NULLFREE(pids); + } return 0; } diff --git a/reader-irdeto.c b/reader-irdeto.c index f2952ee8d..cb4cb55de 100644 --- a/reader-irdeto.c +++ b/reader-irdeto.c @@ -44,38 +44,42 @@ static const uchar sc_GetCountryCode[] = { 0x02, 0x02, 0x03, 0x00, 0x00 }; static const uchar -sc_GetCountryCode2[] = { 0x02, 0x0B, 0x00, 0x00, 0x00 -}, -sc_GetCamKey384CZ[] = { 0x02, 0x09, 0x03, 0x00, 0x40, -0x18, 0xD7, 0x55, 0x14, 0xC0, 0x83, 0xF1, 0x38, -0x39, 0x6F, 0xF2, 0xEC, 0x4F, 0xE3, 0xF1, 0x85, -0x01, 0x46, 0x06, 0xCE, 0x7D, 0x08, 0x2C, 0x74, -0x46, 0x8F, 0x72, 0xC4, 0xEA, 0xD7, 0x9C, 0xE0, -0xE1, 0xFF, 0x58, 0xE7, 0x70, 0x0C, 0x92, 0x45, -0x26, 0x18, 0x4F, 0xA0, 0xE2, 0xF5, 0x9E, 0x46, -0x6F, 0xAE, 0x95, 0x35, 0xB0, 0x49, 0xB2, 0x0E, -0xA4, 0x1F, 0x8E, 0x47, 0xD0, 0x24, 0x11, 0xD0 -}, -sc_GetCamKey384DZ[] = { 0x02, 0x09, 0x03, 0x00, 0x40, -0x27, 0xF2, 0xD6, 0xCD, 0xE6, 0x88, 0x62, 0x46, -0x81, 0xB0, 0xF5, 0x3E, 0x6F, 0x13, 0x4D, 0xCC, -0xFE, 0xD0, 0x67, 0xB1, 0x93, 0xDD, 0xF4, 0xDE, -0xEF, 0xF5, 0x3B, 0x04, 0x1D, 0xE5, 0xC3, 0xB2, -0x54, 0x38, 0x57, 0x7E, 0xC8, 0x39, 0x07, 0x2E, -0xD2, 0xF4, 0x05, 0xAA, 0x15, 0xB5, 0x55, 0x24, -0x90, 0xBB, 0x9B, 0x00, 0x96, 0xF0, 0xCB, 0xF1, -0x8A, 0x08, 0x7F, 0x0B, 0xB8, 0x79, 0xC3, 0x5D -}, -sc_GetCamKey384FZ[] = { 0x02, 0x09, 0x03, 0x00, 0x40, -0x62, 0xFE, 0xD8, 0x4F, 0x44, 0x86, 0x2C, 0x21, -0x50, 0x9A, 0xBE, 0x27, 0x15, 0x9E, 0xC4, 0x48, -0xF3, 0x73, 0x5C, 0xBD, 0x08, 0x64, 0x6D, 0x13, -0x64, 0x90, 0x14, 0xDB, 0xFF, 0xC3, 0xFE, 0x03, -0x97, 0xFA, 0x75, 0x08, 0x12, 0xF9, 0x8F, 0x84, -0x83, 0x17, 0xAA, 0x6F, 0xEF, 0x2C, 0x10, 0x1B, -0xBF, 0x31, 0x41, 0xC3, 0x54, 0x2F, 0x65, 0x50, -0x95, 0xA9, 0x64, 0x22, 0x5E, 0xA4, 0xAF, 0xA9 -}; + sc_GetCountryCode2[] = { + 0x02, 0x0B, 0x00, 0x00, 0x00 + }, + sc_GetCamKey384CZ[] = { + 0x02, 0x09, 0x03, 0x00, 0x40, + 0x18, 0xD7, 0x55, 0x14, 0xC0, 0x83, 0xF1, 0x38, + 0x39, 0x6F, 0xF2, 0xEC, 0x4F, 0xE3, 0xF1, 0x85, + 0x01, 0x46, 0x06, 0xCE, 0x7D, 0x08, 0x2C, 0x74, + 0x46, 0x8F, 0x72, 0xC4, 0xEA, 0xD7, 0x9C, 0xE0, + 0xE1, 0xFF, 0x58, 0xE7, 0x70, 0x0C, 0x92, 0x45, + 0x26, 0x18, 0x4F, 0xA0, 0xE2, 0xF5, 0x9E, 0x46, + 0x6F, 0xAE, 0x95, 0x35, 0xB0, 0x49, 0xB2, 0x0E, + 0xA4, 0x1F, 0x8E, 0x47, 0xD0, 0x24, 0x11, 0xD0 + }, + sc_GetCamKey384DZ[] = { + 0x02, 0x09, 0x03, 0x00, 0x40, + 0x27, 0xF2, 0xD6, 0xCD, 0xE6, 0x88, 0x62, 0x46, + 0x81, 0xB0, 0xF5, 0x3E, 0x6F, 0x13, 0x4D, 0xCC, + 0xFE, 0xD0, 0x67, 0xB1, 0x93, 0xDD, 0xF4, 0xDE, + 0xEF, 0xF5, 0x3B, 0x04, 0x1D, 0xE5, 0xC3, 0xB2, + 0x54, 0x38, 0x57, 0x7E, 0xC8, 0x39, 0x07, 0x2E, + 0xD2, 0xF4, 0x05, 0xAA, 0x15, 0xB5, 0x55, 0x24, + 0x90, 0xBB, 0x9B, 0x00, 0x96, 0xF0, 0xCB, 0xF1, + 0x8A, 0x08, 0x7F, 0x0B, 0xB8, 0x79, 0xC3, 0x5D + }, + sc_GetCamKey384FZ[] = { + 0x02, 0x09, 0x03, 0x00, 0x40, + 0x62, 0xFE, 0xD8, 0x4F, 0x44, 0x86, 0x2C, 0x21, + 0x50, 0x9A, 0xBE, 0x27, 0x15, 0x9E, 0xC4, 0x48, + 0xF3, 0x73, 0x5C, 0xBD, 0x08, 0x64, 0x6D, 0x13, + 0x64, 0x90, 0x14, 0xDB, 0xFF, 0xC3, 0xFE, 0x03, + 0x97, 0xFA, 0x75, 0x08, 0x12, 0xF9, 0x8F, 0x84, + 0x83, 0x17, 0xAA, 0x6F, 0xEF, 0x2C, 0x10, 0x1B, + 0xBF, 0x31, 0x41, 0xC3, 0x54, 0x2F, 0x65, 0x50, + 0x95, 0xA9, 0x64, 0x22, 0x5E, 0xA4, 0xAF, 0xA9 + }; /* some variables for acs57 (Dahlia for ITA dvb-t) */ #define ACS57EMM 0xD1 @@ -93,9 +97,9 @@ typedef struct chid_base_date struct irdeto_data { - int32_t acs57; // A flag for the ACS57 ITA DVB-T + int32_t acs57; // A flag for the ACS57 ITA DVB-T uint16_t acs; - char country_code[3]; // irdeto country code. + char country_code[3]; // irdeto country code. }; static void XRotateLeft8Byte(uchar *buf) @@ -149,7 +153,6 @@ static unsigned char XorSum(const unsigned char *mem, int len) static time_t chid_date(struct s_reader *reader, uint32_t date, char *buf, int32_t l) { - // Irdeto date starts 01.08.1997 which is // 870393600 seconds in unix calendar time // @@ -159,18 +162,20 @@ static time_t chid_date(struct s_reader *reader, uint32_t date, char *buf, int32 // // this is the known default value. uint32_t date_base; - + if((reader->caid>>8) == 0x06) - { date_base = 946598400L; } // this is actually 31.12.1999, 00:00 default for irdeto card + { + date_base = 946598400L; // this is actually 31.12.1999, 00:00 default for irdeto card + } else - { date_base = 870393600L; } // this is actually 01.08.1997, 00:00 default for betacrypt cards - + { + date_base = 870393600L; // this is actually 01.08.1997, 00:00 default for betacrypt cards + } + // CAID, ACS, Country, base date D . M. Y, h : m CHID_BASE_DATE table[] = { - {0x0662, 0x0608, "ITA", 944110500L}, // 01.12.1999, 23.55 {0x0616, 0x0608, "ITA", 944110500L}, // 01.12.1999, 23.55 //nitegate - {0x0647, 0x0005, "ITA", 946598400L}, // 31.12.1999, 00:00 //Redlight irdeto {0x0664, 0x0608, "TUR", 946598400L}, // 31.12.1999, 00:00 {0x0624, 0x0006, "CZE", 946598400L}, // 30.12.1999, 16:00 //skyklink irdeto @@ -189,35 +194,25 @@ static time_t chid_date(struct s_reader *reader, uint32_t date, char *buf, int32 {0x0606, 0x0605, "NLD", 946598400L}, // 31.12.1999, 00:00 //Caiway irdeto card caid: 0606, acs: 6.05 {0x0606, 0x0606, "NLD", 946598400L}, // 31.12.1999, 00:00 //Caiway irdeto card caid: 0606, acs: 6.06 {0x0606, 0x0006, "ZAF", 946598400L}, // 31.12.1999, 00:00 //dstv irdeto - {0x0604, 0x1541, "GRC", 977817600L}, // 26.12.2000, 00:00 {0x0604, 0x1542, "GRC", 977817600L}, // 26.12.2000, 00:00 {0x0604, 0x1543, "GRC", 977817600L}, // 26.12.2000, 00:00 {0x0604, 0x1544, "GRC", 977817600L}, // 26.12.2000, 17:00 - {0x0604, 0x0608, "EGY", 999993600L}, // 08.09.2001, 17:00 - {0x0604, 0x0606, "EGY", 1003276800L}, // 16.10.2001, 17:00 - {0x0604, 0x0605, "GRC", 1011052800L}, // 15.01.2002, 00:00 //nova irdeto {0x0604, 0x0606, "GRC", 1011052800L}, // 15.01.2002, 00:00 //nova irdeto {0x0604, 0x0607, "GRC", 1011052800L}, // 15.01.2002, 00:00 //nova irdeto {0x0604, 0x0608, "GRC", 1011052800L}, // 15.01.2002, 00:00 //nova irdeto {0x0604, 0x0005, "GRC", 1011052800L}, // 15.01.2002, 00:00 //mova irdeto - {0x0604, 0x0606, "NLD", 1066089600L}, // 14.10.2003, 00:00 {0x0610, 0x0608, "NLD", 1066089600L}, // 14.10.2003, 00:00 //Ziggo irdeto caid: 0610, acs: 6.08 {0x0604, 0x0608, "NLD", 1066089600L}, // 14.10.2003, 00:00 //Ziggo irdeto caid: 0604, acs: 6.08 {0x0604, 0x0605, "NLD", 1066089600L}, // 14.10.2003, 00:00 //Ziggo irdeto caid: 0604, acs: 6.05 {0x0604, 0x0005, "NLD", 1066089600L}, // 14.10.2003, 00:00 //Ziggo irdeto caid: 0604, acs: 0.05 - {0x0628, 0x0606, "MCR", 1159574400L}, // 29.09.2006, 00:00 - {0x0652, 0x0005, "MCR", 1206662400L}, // 28.03.2008, 00:00 //Raduga caid:0652, acs: 0.05 {0x0652, 0x0608, "MCR", 1206662400L}, // 28.03.2008, 00:00 //Raduga caid:0652, acs: 6.08 - - // {0x1702, 0x0384, "AUT", XXXXXXXXXL}, // -> we need the base date for this - // {0x1702, 0x0384, "GER", 888883200L}, // 02.03.1998, 16:00 -> this fixes some card but break others (S02). {0x0, 0x0, "", 0L} }; @@ -239,6 +234,7 @@ static time_t chid_date(struct s_reader *reader, uint32_t date, char *buf, int32 { struct tm t; cs_gmtime_r(&ut, &t); + l = 27; snprintf(buf, l, "%04d/%02d/%02d", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday); } return (ut); @@ -248,16 +244,18 @@ static int32_t irdeto_do_cmd(struct s_reader *reader, uchar *buf, uint16_t good, { int32_t rc; if((rc = reader_cmd2icc(reader, buf, buf[4] + 5, cta_res, p_cta_lr))) - { return (rc); } // result may be 0 (success) or negative + { + return (rc); // result may be 0 (success) or negative + } if(*p_cta_lr < 2) - { return (0x7F7F); } // this should never happen + { + return (0x7F7F); // this should never happen + } + return (good != b2i(2, cta_res + *p_cta_lr - 2)); } -#define reader_chk_cmd(cmd, l) \ - { \ - if (reader_cmd2icc(reader, cmd, sizeof(cmd), cta_res, &cta_lr)) return ERROR; \ - if (l && (cta_lr!=l)) return ERROR; } +#define reader_chk_cmd(cmd, l) { if (reader_cmd2icc(reader, cmd, sizeof(cmd), cta_res, &cta_lr)) return ERROR; if (l && (cta_lr!=l)) return ERROR; } static int32_t irdeto_card_init_provider(struct s_reader *reader) { @@ -266,9 +264,10 @@ static int32_t irdeto_card_init_provider(struct s_reader *reader) uchar buf[256] = {0}; struct irdeto_data *csystem_data = reader->csystem_data; - uchar sc_GetProvider[] = { 0x02, 0x03, 0x03, 0x00, 0x00 }; - uchar sc_Acs57Prov[] = { 0xD2, 0x06, 0x03, 0x00, 0x01, 0x3C }; - uchar sc_Acs57_Cmd[] = { ACS57GET, 0xFE, 0x00, 0x00, 0x00 }; + uchar sc_GetProvider[] = { 0x02, 0x03, 0x03, 0x00, 0x00 }; + uchar sc_Acs57Prov[] = { 0xD2, 0x06, 0x03, 0x00, 0x01, 0x3C }; + uchar sc_Acs57_Cmd[] = { ACS57GET, 0xFE, 0x00, 0x00, 0x00 }; + /* * Provider */ @@ -292,63 +291,70 @@ static int32_t irdeto_card_init_provider(struct s_reader *reader) sc_GetProvider[3] = i; reader_chk_cmd(sc_GetProvider, 0); } - //if ((cta_lr==26) && (cta_res[0]!=0xf)) + if(((cta_lr == 26) && ((!(i & 1)) || (cta_res[0] != 0xf))) || (csystem_data->acs57 == 1)) { reader->prid[i][4] = p++; - // maps the provider id for Betacrypt from FFFFFF to 000000, // fixes problems with cascading CCcam and OSCam if(caid_is_betacrypt(reader->caid)) - { memset(&reader->prid[i][0], 0, 4); } + { + memset(&reader->prid[i][0], 0, 4); + } else - { memcpy(&reader->prid[i][0], cta_res + acspadd, 4); } + { + memcpy(&reader->prid[i][0], cta_res + acspadd, 4); + } if(!memcmp(cta_res + acspadd + 1, &reader->hexserial, 3)) - { reader->prid[i][3] = 0xFF; } + { + reader->prid[i][3] = 0xFF; + } snprintf((char *) buf + strlen((char *)buf), sizeof(buf) - strlen((char *)buf), ",%06x", b2i(3, &reader->prid[i][1])); } else - { reader->prid[i][0] = 0xf; } + { + reader->prid[i][0] = 0xf; + } } + if(p) - { rdr_log(reader, "active providers: %d (%s)", p, buf + 1); } + { + rdr_log(reader, "active providers: %d (%s)", p, buf + 1); + } return OK; } - - static int32_t irdeto_card_init(struct s_reader *reader, ATR *newatr) { def_resp; get_atr; int32_t camkey = 0; uchar buf[256] = {0}; - uchar sc_GetCamKey383C[] = { 0x02, 0x09, 0x03, 0x00, 0x40, - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, - 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - }; - - uchar sc_GetASCIISerial[] = { 0x02, 0x00, 0x03, 0x00, 0x00 }, - sc_GetHEXSerial[] = { 0x02, 0x01, 0x00, 0x00, 0x00 }, - sc_GetSCDetails[] = { 0x02, 0x1E, 0x00, 0x00, 0x00 }, - sc_GetCardFile[] = { 0x02, 0x0E, 0x02, 0x00, 0x00 }; - - - uchar sc_Acs57CamKey[70] = { 0xD2, 0x12, 0x03, 0x00, 0x41}, - sc_Acs57Country[] = { 0xD2, 0x04, 0x00, 0x00, 0x01, 0x3E }, - sc_Acs57Ascii[] = { 0xD2, 0x00, 0x03, 0x00, 0x01, 0x3F }, - sc_Acs57Hex[] = { 0xD2, 0x02, 0x03, 0x00, 0x01, 0x3E }, - sc_Acs57CFile[] = { 0xD2, 0x1C, 0x02, 0x00, 0x01, 0x30 }, - sc_Acs57_Cmd[] = { ACS57GET, 0xFE, 0x00, 0x00, 0x00 }; + uchar sc_GetCamKey383C[] = { + 0x02, 0x09, 0x03, 0x00, 0x40, + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + + uchar sc_GetASCIISerial[] = { 0x02, 0x00, 0x03, 0x00, 0x00 }, + sc_GetHEXSerial[] = { 0x02, 0x01, 0x00, 0x00, 0x00 }, + sc_GetSCDetails[] = { 0x02, 0x1E, 0x00, 0x00, 0x00 }, + sc_GetCardFile[] = { 0x02, 0x0E, 0x02, 0x00, 0x00 }; + + uchar sc_Acs57CamKey[70] = { 0xD2, 0x12, 0x03, 0x00, 0x41}, + sc_Acs57Country[] = { 0xD2, 0x04, 0x00, 0x00, 0x01, 0x3E }, + sc_Acs57Ascii[] = { 0xD2, 0x00, 0x03, 0x00, 0x01, 0x3F }, + sc_Acs57Hex[] = { 0xD2, 0x02, 0x03, 0x00, 0x01, 0x3E }, + sc_Acs57CFile[] = { 0xD2, 0x1C, 0x02, 0x00, 0x01, 0x30 }, + sc_Acs57_Cmd[] = { ACS57GET, 0xFE, 0x00, 0x00, 0x00 }; int32_t acspadd = 0; int32_t acs57 = 0; @@ -369,12 +375,14 @@ static int32_t irdeto_card_init(struct s_reader *reader, ATR *newatr) } if(!cs_malloc(&reader->csystem_data, sizeof(struct irdeto_data))) - { return ERROR; } + { + return ERROR; + } struct irdeto_data *csystem_data = reader->csystem_data; csystem_data->acs57 = acs57; rdr_log(reader, "detect irdeto card"); - if(array_has_nonzero_byte(reader->rsa_mod, 64) > 0 && (!reader->force_irdeto || csystem_data->acs57)) // we use rsa from config as camkey + if(array_has_nonzero_byte(reader->rsa_mod, 64) > 0 && (!reader->force_irdeto || csystem_data->acs57)) // we use rsa from config as camkey { char tmp_dbg[65]; rdr_log_dbg(reader, D_READER, "using camkey data from config"); @@ -403,15 +411,18 @@ static int32_t irdeto_card_init(struct s_reader *reader, ATR *newatr) memcpy(reader->boxkey, "\x11\x22\x33\x44\x55\x66\x77\x88", 8); } } + /* * Get Irdeto Smartcard Details - version - patch level etc */ if(csystem_data->acs57 == 0) { if(!irdeto_do_cmd(reader, sc_GetSCDetails, 0, cta_res, &cta_lr)) - rdr_log(reader, "Irdeto SC %0x version %0x revision %0x, patch level %0x", cta_res[0 + acspadd], - cta_res[1 + acspadd], cta_res[2 + acspadd], cta_res[5 + acspadd]); + { + rdr_log(reader, "Irdeto SC %0x version %0x revision %0x, patch level %0x", cta_res[0 + acspadd], cta_res[1 + acspadd], cta_res[2 + acspadd], cta_res[5 + acspadd]); + } } + /* * CountryCode */ @@ -430,7 +441,7 @@ static int32_t irdeto_card_init(struct s_reader *reader, ATR *newatr) reader->caid = (cta_res[5 + acspadd] << 8) | cta_res[6 + acspadd]; memcpy(csystem_data->country_code, cta_res + 13 + acspadd, 3); rdr_log(reader, "caid: %04X, acs: %x.%02x, country code: %c%c%c", - reader->caid, cta_res[0 + acspadd], cta_res[1 + acspadd], cta_res[13 + acspadd], cta_res[14 + acspadd], cta_res[15 + acspadd]); + reader->caid, cta_res[0 + acspadd], cta_res[1 + acspadd], cta_res[13 + acspadd], cta_res[14 + acspadd], cta_res[15 + acspadd]); /* * Ascii/Hex-Serial @@ -463,7 +474,7 @@ static int32_t irdeto_card_init(struct s_reader *reader, ATR *newatr) memcpy(reader->hexserial, cta_res + 12 + acspadd, 4); rdr_log_sensitive(reader, "providers: %d, ascii serial: {%s}, hex serial: {%02X%02X%02X}, hex base: {%02X}", - reader->nprov, buf, reader->hexserial[0], reader->hexserial[1], reader->hexserial[2], reader->hexserial[3]); + reader->nprov, buf, reader->hexserial[0], reader->hexserial[1], reader->hexserial[2], reader->hexserial[3]); /* * CardFile @@ -486,7 +497,9 @@ static int32_t irdeto_card_init(struct s_reader *reader, ATR *newatr) else { for(sc_GetCardFile[2] = 2; sc_GetCardFile[2] < 4; sc_GetCardFile[2]++) - { reader_chk_cmd(sc_GetCardFile, 0); } + { + reader_chk_cmd(sc_GetCardFile, 0); + } } /* @@ -505,94 +518,100 @@ static int32_t irdeto_card_init(struct s_reader *reader, ATR *newatr) case 0x1762: camkey = 3; break; - // case 0x0624: camkey = 4; break; //ice 0D96/0624 has short ATR + // case 0x0624: camkey = 4; break; //ice 0D96/0624 has short ATR default : camkey = 5; break; } } - if((reader->caid == 0x0648) || (reader->caid == 0x0650) || (reader->caid == 0x0666) || (reader->caid == 0x0624 && csystem_data->acs57 == 1)) // acs 6.08 and ice 0D96/0624 + if((reader->caid == 0x0648) || (reader->caid == 0x0650) || (reader->caid == 0x0666) || (reader->caid == 0x0624 && csystem_data->acs57 == 1)) // acs 6.08 and ice 0D96/0624 { camkey = 4; sc_Acs57CamKey[2] = 0; } -// Dirthy hack for Ziggo will be removed when optimum values are find on these T14 cards for v2 and triple -// There are also other readers suffering from simmilar issue for those cards. - if(((reader->caid == 0x0604) || (reader->caid == 0x1722)) && (reader->typ == R_SMART) && (reader->smart_type >= 2)) - { - // Quick and dirty containment for the SmargoV2,Triple and Ziggo irdeto caid: 0604 using smartreader protocol - camkey = 999; - } // end dirthy hack + + // Dirthy hack for Ziggo will be removed when optimum values are find on these T14 cards for v2 and triple + // There are also other readers suffering from simmilar issue for those cards. + if(((reader->caid == 0x0604) || (reader->caid == 0x1722)) && (reader->typ == R_SMART) && (reader->smart_type >= 2)) + { + // Quick and dirty containment for the SmargoV2,Triple and Ziggo irdeto caid: 0604 using smartreader protocol + camkey = 999; + } + // end dirthy hack + rdr_log_dbg(reader, D_READER, "set camkey for type=%d", camkey); switch(camkey) { - case 1: - reader_chk_cmd(sc_GetCamKey384CZ, 10); - break; - case 2: - reader_chk_cmd(sc_GetCamKey384DZ, 10); - break; - case 3: - reader_chk_cmd(sc_GetCamKey384FZ, 10); - break; - case 4: - { - int32_t i, crc = 61; - crc ^= 0x01, crc ^= 0x02, crc ^= 0x09; - crc ^= sc_Acs57CamKey[2], crc ^= sc_Acs57CamKey[3], crc ^= (sc_Acs57CamKey[4] + 1); - for(i = 5; i < (int)sizeof(sc_Acs57CamKey) - 1; i++) - { crc ^= sc_Acs57CamKey[i]; } - sc_Acs57CamKey[69] = crc; - if((reader->caid == 0x0648) || (reader->caid == 0x0650) || (reader->caid == 0x0666) || (reader->caid == 0x0624 && csystem_data->acs57 == 1)) - { - sc_Acs57CamKey[69] = XorSum(sc_Acs57CamKey, 69) ^ 0x3f ^(sc_Acs57CamKey[0] & 0xf0) ^ 0x1b; - if(irdeto_do_cmd(reader, sc_Acs57CamKey, 0x9011, cta_res, &cta_lr)) - { - rdr_log(reader, "You have a bad Cam Key set"); - return ERROR; - } - } - else - { irdeto_do_cmd(reader, sc_Acs57CamKey, 0x9012, cta_res, &cta_lr); } - int32_t acslength = cta_res[cta_lr - 1]; - sc_Acs57_Cmd[4] = acslength; - reader_chk_cmd(sc_Acs57_Cmd, acslength + 2); - } - break; -// dirthy hack ziggo nl card smartredaer v2 and triple will be removed after findings optimum T14 values for v2 and triple - case 999: - { - // For some reason only 4 to 5 bytes are received, while 8 bytes are expected. - - int32_t rc; - rc = reader_cmd2icc(reader, sc_GetCamKey383C, sizeof(sc_GetCamKey383C), cta_res, &cta_lr); - rdr_log_dbg(reader, D_READER, "SmargoV2 camkey exchange containment: Ignoring returncode (%d), should have been 0.", rc); - rdr_log_dbg(reader, D_READER, "In case cardinit NOK and/or no entitlements, retry by restarting oscam."); - } - break; -// end dirthy hack - default: - if(csystem_data->acs57 == 1) + case 1: + reader_chk_cmd(sc_GetCamKey384CZ, 10); + break; + case 2: + reader_chk_cmd(sc_GetCamKey384DZ, 10); + break; + case 3: + reader_chk_cmd(sc_GetCamKey384FZ, 10); + break; + case 4: { - int32_t i, crc = 0x76; - for(i = 6; i < (int)sizeof(sc_Acs57CamKey) - 1; i++) + int32_t i, crc = 61; + crc ^= 0x01, crc ^= 0x02, crc ^= 0x09; + crc ^= sc_Acs57CamKey[2], crc ^= sc_Acs57CamKey[3], crc ^= (sc_Acs57CamKey[4] + 1); + for(i = 5; i < (int)sizeof(sc_Acs57CamKey) - 1; i++) { crc ^= sc_Acs57CamKey[i]; } sc_Acs57CamKey[69] = crc; - irdeto_do_cmd(reader, sc_Acs57CamKey, 0x9012, cta_res, &cta_lr); + if((reader->caid == 0x0648) || (reader->caid == 0x0650) || (reader->caid == 0x0666) || (reader->caid == 0x0624 && csystem_data->acs57 == 1)) + { + sc_Acs57CamKey[69] = XorSum(sc_Acs57CamKey, 69) ^ 0x3f ^(sc_Acs57CamKey[0] & 0xf0) ^ 0x1b; + if(irdeto_do_cmd(reader, sc_Acs57CamKey, 0x9011, cta_res, &cta_lr)) + { + rdr_log(reader, "You have a bad Cam Key set"); + return ERROR; + } + } + else + { + irdeto_do_cmd(reader, sc_Acs57CamKey, 0x9012, cta_res, &cta_lr); + } int32_t acslength = cta_res[cta_lr - 1]; sc_Acs57_Cmd[4] = acslength; reader_chk_cmd(sc_Acs57_Cmd, acslength + 2); - } - else + } break; + + // dirthy hack ziggo nl card smartredaer v2 and triple will be removed after findings optimum T14 values for v2 and triple + case 999: { - reader_chk_cmd(sc_GetCamKey383C, 0); - } - break; + // For some reason only 4 to 5 bytes are received, while 8 bytes are expected. + int32_t rc; + rc = reader_cmd2icc(reader, sc_GetCamKey383C, sizeof(sc_GetCamKey383C), cta_res, &cta_lr); + rdr_log_dbg(reader, D_READER, "SmargoV2 camkey exchange containment: Ignoring returncode (%d), should have been 0.", rc); + rdr_log_dbg(reader, D_READER, "In case cardinit NOK and/or no entitlements, retry by restarting oscam."); + } break;// end dirthy hack + + default: + if(csystem_data->acs57 == 1) + { + int32_t i, crc = 0x76; + for(i = 6; i < (int)sizeof(sc_Acs57CamKey) - 1; i++) + { + crc ^= sc_Acs57CamKey[i]; + } + sc_Acs57CamKey[69] = crc; + irdeto_do_cmd(reader, sc_Acs57CamKey, 0x9012, cta_res, &cta_lr); + int32_t acslength = cta_res[cta_lr - 1]; + sc_Acs57_Cmd[4] = acslength; + reader_chk_cmd(sc_Acs57_Cmd, acslength + 2); + } + else + { + reader_chk_cmd(sc_GetCamKey383C, 0); + } break; } if((reader->cardmhz != 600 && reader->typ != R_INTERNAL) || (reader->typ == R_INTERNAL && (reader->mhz < 510 || reader->cardmhz > 690))) - { rdr_log(reader, "WARNING: For Irdeto cards you will have to set '%s= 600' in oscam.server", (reader->typ == R_INTERNAL ? "mhz" : "cardmhz") ); } + { + rdr_log(reader, "WARNING: For Irdeto cards you will have to set '%s= 600' in oscam.server", (reader->typ == R_INTERNAL ? "mhz" : "cardmhz") ); + } return irdeto_card_init_provider(reader); } @@ -612,7 +631,7 @@ int32_t irdeto_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, struct s_e { int32_t crc = 63; sc_Acs57Ecm[4] = er->ecm[2] - 2; - if((reader->caid == 0x0648) || (reader->caid == 0x0650) || (reader->caid == 0x0666) || (reader->caid == 0x0624 && csystem_data->acs57 == 1)) //crc for orf, cslink, skylink + if((reader->caid == 0x0648) || (reader->caid == 0x0650) || (reader->caid == 0x0666) || (reader->caid == 0x0624 && csystem_data->acs57 == 1)) //crc for orf, cslink, skylink { sc_Acs57Ecm[2] = 0; crc ^= 0x01; @@ -621,7 +640,9 @@ int32_t irdeto_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, struct s_e crc ^= sc_Acs57Ecm[3]; crc ^= (sc_Acs57Ecm[4] - 1); for(i = 6; i < er->ecm[2] + 4; i++) - { crc ^= er->ecm[i]; } + { + crc ^= er->ecm[i]; + } } else { @@ -632,7 +653,9 @@ int32_t irdeto_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, struct s_e crc ^= sc_Acs57Ecm[3]; crc ^= (sc_Acs57Ecm[4] - 1); for(i = 6; i < er->ecm[3] - 5; i++) - { crc ^= er->ecm[i]; } + { + crc ^= er->ecm[i]; + } } memcpy(cta_cmd, sc_Acs57Ecm, sizeof(sc_Acs57Ecm)); memcpy(cta_cmd + 5, er->ecm + 6, er->ecm[2] - 1); @@ -670,7 +693,9 @@ int32_t irdeto_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, struct s_e do { if(try > 1) - snprintf(ea->msglog, MSGLOGSIZE, "%.22s irdeto_do_cmd try nr %i", reader->label, try); + { + snprintf(ea->msglog, MSGLOGSIZE, "%.22s irdeto_do_cmd try nr %i", reader->label, try); + } ret = (irdeto_do_cmd(reader, cta_cmd, 0x9D00, cta_res, &cta_lr)); ret = ret || (cta_lr < 24); if(ret) @@ -725,7 +750,7 @@ int32_t irdeto_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, struct s_e snprintf(ea->msglog, MSGLOGSIZE,"%.17s surflock enabled", reader->label); return E_CORRUPT; } - + default: // all other error status { snprintf(ea->msglog, MSGLOGSIZE, "%.16s irdeto_do_cmd [%d] %02x %02x", reader->label, cta_lr, cta_res[cta_lr - 2], cta_res[cta_lr - 1]); @@ -737,7 +762,9 @@ int32_t irdeto_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, struct s_e } while((try < 3) && (ret)); if(ret) - { return ERROR; } + { + return ERROR; + } } if(cta_res[5]== 0x36 || cta_res[5]== 0x37 || cta_res[5]== 0x24 || cta_res[5]== 0x25) @@ -777,7 +804,10 @@ static int32_t irdeto_get_emm_type(EMM_PACKET *ep, struct s_reader *rdr) return 0; // base doesnt match! } } - else { return 1; } // provider based, match all! + else + { + return 1; + } // provider based, match all! case 2: // shared emm, 2 bytes addressed @@ -786,8 +816,7 @@ static int32_t irdeto_get_emm_type(EMM_PACKET *ep, struct s_reader *rdr) memcpy(ep->hexserial, ep->emm + 4, l); cs_hexdump(1, rdr->hexserial, l, dumprdrserial, sizeof(dumprdrserial)); cs_hexdump(1, ep->hexserial, l, dumpemmserial, sizeof(dumpemmserial)); - rdr_log_dbg_sensitive(rdr, D_EMM, "SHARED l = %d ep = {%s} rdr = {%s} base = %02x", l, - dumpemmserial, dumprdrserial, base); + rdr_log_dbg_sensitive(rdr, D_EMM, "SHARED l = %d ep = {%s} rdr = {%s} base = %02x", l, dumpemmserial, dumprdrserial, base); if(base & 0x10) { @@ -797,12 +826,18 @@ static int32_t irdeto_get_emm_type(EMM_PACKET *ep, struct s_reader *rdr) else { if(!memcmp(ep->emm + 4, rdr->hexserial, l)) - { return 1; } + { + return 1; + } // provider addressed for(i = 0; i < rdr->nprov; i++) + { if(base == rdr->prid[i][0] && !memcmp(ep->emm + 4, &rdr->prid[i][1], l)) - { return 1; } + { + return 1; + } + } } rdr_log_dbg(rdr, D_EMM, "neither hex nor provider addressed or unknown provider id"); return 0; @@ -814,21 +849,27 @@ static int32_t irdeto_get_emm_type(EMM_PACKET *ep, struct s_reader *rdr) memcpy(ep->hexserial, ep->emm + 4, l); cs_hexdump(1, rdr->hexserial, l, dumprdrserial, sizeof(dumprdrserial)); cs_hexdump(1, ep->hexserial, l, dumpemmserial, sizeof(dumpemmserial)); - rdr_log_dbg_sensitive(rdr, D_EMM, "UNIQUE l = %d ep = {%s} rdr = {%s} base = %02x", l, - dumpemmserial, dumprdrserial, base); + rdr_log_dbg_sensitive(rdr, D_EMM, "UNIQUE l = %d ep = {%s} rdr = {%s} base = %02x", l, dumpemmserial, dumprdrserial, base); - if(base & 0x10) - // unique hex addressed - { return (base == rdr->hexserial[3] && !memcmp(ep->emm + 4, rdr->hexserial, l)); } + if(base & 0x10) // unique hex addressed + { + return (base == rdr->hexserial[3] && !memcmp(ep->emm + 4, rdr->hexserial, l)); + } else { if(!memcmp(ep->emm + 4, rdr->hexserial, l)) - { return 1; } + { + return 1; + } // unique provider addressed for(i = 0; i < rdr->nprov; i++) + { if(base == rdr->prid[i][0] && !memcmp(ep->emm + 4, &rdr->prid[i][1], l)) - { return 1; } + { + return 1; + } + } } rdr_log_dbg(rdr, D_EMM, "neither hex nor provider addressed or unknown provider id"); return 0; @@ -891,7 +932,9 @@ static int32_t irdeto_get_emm_filter(struct s_reader *rdr, struct s_csystem_emm_ { // 00XX00 provider is a not initialised not used provider if(rdr->prid[i][1] == 0xFF || (rdr->prid[i][1] == 0x00 && rdr->prid[i][3] == 0x00 && rdr->caid != 0x0647)) - { continue; } + { + continue; + } filters[idx].type = EMM_UNIQUE; filters[idx].enabled = 1; @@ -926,7 +969,9 @@ static int32_t irdeto_get_tunemm_filter(struct s_reader *rdr, struct s_csystem_e { const unsigned int max_filter_count = 3; if(!cs_malloc(emm_filters, max_filter_count * sizeof(struct s_csystem_emm_filter))) - { return ERROR; } + { + return ERROR; + } struct s_csystem_emm_filter *filters = *emm_filters; *filter_count = 0; @@ -977,25 +1022,35 @@ void irdeto_add_emm_header(EMM_PACKET *ep) if(ep->emm[0] == 0x83 && ep->emm[5] == 0x10) { if(ep->emm[7] == 0x00) - { ep->type = UNIQUE; } + { + ep->type = UNIQUE; + } else - { ep->type = SHARED; } + { + ep->type = SHARED; + } } else { if(ep->emm[0] == 0x82) - { ep->type = GLOBAL; } + { + ep->type = GLOBAL; + } } if(ep->type != UNKNOWN && ep->emmlen == 142) - { cs_log_dbg(D_EMM, "[TUN_EMM] Type: %s - rewriting header", typtext[ep->type]); } + { + cs_log_dbg(D_EMM, "[TUN_EMM] Type: %s - rewriting header", typtext[ep->type]); + } else - { return; } + { + return; + } // BETACRYPT/IRDETO EMM HEADER: - static uint8_t headerD0[6] = { 0x82, 0x70, 0x89, 0xd0, 0x01, 0x00 }; // GLOBAL - static uint8_t headerD2[8] = { 0x82, 0x70, 0x8b, 0xd2, 0x00, 0x00, 0x01, 0x00 }; // SHARED - static uint8_t headerD3[9] = { 0x82, 0x70, 0x8c, 0xd3, 0x00, 0x00, 0x00, 0x01, 0x00 }; // UNIQUE + static uint8_t headerD0[6] = { 0x82, 0x70, 0x89, 0xd0, 0x01, 0x00 }; // GLOBAL + static uint8_t headerD2[8] = { 0x82, 0x70, 0x8b, 0xd2, 0x00, 0x00, 0x01, 0x00 }; // SHARED + static uint8_t headerD3[9] = { 0x82, 0x70, 0x8c, 0xd3, 0x00, 0x00, 0x00, 0x01, 0x00 }; // UNIQUE switch(ep->type) { @@ -1081,7 +1136,11 @@ static int32_t irdeto_do_emm(struct s_reader *reader, EMM_PACKET *ep) rdr_log_dbg(reader, D_EMM, "dataLen %d seems wrong, faulty EMM?", dataLen); return ERROR; } - if(ep->type == GLOBAL && ((reader->caid == 0x0624 && csystem_data->acs57 == 1) || reader->caid == 0x0648 || reader->caid == 0x0650 || reader->caid == 0x0666)) { dataLen += 2; } + if(ep->type == GLOBAL && ((reader->caid == 0x0624 && csystem_data->acs57 == 1) || reader->caid == 0x0648 || reader->caid == 0x0650 || reader->caid == 0x0666)) + { + dataLen += 2; + } + int32_t crc = 63; sc_Acs57Emm[4] = dataLen; memcpy(&cta_cmd, sc_Acs57Emm, sizeof(sc_Acs57Emm)); @@ -1102,9 +1161,9 @@ static int32_t irdeto_do_emm(struct s_reader *reader, EMM_PACKET *ep) { memcpy(&cta_cmd[9], &ep->emm[6], 1); memcpy(&cta_cmd[10], &ep->emm[7], dataLen - 6); - // cta_cmd[9]=0x00; + // cta_cmd[9]=0x00; } - else if((reader->caid == 0x0624 && csystem_data->acs57 == 1) || reader->caid == 0x0648 || reader->caid == 0x0650 || reader->caid == 0x0666) //only orf, cslink, skylink + else if((reader->caid == 0x0624 && csystem_data->acs57 == 1) || reader->caid == 0x0648 || reader->caid == 0x0650 || reader->caid == 0x0666) //only orf, cslink, skylink { memcpy(&cta_cmd[9], &ep->emm[8], dataLen - 4); } @@ -1113,24 +1172,30 @@ static int32_t irdeto_do_emm(struct s_reader *reader, EMM_PACKET *ep) memcpy(&cta_cmd[10], &ep->emm[9], dataLen - 6); } } + for(i = 5; i < dataLen + 4; i++) - { crc ^= cta_cmd[i]; } + { + crc ^= cta_cmd[i]; + } cta_cmd[dataLen - 1 + 5] = crc; irdeto_do_cmd(reader, cta_cmd, 0, cta_res, &cta_lr); int32_t acslength = cta_res[cta_lr - 1]; sc_Acs57_Cmd[4] = acslength; reader_chk_cmd(sc_Acs57_Cmd, acslength + 2); - rdr_log_dbg(reader, D_EMM,"response %02X %02X %02X %02X %02X (%s)", cta_res[0], cta_res[1], cta_res[2], cta_res[3], cta_res[4], + + rdr_log_dbg(reader, D_EMM,"response %02X %02X %02X %02X %02X (%s)", + cta_res[0], cta_res[1], cta_res[2], cta_res[3], cta_res[4], ((cta_res[2] == 0 || cta_res[2] == 0x7B || cta_res[2] == 0x7C) ? "OK" : "ERROR")); + if(cta_res[2] == 0x7B || cta_res[2] == 0x7C) // chid already written or chid already up to date { return SKIPPED; } if(cta_res[2] == 0x00) - { + { return OK; } - return ERROR; // all other + return ERROR; // all other } else // non acs57 based cards { @@ -1141,17 +1206,18 @@ static int32_t irdeto_do_emm(struct s_reader *reader, EMM_PACKET *ep) return ERROR; } uchar *ptr = cta_cmd; - memcpy(ptr, sc_EmmCmd, sizeof(sc_EmmCmd)); // copy card command - ptr[4] = dataLen + ADDRLEN; // set card command emm size + memcpy(ptr, sc_EmmCmd, sizeof(sc_EmmCmd)); // copy card command + ptr[4] = dataLen + ADDRLEN; // set card command emm size ptr += sizeof(sc_EmmCmd); emm += 3; - memset(ptr, 0, ADDRLEN); // clear addr range - memcpy(ptr, emm, l); // copy addr bytes + memset(ptr, 0, ADDRLEN); // clear addr range + memcpy(ptr, emm, l); // copy addr bytes ptr += ADDRLEN; emm += l; - memcpy(ptr, &emm[2], dataLen); // copy emm bytes] + memcpy(ptr, &emm[2], dataLen); // copy emm bytes] irdeto_do_cmd(reader, cta_cmd, 0, cta_res, &cta_lr); - rdr_log_dbg(reader, D_EMM,"response %02X %02X %02X %02X %02X (%s)", cta_res[0], cta_res[1], cta_res[2], cta_res[3], cta_res[4], + rdr_log_dbg(reader, D_EMM,"response %02X %02X %02X %02X %02X (%s)", + cta_res[0], cta_res[1], cta_res[2], cta_res[3], cta_res[4], ((cta_res[cta_lr-2] == 0 || cta_res[cta_lr-2] == 0x7B || cta_res[cta_lr-2] == 0x7C) ? "OK" : "ERROR")); if(cta_res[cta_lr-2] == 0x7B || cta_res[cta_lr-2] == 0x7C) // chid already written or chid already up to date @@ -1159,14 +1225,14 @@ static int32_t irdeto_do_emm(struct s_reader *reader, EMM_PACKET *ep) return SKIPPED; } if(cta_res[cta_lr-2] == 0x00) - { + { return OK; } return ERROR; // all other } } else - { + { rdr_log_dbg(reader, D_EMM, "addrlen %d > %d", l, ADDRLEN); return ERROR; } @@ -1186,10 +1252,8 @@ static int32_t irdeto_card_info(struct s_reader *reader) cs_clear_entitlement(reader); // reset the entitlements - uchar sc_GetChanelIds[] = { 0x02, 0x04, 0x00, 0x00, 0x01, 0x00 }; - uchar sc_Acs57Code[] = { 0xD2, 0x16, 0x00, 0x00, 0x01 , 0x37}, - sc_Acs57Prid[] = { 0xD2, 0x08, 0x00, 0x00, 0x02, 0x00, 0x00 }, - sc_Acs57_Cmd[] = { ACS57GET, 0xFE, 0x00, 0x00, 0x00 }; + uchar sc_GetChanelIds[] = { 0x02, 0x04, 0x00, 0x00, 0x01, 0x00 }; + uchar sc_Acs57Code[] = { 0xD2, 0x16, 0x00, 0x00, 0x01 , 0x37}, sc_Acs57Prid[] = { 0xD2, 0x08, 0x00, 0x00, 0x02, 0x00, 0x00 }, sc_Acs57_Cmd[] = { ACS57GET, 0xFE, 0x00, 0x00, 0x00 }; /* * ContryCode2 @@ -1243,10 +1307,16 @@ static int32_t irdeto_card_info(struct s_reader *reader) sc_Acs57Prid[6] = crc; irdeto_do_cmd(reader, sc_Acs57Prid, 0x903C, cta_res, &cta_lr); int32_t acslength = cta_res[cta_lr - 1]; - if(acslength == 0x09) { break; } + if(acslength == 0x09) + { + break; + } sc_Acs57_Cmd[4] = acslength; reader_chk_cmd(sc_Acs57_Cmd, acslength + 2); - if(cta_res[10] == 0xFF) { break; } + if(cta_res[10] == 0xFF) + { + break; + } cta_res[cta_lr - 3] = 0xff; cta_res[cta_lr - 2] = 0xff; cta_res[cta_lr - 1] = 0xff; diff --git a/reader-nagra.c b/reader-nagra.c index a8af3387f..212734a1d 100644 --- a/reader-nagra.c +++ b/reader-nagra.c @@ -43,6 +43,7 @@ static time_t tier_date(uint32_t date, char *buf, int32_t l) struct tm t; t.tm_isdst = -1; cs_gmtime_r(&ut, &t); + l = 27; snprintf(buf, l, "%04d/%02d/%02d", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday); } return ut; @@ -56,19 +57,29 @@ static char *nagra_datetime(struct s_reader *rdr, uint8_t *ndays, int32_t offset int32_t days = (ndays[0] << 8 | ndays[1]) + offset; int32_t sec = 0; if(!csystem_data->is_tiger) - { sec = (ndays[2] << 8 | ndays[3]); } - if(days > 0x41B4 && sizeof(time_t) < 8) // to overcome 32-bit systems limitations - { days = 0x41A2; } // 01-01-2038 + { + sec = (ndays[2] << 8 | ndays[3]); + } + if(days > 0x41B4 && sizeof(time_t) < 8) // to overcome 32-bit systems limitations + { + days = 0x41A2; // 01-01-2038 + } tms.tm_year = 92; tms.tm_mday = days + 1; tms.tm_sec = sec; time_t ut = mktime(&tms); if(t) - { *t = ut; } + { + *t = ut; + } if(csystem_data->is_tiger) - { snprintf(result, 11, "%02d/%02d/%04d", tms.tm_mday, tms.tm_mon + 1, tms.tm_year + 1900); } + { + snprintf(result, 27, "%02d/%02d/%04d", tms.tm_mday, tms.tm_mon + 1, tms.tm_year + 1900); + } else - { snprintf(result, 17, "%04d/%02d/%02d %02d:%02d", tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, tms.tm_hour, tms.tm_min); } + { + snprintf(result, 33, "%04d/%02d/%02d %02d:%02d", tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, tms.tm_hour, tms.tm_min); + } return result; } @@ -92,7 +103,11 @@ static int32_t do_cmd(struct s_reader *reader, unsigned char cmd, int32_t ilen, msg[5] = cmd; int32_t dlen = ilen - 2; msg[6] = dlen; - if(data && dlen > 0) { memcpy(msg + 7, data, dlen); } + + if(data && dlen > 0) + { + memcpy(msg + 7, data, dlen); + } msg[dlen + 7] = rlen; if(dlen < 0) { @@ -147,7 +162,10 @@ static void Signature(unsigned char *sig, const unsigned char *vkey, const unsig idea_set_encrypt_key(b200, &ks); memset(v, 0, sizeof(v)); idea_cbc_encrypt(msg + i, b0f0, 8, &ks, v, IDEA_DECRYPT); - for(j = 7; j >= 0; j--) { b0f0[j] ^= msg[i + j]; } + for(j = 7; j >= 0; j--) + { + b0f0[j] ^= msg[i + j]; + } memcpy(b200 + 0, b0f0, 8); memcpy(b200 + 8, b0f0, 8); } @@ -317,25 +335,25 @@ static int32_t NegotiateSessionKey_Tiger(struct s_reader *reader) } rdr_log(reader, "Negotiate sessionkey was not successful! Please check tivusat rsa key"); return ERROR; - } static int32_t NegotiateSessionKey(struct s_reader *reader) { def_resp; unsigned char negot[64]; - unsigned char cmd2b[] = {0x21, 0x40, 0x4D, 0xA0, 0xCA, 0x00, 0x00, 0x47, 0x27, 0x45, - 0x1C, 0x54, 0xd1, 0x26, 0xe7, 0xe2, 0x40, 0x20, - 0xd1, 0x66, 0xf4, 0x18, 0x97, 0x9d, 0x5f, 0x16, - 0x8f, 0x7f, 0x7a, 0x55, 0x15, 0x82, 0x31, 0x14, - 0x06, 0x57, 0x1a, 0x3f, 0xf0, 0x75, 0x62, 0x41, - 0xc2, 0x84, 0xda, 0x4c, 0x2e, 0x84, 0xe9, 0x29, - 0x13, 0x81, 0xee, 0xd6, 0xa9, 0xf5, 0xe9, 0xdb, - 0xaf, 0x22, 0x51, 0x3d, 0x44, 0xb3, 0x20, 0x83, - 0xde, 0xcb, 0x5f, 0x35, 0x2b, 0xb0, 0xce, 0x70, - 0x01, 0x02, 0x03, 0x04, //IRD nr - 0x00 - };//keynr + unsigned char cmd2b[] = { + 0x21, 0x40, 0x4D, 0xA0, 0xCA, 0x00, 0x00, 0x47, 0x27, 0x45, + 0x1C, 0x54, 0xd1, 0x26, 0xe7, 0xe2, 0x40, 0x20, + 0xd1, 0x66, 0xf4, 0x18, 0x97, 0x9d, 0x5f, 0x16, + 0x8f, 0x7f, 0x7a, 0x55, 0x15, 0x82, 0x31, 0x14, + 0x06, 0x57, 0x1a, 0x3f, 0xf0, 0x75, 0x62, 0x41, + 0xc2, 0x84, 0xda, 0x4c, 0x2e, 0x84, 0xe9, 0x29, + 0x13, 0x81, 0xee, 0xd6, 0xa9, 0xf5, 0xe9, 0xdb, + 0xaf, 0x22, 0x51, 0x3d, 0x44, 0xb3, 0x20, 0x83, + 0xde, 0xcb, 0x5f, 0x35, 0x2b, 0xb0, 0xce, 0x70, + 0x01, 0x02, 0x03, 0x04, //IRD nr + 0x00 };//keynr + unsigned char tmp[64]; unsigned char idea1[16]; unsigned char idea2[16]; @@ -585,64 +603,57 @@ static int32_t ParseDataType(struct s_reader *reader, unsigned char dt, unsigned uint16_t chid; switch(dt) { - case IRDINFO: - { - reader->prid[0][0] = 0; - reader->prid[0][1] = 0; - reader->prid[0][2] = cta_res[7]; - reader->prid[0][3] = cta_res[8]; - if(((cta_res[7] == 0x34) && (cta_res[8] == 0x11)) || ((cta_res[7] == 0x04) && (cta_res[8] == 0x01))) //provider 3411, 0401 needs cw swap + case IRDINFO: { - rdr_log_dbg(reader, D_READER, "detect provider with swap cw!"); - csystem_data->swapCW = 1; - } + reader->prid[0][0] = 0; + reader->prid[0][1] = 0; + reader->prid[0][2] = cta_res[7]; + reader->prid[0][3] = cta_res[8]; + if(((cta_res[7] == 0x34) && (cta_res[8] == 0x11)) || ((cta_res[7] == 0x04) && (cta_res[8] == 0x01))) //provider 3411, 0401 needs cw swap + { + rdr_log_dbg(reader, D_READER, "detect provider with swap cw!"); + csystem_data->swapCW = 1; + } - reader->prid[1][0] = 0x00; - reader->prid[1][1] = 0x00; - reader->prid[1][2] = 0x00; - reader->prid[1][3] = 0x00; - memcpy(reader->sa[1], reader->sa[0], 4); - reader->nprov += 1; + reader->prid[1][0] = 0x00; + reader->prid[1][1] = 0x00; + reader->prid[1][2] = 0x00; + reader->prid[1][3] = 0x00; + memcpy(reader->sa[1], reader->sa[0], 4); + reader->nprov += 1; - reader->caid = (SYSTEM_NAGRA | cta_res[11]); - memcpy(reader->irdId, cta_res + 14, 4); - if(reader->csystem_active) // do not output on init but only afterwards in card_info - { - rdr_log_sensitive(reader, "IRD ID: {%s}", cs_hexdump(1, reader->irdId, 4, ds, sizeof(ds))); - nagra_datetime(reader, cta_res + 24, 0, ds, &reader->card_valid_to); - rdr_log(reader, "active to: %s", ds); - } - return OK; - } - case TIERS: - if((cta_lr > 33) && (chid = b2i(2, cta_res + 11))) - { - int32_t id = (cta_res[7] * 256) | cta_res[8]; - int32_t expire_date1 = b2i(2, cta_res + 13); - int32_t expire_date2 = b2i(2, cta_res + 24); - int32_t sooner_expire_date = expire_date1 <= expire_date2 ? expire_date1 : expire_date2; - // todo: add entitlements to list - cs_add_entitlement(reader, - reader->caid, - id, - chid, - 0, - tier_date(b2i(2, cta_res + 20) - 0x7f7, ds, 15), - tier_date(sooner_expire_date - 0x7f7, de, 15), - 4, - 1); - rdr_log(reader, "|%04X|%04X |%s |%s |", id, chid, ds, de); - addProvider(reader, cta_res); - } - return OK; - case 0x08: - case 0x88: - if(cta_res[11] == 0x49){ - decryptDT08(reader, cta_res); + reader->caid = (SYSTEM_NAGRA | cta_res[11]); + memcpy(reader->irdId, cta_res + 14, 4); + if(reader->csystem_active) // do not output on init but only afterwards in card_info + { + rdr_log_sensitive(reader, "IRD ID: {%s}", cs_hexdump(1, reader->irdId, 4, ds, sizeof(ds))); + nagra_datetime(reader, cta_res + 24, 0, ds, &reader->card_valid_to); + rdr_log(reader, "active to: %s", ds); + } + return OK; } - return OK; - default: - return OK; + case TIERS: + if((cta_lr > 33) && (chid = b2i(2, cta_res + 11))) + { + int32_t id = (cta_res[7] * 256) | cta_res[8]; + int32_t expire_date1 = b2i(2, cta_res + 13); + int32_t expire_date2 = b2i(2, cta_res + 24); + int32_t sooner_expire_date = expire_date1 <= expire_date2 ? expire_date1 : expire_date2; + // todo: add entitlements to list + cs_add_entitlement(reader, reader->caid, id, chid, 0, tier_date(b2i(2, cta_res + 20) - 0x7f7, ds, 15), tier_date(sooner_expire_date - 0x7f7, de, 15), 4, 1); + rdr_log(reader, "|%04X|%04X |%s |%s |", id, chid, ds, de); + addProvider(reader, cta_res); + } + return OK; + case 0x08: + case 0x88: + if(cta_res[11] == 0x49) + { + decryptDT08(reader, cta_res); + } + return OK; + default: + return OK; } return ERROR; } @@ -732,7 +743,9 @@ static int32_t nagra2_card_init(struct s_reader *reader, ATR *newatr) rdr_log(reader, "rsa key configured -> using nagra mode"); is_pure_nagra = 1; if(!cs_malloc(&reader->csystem_data, sizeof(struct nagra_data))) - { return ERROR; } + { + return ERROR; + } struct nagra_data *csystem_data = reader->csystem_data; csystem_data->is_pure_nagra = is_pure_nagra; if(!do_cmd(reader, 0x10, 0x02, 0x90, 0x11, 0, cta_res, &cta_lr)) @@ -747,7 +760,10 @@ static int32_t nagra2_card_init(struct s_reader *reader, ATR *newatr) rdr_log(reader, "detect seca/nagra tunneled card"); if(!cs_malloc(&reader->csystem_data, sizeof(struct nagra_data))) - { rdr_log(reader,"mem alloc error"); return ERROR; } + { + rdr_log(reader,"mem alloc error"); return ERROR; + } + if(!card_write(reader, ins80, handshake, cta_res, &cta_lr)) // try to init nagra layer { if(cta_res[0] == 0x61 && cta_res[1] == 0x10) @@ -760,15 +776,18 @@ static int32_t nagra2_card_init(struct s_reader *reader, ATR *newatr) } reader->card_atr_length = 23; const struct s_cardreader *crdr_ops = reader->crdr; - if (!crdr_ops) return ERROR; + if (!crdr_ops) + { + return ERROR; + } call(crdr_ops->activate(reader, newatr)); //read nagra atr get_atr2; - memcpy(reader->rom, atr2 + 8, 15);// get historical bytes containing romrev from nagra atr + memcpy(reader->rom, atr2 + 8, 15); // get historical bytes containing romrev from nagra atr rdr_log(reader,"Nagra layer found"); rdr_log(reader,"Rom revision: %.15s", reader->rom); reader->card_atr_length = 14; reader->seca_nagra_card = 2; - call(crdr_ops->activate(reader, newatr));// read seca atr to switch back + call(crdr_ops->activate(reader, newatr)); // read seca atr to switch back if ((reader->typ == R_SMART || reader->typ == R_INTERNAL || is_smargo_reader(reader)) && ins7e11_state == 1) { ins7e11_state = 0; @@ -784,14 +803,20 @@ static int32_t nagra2_card_init(struct s_reader *reader, ATR *newatr) NULLFREE(reader->csystem_data); return ERROR; // quitting csystem still not having needed commands to run on nagra layer } - else { return ERROR; } - + else + { + return ERROR; + } + // Private data may be already allocated, see above (the irdeto check). if(!reader->csystem_data) { if(!cs_malloc(&reader->csystem_data, sizeof(struct nagra_data))) - { return ERROR; } + { + return ERROR; + } } + struct nagra_data *csystem_data = reader->csystem_data; csystem_data->is_pure_nagra = is_pure_nagra; csystem_data->is_tiger = is_tiger; @@ -885,7 +910,7 @@ static int32_t reccmp2(const void *r1, const void *r2) static int32_t nagra2_card_info(struct s_reader *reader) { int32_t i; - char currdate[11], tmp[64]; + char currdate[27], tmp[64]; struct nagra_data *csystem_data = reader->csystem_data; rdr_log(reader, "ROM: %c %c %c %c %c %c %c %c", reader->rom[0], reader->rom[1], reader->rom[2], reader->rom[3], reader->rom[4], reader->rom[5], reader->rom[6], reader->rom[7]); rdr_log(reader, "REV: %c %c %c %c %c %c", reader->rom[9], reader->rom[10], reader->rom[11], reader->rom[12], reader->rom[13], reader->rom[14]); @@ -966,9 +991,13 @@ static int32_t nagra2_card_info(struct s_reader *reader) } } if(reader->nagra_read == 1) - { qsort(records, num_records, sizeof(ncmed_rec), reccmp); } + { + qsort(records, num_records, sizeof(ncmed_rec), reccmp); + } else - { qsort(records, num_records, sizeof(ncmed_rec), reccmp2); } + { + qsort(records, num_records, sizeof(ncmed_rec), reccmp2); + } int32_t euro = 0; char tiername[83]; @@ -982,40 +1011,55 @@ static int32_t nagra2_card_info(struct s_reader *reader) { switch(records[i].type) { - case 0x00: - case 0x01: - if(reccmp(records[i].date2, currdate) >= 0) - { - if(reader->nagra_read == 2) - rdr_log(reader, "Tier : %04X, expiry date: %s %s", - records[i].value, records[i].date2, get_tiername(records[i].value, reader->caid, tiername)); - else if(reader->nagra_read == 1) + case 0x00: + case 0x01: + if(reccmp(records[i].date2, currdate) >= 0) { - euro = (records[i].price / 100); - rdr_log(reader, "Activation : ( %04X ) from %s to %s (%3d euro) %s", + if(reader->nagra_read == 2) + { + rdr_log(reader, "Tier : %04X, expiry date: %s %s", + records[i].value, records[i].date2, get_tiername(records[i].value, reader->caid, tiername)); + } + else if(reader->nagra_read == 1) + { + euro = (records[i].price / 100); + rdr_log(reader, "Activation : ( %04X ) from %s to %s (%3d euro) %s", records[i].value, records[i].date1, records[i].date2, euro, get_tiername(records[i].value, reader->caid, tiername)); - } - cs_add_entitlement(reader, reader->caid, b2ll(4, reader->prid[0]), records[i].value, 0, tiger_date2time(records[i].date1), tiger_date2time(records[i].date2)+ 0x1517F, 4, 1); - } - break; - - case 0x20: - case 0x21: - if(reccmp(records[i].date2, currdate) >= 0) - { - if(reader->nagra_read == 2) + } + cs_add_entitlement( + reader, + reader->caid, + b2ll(4, reader->prid[0]), + records[i].value, + 0, + tiger_date2time(records[i].date1), + tiger_date2time(records[i].date2)+ 0x1517F, + 4, + 1); + } break; + case 0x20: + case 0x21: + if(reccmp(records[i].date2, currdate) >= 0) { - rdr_log(reader, "Tier : %04X, expiry date: %s %s", - records[i].value, records[i].date2, get_tiername(records[i].value, reader->caid, tiername)); - } - cs_add_entitlement(reader, reader->caid, b2ll(4, reader->prid[0]), records[i].value, 0, tiger_date2time(records[i].date1), tiger_date2time(records[i].date2)+ 0x1517F, 4, 1); - } - break; + if(reader->nagra_read == 2) + { + rdr_log(reader, "Tier : %04X, expiry date: %s %s", records[i].value, records[i].date2, get_tiername(records[i].value, reader->caid, tiername)); + } + cs_add_entitlement( + reader, + reader->caid, + b2ll(4, reader->prid[0]), + records[i].value, + 0, + tiger_date2time(records[i].date1), + tiger_date2time(records[i].date2)+ 0x1517F, + 4, + 1); + } break; } if(reader->nagra_read == 2) { - while(i < num_records - 1 && records[i].value == records[i + 1].value) - { ++i; } + while(i < num_records - 1 && records[i].value == records[i + 1].value) { ++i; } } } @@ -1023,41 +1067,41 @@ static int32_t nagra2_card_info(struct s_reader *reader) { switch(records[i].type) { - case 0x80: - if(reader->nagra_read == 1) - { - euro = (records[i].price / 100) - prepaid; - credit += euro; - prepaid += euro; - if(euro) - rdr_log(reader, "Recharge : %s (%3d euro)", - records[i].date2, euro); - } - break; - - case 0x20: - case 0x21: - if(reader->nagra_read == 1) - { - euro = records[i].price / 100; - credit -= euro; - rdr_log(reader, "Subscription : ( %04X ) from %s to %s (%3d euro) %s", + case 0x80: + if(reader->nagra_read == 1) + { + euro = (records[i].price / 100) - prepaid; + credit += euro; + prepaid += euro; + if(euro) + { + rdr_log(reader, "Recharge : %s (%3d euro)", records[i].date2, euro); + } + } break; + case 0x20: + case 0x21: + if(reader->nagra_read == 1) + { + euro = records[i].price / 100; + credit -= euro; + rdr_log(reader, "Subscription : ( %04X ) from %s to %s (%3d euro) %s", records[i].value, records[i].date1, records[i].date2, euro, get_tiername(records[i].value, reader->caid, tiername)); - } - break; - - case 0x29: - euro = records[i].price / 100; - if(reader->nagra_read == 1) { credit -= euro; } - rdr_log(reader, "Event purchase : ( %04X ) from %s to %s (%3d euro)", - records[i].value, records[i].date1, records[i].date2, euro); - break; + } break; + case 0x29: + euro = records[i].price / 100; + if(reader->nagra_read == 1) { credit -= euro; } + rdr_log(reader, "Event purchase : ( %04X ) from %s to %s (%3d euro)", records[i].value, records[i].date1, records[i].date2, euro); + break; } } if(reader->nagra_read == 1) - { rdr_log(reader, "Credit : %3d euro", credit); } + { + rdr_log(reader, "Credit : %3d euro", credit); + } else - { rdr_log(reader, "Credit : %3d euro", balance); } + { + rdr_log(reader, "Credit : %3d euro", balance); + } } } else @@ -1074,7 +1118,11 @@ static int32_t nagra2_card_info(struct s_reader *reader) rdr_log_dbg_sensitive(reader, D_READER, "SER: {%s}", cs_hexdump(1, reader->hexserial + 2, 4, tmp_dbg, sizeof(tmp_dbg))); memcpy(reader->sa[0], cta_res + 2, 3); reader->nprov = 1; - if(!GetDataType(reader, IRDINFO, 0x39)) { return ERROR; } + if(!GetDataType(reader, IRDINFO, 0x39)) + { + return ERROR; + } + rdr_log_dbg(reader, D_READER, "IRDINFO DONE"); CamStateRequest(reader); @@ -1097,8 +1145,14 @@ void nagra2_post_process(struct s_reader *reader) if(!csystem_data->is_tiger) { CamStateRequest(reader); - if RENEW_SESSIONKEY() { NegotiateSessionKey(reader); } - if SENDDATETIME() { DateTimeCMD(reader); } + if RENEW_SESSIONKEY() + { + NegotiateSessionKey(reader); + } + if SENDDATETIME() + { + DateTimeCMD(reader); + } } } @@ -1118,7 +1172,9 @@ static int32_t nagra2_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, str while(!do_cmd(reader, er->ecm[3] + 1, er->ecm[4] + 5 + 2, 0x88, 0x04, ecm_pkt, cta_res, &cta_lr)) { if(retry == 0) - { rdr_log_dbg(reader, D_READER, "nagra2_do_ecm (N3_NA) failed, retry"); } + { + rdr_log_dbg(reader, D_READER, "nagra2_do_ecm (N3_NA) failed, retry"); + } else { rdr_log_dbg(reader, D_READER, "nagra2_do_ecm (N3_NA) failed, retry failed!"); @@ -1130,18 +1186,21 @@ static int32_t nagra2_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, str } else { - if(reader->ecmcommand < 5) // cache ecm commands until ecmcommand cache is full + if(reader->ecmcommand < 5) // cache ecm commands until ecmcommand cache is full { reader->ecmcommandcache[reader->ecmcommand] = er->ecm[3]; reader->ecmcommand++; - if(reader->ecmcommand == 5) // cache is full, comparing! + if(reader->ecmcommand == 5) // cache is full, comparing! { int32_t t = 0; int32_t matchfound = 0; reader->ecmcommand++; // No more caching of ecm commands, next ecms will be compared! while(t < 5) { - if(reader->ecmcommandcache[t] == er->ecm[3]) { matchfound++; } + if(reader->ecmcommandcache[t] == er->ecm[3]) + { + matchfound++; + } t++; } if(matchfound != 5) @@ -1166,7 +1225,9 @@ static int32_t nagra2_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, str while(!do_cmd(reader, er->ecm[3], er->ecm[4] + 2, 0x87, 0x02, er->ecm + 3 + 2, cta_res, &cta_lr)) { if(retry == 0) - { rdr_log_dbg(reader, D_READER, "nagra2_do_ecm failed, retry"); } + { + rdr_log_dbg(reader, D_READER, "nagra2_do_ecm failed, retry"); + } else { rdr_log_dbg(reader, D_READER, "nagra2_do_ecm failed, retry failed!"); @@ -1205,12 +1266,14 @@ static int32_t nagra2_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, str } else { - //check ECM prov id + // check ECM prov id if(memcmp(&reader->prid[0][2], er->ecm + 5, 2)) - { return ERROR; } + { + return ERROR; + } - // ecm_data: 80 30 89 D3 87 54 11 10 DA A6 0F 4B 92 05 34 00 ... - //serial_data: A0 CA 00 00 8C D3 8A 00 00 00 00 00 10 DA A6 0F . + // ecm_data: 80 30 89 D3 87 54 11 10 DA A6 0F 4B 92 05 34 00 + // serial_data: A0 CA 00 00 8C D3 8A 00 00 00 00 00 10 DA A6 0F unsigned char ecm_trim[150]; memset(ecm_trim, 0, 150); memcpy(&ecm_trim[5], er->ecm + 3 + 2 + 2, er->ecm[4] + 2); @@ -1218,7 +1281,6 @@ static int32_t nagra2_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, str { if(cta_res[2] == 0x01) { - unsigned char v[8]; memset(v, 0, sizeof(v)); idea_cbc_encrypt(&cta_res[14], ea->cw, 8, &csystem_data->ksSession, v, IDEA_DECRYPT); @@ -1256,7 +1318,7 @@ static int32_t nagra2_do_emm(struct s_reader *reader, EMM_PACKET *ep) { //check EMM prov id if(memcmp(&reader->prid[0][2], ep->emm + 10, 2)) - { + { rdr_log_dbg(reader, D_READER, "EMM skipped since provider doesnt match!"); return SKIPPED; } diff --git a/reader-nagracak7.c b/reader-nagracak7.c index b4a2209f2..2ab38b00a 100644 --- a/reader-nagracak7.c +++ b/reader-nagracak7.c @@ -27,6 +27,7 @@ static time_t tier_date(uint64_t date, char *buf, int32_t l) if(buf){ struct tm t; cs_gmtime_r(&ut, &t); + l = 27; snprintf(buf, l, "%04d/%02d/%02d", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday); } return ut; diff --git a/reader-viaccess.c b/reader-viaccess.c index 4219a9597..4dfe6c060 100644 --- a/reader-viaccess.c +++ b/reader-viaccess.c @@ -50,38 +50,6 @@ static void parse_via_date(const uchar *buf, struct via_date *vd, int32_t fend) } } -//static void get_via_data(const uchar *b, int32_t l, time_t *start_t, time_t *end_t, uchar *cls) -//{ -// int32_t i, j; -// struct via_date vd; -// struct tm tm; -// memset(&vd, 0, sizeof(struct via_date)); -// -// // b -> via date (4 uint8_ts) -// b+=4; -// l-=4; -// -// j=l-1; -// for (; j>=0; j--) -// for (i=0; i<8; i++) -// if (b[j] & (1 << (i&7))) -// { -// parse_via_date(b-4, &vd, 1); -// *cls=(l-(j+1))*8+i; -// } -// -// memset(&tm, 0, sizeof(struct tm)); -// tm.tm_year = vd.year_s + 80; //via year starts in 1980, tm_year starts in 1900 -// tm.tm_mon = vd.month_s - 1; // january is 0 in tm_mon -// tm.tm_mday = vd.day_s; -// *start_t = mktime(&tm); -// -// tm.tm_year = vd.year_e + 80; -// tm.tm_mon = vd.month_e - 1; -// tm.tm_mday = vd.day_e; -// *end_t = mktime(&tm); -// -//} struct emm_rass *find_rabuf(struct s_client *client, int32_t provid, uint8_t nano, int8_t add) { struct emm_rass *e; @@ -99,10 +67,17 @@ struct emm_rass *find_rabuf(struct s_client *client, int32_t provid, uint8_t nan if(!add && e->provid == provid && e->emmlen != 0) { return e; } if(add && e->provid == provid && e->emm[0] == nano) { return e; } } - if(!add) return NULL; - + + if(!add) + { + return NULL; + } + if(!cs_malloc(&e, sizeof(struct emm_rass))) - { return NULL; } + { + return NULL; + } + e->provid = provid; ll_append(client->ra_buf, e); return e; @@ -118,14 +93,16 @@ static void show_class(struct s_reader *reader, const char *p, uint32_t provid, j = l - 1; for(; j >= 0; j--) + { for(i = 0; i < 8; i++) + { if(b[j] & (1 << (i & 7))) { uchar cls; struct via_date vd; parse_via_date(b - 4, &vd, 1); cls = (l - (j + 1)) * 8 + i; - + if(p) // just show class info, dont add entitlement! { rdr_log(reader, "%sclass: %02X, expiry date: %04d/%02d/%02d - %04d/%02d/%02d", p, cls, @@ -137,7 +114,7 @@ static void show_class(struct s_reader *reader, const char *p, uint32_t provid, rdr_log(reader, "class: %02X, expiry date: %04d/%02d/%02d - %04d/%02d/%02d", cls, vd.year_s + 1980, vd.month_s, vd.day_s, vd.year_e + 1980, vd.month_e, vd.day_e); - + //convert time: time_t start_t, end_t; struct tm tm; @@ -154,6 +131,8 @@ static void show_class(struct s_reader *reader, const char *p, uint32_t provid, cs_add_entitlement(reader, reader->caid, provid, cls, cls, start_t, end_t, 5, 1); } } + } + } } static int8_t add_find_class(struct s_reader *reader, uint32_t provid, const uchar *b, int32_t l, int8_t add) @@ -166,7 +145,9 @@ static int8_t add_find_class(struct s_reader *reader, uint32_t provid, const uch j = l - 1; for(; j >= 0; j--) + { for(i = 0; i < 8; i++) + { if(b[j] & (1 << (i & 7))) { uchar cls; @@ -192,12 +173,12 @@ static int8_t add_find_class(struct s_reader *reader, uint32_t provid, const uch tm.tm_mon = vd.month_s - 1; // january is 0 in tm_mon tm.tm_mday = vd.day_s; start_t = cs_timegm(&tm); - + tm.tm_year = vd.year_e + 80; //via year starts in 1980, tm_year starts in 1900 tm.tm_mon = vd.month_e - 1; // january is 0 in tm_mon tm.tm_mday = vd.day_e; end_t = cs_timegm(&tm); - + if(cs_add_entitlement(reader, reader->caid, provid, cls, cls, start_t, end_t, 5, add) != NULL) { if(!add) @@ -211,14 +192,19 @@ static int8_t add_find_class(struct s_reader *reader, uint32_t provid, const uch } } } - if(freshdate == 0) return -2; + } + } + + if(freshdate == 0) + { + return -2; + } + return 1; // emmdate is fresh! } static void show_subs(struct s_reader *reader, const uchar *emm) { - // emm -> A9, A6, B6 - switch(emm[0]) { case 0xA9: @@ -226,7 +212,6 @@ static void show_subs(struct s_reader *reader, const uchar *emm) show_class(reader, "nano A9: ", 1, emm + 2, emm[1]); break; } - case 0xA6: { char szGeo[256]; @@ -236,7 +221,6 @@ static void show_subs(struct s_reader *reader, const uchar *emm) rdr_log(reader, "nano A6: geo %s", szGeo); break; } - case 0xB6: { uchar m; // modexp @@ -244,8 +228,13 @@ static void show_subs(struct s_reader *reader, const uchar *emm) m = emm[emm[1] + 1]; parse_via_date(emm + 2, &vd, 0); - rdr_log(reader, "nano B6: modexp %d%d%d%d%d%d: %02d/%02d/%04d", (m & 0x20) ? 1 : 0, - (m & 0x10) ? 1 : 0, (m & 0x08) ? 1 : 0, (m & 0x04) ? 1 : 0, (m & 0x02) ? 1 : 0, (m & 0x01) ? 1 : 0, + rdr_log(reader, "nano B6: modexp %d%d%d%d%d%d: %02d/%02d/%04d", + (m & 0x20) ? 1 : 0, + (m & 0x10) ? 1 : 0, + (m & 0x08) ? 1 : 0, + (m & 0x04) ? 1 : 0, + (m & 0x02) ? 1 : 0, + (m & 0x01) ? 1 : 0, vd.day_s, vd.month_s, vd.year_s + 1980); break; } @@ -256,11 +245,20 @@ static int32_t chk_prov(struct s_reader *reader, uchar *id, uchar keynr) { struct viaccess_data *csystem_data = reader->csystem_data; int32_t i, j, rc; + for(rc = i = 0; (!rc) && (i < reader->nprov); i++) + { if(!memcmp(&reader->prid[i][1], id, 3)) + { for(j = 0; (!rc) && (j < 16); j++) + { if(csystem_data->availkeys[i][j] == keynr) - { rc = 1; } + { + rc = 1; + } + } + } + } return (rc); } @@ -272,7 +270,7 @@ static int32_t get_maturity(struct s_reader *reader) uchar insac[] = { 0xca, 0xac, 0x00, 0x00, 0x00 }; // select data uchar insb8[] = { 0xca, 0xb8, 0x00, 0x00, 0x00 }; // read selected data - + insac[2]=0x06; write_cmd(insac, NULL); // request maturity rating insb8[4]=0x02; write_cmd(insb8, NULL); // read maturity rating nano + len insb8[4]=cta_res[1]; write_cmd(insb8, NULL); // read maturity rating @@ -321,7 +319,7 @@ static int32_t unlock_parental(struct s_reader *reader) } } else - { + { rdr_log(reader, "Parental lock disabled"); get_maturity(reader); } @@ -549,7 +547,7 @@ void hdSurEncPhase1_D2_0F_11(uint8_t *CWs) { a4[i2] = i1 + (i2 * 4); } - for(i2 = 0; i2 <= i1 - 1; ++i2) // the given code in Func1_3 seems to be wrong here(3 instead of i1-1)! + for(i2 = 0; i2 <= i1 - 1; ++i2) // the given code in Func1_3 seems to be wrong here(3 instead of i1-1)! { uint8_t tmp = CWs[a4[0]]; for(i3 = 1; i3 <= 3; ++i3) @@ -796,16 +794,22 @@ void CommonMain_D2_13_15(const uint8_t *datain, uint8_t *dataout, int loopval) uint8_t buff11[11+1]; // +1 to avoid func2 bug int i1, i2; buff11[11] = 0; - + CommonMain_1_D2_13_15(datain, buff11); for (i1 = 0; i1 < 11; i1++) - { buff11[i1] ^= Tab1_Comp[(loopval * 11) + i1]; } + { + buff11[i1] ^= Tab1_Comp[(loopval * 11) + i1]; + } for (i1 = 0; i1 < 8; i1++) - { buff8[i1] = CommonMain_2_D2_13_15(buff11, i1 * 11); } + { + buff8[i1] = CommonMain_2_D2_13_15(buff11, i1 * 11); + } for (i1 = 0; i1 < 8; i1++) - { dataout[i1] = Tab0_Comp[buff8[i1]]; } + { + dataout[i1] = Tab0_Comp[buff8[i1]]; + } i1 = 1; while (i1 < 8) @@ -827,7 +831,9 @@ void Common_D2_13_15(uint8_t *cw0, const uint8_t *cw1, int loopval) CommonMain_D2_13_15(cw1, buff8, loopval); for (i = 0; i < 8; i++) - { cw0[i] ^= buff8[i]; } + { + cw0[i] ^= buff8[i]; + } } void ExchangeCWs(uint8_t *cw0, uint8_t *cw1) @@ -852,12 +858,13 @@ void hdSurEncPhase1_D2_13_15(uint8_t *cws) { // Possible code if ((i & 1)==0) + { Common_D2_13_15((uint8_t *) &cws[0], (uint8_t *) &cws[8], i); + } else + { Common_D2_13_15((uint8_t *) &cws[8], (uint8_t *) &cws[0], i); - // Other possible code - //Common_D2_13_15((uint8_t *) &cws[0], (uint8_t *) &cws[8], i); - //ExchangeCWs((uint8_t *) &cws[0], (uint8_t *) &cws[8]); + } } ExchangeCWs((uint8_t *) &cws[0], (uint8_t *) &cws[8]); } @@ -870,12 +877,13 @@ void hdSurEncPhase2_D2_13_15(uint8_t *cws) { // Possible code if ((i & 1)==0) - Common_D2_13_15((uint8_t *) &cws[8], (uint8_t *) &cws[0], i); + { + Common_D2_13_15((uint8_t *) &cws[8], (uint8_t *) &cws[0], i); + } else + { Common_D2_13_15((uint8_t *) &cws[0], (uint8_t *) &cws[8], i); - // Other possible code - //Common_D2_13_15((uint8_t *) &cws[0], (uint8_t *) &cws[8], i); - //ExchangeCWs((uint8_t *) &cws[0], (uint8_t *) &cws[8]); + } } ExchangeCWs((uint8_t *) &cws[8], (uint8_t *) &cws[0]); } @@ -897,16 +905,22 @@ static int32_t viaccess_card_init(struct s_reader *reader, ATR *newatr) static unsigned char ins8704[] = { 0x87, 0x04, 0x00, 0x00, 0x07 }; static unsigned char ins8706[] = { 0x87, 0x06, 0x00, 0x00, 0x04 }; - if((atr[1] != 0x77) || ((atr[2] != 0x18) && (atr[2] != 0x11) && (atr[2] != 0x19)) || ((atr[9] != 0x68) && (atr[9] != 0x6C) && (atr[9] != 0x64))) - { return ERROR; } + { + return ERROR; + } write_cmd(insFAC, FacDat); if(!(cta_res[cta_lr - 2] == 0x90 && cta_res[cta_lr - 1] == 0)) - { return ERROR; } + { + return ERROR; + } if(!cs_malloc(&reader->csystem_data, sizeof(struct viaccess_data))) - { return ERROR; } + { + return ERROR; + } + struct viaccess_data *csystem_data = reader->csystem_data; write_cmd(insFAC, ins8702_data); @@ -924,15 +938,6 @@ static int32_t viaccess_card_init(struct s_reader *reader, ATR *newatr) } } - - // switch((atr[atrsize-4]<<8)|atr[atrsize-3]) - // { - // case 0x6268: ver="2.3"; break; - // case 0x6668: ver="2.4(?)"; break; - // case 0xa268: - // default: ver="unknown"; break; - // } - reader->caid = 0x500; memset(reader->prid, 0xff, sizeof(reader->prid)); insac[2] = 0xa4; @@ -940,9 +945,8 @@ static int32_t viaccess_card_init(struct s_reader *reader, ATR *newatr) insb8[4] = 0x07; write_cmd(insb8, NULL); // read unique id memcpy(reader->hexserial, cta_res + 2, 5); - // rdr_log(reader, "[viaccess-reader] type: Viaccess, ver: %s serial: %llu", ver, b2ll(5, cta_res+2)); - rdr_log_sensitive(reader, "type: Viaccess (%sstandard atr), caid: %04X, serial: {%llu}", - atr[9] == 0x68 ? "" : "non-", reader->caid, (unsigned long long) b2ll(5, cta_res + 2)); + // rdr_log(reader, "[viaccess-reader] type: Viaccess, ver: %s serial: %llu", ver, b2ll(5, cta_res+2)); + rdr_log_sensitive(reader, "type: Viaccess (%sstandard atr), caid: %04X, serial: {%llu}", atr[9] == 0x68 ? "" : "non-", reader->caid, (unsigned long long) b2ll(5, cta_res + 2)); i = 0; insa4[2] = 0x00; @@ -957,7 +961,7 @@ static int32_t viaccess_card_init(struct s_reader *reader, ATR *newatr) memcpy(&reader->prid[i][1], cta_res, 3); memcpy(&csystem_data->availkeys[i][0], cta_res + 10, 16); snprintf((char *)buf + strlen((char *)buf), sizeof(buf) - strlen((char *)buf), ",%06X", b2i(3, &reader->prid[i][1])); - //rdr_log(reader, "[viaccess-reader] buf: %s", buf); + // rdr_log(reader, "[viaccess-reader] buf: %s", buf); insac[2] = 0xa5; write_cmd(insac, NULL); // request sa @@ -965,15 +969,6 @@ static int32_t viaccess_card_init(struct s_reader *reader, ATR *newatr) write_cmd(insb8, NULL); // read sa memcpy(&reader->sa[i][0], cta_res + 2, 4); - /* - insac[2]=0xa7; write_cmd(insac, NULL); // request name - insb8[4]=0x02; write_cmd(insb8, NULL); // read name nano + len - l=cta_res[1]; - insb8[4]=l; write_cmd(insb8, NULL); // read name - cta_res[l]=0; - rdr_log(reader, "[viaccess-reader] name: %s", cta_res); - */ - insa4[2] = 0x02; write_cmd(insa4, NULL); // select next issuer i++; @@ -1031,7 +1026,7 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s //nanoD2 d2 02 0d 02 -> D2 nano, len 2 // 0b, 0f, 13 -> pre AES decrypt CW // 0d, 11, 15 -> post AES decrypt CW - + int32_t nanoD2 = 0; // knowns D2 nanos: 0x0b ,0x0d ,0x0f ,0x11, 0x13, 0x15 memset(DE04, 0, sizeof(DE04)); //fix dorcel de04 bug @@ -1096,6 +1091,7 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s nanoD2 = 0x15; rdr_log_dbg(reader, D_READER, "ECM: nano D2 0x15"); } + // use the d2 arguments to get the key # to be used int32_t len = ecm88Data[1] + 2; D2KeyID = ecm88Data[3]; @@ -1105,8 +1101,9 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s hasD2 = 1; } else - { hasD2 = 0; } - + { + hasD2 = 0; + } // 40 07 03 0b 00 -> nano 40, len =7 ident 030B00 (tntsat), key #0 <== we're pointing here // 09 -> use key #9 @@ -1140,7 +1137,8 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s { if(ecm88Data[nanoLen - 1] == 0x01) { - rdr_log_dbg(reader, D_READER, "Skip ECM ending with = %02x for ecm number (%x) for provider %02x%02x%02x", ecm88Data[nanoLen - 1], curnumber_ecm, ecm88Data[2], ecm88Data[3], ecm88Data[4]); + rdr_log_dbg(reader, D_READER, "Skip ECM ending with = %02x for ecm number (%x) for provider %02x%02x%02x", + ecm88Data[nanoLen - 1], curnumber_ecm, ecm88Data[2], ecm88Data[3], ecm88Data[4]); } rdr_log_dbg(reader, D_READER, "Skip ECM ending with = %02x for ecm number (%x)", ecm88Data[nanoLen - 1], curnumber_ecm); ecm88Data = nextEcm; @@ -1164,10 +1162,11 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s // check that we have the AES key to decode the CW // if not there is no need to send the ecm to the card if(!aes_present(reader->aes_list, 0x500, (uint32_t)(provid & 0xFFFFF0) , D2KeyID)) - { return ERROR; } + { + return ERROR; + } } - if(!chk_prov(reader, ident, keynr)) { rdr_log_dbg(reader, D_READER, "ECM: provider or key not found on card"); @@ -1185,7 +1184,7 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s memcpy(DE04, &ecm88Data[0], 6); ecm88Data += 6; } - + // E0 (seen so far in logs: E0020002 or E0022002, but not in all cases delivers invalid cw so just detect!) if(ecm88Data[0] == 0xE0 && ecm88Data[1] == 0x02) { @@ -1201,9 +1200,8 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s csystem_data->last_geo.geo[0] = 0; write_cmd(insa4, ident); // set provider } - - // Nano D2 0x0b, 0x0f, 0x13 -> pre AES decrypt CW + // Nano D2 0x0b, 0x0f, 0x13 -> pre AES decrypt CW if(hasD2 && (nanoD2 == 0x0b|| nanoD2 == 0x0f|| nanoD2 == 0x13)) { uchar *ecm88DataCW = ecm88Data; @@ -1233,7 +1231,9 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s // use AES from list to decrypt CW rdr_log_dbg(reader, D_READER, "Decoding CW : using AES key id %d for provider %06x", D2KeyID, (provid & 0xFFFFF0)); if(aes_decrypt_from_list(reader->aes_list, 0x500, (uint32_t)(provid & 0xFFFFF0), D2KeyID, &ecm88DataCW[0], 16) == 0) - { snprintf(ea->msglog, MSGLOGSIZE, "Missing AES key(%d)[aka E%X]",D2KeyID, D2KeyID); } + { + snprintf(ea->msglog, MSGLOGSIZE, "Missing AES key(%d)[aka E%X]",D2KeyID, D2KeyID); + } if(nanoD2 == 0x0f) { hdSurEncPhase1_D2_0F_11(ecm88DataCW); @@ -1248,16 +1248,18 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s { nanoLen = ecm88Data[1] + 2; if(!ecmf8Data) - { ecmf8Data = (uchar *)ecm88Data; } + { + ecmf8Data = (uchar *)ecm88Data; + } ecmf8Len += nanoLen; ecm88Len -= nanoLen; curEcm88len -= nanoLen; ecm88Data += nanoLen; } + if(ecmf8Len) { - if(csystem_data->last_geo.geo_len != ecmf8Len || - memcmp(csystem_data->last_geo.geo, ecmf8Data, csystem_data->last_geo.geo_len)) + if(csystem_data->last_geo.geo_len != ecmf8Len || memcmp(csystem_data->last_geo.geo, ecmf8Data, csystem_data->last_geo.geo_len)) { memcpy(csystem_data->last_geo.geo, ecmf8Data, ecmf8Len); csystem_data->last_geo.geo_len = ecmf8Len; @@ -1289,37 +1291,33 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s { write_cmd(ins88, (uchar *)ecm88Data); // request dcw } - // + write_cmd(insc0, NULL); // read dcw switch(cta_res[0]) { - case 0xe8: // even - if(cta_res[1] == 8) - { - memcpy(ea->cw, cta_res + 2, 8); - rc = 1; - } - break; - case 0xe9: // odd - if(cta_res[1] == 8) - { - memcpy(ea->cw + 8, cta_res + 2, 8); - rc = 1; - } - break; - case 0xea: // complete - if(cta_res[1] == 16) - { - memcpy(ea->cw, cta_res + 2, 16); - rc = 1; - } - break; - - default : - ecm88Data = nextEcm; - ecm88Len -= curEcm88len; - rdr_log_dbg(reader, D_READER, "Error: card respondend %02X %02X, trying next ECM", cta_res[0], cta_res[1]); - snprintf(ea->msglog, MSGLOGSIZE, "key to use is not the current one, trying next ECM"); + case 0xe8: // even + if(cta_res[1] == 8) + { + memcpy(ea->cw, cta_res + 2, 8); + rc = 1; + } break; + case 0xe9: // odd + if(cta_res[1] == 8) + { + memcpy(ea->cw + 8, cta_res + 2, 8); + rc = 1; + } break; + case 0xea: // complete + if(cta_res[1] == 16) + { + memcpy(ea->cw, cta_res + 2, 16); + rc = 1; + } break; + default : + ecm88Data = nextEcm; + ecm88Len -= curEcm88len; + rdr_log_dbg(reader, D_READER, "Error: card respondend %02X %02X, trying next ECM", cta_res[0], cta_res[1]); + snprintf(ea->msglog, MSGLOGSIZE, "key to use is not the current one, trying next ECM"); } } else @@ -1331,7 +1329,7 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s return ERROR; /*Lets interupt the loop and exit, because we don't know this ECM type.*/ } } - + // Nano D2 0d, 11, 15 -> post AES decrypt CW if(hasD2 && !dcw_crc(ea->cw) && (nanoD2 == 0x0d || nanoD2 == 0x11 || nanoD2 == 0x15 )) @@ -1348,7 +1346,9 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s rdr_log_dbg(reader, D_READER, "Decoding CW : using AES key id %d for provider %06x", D2KeyID, (provid & 0xFFFFF0)); rc = aes_decrypt_from_list(reader->aes_list, 0x500, (uint32_t)(provid & 0xFFFFF0), D2KeyID, ea->cw, 16); if(rc == 0) - { snprintf(ea->msglog, MSGLOGSIZE, "Missing AES key(%d)[aka E%X]",D2KeyID, D2KeyID); } + { + snprintf(ea->msglog, MSGLOGSIZE, "Missing AES key(%d)[aka E%X]",D2KeyID, D2KeyID); + } if(nanoD2 == 0x11) { hdSurEncPhase1_D2_0F_11(ea->cw); @@ -1358,18 +1358,21 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s hdSurEncPhase2_D2_13_15(ea->cw); } } - + if ( hasE0 ) { - if ( reader->initCA28 ){ + if ( reader->initCA28 ) + { rdr_log_dbg(reader, D_READER, "Decrypting nano E0 encrypted cw."); uint8_t returnedcw[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; memcpy(returnedcw,ea->cw,16); + // Processing 3DES // Processing even cw des(returnedcw, reader->key_schedule1, 0); //decrypt des(returnedcw, reader->key_schedule2, 1); //crypt des(returnedcw, reader->key_schedule1, 0); //decrypt + // Processing odd cw des(returnedcw+8, reader->key_schedule1, 0); //decrypt des(returnedcw+8, reader->key_schedule2, 1); //crypt @@ -1377,7 +1380,9 @@ static int32_t viaccess_do_ecm(struct s_reader *reader, const ECM_REQUEST *er, s // returning value memcpy(ea->cw,returnedcw, 16); - }else{ + } + else + { snprintf(ea->msglog, MSGLOGSIZE, "nano E0 detected, no valid boxkey / deskey defined: no decoding"); } } @@ -1437,8 +1442,9 @@ static int32_t viaccess_get_emm_type(EMM_PACKET *ep, struct s_reader *rdr) for(i = 0; i < rdr->nprov; i++) { if(!memcmp(&rdr->prid[i][2], ep->hexserial+1, 2)) - { return 1; } - + { + return 1; + } return (!memcmp(&rdr->sa[0][0], ep->hexserial, 3)); } /* fallthrough */ @@ -1455,18 +1461,19 @@ static int32_t viaccess_get_emm_filter(struct s_reader *rdr, struct s_csystem_em { bool network = is_network_reader(rdr); int8_t device_emm = ((rdr->deviceemm >0) ? 1 : 0); // set to 1 if device specific emms should be catched too - const unsigned int max_filter_count = 4 + ((device_emm != 0 && rdr->nprov > 0) ? 1:0) + (3 * ((rdr->nprov > 0) ? (rdr->nprov - 1) : 0)); - + if(!cs_malloc(emm_filters, max_filter_count * sizeof(struct s_csystem_emm_filter))) - { return ERROR; } + { + return ERROR; + } struct s_csystem_emm_filter *filters = *emm_filters; *filter_count = 0; int32_t idx = 0; int32_t prov; - + if(rdr->nprov > 0 && device_emm == 1) { filters[idx].type = EMM_GLOBAL; // 8A or 8B no reassembly needed! @@ -1477,7 +1484,7 @@ static int32_t viaccess_get_emm_filter(struct s_reader *rdr, struct s_csystem_em filters[idx].mask[3] = 0x80; idx++; } - + // shared are most important put them on top, define first since viaccess produces a lot of filters! for(prov = 0; (prov < rdr->nprov); prov++) { @@ -1485,7 +1492,7 @@ static int32_t viaccess_get_emm_filter(struct s_reader *rdr, struct s_csystem_em { continue; } - + filters[idx].type = EMM_SHARED; // 8C or 8D always first part of shared, second part delivered by 8E! filters[idx].enabled = 1; filters[idx].filter[0] = 0x8C; @@ -1509,7 +1516,7 @@ static int32_t viaccess_get_emm_filter(struct s_reader *rdr, struct s_csystem_em } idx++; } - + // globals are less important, define last since viaccess produces a lot of filters! for(prov = 0; (prov < rdr->nprov); prov++) { @@ -1517,7 +1524,7 @@ static int32_t viaccess_get_emm_filter(struct s_reader *rdr, struct s_csystem_em { continue; } - + filters[idx].type = EMM_GLOBAL; // 8A or 8B no reassembly needed! filters[idx].enabled = 1; filters[idx].filter[0] = 0x8A; @@ -1535,7 +1542,7 @@ static int32_t viaccess_get_emm_filter(struct s_reader *rdr, struct s_csystem_em } idx++; } - + filters[idx].type = EMM_UNIQUE; filters[idx].enabled = 1; filters[idx].filter[0] = 0x88; @@ -1566,8 +1573,6 @@ static int32_t viaccess_do_emm(struct s_reader *reader, EMM_PACKET *ep) unsigned char insf4[] = { 0xca, 0xf4, 0x00, 0x01, 0x00 }; // set adf, encrypted unsigned char ins18[] = { 0xca, 0x18, 0x01, 0x01, 0x00 }; // set subscription unsigned char ins1c[] = { 0xca, 0x1c, 0x01, 0x01, 0x00 }; // set subscription, encrypted - //static const unsigned char insc8[] = { 0xca,0xc8,0x00,0x00,0x02 }; // read extended status - // static const unsigned char insc8Data[] = { 0x00,0x00 }; // data for read extended status struct viaccess_data *csystem_data = reader->csystem_data; int32_t emmdatastart = 7; @@ -1589,8 +1594,16 @@ static int32_t viaccess_do_emm(struct s_reader *reader, EMM_PACKET *ep) } } - if(ep->type == UNIQUE) { emmdatastart++; } - if(ep->type == GLOBAL && emmdatastart == 7) { emmdatastart -= 4; } + if(ep->type == UNIQUE) + { + emmdatastart++; + } + + if(ep->type == GLOBAL && emmdatastart == 7) + { + emmdatastart -= 4; + } + int32_t emmLen = SCT_LEN(ep->emm) - emmdatastart; int32_t rc = 0; @@ -1714,7 +1727,7 @@ static int32_t viaccess_do_emm(struct s_reader *reader, EMM_PACKET *ep) NULLFREE(tmpbuf); } } - } + } else { /* other nanos */ @@ -1726,16 +1739,8 @@ static int32_t viaccess_do_emm(struct s_reader *reader, EMM_PACKET *ep) rdr_log(reader, "no provid in shared emm -> skipped!"); return SKIPPED; } - int8_t match = add_find_class(reader, emm_provid, emmParsed + 2, emmParsed[1], 0); - - // seems not all classes have to be present on card to accept the emm - /*if(match == -1) - { - rdr_log(reader, "shared emm provid %06X one or more classes of this emm do not match with your card -> skipped!", emm_provid); - return SKIPPED; - }*/ - + if(match == -2) { rdr_log(reader, "shared emm provid %06X all classes have entitlementdate already same or newer -> skipped!", emm_provid); @@ -1819,7 +1824,7 @@ static int32_t viaccess_do_emm(struct s_reader *reader, EMM_PACKET *ep) { rdr_log_dump(reader, ins18, 5, "set subscription cmd:"); rdr_log_dump(reader, insData, ins18[4], "set subscription data:"); - if(!(cta_res[cta_lr -2] == 0x90 && cta_res[cta_lr - 1] == 0x40)) // dont throw softerror 9040 in log! + if(!(cta_res[cta_lr -2] == 0x90 && cta_res[cta_lr - 1] == 0x40)) // dont throw softerror 9040 in log! { rdr_log(reader, "update error: %02X %02X", cta_res[cta_lr - 2], cta_res[cta_lr - 1]); } @@ -1841,7 +1846,11 @@ static int32_t viaccess_do_emm(struct s_reader *reader, EMM_PACKET *ep) } ins1c[2] = nano9EData ? 0x01 : 0x00; // found 9E nano ? - if(ep->type == UNIQUE) { ins1c[2] = 0x02; } + if(ep->type == UNIQUE) + { + ins1c[2] = 0x02; + } + ins1c[3] = keynr; // key ins1c[4] = nano92Data[1] + 2 + nano81Data[1] + 2 + nanoF0Data[1] + 2; memcpy(insData, nano92Data, nano92Data[1] + 2); @@ -1849,49 +1858,14 @@ static int32_t viaccess_do_emm(struct s_reader *reader, EMM_PACKET *ep) memcpy(insData + nano92Data[1] + 2 + nano81Data[1] + 2, nanoF0Data, nanoF0Data[1] + 2); write_cmd(ins1c, insData); - if((cta_res[cta_lr - 2] == 0x90 || cta_res[cta_lr - 2] == 0x91) && - (cta_res[cta_lr - 1] == 0x00 || cta_res[cta_lr - 1] == 0x08)) + if((cta_res[cta_lr - 2] == 0x90 || cta_res[cta_lr - 2] == 0x91) && (cta_res[cta_lr - 1] == 0x00 || cta_res[cta_lr - 1] == 0x08)) { rdr_log(reader, "update successfully written"); rc = 1; // written } rc = 1; - /* don't return ERROR at this place - else { - if( cta_res[cta_lr-2]&0x1 ) - rdr_log(reader, "update not written. Data already exists or unknown address"); - - //if( cta_res[cta_lr-2]&0x8 ) { - write_cmd(insc8, NULL); - if( (cta_res[cta_lr-2]==0x90 && cta_res[cta_lr-1]==0x00) ) { - rdr_log(reader, "extended status %02X %02X", cta_res[0], cta_res[1]); - } - //} - return ERROR; - } */ - } - /* - Sub Main() - Sc.Write("CA A4 04 00 03") - RX - Sc.Write("02 07 11") - RX - Sc.Write("CA F0 00 01 22") - RX - Sc.Write("9E 20") - Sc.Write("10 10 08 8A 80 00 04 00 10 10 26 E8 54 80 1E 80") - Sc.Write("00 01 00 00 00 00 00 50 00 00 80 02 22 00 08 50") - RX - Sc.Write("CA 18 01 01 11") - RX - Sc.Write("A9 05 34 DE 34 FF 80") - Sc.Write("F0 08 1A 3E AF B5 2B EE E3 3B") - RX - - End Sub - */ return rc; } @@ -1931,7 +1905,7 @@ static int32_t viaccess_card_info(struct s_reader *reader) insa4[2] = 0x00; write_cmd(insa4, NULL); // select issuer 0 - + for(i = 1; (cta_res[cta_lr - 2] == 0x90) && (cta_res[cta_lr - 1] == 0); i++) { bool added = false; @@ -1957,10 +1931,15 @@ static int32_t viaccess_card_info(struct s_reader *reader) write_cmd(insb8, NULL); // read name cta_res[l] = 0; trim((char *)cta_res); + if(cta_res[0]) - { snprintf((char *)l_name, sizeof(l_name), ", name: %s", cta_res); } + { + snprintf((char *)l_name, sizeof(l_name), ", name: %.55s", cta_res); + } else - { l_name[0] = 0; } + { + l_name[0] = 0; + } // read GEO insac[2] = 0xa6; @@ -1971,10 +1950,7 @@ static int32_t viaccess_card_info(struct s_reader *reader) char tmp[l * 3 + 1]; insb8[4] = l; write_cmd(insb8, NULL); // read geo - rdr_log_sensitive(reader, "provider: %d, id: {%06X%s}, sa: {%08X}, geo: %s", - i, l_provid, l_name, l_sa, (l < 4) ? "empty" : cs_hexdump(1, cta_res, l, tmp, sizeof(tmp))); - - + rdr_log_sensitive(reader, "provider: %d, id: {%06X%s}, sa: {%08X}, geo: %s", i, l_provid, l_name, l_sa, (l < 4) ? "empty" : cs_hexdump(1, cta_res, l, tmp, sizeof(tmp))); // read classes subscription insac[2] = 0xa9; @@ -1982,12 +1958,13 @@ static int32_t viaccess_card_info(struct s_reader *reader) if(!reader->read_old_classes) { now = time(NULL) - (24*60*60); - cs_gmtime_r(&now, &timeinfo); + cs_gmtime_r(&now, &timeinfo); tmpdate = timeinfo.tm_mday | ((timeinfo.tm_mon + 1) << 5) | ((timeinfo.tm_year - 80) << 9); cls[0] = tmpdate >> 8; cls[1] = tmpdate & 0xff; } write_cmd(insac, cls); // request class subs + while((cta_res[cta_lr - 2] == 0x90) && (cta_res[cta_lr - 1] == 0)) { insb8[4] = 0x02; @@ -1997,15 +1974,14 @@ static int32_t viaccess_card_info(struct s_reader *reader) l = cta_res[1]; insb8[4] = l; write_cmd(insb8, NULL); // read class subs - if((cta_res[cta_lr - 2] == 0x90) && - (cta_res[cta_lr - 1] == 0x00 || cta_res[cta_lr - 1] == 0x08)) + if((cta_res[cta_lr - 2] == 0x90) && (cta_res[cta_lr - 1] == 0x00 || cta_res[cta_lr - 1] == 0x08)) { show_class(reader, NULL, l_provid, cta_res, cta_lr - 2); added = true; } } } - + if(!added) { // add entitlement info for provid without class @@ -2028,6 +2004,7 @@ static int32_t viaccess_card_info(struct s_reader *reader) uchar ins28_data[4]; memcpy(ins28_data, reader->boxkey, 4); write_cmd(ins28, ins28_data); // unlock card to reply on E002xxyy + if((cta_res[cta_lr - 2] == 0x90) && (cta_res[cta_lr - 1] == 0)) { rdr_log(reader, "CA 28 initialisation successful!"); @@ -2053,9 +2030,12 @@ static int32_t viaccess_reassemble_emm(struct s_reader *rdr, struct s_client *cl int16_t k; int32_t prov, provid = 0; struct emm_rass *r_emm = NULL; - + // Viaccess - if(*len > 500) { return 0; } + if(*len > 500) + { + return 0; + } switch(buffer[0]) { @@ -2074,12 +2054,12 @@ static int32_t viaccess_reassemble_emm(struct s_reader *rdr, struct s_client *cl { return 0; } - memset(&r_emm->emm[0], 0, sizeof(r_emm->emm)); // zero it! + memset(&r_emm->emm[0], 0, sizeof(r_emm->emm)); // zero it! memcpy(&r_emm->emm[0], &buffer[0], *len); // put the fresh new shared emm r_emm->emmlen = *len; // put the emmlen indicating that this shared emm isnt being reassembled rdr_log_dump_dbg(rdr, D_EMM, r_emm->emm, r_emm->emmlen, "%s: received fresh emm-gh for provid %06X", __func__, provid); return 0; - + case 0x8e: // emm-s part 2 for(prov = 0; prov < rdr->nprov ; prov++) @@ -2099,7 +2079,7 @@ static int32_t viaccess_reassemble_emm(struct s_reader *rdr, struct s_client *cl } r_emm = find_rabuf(client, provid, 0, 0); // nano = dont care, the shared 8c or 8d not been written gets returned! if(!r_emm || !r_emm->emmlen) - { + { continue; // match but no emm-gh found for this provider } else @@ -2108,8 +2088,10 @@ static int32_t viaccess_reassemble_emm(struct s_reader *rdr, struct s_client *cl } } } - if(!r_emm || !r_emm->emmlen) { return 0; } // stop -> no emm-gh found! - + if(!r_emm || !r_emm->emmlen) + { + return 0; // stop -> no emm-gh found! + } //extract nanos from emm-gh and emm-s uchar emmbuf[512]; diff --git a/webif/cacheex/cacheex.html b/webif/cacheex/cacheex.html index 438aa5e21..4d76808e7 100644 --- a/webif/cacheex/cacheex.html +++ b/webif/cacheex/cacheex.html @@ -1,7 +1,7 @@ ##TPLHEADERSHORT## ##REFRESH## - + diff --git a/webif/entitlements/entitlements_bit.html b/webif/entitlements/entitlements_bit.html index be9680888..cbb81b2e5 100644 --- a/webif/entitlements/entitlements_bit.html +++ b/webif/entitlements/entitlements_bit.html @@ -4,8 +4,8 @@ document.getElementById('serialButton').style.display = "none"; } - - + + diff --git a/webif/entitlements/entitlements_cccambit.html b/webif/entitlements/entitlements_cccambit.html index 7d62ae2ae..01493135c 100644 --- a/webif/entitlements/entitlements_cccambit.html +++ b/webif/entitlements/entitlements_cccambit.html @@ -2,5 +2,5 @@ ##CCCAMSTATSENTRY##
CardsystemValid ToIRD ID (nagra)MaturityProvider
##READERCSYSTEM####READERCARDVALIDTO####READERIRDID####READERMATURITY####READERPROVIDS##
HostCaidSystemTypeShare idRemote idUphopsReshareProvidersNodesGood sidsBad sids
-
##TOTALS##
+
##TOTALS##
##CONTROLS##
diff --git a/webif/files/file.html b/webif/files/file.html index a173cc763..abe25859e 100644 --- a/webif/files/file.html +++ b/webif/files/file.html @@ -9,7 +9,7 @@
##FILTERFORM##
- +

##WRITEPROTECTION##

##TPLFOOTER## \ No newline at end of file diff --git a/webif/include/footer.html b/webif/include/footer.html index 370b5cf4a..5ec25ddd6 100644 --- a/webif/include/footer.html +++ b/webif/include/footer.html @@ -7,7 +7,7 @@
  • Process ID: ##PROCESSID## Access from: ##CURIP## Run as: ##RUNAS## ##UPTIMETXT## ##UPTIME##
  • OSCam: ##CS_VERSION## Build: r##CS_SVN_VERSION## Compiler: ##CS_TARGET##
  • WebIf Style by
  • - + diff --git a/webif/readerconfig/readerconfig_hwreader_nagracak7.html b/webif/readerconfig/readerconfig_hwreader_nagracak7.html index 2b7df7ba9..6f468cb60 100644 --- a/webif/readerconfig/readerconfig_hwreader_nagracak7.html +++ b/webif/readerconfig/readerconfig_hwreader_nagracak7.html @@ -5,4 +5,4 @@ key60: exp60: Nuid: - CWPK: + CWPK: diff --git a/webif/readerconfig/readerconfig_hwreader_videoguard.html b/webif/readerconfig/readerconfig_hwreader_videoguard.html index f8106b3db..6e49f988b 100644 --- a/webif/readerconfig/readerconfig_hwreader_videoguard.html +++ b/webif/readerconfig/readerconfig_hwreader_videoguard.html @@ -23,4 +23,4 @@ ins7E11 TA1 Byte (1 byte): ins2E06 payload (4 bytes): - ins7E payload (26 bytes): + ins7E payload (26 bytes): diff --git a/webif/readers/readers.html b/webif/readers/readers.html index 8e0114836..caa4b1889 100644 --- a/webif/readers/readers.html +++ b/webif/readers/readers.html @@ -1,7 +1,7 @@ ##TPLHEADERSHORT## ##REFRESH## ##TPLBODY## ##TPLMENU##