Changeset 1189


Ignore:
Timestamp:
01/11/10 19:30:52 (12 years ago)
Author:
alno
Message:

WebIf:

  • Merging revisions 1180-1185 of trunk
Location:
branches/monitor-improvement
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/monitor-improvement/CMakeLists.txt

    r1180 r1189  
    5555        set (CS_OS_HW "mac")
    5656        set (CS_OS_SYS "macosx")
     57        SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
     58        SET( CMAKE_CFLAGS "${CMAKE_CFLAGS} -m32" )
    5759    elseif (${CYGWIN})
    5860        set (OSCamOperatingSystem "Windows/Cygwin")
     
    202204elseif (OSCamOperatingSystem MATCHES "Tuxbox")
    203205    target_link_libraries ( ${exe_name} dl)
    204 elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
    205206elseif (OSCamOperatingSystem MATCHES "SlugOS")
    206207elseif (OSCamOperatingSystem MATCHES "Fonera2")
  • branches/monitor-improvement/Distribution/doc/man/oscam.conf.5

    r1117 r1189  
    340340.RS 3n
    341341user name for DVB API client, default:anonymous
     342.RE
     343.PP
     344\fBignore\fP = \fBCAID[,CAID]...\fP
     345.RS 3n
     346CAIDs to be ignored, default:none
     347.RE
     348.PP
     349\fBpriority\fP = \fBCAID[,CAID]...\fP
     350.RS 3n
     351CAIDs to be prioritized, default:CAIDs of local SCs will be prioritized
    342352.RE
    343353.PP
  • branches/monitor-improvement/Distribution/doc/txt/oscam.conf.txt

    r1117 r1189  
    246246      user name for DVB API client, default:anonymous
    247247
     248       ignore = CAID[,CAID]...
     249      CAIDs to be ignored, default:none
     250
     251       priority = CAID[,CAID]...
     252      CAIDs to be prioritized, default:CAIDs of local SCs will be  priori
     253      tized
     254
    248255       au = 0|1
    249256      1 = enable AU, default:0
    250257
    251258       boxtype = dbox2|dreambox|ufs910
    252       set  boxtype,  auto  detection  of  DVB   API   will   be   aspired,
     259      set   boxtype,   auto   detection   of  DVB  API  will  be  aspired,
    253260      default:dreambox
    254261
     
    258265
    259266       numusers = quantity
    260       anti-cascading:  user per account, 0 = anti-cascading not permitted,
     267      anti-cascading: user per account, 0 = anti-cascading not permitted,
    261268      default:0
    262269
     
    341348
    342349SEE ALSO
    343        oscam(1),     oscam.user(5),  oscam.server(5),      oscam.srvid(5),
    344        oscam.guess(5),    oscam.cert(5),    oscam.services(5),   oscam.ird(5),
     350       oscam(1),      oscam.user(5),      oscam.server(5),     oscam.srvid(5),
     351       oscam.guess(5),   oscam.cert(5),    oscam.services(5),    oscam.ird(5),
    345352       oscam.ac(5)
    346353
  • branches/monitor-improvement/csctapi/icc_async.c

    r1180 r1189  
    7878        return ICC_ASYNC_IFD_ERROR;
    7979    /* Reset ICC */
     80#ifdef COOL
     81    if (ifd->io->com == RTYP_SCI) {
     82        if (!Cool_Reset(&(icc->atr)))
     83        {
     84            icc->atr = NULL;
     85            return ICC_ASYNC_IFD_ERROR;
     86        }
     87    }
     88    else
     89#endif
    8090    if (IFD_Towitoko_ResetAsyncICC (ifd, &(icc->atr)) != IFD_TOWITOKO_OK)
    8191    {
     
    8393        return ICC_ASYNC_IFD_ERROR;
    8494    }
    85    
    8695    /* Get ICC convention */
    8796    if (ATR_GetConvention (icc->atr, &(icc->convention)) != ATR_OK)
     
    257266}
    258267
    259 #ifdef COOL
    260 extern unsigned char cardbuffer[255];
    261 extern int cardbuflen;
    262 #endif
    263 
    264268int ICC_Async_Transmit (ICC_Async * icc, unsigned size, BYTE * data)
    265269{
     
    283287   
    284288#ifdef COOL
    285 //transmit buffer to SC and put answer in cardbuffer
    286289    if (icc->ifd->io->com == RTYP_SCI) {
    287 #define TIMEOUT 4000 //max 4294
    288     cardbuflen = 256;//it needs to know max buffer size to respond?
    289   if (cnxt_smc_read_write(handle, FALSE, sent, size, cardbuffer, &cardbuflen, TIMEOUT, 0))
    290         return ICC_ASYNC_IFD_ERROR;
    291 
    292 #ifdef DEBUG_IFD
    293   //usually done in IFD_Towitoko, for COOL do it here
    294     printf ("COOLIFD: Transmit: ");
    295     int i;
    296     for (i = 0; i < size; i++)
    297       printf ("%X ", sent[i]);
    298     printf ("\n");
    299 #endif
    300     }
    301     else
    302 #else
     290        if (!Cool_Transmit(sent, size))
     291            return ICC_ASYNC_IFD_ERROR;
     292    }
     293    else
     294#endif
    303295    if (IFD_Towitoko_Transmit (icc->ifd, &timings, size, sent) != IFD_TOWITOKO_OK)
    304296        return ICC_ASYNC_IFD_ERROR;
    305 #endif
    306297   
    307298    if (icc->convention == ATR_CONVENTION_INVERSE)
     
    319310   
    320311#ifdef COOL
    321 //receive  buffer to SC
    322     if (size > cardbuflen)
    323         size = cardbuflen; //never read past end of buffer
    324   memcpy(data,cardbuffer,size);
    325     cardbuflen -= size;
    326     memmove(cardbuffer,cardbuffer+size,cardbuflen);
    327 
    328 #ifdef DEBUG_IFD
    329   int i;
    330   printf ("COOLIFD: Receive: "); //I think
    331   for (i = 0; i < size; i++)
    332     printf ("%X ", data[i]);
    333   printf ("\n");
    334     fflush(stdout);
    335 #endif
    336   return ICC_ASYNC_OK;
     312    if (icc->ifd->io->com == RTYP_SCI) {
     313        if (!Cool_Receive(data, size))
     314            return ICC_ASYNC_IFD_ERROR;
     315    }
     316    else
    337317#else
    338318    if (IFD_Towitoko_Receive (icc->ifd, &timings, size, data) != IFD_TOWITOKO_OK)
  • branches/monitor-improvement/csctapi/ifd_cool.c

    r1177 r1189  
    77#include <stdio.h>
    88#include <time.h>
     9#include <string.h>
    910#include"ifd_cool.h"
    10 /*
    11 #include "io_serial.h"
    12 #include "sci_global.h"
    13 #include "sci_ioctl.h"
    14 */
    15 
    16 // these should be called from icc, t0, cardterminal etc. like this:
    17 // switch (reader[ridx].type) {
    18 //   case INTERN:
    19 // #ifdef COOL
    20 //       Cool_Init();
    21 //       break;
    22 // #endif
    23 // #ifdef SCI_DEV
    24 // //still in towitoko shit
    25 // #endif
    26 //   case SMART:
    27 //   case MOUSE:
    28 //       IFD_Towitoko_Init(ifd, io, slot);
    29 //       break;
    30 //   default:
    31 //       return ERROR;
    32 // }
    33 // all other IFD_Towitoko functions should be
    34 // -eliminated (like SetLed or administrative jobs)
    35 // -rewritten eg. setparity should become a call to getproperties, setproperties
    36 // ActivateICC should call ResetICC automagically
    37 // DeactivateICC for symmetry and cleanup
    38 //
    3911
    4012#define OK      1
     
    4820int Cool_Init ()
    4921{
    50     //initialize properties(input_bitrate, output_bitrate, bits, stopbits, parity,dtr, rts) of device to default values
    51     //initialize ifd settings
    52     //and get reader info
    5322    if (cnxt_kal_initialize ())
    5423        return FALSE;
     
    7039}
    7140
    72 /*
    73 int Cool_GetStatus (BYTE * result)
    74 {
    75 // return status : 0 -start, 1 - card, 2- no card
    7641
    77     //extern int cnxt_smc_get_state();
     42int Cool_GetStatus (int * in)
     43{
     44    int state;
     45    if (cnxt_smc_get_state(handle, &state))
     46        return ERROR;
     47    //state = 0 no card, 1 = not ready, 2 = ready
     48    if (state)
     49        *in = 1; //CARD, even if not ready report card is in, or it will never get activated
     50    else
     51        *in = 0; //NOCARD
    7852    return OK;
    7953}
    80 */
     54
    8155int Cool_Reset (ATR ** atr)
    8256{
    83 printf("Entering coolreset");
    84 fflush(stdout);
    85     //reset needs clock to be reset by hand
    86     typedef unsigned long u_int32;
    87     u_int32 clk;
    88     clk = 357*10000; // MHZ
    89     if (cnxt_smc_set_clock_freq(handle, clk))
     57    if (!Cool_SetBaudrate(357))
    9058        return ERROR;
    9159
     
    9664
    9765    int n = 40;
    98     //int atr_len = 40;
    9966    unsigned char buf[40];
    10067    if (cnxt_smc_get_atr (handle, buf, &n))
    10168        return ERROR;
    102     //atr_len = n;
    103 //  atr = buf;
    104     /////////////
    105         (*atr) = ATR_New ();
    106         if(ATR_InitFromArray ((*atr), buf, n) == ATR_OK)
    107         {
    108             struct timespec req_ts;
    109             req_ts.tv_sec = 0;
    110             req_ts.tv_nsec = 50000000;
    111             nanosleep (&req_ts, NULL);
    112 #ifdef SCI_DEV
    113             if (ioctl(ifd->io->fd, IOCTL_SET_ATR_READY)<0)
    114                 return ERROR;
    115 #endif
    116             return OK;
    117         }
    118         else
    119         {
    120             ATR_Delete (*atr);
    121             (*atr) = NULL;
    122             return ERROR;
    123         }
    124     ///////////
     69       
     70    (*atr) = ATR_New ();
     71    if(ATR_InitFromArray ((*atr), buf, n) == ATR_OK)
     72    {
     73        struct timespec req_ts;
     74        req_ts.tv_sec = 0;
     75        req_ts.tv_nsec = 50000000;
     76        nanosleep (&req_ts, NULL);
     77        return OK;
     78    }
     79    else
     80    {
     81        ATR_Delete (*atr);
     82        (*atr) = NULL;
     83        return ERROR;
     84    }
    12585}
    126 /*
    127 int Cool_DeactivateICC ()
    128 {
    129 #ifdef DEBUG_IFD
    130     printf ("IFD: Deactivating card\n");
    131 #endif
    132 /*
    133         int in;
    134        
    135 #if defined(TUXBOX) && (defined(MIPSEL) || defined(PPC) || defined(SH4))
    136         if(ioctl(ifd->io->fd, IOCTL_GET_IS_CARD_PRESENT, &in)<0)
    137 #else
    138         if(ioctl(ifd->io->fd, IOCTL_GET_IS_CARD_ACTIVATED, &in)<0)
    139 #endif
    140             return IFD_TOWITOKO_IO_ERROR;
    141            
    142         if(in)
    143         {
    144             if(ioctl(ifd->io->fd, IOCTL_SET_DEACTIVATE)<0)
    145                 return IFD_TOWITOKO_IO_ERROR;
    146         }
    147 */     
    148 /*
    149     return OK;
    150 }
    151 */
    15286
    15387int Cool_Transmit (BYTE * sent, unsigned size)
     
    15589#define TIMEOUT 4000 //max 4294
    15690    cardbuflen = 256;//it needs to know max buffer size to respond?
    157   int rc = cnxt_smc_read_write(handle, FALSE, sent, size, cardbuffer, &cardbuflen, TIMEOUT, 0);
     91    if (cnxt_smc_read_write(handle, FALSE, sent, size, cardbuffer, &cardbuflen, TIMEOUT, 0))
     92        return ERROR;
    15893
    15994#ifdef DEBUG_IFD
    160   //usually done in IFD_Towitoko, for COOL do it here
     95    //usually done in IFD_Towitoko, for COOL do it here
    16196    printf ("COOLIFD: Transmit: ");
    16297    int i;
    16398    for (i = 0; i < size; i++)
    164       printf ("%X ", sent[i]);
     99        printf ("%X ", sent[i]);
    165100    printf ("\n");
    166101#endif
    167 
    168     //FIXME implement rc
     102    return OK;
    169103}
    170104
    171 int Cool_Receive (BYTE * buffer, unsigned size)
    172 { //receive buffer to SC
    173     //memcpy(buffer,cardbuffer,cardbuflen);
    174     //size = cardbuflen;
     105int Cool_Receive (BYTE * data, unsigned size)
     106{
     107    if (size > cardbuflen)
     108        size = cardbuflen; //never read past end of buffer
     109    memcpy(data,cardbuffer,size);
     110    cardbuflen -= size;
     111    memmove(cardbuffer,cardbuffer+size,cardbuflen);
    175112
    176113#ifdef DEBUG_IFD
    177114    int i;
    178     printf ("IFD: Receive: "); //I think
     115    printf ("COOLIFD: Receive: "); //I think
    179116    for (i = 0; i < size; i++)
    180         printf ("%X ", buffer[i]);
     117        printf ("%X ", data[i]);
    181118    printf ("\n");
     119    fflush(stdout);
    182120#endif
    183 
    184121    return OK;
    185122}   
     
    189126    typedef unsigned long u_int32;
    190127    u_int32 clk;
    191     //clk = 357 * 10000;        // MHZ
    192     clk = mhz * 10000;  // MHZ
     128    clk = mhz * 10000;
    193129    if (cnxt_smc_set_clock_freq (handle, clk))
    194130        return ERROR;
  • branches/monitor-improvement/csctapi/ifd_towitoko.c

    r1177 r1189  
    364364#elif COOL
    365365    if(ifd->io->com==RTYP_SCI)
    366     {
    367     //  in=1;//FIXME
    368         int state;
    369         if (cnxt_smc_get_state(handle, &state))
    370             return IFD_TOWITOKO_IO_ERROR;
    371         //guessing: state = 0 no card, 1 = not ready, 2 = ready
    372         if (state)
    373           in = 1; //CARD, even if not ready report card is in, or it will never get activated
    374         else
    375             in = 0; //Nocard
     366    {   
     367        if (!Cool_GetStatus(&in))
     368            return IFD_TOWITOKO_IO_ERROR;
    376369    }
    377370    else
     
    627620        if(n==0)
    628621            return IFD_TOWITOKO_IO_ERROR;
    629 #elif COOL
    630     if(ifd->io->com==RTYP_SCI) {
    631         //Cool_Reset(atr);
    632         //reset needs clock to be reset by hand
    633         typedef unsigned long u_int32;
    634         u_int32 clk;
    635         clk = 357*10000; // MHZ
    636         if (cnxt_smc_set_clock_freq(handle, clk))
    637             return IFD_TOWITOKO_IO_ERROR;
     622#endif
    638623           
    639         //reset card
    640         int timeout = 5000; // Timout in ms?
    641         if (cnxt_smc_reset_card (handle, timeout, NULL, NULL))
    642             return IFD_TOWITOKO_IO_ERROR;
    643 
    644         int n = 40;
    645         unsigned char buf[40];
    646         if (cnxt_smc_get_atr (handle, buf, &n))
    647             return IFD_TOWITOKO_IO_ERROR;
    648 #endif
    649            
    650 #if defined(SCI_DEV) || defined(COOL)
     624#ifdef SCI_DEV
    651625        (*atr) = ATR_New ();
    652626        if(ATR_InitFromArray ((*atr), buf, n) == ATR_OK)
  • branches/monitor-improvement/csctapi/io_serial.c

    r1180 r1189  
    520520
    521521   /* Set the bitrate */
    522    if(io->reader_type==RTYP_SMART)
    523    {
    524 #ifdef DEBUG_IO
    525       printf("IO: SMARTREADER .. switching to frequency to %2.2fMHz\n", (float)io->mhz/100.0);
    526 #endif
    527       if(!IO_Serial_Set_Smartreader_Freq(io))
    528       {
    529 #ifdef DEBUG_IO
    530          printf("IO: SMARTREADER .. ERROR switching to 6MHz\n");
    531 #endif
    532          return FALSE;
    533       }
    534    }
    535 
    536522#ifdef OS_LINUX
    537523   if (io->mhz == io->cardmhz)
     
    10641050        return TRUE;
    10651051}
    1066 
    1067 
    1068 bool IO_Serial_Set_Smartreader_Freq(IO_Serial * io)
    1069  {
    1070    struct termios term;
    1071    struct termios orig;
    1072    int freq = io->mhz;
    1073    unsigned char fi_di[4]={0x01, 0x01, 0x74, 0x01};
    1074    unsigned char fr[3]={0x02, 0x00, 0x00};
    1075    unsigned char nn[2]={0x03, 0x00};
    1076    unsigned char pr[2]={0x04, 0x00};
    1077    unsigned char in[2]={0x05, 0x00};
    1078    
    1079    orig=term;
    1080      
    1081    /* set smartreader in CMD mode */
    1082    tcgetattr(io->fd, &term);
    1083    
    1084    term.c_cflag &= ~CSIZE;
    1085    term.c_cflag |= CS5;
    1086    cfsetospeed(&term, 9600);
    1087    cfsetispeed(&term, 9600);
    1088    tcsetattr(io->fd, TCSANOW, &term);
    1089    
    1090    // our freq comes in as 358, 357 or 600 so it needs this to be in KHz for the FR command
    1091    freq*=10;
    1092    fr[1]=(unsigned char)((freq & 0xff00)>>8);
    1093    fr[2]=(unsigned char)(freq & 0x00ff);
    1094 
    1095    // Irdeto card supposedly need NN set to 1 .. to be confirmed
    1096    if(io->cardmhz == 600)
    1097       nn[1]=0x01;
    1098      
    1099    // send the commands
    1100    IO_Serial_Write (io, 0, 4, fi_di);
    1101    IO_Serial_Flush(io);
    1102    
    1103    IO_Serial_Write (io, 0, 3, fr);
    1104    IO_Serial_Flush(io);
    1105 
    1106    IO_Serial_Write (io, 0, 2, nn);
    1107    IO_Serial_Flush(io);
    1108 
    1109    IO_Serial_Write (io, 0, 2, pr);
    1110    IO_Serial_Flush(io);
    1111 
    1112    IO_Serial_Write (io, 0, 2, in);
    1113    IO_Serial_Flush(io);
    1114      
    1115    /* set smartreader in DATA mode */
    1116    tcgetattr(io->fd, &orig);
    1117    orig.c_cflag &= ~CSIZE;
    1118    orig.c_cflag |= CS8;
    1119    tcsetattr(io->fd, TCSANOW, &orig);
    1120 
    1121    return TRUE;
    1122  }
    11231052 
  • branches/monitor-improvement/csctapi/io_serial.h

    r1126 r1189  
    108108extern void IO_Serial_GetPnPId (IO_Serial * io, BYTE * pnp_id, unsigned *length);
    109109
    110 /* smartreader Frequency set */
    111 extern bool IO_Serial_Set_Smartreader_Freq(IO_Serial * io);
    112 
    113110#endif /* IO_SERIAL */
  • branches/monitor-improvement/csctapi/pps.c

    r1177 r1189  
    471471#elif COOL
    472472    if(pps->icc->ifd->io->com==RTYP_SCI) {
    473         typedef unsigned long u_int32;
    474         u_int32 clk;
    475         clk = atr_fs_table[pps->parameters.FI];
    476         if (cnxt_smc_set_clock_freq(handle, clk))
    477             return ICC_ASYNC_IFD_ERROR;
    478 #ifdef DEBUG_PROTOCOL
    479         printf("Coolstream: set clock to %lu Hz\n", clk);
    480 #endif
    481         return ICC_ASYNC_OK;
     473        int mhz = atr_fs_table[pps->parameters.FI] / 10000;
     474        if (!Cool_SetBaudrate(mhz))
     475            return PPS_ICC_ERROR;
     476#ifdef DEBUG_PROTOCOL
     477        printf("Coolstream: set clock to %i * 10kHz\n", mhz);
     478#endif
     479        return PPS_OK;
    482480    }
    483481    else
  • branches/monitor-improvement/globals.h

    r1176 r1189  
    581581  int       dvbapi_enabled;
    582582  int       dvbapi_au;
    583   char      dvbapi_usr[64];
     583  char      dvbapi_usr[33]; 
    584584  char      dvbapi_boxtype[20];
     585  char      dvbapi_priority[64];
     586  char      dvbapi_ignore[64]; 
    585587#endif
    586588#ifdef CS_ANTICASC
  • branches/monitor-improvement/module-dvbapi.c

    r1117 r1189  
    3535#define BUFSIZE 1024
    3636#define MAX_DEMUX 5
     37#define MAX_CAID 50
     38#define TAB_SIZE 30
     39#define ECM_PIDS 20
    3740
    3841static int listenfd = -1;
     
    4043typedef struct ECMPIDS
    4144{
    42     int CA_PID;
    43     int CA_System_ID;
    44     int EMM_PID;
     45    unsigned short CA_PID;
     46    unsigned short CA_System_ID;
     47    unsigned short EMM_PID;
    4548} ECMPIDSTYPE;
    4649
     
    5457    int active;
    5558    int ECMpidcount;
    56     ECMPIDSTYPE ECMpids[20];
     59    ECMPIDSTYPE ECMpids[ECM_PIDS];
    5760    unsigned int program_number;
    5861    unsigned int ca_system_id;
     
    6164    unsigned int emm_pid;
    6265    int STREAMpidcount;
    63     short STREAMpids[20];
     66    short STREAMpids[ECM_PIDS];
    6467    unsigned char buffer_cache_dmx[12];
    6568    unsigned char lastcw0[8];
     
    134137DEMUXTYPE demux[MAX_DEMUX];
    135138
     139unsigned short global_caid_list[MAX_CAID];
     140unsigned short prioritytab[TAB_SIZE], ignoretab[TAB_SIZE];
     141
    136142#define BOX_COUNT 2
    137143struct box_devices
     
    150156int selected_api=-1;
    151157
    152 int dvbapi_set_filter(int dmx_fd, int api, int pid, unsigned char filt, unsigned char mask, int timeout)
    153 {
    154     int command,ret;
     158int dvbapi_set_filter(int dmx_fd, int api, unsigned short pid, unsigned char filt, unsigned char mask, int timeout)
     159{
     160    int command,ret=-1;
    155161
    156162    cs_debug("dvbapi: set filter pid:%04x, value:%04x",pid, filt);
     
    159165    {
    160166        case 0:
     167            //dvbapi 3
     168            command=0;
     169            struct dmx_sct_filter_params sFP2;
     170
     171            memset(&sFP2,0,sizeof(sFP2));
     172
     173            sFP2.pid            = pid;
     174            sFP2.timeout            = timeout;
     175            sFP2.flags          = DMX_IMMEDIATE_START;
     176            sFP2.filter.filter[0]   = filt;
     177            sFP2.filter.mask[0]     = mask;
     178            ret=ioctl(dmx_fd, DMX_SET_FILTER, &sFP2);
     179
     180            break;
     181        case 1:
    161182            //dvbapi 1
    162183            command=0;
     
    173194
    174195            break;
    175         case 1:
    176             //dvbapi 3
    177             command=0;
    178             struct dmx_sct_filter_params sFP2;
    179 
    180             memset(&sFP2,0,sizeof(sFP2));
    181 
    182             sFP2.pid            = pid;
    183             sFP2.timeout            = timeout;
    184             sFP2.flags          = DMX_IMMEDIATE_START;
    185             sFP2.filter.filter[0]   = filt;
    186             sFP2.filter.mask[0]     = mask;
    187             ret=ioctl(dmx_fd, DMX_SET_FILTER, &sFP2);
    188 
    189             break;
    190196        default:
    191197            break;
     
    193199
    194200    if (ret < 0)
    195         cs_log("dvbapi: could not start demux filter (Errno: %d)", errno);
     201        cs_debug("dvbapi: could not start demux filter (Errno: %d)", errno);
    196202
    197203    return ret;
     
    235241    selected_box=devnum;
    236242    selected_api=apinum;
    237     cs_log("Detect %s Api: %d", devices[devnum].demux_device_path, apinum);
     243    cs_debug("dvbapi: Detected %s Api: %d", device_path, apinum);
    238244
    239245    return 1;
     
    267273            ca_offset=1;
    268274
    269         sprintf(device_path, devices[selected_box].ca_device_path, demux[index_demux].demux_index+ca_offset);
     275        sprintf(device_path, devices[selected_box].ca_device_path, demux[index_demux].cadev_index+ca_offset);
    270276    }
    271277
     
    273279        if (type==1 && errno==16) // ca device already open
    274280            for (i=0;i<MAX_DEMUX;i++)
    275                 if (demux[i].demux_index==demux[index_demux].demux_index && demux[i].ca_fd>0)
     281                if (demux[i].cadev_index==demux[index_demux].cadev_index && demux[i].ca_fd>0)
    276282                    dmx_fd=demux[i].ca_fd;
    277283
    278284        if (dmx_fd<=0)
    279             cs_log("dvbapi: error opening device %s (Errno: %d)", device_path, errno);
     285            cs_debug("dvbapi: error opening device %s (Errno: %d)", device_path, errno);
    280286    }
    281287
     
    298304}
    299305
    300 unsigned short dvbapi_get_provid(int demux_index, int pid)
     306unsigned long dvbapi_get_provid(int demux_index, unsigned short pid)
    301307{
    302308    unsigned char buf[BUFSIZE];
     
    310316
    311317    if (len > 0) {
    312         short int provid = (buf[10] << 8) | buf[11];
     318        unsigned long provid = (buf[10] << 8) | buf[11];
    313319        return provid;
    314320    }
     
    317323}
    318324
    319 unsigned short dvbapi_get_single_ecm(int demux_index, int caid, int pid, unsigned short provid)
     325unsigned short dvbapi_get_single_ecm(int demux_index, unsigned short caid, unsigned short pid, unsigned long provid)
    320326{
    321327    unsigned char buf[BUFSIZE];
     
    454460void dvbapi_stop_descrambling_all(int demux_index)
    455461{
    456     int i,j;
     462    int j;
    457463    for (j=0;j<MAX_DEMUX;j++) {
    458464        if (demux[j].demux_index != demux_index)
     
    465471}
    466472
    467 void dvbapi_start_descrambling(int demux_index, int caid, int capid, unsigned short provider_id)
     473void dvbapi_start_descrambling(int demux_index, unsigned short caid, unsigned short capid, unsigned long provider_id)
    468474{
    469475    int i;
     
    531537
    532538        //grep ecm
    533         dvbapi_get_single_ecm(demux_index, demux[demux_index].ECMpids[n].CA_System_ID,demux[demux_index].ECMpids[n].CA_PID, provid);
     539        dvbapi_get_single_ecm(demux_index, demux[demux_index].ECMpids[n].CA_System_ID, demux[demux_index].ECMpids[n].CA_PID, provid);
    534540
    535541        sleep(3); //try next if no cw for .. secs
     
    569575            n=0;
    570576            k++;
     577            continue;
    571578        }
    572579        n++;
     
    575582            return 0;
    576583
    577         sleep(1);
     584        sleep(10);
    578585    }
    579586
     
    617624                        continue;
    618625
    619                     if (buffer[0] == 0x80 | buffer[0] == 0x81)
     626                    if (buffer[0] == 0x80 || buffer[0] == 0x81)
    620627                    {
    621628                        if (memcmp(buffer, demux[demux_index].buffer_cache_dmx, 12) != 0) {
     
    677684}
    678685
     686int dvbapi_check_array(unsigned short *array, int len, unsigned short match)
     687{
     688    int i;
     689    for (i=0; i<len; i++) {
     690        if (array[i]==match) {
     691            return 1;
     692        }
     693    }
     694    return 0;
     695}
     696
     697void dvbapi_resort_ecmpids(int demux_index)
     698{
     699    ECMPIDSTYPE tmppids[ECM_PIDS];
     700    ECMPIDSTYPE tmppids2[ECM_PIDS];
     701
     702    int tmppidcount=0,tmppid2count=0,n;
     703
     704    int i,k,j;
     705
     706    for (i=0;i<MAX_CAID;i++)
     707        global_caid_list[i]=0;
     708
     709    k=0;
     710    for (i=0;i<CS_MAXREADER;i++) {
     711        for (j=0;j<16;j++) {
     712            if (reader[i].caid[j] != 0) {
     713                if (k+1>=MAX_CAID) break;
     714                global_caid_list[k]=reader[i].caid[j];
     715                k++;
     716               
     717            }
     718        }
     719    }
     720    for (n=0; n<demux[demux_index].ECMpidcount; n++) {
     721        if (dvbapi_check_array(ignoretab, TAB_SIZE, demux[demux_index].ECMpids[n].CA_System_ID)) {
     722            cs_debug("-> ignore %04x", demux[demux_index].ECMpids[n].CA_System_ID);
     723        } else if (dvbapi_check_array(global_caid_list, MAX_CAID, demux[demux_index].ECMpids[n].CA_System_ID)) {
     724            cs_debug("-> caid list %04x", demux[demux_index].ECMpids[n].CA_System_ID);
     725            tmppids[tmppidcount]=demux[demux_index].ECMpids[n];
     726            tmppidcount++;
     727        } else if (dvbapi_check_array(prioritytab, TAB_SIZE, demux[demux_index].ECMpids[n].CA_System_ID)) {
     728            cs_debug("-> priority %04x", demux[demux_index].ECMpids[n].CA_System_ID);
     729            tmppids[tmppidcount]=demux[demux_index].ECMpids[n];
     730            tmppidcount++;
     731        } else {
     732            tmppids2[tmppid2count]=demux[demux_index].ECMpids[n];
     733            tmppid2count++;
     734        }
     735    }
     736
     737    for (n=0;n<tmppid2count;n++) {
     738        tmppids[tmppidcount]=tmppids2[n];
     739        tmppidcount++;
     740    }
     741
     742    for (n=0; n<tmppidcount; n++) {
     743        demux[demux_index].ECMpids[n]=tmppids[n];
     744    }
     745
     746    demux[demux_index].ECMpidcount=tmppidcount;
     747    cs_debug("dvbapi: ECMpidscount is now %d", demux[demux_index].ECMpidcount);
     748
     749    return;
     750}
     751
    679752// from tuxbox camd
    680753int dvbapi_parse_capmt(unsigned char *buffer, unsigned int length)
    681754{
    682     int i, j, u;
    683     int n, added, ca_mask=1, demux_index2=0;
     755    int i, j, u, n, added;
     756    int ca_mask=0x01, demux_index2=0x00;
    684757
    685758    int ca_pmt_list_management = buffer[0];
    686759    unsigned int program_number = (buffer[1] << 8) | buffer[2];
    687     unsigned int program_info_length = ((buffer[4] & 0x0F) << 8) | buffer[5];
     760    int program_info_length = ((buffer[4] & 0x0F) << 8) | buffer[5];
    688761
    689762    switch (ca_pmt_list_management)
     
    711784        dvbapi_stop_descrambling_all(0);
    712785    }
    713 
    714786
    715787    for (i=0;i<MAX_DEMUX;i++) {
     
    741813    }
    742814
    743     cs_debug("dvbapi: got id %d", demux_id);
    744 
    745815    if (demux_id<0) {
    746816        cs_log("dvbapi: error no free id (MAX_DEMUX)");
    747         return;
     817        return 0;
    748818    }
    749819
     
    757827    demux[demux_id].STREAMpidcount=0;
    758828    demux[demux_id].active=1;
    759 
    760     cs_debug("dvbapi: demux index %d", demux[demux_id].demux_index);
     829    demux[demux_id].cadev_index=demux_index2;
     830
     831    for (i=0;i<8;i++) {
     832        if (ca_mask & (1 << i)) {
     833            demux[demux_id].cadev_index=i;
     834            break;
     835        }
     836    }
     837
     838    cs_debug("dvbapi: demux index: %d ca index: %d", demux[demux_id].demux_index, demux[demux_id].cadev_index);
    761839
    762840    //CA_PIDS for all streams
     
    800878            int ca_pmt_cmd_id = buffer[i + 5];
    801879            cs_debug("dvbapi: ca_pmt_cmd_id 0x%02x", ca_pmt_cmd_id);
    802             int descriptor_length=0;
     880            unsigned int descriptor_length=0;
    803881            for (j = 0; j < es_info_length - 1; j += descriptor_length + 2)
    804882            {
     
    832910
    833911    if (demux[demux_id].ECMpidcount>0) {
    834         pthread_create (&p3, NULL, thread_descrambling, (void *)demux_id);
     912        dvbapi_resort_ecmpids(demux_id);
     913        if (demux[demux_id].ECMpidcount>0)
     914            pthread_create (&p3, NULL, thread_descrambling, (void *)demux_id);
    835915    }
    836916
     
    842922void dvbapi_handlesockmsg (unsigned char *buffer, ssize_t len)
    843923{
    844     int i;
    845     unsigned int val, size;
     924    unsigned int val, size, i;
    846925
    847926    //cs_dump(buffer, len, "handlesockmsg:");
     
    872951            if ((3 + size + val) == len)
    873952                dvbapi_parse_capmt(buffer + 3 + size, val);
    874             else
     953            else {
    875954                cs_log("dvbapi: ca_pmt invalid length");
     955                cs_dump(buffer, len, "invalid length:");
     956            }
    876957            break;
    877958        case 0x3f:
     
    10101091    }
    10111092
     1093    char *ptr1, *ptr3;
     1094    //priority
     1095    for (i=0, ptr1=strtok(cfg->dvbapi_priority, ","); (i<20) && (ptr1); ptr1=strtok(NULL, ","))
     1096    {
     1097        unsigned long caid, prov;
     1098        if( (ptr3=strchr(trim(ptr1), ':')) )
     1099            *ptr3++='\0';
     1100        else
     1101            ptr3="";
     1102
     1103        if (((caid=a2i(ptr1, 2))|(prov=a2i(ptr3, 3))) < 0x10000)
     1104        {
     1105            prioritytab[i]=caid;
     1106            i++;
     1107        }
     1108    }
     1109    //ignore
     1110    for (i=0, ptr1=strtok(cfg->dvbapi_ignore, ","); (i<20) && (ptr1); ptr1=strtok(NULL, ","))
     1111    {
     1112        unsigned long caid, prov;
     1113        if( (ptr3=strchr(trim(ptr1), ':')) )
     1114            *ptr3++='\0';
     1115        else
     1116            ptr3="";
     1117
     1118        if (((caid=a2i(ptr1, 2))|(prov=a2i(ptr3, 3))) < 0x10000)
     1119        {
     1120            ignoretab[i]=caid;
     1121            i++;
     1122        }
     1123    }
    10121124
    10131125    pfd2[0].fd = fd_m2c;
     
    10511163    memcpy(cw_0, er->cw, 8);
    10521164    memcpy(cw_1, er->cw+8, 8);
    1053 
    1054     int cam_fd=0;
    10551165
    10561166    for (i=0;i<MAX_DEMUX;i++)
  • branches/monitor-improvement/oscam-config.c

    r1180 r1189  
    569569    if (!strcmp(token, "boxtype"))  { strncpy(cfg->dvbapi_boxtype, value, sizeof(cfg->dvbapi_boxtype)-1); return; }
    570570    if (!strcmp(token, "user"))     { strncpy(cfg->dvbapi_usr, value, sizeof(cfg->dvbapi_usr)-1); return; }
    571 
     571    if (!strcmp(token, "priority")) { strncpy(cfg->dvbapi_priority, value, sizeof(cfg->dvbapi_priority)-1); return; }
     572    if (!strcmp(token, "ignore"))   { strncpy(cfg->dvbapi_ignore, value, sizeof(cfg->dvbapi_ignore)-1); return; }
     573   
    572574    if (token[0] != '#')
    573575        fprintf(stderr, "Warning: keyword '%s' in dvbapi section not recognized\n",token);
  • branches/monitor-improvement/oscam-http.c

    r1176 r1189  
    697697      for (i=1; i<CS_MAXCAIDTAB; account->ctab.mask[i++]=0xffff);
    698698      for (i=1; i<CS_MAXTUNTAB; account->ttab.bt_srvid[i++]=0x0000);
     699      account->expirationdate=(time_t)NULL;
    699700#ifdef CS_ANTICASC
    700701      account->ac_users=cfg->ac_users;
     
    716717    for(i=0;i<(*params).paramcount;i++){
    717718        if ((strcmp((*params).params[i], "action")) && (strcmp((*params).params[i], "user")) && (strcmp((*params).params[i], "newuser"))){
     719            if (!strcmp((*params).params[i], "expdate"))
     720                account->expirationdate=(time_t)NULL;
    718721            if (!strcmp((*params).params[i], "services"))
    719722                sprintf(servicelabels + strlen(servicelabels), "%s,", (*params).values[i]);
Note: See TracChangeset for help on using the changeset viewer.