forked from catalinii/minisatip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdvbapi.h
128 lines (106 loc) · 3.47 KB
/
dvbapi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef DISABLE_DVBAPI
#ifndef DVBAPI_H
#define DVBAPI_H
#include "adapter.h"
#include "stream.h"
#define DVBAPI_PROTOCOL_VERSION 2
#define DVBAPI_FILTER_DATA 0xFFFF0000
#define DVBAPI_CLIENT_INFO 0xFFFF0001
#define DVBAPI_SERVER_INFO 0xFFFF0002
#define DVBAPI_DMX_SET_FILTER 0x403c6f2b
#define DVBAPI_CA_SET_PID 0x40086f87
#define DVBAPI_CA_SET_DESCR 0x40106f86
#define DVBAPI_DMX_STOP 0x00006f2a
#define CA_SET_DESCR_X 0x866f10
#define CA_SET_DESCR_AES 0x40106f87
#define CA_SET_DESCR_AES_X 0x876f10
#define CA_SET_PID_X 0x876f08
#define DMX_STOP_X 0x2a6f00
#define DMX_SET_FILTER_X 0x2b6f3c
#define DVBAPI_ECM_INFO 0xFFFF0003
#define CA_SET_DESCR_MODE 0x400c6f88
#define AOT_CA_PMT 0x9F803282
#define CAPMT_LIST_MORE 0x00 // append a 'MORE' CAPMT object the list and start receiving the next object
#define CAPMT_LIST_FIRST 0x01 // clear the list when a 'FIRST' CAPMT object is received, and start receiving the next object
#define CAPMT_LIST_LAST 0x02 // append a 'LAST' CAPMT object to the list and start working with the list
#define CAPMT_LIST_ONLY 0x03 // clear the list when an 'ONLY' CAPMT object is received, and start working with the object
#define CAPMT_LIST_ADD 0x04 // append an 'ADD' CAPMT object to the current list and start working with the updated list
#define CAPMT_LIST_UPDATE 0x05 // replace an entry in the list with an 'UPDATE' CAPMT object, and start working with the updated list
#define MAX_KEYS 255
#define MAX_PMT_DATA 1880
#define CA_ALGO_DVBCSA 0
#define CA_ALGO_DES 1
#define CA_ALGO_AES128 2
#define CA_MODE_ECB 0
#define CA_MODE_CBC 1
typedef struct struct_batch // same as struct dvbcsa_bs_batch_s
{
unsigned char *data; /* pointer to payload */
unsigned int len; /* payload bytes lenght */
} dvbapi_batch;
typedef void *(*Create_cwkey)(void );
typedef void (*Delete_cwkey)(void *);
typedef int (*Batch_size)(void);
typedef void (*Set_CW)(unsigned char *cw,void *key);
typedef void (*Decrypt_Stream)(void *key, dvbapi_batch *batch, int batch_len);
typedef struct struct_dvbapi_op
{
int algo;
int mode;
Create_cwkey create_cwkey;
Delete_cwkey delete_cwkey;
Batch_size batch_size;
Set_CW set_cw;
Decrypt_Stream decrypt_stream;
} dvbapi_op;
typedef struct struct_key
{
char enabled;
SMutex mutex;
void *key[2];
char key_ok[2];
unsigned char cw[2][16];
char next_cw[2][16];
uint32_t cw_time[2];
int key_len;
int sid;
int pmt_pid;
int64_t last_ecm;
uint8_t hops;
uint16_t caid, info_pid;
uint32_t prid;
int ecmtime;
int id;
int adapter;
int demux;
int ver;
int program_id; // pmt sid
unsigned char *pi, *ecm_info, *cardsystem, *reader, *from, *protocol;
int pi_len;
dvbapi_batch batch[130];
int parity;
int blen;
int64_t last_parity_change;
struct struct_key *next_key;
dvbapi_op *op;
} SKey;
#define MAX_KEY_TIME 25000 // 25s
void init_dvbapi();
int have_dvbapi();
int dvbapi_enabled();
int send_ecm(adapter *ad, void *arg);
int batch_size();
int decrypt_stream(adapter *ad, void *arg);
int keys_add(int adapter, int sid, int pmt);
int keys_del(int i);
SKey *get_key(int i);
int dvbapi_process_pmt(unsigned char *b, adapter *ad);
void dvbapi_pid_add(adapter *a,int pid, SPid *cp, int existing);
void dvbapi_pid_del(adapter *a,int pid, SPid *cp);
void dvbapi_delete_keys_for_adapter(int aid);
void register_dvbapi();
void unregister_dvbapi();
void send_client_info(sockets *s);
int set_algo(SKey *k, int algo, int mode);
#endif
#endif