source: trunk/oscam-nano.c@ 109

Last change on this file since 109 was 21, checked in by smurzch2, 12 years ago

Rename from MpCS to OSCam

File size: 1.5 KB
Line 
1#include "globals.h"
2
3//#define CS_NANO_GEO 0x9F
4#define CS_NANO_CLASS 0xE2
5
6int find_nano(uchar *ecm, int l, uchar nano, int s)
7{
8 uchar *snano;
9
10 if( s >= l ) return 0;
11 if( !s ) s=(ecm[4]==0xD2) ? 12 : 9; // tpsflag -> offset+3
12 snano = ecm + s;
13
14 while( (*snano!=nano) && (s<l) )
15 {
16 if( *snano == 0xEA ) return 0;
17 snano++;
18 s++;
19 }
20
21 return (s<l)?++s:0;
22}
23
24int chk_class(ECM_REQUEST *er, CLASSTAB *clstab, const char *type, const char *name)
25{
26 int i, j, an, cl_n, l;
27 uchar ecm_class;
28
29 if( er->caid!=0x0500 ) return 1;
30 if( !clstab->bn && !clstab->an ) return 1;
31
32 j=an=cl_n=l=0;
33 while( (j=find_nano(er->ecm, er->l, CS_NANO_CLASS, j)) > 0 )
34 {
35 l = er->ecm[j];
36 ecm_class = er->ecm[j+l];
37 cs_debug("ecm class=%02X", ecm_class);
38 for( i=0; i<clstab->bn; i++ ) // search in blocked
39 if( ecm_class==clstab->bclass[i] )
40 {
41 cs_debug("class %02X rejected by %s '%s' !%02X filter",
42 ecm_class, type, name, ecm_class);
43 return 0;
44 }
45
46 cl_n++;
47 for( i=0; i<clstab->an; i++ ) // search in allowed
48 if( ecm_class==clstab->aclass[i] )
49 {
50 an++;
51 break;
52 }
53 j+=l;
54 }
55
56 if( cl_n && clstab->an )
57 {
58 if( an )
59 cs_debug("ECM classes allowed by %s '%s' filter", type, name);
60 else {
61 cs_debug("ECM classes don't match %s '%s' filter, rejecting", type, name);
62 return 0;
63 }
64 }
65
66 return 1;
67}
68
69/*
70int chk_geo(ECM_REQUEST *er, int el, unsigned char *rclass, int cl)
71{
72
73 return 1;
74}
75*/
Note: See TracBrowser for help on using the repository browser.