Example #1
0
static void oscam_ser_process_pmt(uchar *buf, int32_t l)
{
  int32_t i;
  uchar sbuf[32];
  struct s_serial_client *serialdata=cur_client()->serialdata;
  switch(serialdata->connected)
  {
    case P_SSSP:
      serialdata->sssp_fix=0;
      memset(serialdata->sssp_tab, 0, sizeof(serialdata->sssp_tab));
      serialdata->sssp_srvid=b2i(2, buf+3);
      serialdata->sssp_num=0;


      for (i=9; (i<l) && (serialdata->sssp_num<SSSP_MAX_PID); i+=7)
      {
	if(chk_ser_srvid(cur_client(), b2i(2, buf+i), b2i(2, buf+3), b2i(3, buf+i+4))) { // check support for pid (caid, sid and provid in oscam.services)
            memcpy(sbuf+3+(serialdata->sssp_num<<1), buf+i+2, 2);
	    serialdata->sssp_tab[serialdata->sssp_num].caid=b2i(2, buf+i  );
    	    serialdata->sssp_tab[serialdata->sssp_num].pid =b2i(2, buf+i+2);
    	    serialdata->sssp_tab[serialdata->sssp_num].prid=b2i(3, buf+i+4);
    	    serialdata->sssp_num++;
        }
      }
      sbuf[0]=0xF1;
      sbuf[1]=0;
      sbuf[2]=(serialdata->sssp_num<<1);
      oscam_ser_send(cur_client(), sbuf, sbuf[2]+3);
      break;
  }
}
Example #2
0
static int32_t oscam_ser_send_ecm(struct s_client *client, ECM_REQUEST *er, uchar *buf)
{
	char *tmp;
	switch(client->serialdata->oscam_ser_proto)
	{
	case P_HSIC:
		memset(buf, 0, 12);
		buf[0] = 2;
		i2b_buf(2, er->caid, buf + 1);
		i2b_buf(3, er->prid, buf + 3);
		i2b_buf(2, er->pid, buf + 6);
		i2b_buf(2, er->srvid, buf + 10);
		memcpy(buf + 12, er->ecm, er->ecmlen);
		oscam_ser_send(client, buf, 12 + er->ecmlen);
		break;
	case P_BOMBA:
		oscam_ser_send(client, er->ecm, er->ecmlen);
		break;
	case P_DSR95:
		if(cs_malloc(&tmp, er->ecmlen * 2 + 1))
		{
			if(client->serialdata->dsr9500type == P_DSR_WITHSID)
			{
				snprintf((char *)buf, 512, "%c%08X%04X%s%04X\n\r",
						 3, er->prid, er->caid, cs_hexdump(0, er->ecm, er->ecmlen, tmp, er->ecmlen * 2 + 1), er->srvid);
				oscam_ser_send(client, buf, (er->ecmlen << 1) + 19); // 1 + 8 + 4 + l*2 + 4 + 2
			}
			else
			{
				snprintf((char *)buf, 512, "%c%08X%04X%s\n\r",
						 3, er->prid, er->caid, cs_hexdump(0, er->ecm, er->ecmlen, tmp, er->ecmlen * 2 + 1));
				oscam_ser_send(client, buf, (er->ecmlen << 1) + 15); // 1 + 8 + 4 + l*2 + 2
			}
			free(tmp);
		}
		break;
	case P_ALPHA:
		buf[0] = 0x80;
		i2b_buf(2, 2 + er->ecmlen, buf + 1);
		i2b_buf(2, er->caid, buf + 3);
		memcpy(buf + 5, er->ecm, er->ecmlen);
		oscam_ser_send(client, buf, oscam_ser_alpha_convert(buf, 5 + er->ecmlen));
		break;
	}
	return (0);
}
Example #3
0
static void oscam_ser_init_client(void)
{
  uchar mbuf[4];
  switch(cur_client()->serialdata->oscam_ser_proto)		// sure, does not work in auto-mode
  {
    case P_GS:
      oscam_ser_disconnect_client(); // send disconnect first
      cs_sleepms(300);		        // wait a little bit
      mbuf[0] = 0x00;
      mbuf[1] = 0x00;
      mbuf[2] = 0x00;
      mbuf[3] = 0x00;
      oscam_ser_send(cur_client(), mbuf, 4);	// send connect
      break;
  }
}
Example #4
0
static void oscam_ser_client_logon(uchar *buf, int32_t l)
{
  uchar gs_logon[]={0, 1, 0, 0, 2, 1, 0, 0};
  switch(cur_client()->serialdata->connected)
  {
    case P_GS:
      if ((l>=8) && (!memcmp(buf, gs_logon, 8)))
      {
        buf[0] = 0x02;
        buf[1] = 0x04;
        buf[2] = 0x00;
        buf[3] = 0x00;
        oscam_ser_send(cur_client(), buf, 4);
      }
      break;
  }
}
Example #5
0
static void oscam_ser_disconnect_client(void)
{
  uchar mbuf[1024];
  struct s_serial_client *serialdata=cur_client()->serialdata;
  switch(serialdata->connected ? serialdata->connected : serialdata->oscam_ser_proto)
  {
    case P_GS:
      mbuf[0] = 0x01;
      mbuf[1] = 0x00;
      mbuf[2] = 0x00;
      mbuf[3] = 0x00;
      oscam_ser_send(cur_client(), mbuf, 4);
      break;
  }
  serialdata->dsr9500type=P_DSR_AUTO;
  serialdata->serial_errors=0;
}
Example #6
0
static void oscam_ser_send_dcw(struct s_client *client, ECM_REQUEST *er)
{
  uchar mbuf[23];
  int32_t i;
  uchar crc;
  struct s_serial_client *serialdata=cur_client()->serialdata;
  if (er->rc<E_NOTFOUND)		// found
    switch(serialdata->connected)
    {
      case P_HSIC:
        for (i=0, crc=HSIC_CRC; i<16; i++)
          crc^=er->cw[i];
        memset(mbuf   , 0x04  ,  2);
        memset(mbuf+2 , 0x3a  ,  2);
        memcpy(mbuf+4 , er->cw, 16);
        memcpy(mbuf+20, &crc  ,  1);
        memset(mbuf+21, 0x1b  ,  2);
        oscam_ser_send(client, mbuf, 23);
        break;
      case P_SSSP:
        mbuf[0]=0xF2;
        mbuf[1]=0;
        mbuf[2]=16;
        memcpy(mbuf+3, er->cw, 16);
        oscam_ser_send(client, mbuf, 19);
        if (!serialdata->sssp_fix)
        {
          mbuf[0]=0xF1;
          mbuf[1]=0;
          mbuf[2]=2;
          i2b_buf(2, er->pid, mbuf + 3);
          oscam_ser_send(client, mbuf, 5);
          serialdata->sssp_fix=1;
        }
        break;
      case P_GBOX:
      case P_BOMBA:
        oscam_ser_send(client, er->cw, 16);
        break;
      case P_DSR95:
        mbuf[0]=4;
        memcpy(mbuf+1, er->cw, 16);
        oscam_ser_send(client, mbuf, 17);
        if( serialdata->dsr9500type==P_DSR_GNUSMAS )
        {
          serialdata->samsung_0a=0;
          for( i=1; i<17; i++ )
            if( mbuf[i]==0x0A )
              serialdata->samsung_0a++;
          serialdata->samsung_dcw++;
        }
        break;
      case P_GS:
        mbuf[0]=0x03;
        mbuf[1]=0x08;
        mbuf[2]=0x10;
        mbuf[3]=0x00;
        memcpy(mbuf+4, er->cw, 16);
        oscam_ser_send(client, mbuf, 20);
        break;
      case P_ALPHA:
        mbuf[0]=0x88;
        mbuf[1]=0x00;
        mbuf[2]=0x10;
        memcpy(mbuf+3, er->cw, 16);
        oscam_ser_send(client, mbuf, 19);
        break;
    }
  else			// not found
    switch(serialdata->connected)
    {
      case P_GS:
        mbuf[0]=0x03;
        mbuf[1]=0x09;
        mbuf[2]=0x00;
        mbuf[3]=0x00;
        oscam_ser_send(client, mbuf, 4);
        break;
    }
  serialdata->serial_errors=0; // clear error counter
}