SASC-NG
DVBSoftCAM

cAuxSrv Class Reference

Inheritance diagram for cAuxSrv:

List of all members.

Public Member Functions

int Map (int map, unsigned char *data, int len, int outlen)

Detailed Description

Definition at line 36 of file nagra2-0101.c.


Member Function Documentation

int cAuxSrv::Map ( int  map,
unsigned char *  data,
int  len,
int  outlen 
)

Definition at line 68 of file nagra2-0101.c.

References auxEnabled, cNetSocket::Connected(), cNetSocket::Disconnect(), L_SYS_MAP, PRINTF, cNetSocket::Read(), and cNetSocket::Write().

Referenced by cMap0101::Map().

{
  if(!auxEnabled) {
    PRINTF(L_SYS_MAP,"auxsrv: AUXserver is disabled!");
    return -1;
    }
  if(len>500 || outlen>500) return -1;
  cMutexLock lock(this);
  if(!so.Connected() && !Login()) return false;
  PRINTF(L_SYS_MAP,"auxsrv: calling map%02x",map);
  unsigned char buff[512];
  buff[0]=0xA7;
  buff[1]=0x7A;
  buff[2]=((len+1)>>8) & 0xff;
  buff[3]=(len+1)&0xff;
  buff[4]=map;
  memcpy(&buff[5],data,len);
  buff[len+5]=0xFF;
  if(so.Write(buff,len+6)>0) {
    if(so.Read(buff,5)>0) {
      if(buff[0]==0x7A && buff[1]==0xA7) {
        int l=buff[2]*256+buff[3];
        if(so.Read(buff+5,l,200)>0) {
          if(buff[4]==0x00) {
            int cycles=(buff[5]<<16)|(buff[6]<<8)|buff[7];
            if(l==outlen+4) {
              if(buff[l+4]==0xFF) {
                memcpy(data,buff+8,outlen);
                return cycles;
                }
              else PRINTF(L_SYS_MAP,"auxsrv: bad footer in map%02x response",map);
              }
            else PRINTF(L_SYS_MAP,"auxsrv: bad length in map%02x response (got=%d want=%d)",map,l-4,outlen);
            }
          else PRINTF(L_SYS_MAP,"auxsrv: map%02x not successfull (unsupported?)",map);
          }
        else PRINTF(L_SYS_MAP,"auxsrv: map%02x read failed (2)",map);
        }
      else PRINTF(L_SYS_MAP,"auxsrv: bad response to map%02x",map);
      }
    else PRINTF(L_SYS_MAP,"auxsrv: map%02x read failed",map);
    }
  else  PRINTF(L_SYS_MAP,"auxsrv: map%02x write failed",map);
  so.Disconnect();
  return -1;
}

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines