|
@@ -81,10 +81,8 @@ void process_pmt(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
81
|
81
|
#define dump_sz (16)
|
82
|
82
|
#define dump_buf_sz (dump_sz * 6)
|
83
|
83
|
|
84
|
|
-void process_emm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
|
84
|
+static void __process_emm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
85
|
85
|
char dump[dump_buf_sz];
|
86
|
|
- if (!ts->emm_pid || ts->emm_pid != pid)
|
87
|
|
- return;
|
88
|
86
|
|
89
|
87
|
show_ts_pack(ts, pid, "emm", NULL, ts_packet);
|
90
|
88
|
|
|
@@ -111,19 +109,21 @@ void process_emm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
111
|
109
|
ts_privsec_clear(ts->emm);
|
112
|
110
|
}
|
113
|
111
|
|
114
|
|
-void process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
|
112
|
+static void __process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
115
|
113
|
char dump[dump_buf_sz];
|
116
|
114
|
|
117
|
|
- if (ts->emm_only)
|
118
|
|
- return;
|
119
|
|
-
|
120
|
|
- if (!ts->ecm_pid || ts->ecm_pid != pid)
|
121
|
|
- return;
|
122
|
|
-
|
123
|
115
|
ts->ecm = ts_privsec_push_packet(ts->ecm, ts_packet);
|
124
|
116
|
if (!ts->ecm->initialized)
|
125
|
117
|
return;
|
126
|
118
|
|
|
119
|
+ if (ts->req_CA_sys == CA_IRDETO) {
|
|
120
|
+ int type = ts->ecm->section_header->section_data[4];
|
|
121
|
+ if (type != ts->irdeto_ecm) {
|
|
122
|
+ ts_privsec_clear(ts->ecm);
|
|
123
|
+ return;
|
|
124
|
+ }
|
|
125
|
+ }
|
|
126
|
+
|
127
|
127
|
struct ts_header *th = &ts->ecm->ts_header;
|
128
|
128
|
struct ts_section_header *sec = ts->ecm->section_header;
|
129
|
129
|
int duplicate = ts_privsec_is_same(ts->ecm, ts->last_ecm);
|
|
@@ -153,3 +153,65 @@ void process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
153
|
153
|
|
154
|
154
|
show_ts_pack(ts, pid, !duplicate ? "ecm" : "ec+", NULL, ts_packet);
|
155
|
155
|
}
|
|
156
|
+
|
|
157
|
+// There are cryptosystems that are puting more than one PSI table
|
|
158
|
+// in TS packet. IRDETO is such example. Because libtsfuncs assumes
|
|
159
|
+// that one ts packet can produce maximum 1 PSI table, the following
|
|
160
|
+// workaround is used for EMM/ECM private sections. Basically we detect
|
|
161
|
+// if after the section there is something else than 0xff (filler) and
|
|
162
|
+// if there is something change ts_packet pointer field to point to
|
|
163
|
+// start of the potential section and reparse section.
|
|
164
|
+void process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
|
165
|
+ int section_end;
|
|
166
|
+
|
|
167
|
+ if (ts->emm_only)
|
|
168
|
+ return;
|
|
169
|
+
|
|
170
|
+ if (!ts->ecm_pid || ts->ecm_pid != pid)
|
|
171
|
+ return;
|
|
172
|
+
|
|
173
|
+process_psi:
|
|
174
|
+ ts->tmp_ecm = ts_privsec_push_packet(ts->tmp_ecm, ts_packet);
|
|
175
|
+ if (!ts->tmp_ecm->initialized) {
|
|
176
|
+ __process_ecm(ts, pid, ts_packet);
|
|
177
|
+ return;
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+ section_end = ts->tmp_ecm->section_header->pointer_field + ts->tmp_ecm->section_header->section_length + 3 + 4 + 1;
|
|
181
|
+ if (section_end < 188 && ts_packet[section_end] != 0xff) {
|
|
182
|
+ __process_ecm(ts, pid, ts_packet);
|
|
183
|
+ ts_packet[4] = ts_packet[4] + ts->tmp_ecm->section_header->section_length + 3;
|
|
184
|
+ ts_privsec_clear(ts->tmp_ecm);
|
|
185
|
+ goto process_psi;
|
|
186
|
+ } else {
|
|
187
|
+ __process_ecm(ts, pid, ts_packet);
|
|
188
|
+ }
|
|
189
|
+
|
|
190
|
+ ts_privsec_clear(ts->tmp_ecm);
|
|
191
|
+}
|
|
192
|
+
|
|
193
|
+void process_emm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
|
194
|
+ int section_end;
|
|
195
|
+
|
|
196
|
+ if (!ts->emm_pid || ts->emm_pid != pid)
|
|
197
|
+ return;
|
|
198
|
+
|
|
199
|
+process_psi:
|
|
200
|
+ ts->tmp_emm = ts_privsec_push_packet(ts->tmp_emm, ts_packet);
|
|
201
|
+ if (!ts->tmp_emm->initialized) {
|
|
202
|
+ __process_emm(ts, pid, ts_packet);
|
|
203
|
+ return;
|
|
204
|
+ }
|
|
205
|
+
|
|
206
|
+ section_end = ts->tmp_emm->section_header->pointer_field + ts->tmp_emm->section_header->section_length + 3 + 4 + 1;
|
|
207
|
+ if (section_end < 188 && ts_packet[section_end] != 0xff) {
|
|
208
|
+ __process_emm(ts, pid, ts_packet);
|
|
209
|
+ ts_packet[4] = ts_packet[4] + ts->tmp_emm->section_header->section_length + 3;
|
|
210
|
+ ts_privsec_clear(ts->tmp_emm);
|
|
211
|
+ goto process_psi;
|
|
212
|
+ } else {
|
|
213
|
+ __process_emm(ts, pid, ts_packet);
|
|
214
|
+ }
|
|
215
|
+
|
|
216
|
+ ts_privsec_clear(ts->tmp_emm);
|
|
217
|
+}
|