source: trunk/oscam-nano.c@ 3181

Last change on this file since 3181 was 3181, checked in by dingo35, 10 years ago

Adding threadsafety FIXMEs, feel free to join checking..

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