Browse Source

Add support for Irdeto CHID filtering (tested with Raduga).

Georgi Chorbadzhiyski 10 years ago
parent
commit
08ca2d7df8
7 changed files with 63 additions and 15 deletions
  1. 1
    0
      ChangeLog
  2. 8
    1
      README
  3. 3
    0
      data.c
  4. 8
    1
      data.h
  5. 10
    2
      tables.c
  6. 15
    5
      tsdecrypt.1
  7. 18
    6
      tsdecrypt.c

+ 1
- 0
ChangeLog View File

@@ -10,6 +10,7 @@ now : current
10 10
  * Add support for setting multicast source address /SSM/ (--input-source).
11 11
  * Add support for EMM filters similar to DVBAPI filters (match + mask).
12 12
  * Add support for EMM filters based on section length.
13
+ * Add support for Irdeto CHID filtering (tested with Raduga).
13 14
 
14 15
 2012-09-10 : Version 9.0
15 16
  * Add --no-output-on-error (-u) option. By using this option output can be

+ 8
- 1
README View File

@@ -181,7 +181,9 @@ ECM options:
181 181
  -H --ecm-report-time <sec> | Report each <sec> how much ECMs and CWs have been
182 182
                             .   processed/skipped. Set <sec> to 0 to disable
183 183
                             .   the reports. Default: 60 sec
184
- -G --ecm-irdeto-type <int> | Process IRDETO ECMs with type X /0-3/. Default: 0
184
+ -G --ecm-irdeto-type <int> | Process IRDETO ECMs with index X /0-255/
185
+                            .   It is better to use --ecm-irdeto-chid option!
186
+ -2 --ecm-irdeto-chid <int> | Set CHID to filter Irdeto ECMs (Default: 0x0000).
185 187
  -K --ecm-no-log            | Disable ECM and code words logging.
186 188
  -J --cw-warn-time <sec>    | Warn if no valid code word has been received.
187 189
                             .   Set <sec> to 0 to disable. Default: 60 sec
@@ -266,6 +268,11 @@ Examples:
266 268
    tsdecrypt --ecm-file ecm.txt --caid 0x5581 --input-service 12345 \
267 269
        --camd-server example.com
268 270
 
271
+   # Decrypt IRDETO stream from Raduga (CHID == 0x0015)
272
+   tsdecrypt --input 239.0.50.11:5000 --output 239.78.78.78:5000 \
273
+             --camd-server example.com \
274
+             --ca-system IRDETO --caid 0x0652 --ecm-irdeto-chid 0x0015
275
+
269 276
 OSCAM cs378x configuration
270 277
 ==========================
271 278
 In order for tsdecrypt to communicate with OSCAM using cs378x (camd35

+ 3
- 0
data.c View File

@@ -85,6 +85,9 @@ void data_init(struct ts *ts) {
85 85
 	ts->ecm_report_interval = 60;
86 86
 	ts->ecm_last_report     = time(NULL);
87 87
 
88
+	ts->irdeto_ecm_idx         = 0;
89
+	ts->irdeto_ecm_filter_type = IRDETO_FILTER_IDX;
90
+
88 91
 	ts->cw_warn_sec = 60;
89 92
 	ts->cw_last_warn= time(NULL);
90 93
 	ts->cw_last_warn= ts->cw_last_warn + ts->cw_warn_sec;

+ 8
- 1
data.h View File

@@ -290,7 +290,14 @@ struct ts {
290 290
 	int					tdt_passthrough;
291 291
 	int					nit_passthrough;
292 292
 
293
-	uint8_t				irdeto_ecm;
293
+	uint8_t				irdeto_ecm_idx;
294
+	uint16_t			irdeto_ecm_chid;
295
+
296
+	enum {
297
+		IRDETO_FILTER_IDX,
298
+		IRDETO_FILTER_CHID,
299
+	} irdeto_ecm_filter_type;
300
+
294 301
 	int					ecm_cw_log;
295 302
 
296 303
 	int					rtp_input;

+ 10
- 2
tables.c View File

@@ -314,8 +314,16 @@ static void __process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
314 314
 		return;
315 315
 
316 316
 	if (ts->req_CA_sys == CA_IRDETO) {
317
-		int type = ts->ecm->section_header->section_data[4];
318
-		if (type != ts->irdeto_ecm) {
317
+		uint8_t idx     = ts->ecm->section_header->section_data[4];
318
+		uint16_t chid   = (ts->ecm->section_header->section_data[6] << 8) | ts->ecm->section_header->section_data[7];
319
+
320
+		bool ecm_ok = false;
321
+		switch (ts->irdeto_ecm_filter_type) {
322
+		case IRDETO_FILTER_IDX : ecm_ok = (idx == ts->irdeto_ecm_idx); break;
323
+		case IRDETO_FILTER_CHID: ecm_ok = (chid == ts->irdeto_ecm_chid); break;
324
+		}
325
+
326
+		if (!ecm_ok) {
319 327
 			ts_privsec_clear(ts->ecm);
320 328
 			return;
321 329
 		}

+ 15
- 5
tsdecrypt.1 View File

@@ -267,11 +267,16 @@ time on stream decoding.
267 267
 Set interval for ECM reports. The default is \fB60\fR seconds. Set to \fB0\fR
268 268
 to disable ECM reports.
269 269
 .TP
270
-\fB\-G\fR, \fB\-\-ecm\-irdeto\-type\fR <type>
271
-Set ECM IRDETO type. IRDETO CA send ECMs with different id mixed
272
-into one stream. Only one of the IDs are valid in given time. This
273
-option lets you choose which stream to process. The default stream
274
-type is \fB0\fR.
270
+\fB\-G\fR, \fB\-\-ecm\-irdeto\-type\fR <int>
271
+Set the index of the IRDETO ECM stream. \fBNOTE: This option is deprecated,
272
+better use \-\-ecm\-irdeto\-chid\fR.
273
+.TP
274
+\fB\-2\fR, \fB\-\-ecm\-irdeto\-chid\fR <int>
275
+IRDETO CA sends ECMs mixed in single stream on single PID. In order to select
276
+the correct ECM stream the so called CHID number is used. Oscam reports what
277
+CHIDs are activated in your card and tsdecrypt allows you to set the correct
278
+CHID number using this option. tsderypt reports what CHIDs are available
279
+in the incoming ECM stream. The CHID is 16-bit number (0x0000 - 0xffff).
275 280
 .TP
276 281
 \fB\-K\fR, \fB\-\-ecm\-no\-log\fR
277 282
 Disable logging of ECMs and code words. Code word errors and stats
@@ -396,6 +401,11 @@ CA system is set to CONAX, you can change it using \fB\-\-ca-system\fR parameter
396 401
    # Send ECM from file
397 402
    tsdecrypt --ecm-file ecm.txt --caid 0x5581 --input-service 12345 \\
398 403
        --camd-server example.com
404
+
405
+   # Decrypt IRDETO stream from Raduga (CHID == 0x0015)
406
+   tsdecrypt --input 239.0.50.11:5000 --output 239.78.78.78:5000 \\
407
+             --camd-server example.com \\
408
+             --ca-system IRDETO --caid 0x0652 --ecm-irdeto-chid 0x0015
399 409
 .fi
400 410
 .SH SEE ALSO
401 411
 See the README file for more information. If you have questions, remarks,

+ 18
- 6
tsdecrypt.c View File

@@ -79,9 +79,9 @@ static void LOG_func(const char *msg) {
79 79
 		LOG(msg);
80 80
 }
81 81
 
82
-static const char short_options[] = "i:d:N:Sl:L:F:I:1:RzM:T:W:O:o:t:rk:g:upwxyc:C:Y:Q:A:s:U:P:B:46eZ:Ef:a:X:vqH:G:KJ:D:jbhVn:m:";
82
+static const char short_options[] = "i:d:N:Sl:L:F:I:1:RzM:T:W:O:o:t:rk:g:upwxyc:C:Y:Q:A:s:U:P:B:46eZ:Ef:a:X:vqH:G:2:KJ:D:jbhVn:m:";
83 83
 
84
-// Unused short options: 0235789
84
+// Unused short options: 035789
85 85
 static const struct option long_options[] = {
86 86
 	{ "ident",				required_argument, NULL, 'i' },
87 87
 	{ "daemon",				required_argument, NULL, 'd' },
@@ -134,6 +134,7 @@ static const struct option long_options[] = {
134 134
 	{ "ecm-only",			no_argument,       NULL, 'v' },
135 135
 	{ "ecm-report-time",	required_argument, NULL, 'H' },
136 136
 	{ "ecm-irdeto-type",	required_argument, NULL, 'G' },
137
+	{ "ecm-irdeto-chid",	required_argument, NULL, '2' },
137 138
 	{ "ecm-no-log",			no_argument      , NULL, 'K' },
138 139
 	{ "cw-warn-time",		required_argument, NULL, 'J' },
139 140
 
@@ -242,7 +243,9 @@ static void show_help(struct ts *ts) {
242 243
 	printf(" -H --ecm-report-time <sec> | Report each <sec> how much ECMs and CWs have been\n");
243 244
 	printf("                            .   processed/skipped. Set <sec> to 0 to disable\n");
244 245
 	printf("                            .   the reports. Default: %d sec\n", ts->ecm_report_interval);
245
-	printf(" -G --ecm-irdeto-type <int> | Process IRDETO ECMs with type X /0-3/. Default: %d\n", ts->irdeto_ecm);
246
+	printf(" -G --ecm-irdeto-type <int> | Process IRDETO ECMs with index X /0-255/\n");
247
+	printf("                            .   It is better to use --ecm-irdeto-chid option!\n");
248
+	printf(" -2 --ecm-irdeto-chid <int> | Set CHID to filter Irdeto ECMs (Default: 0x0000).\n");
246 249
 	printf(" -K --ecm-no-log            | Disable ECM and code words logging.\n");
247 250
 	printf(" -J --cw-warn-time <sec>    | Warn if no valid code word has been received.\n");
248 251
 	printf("                            .   Set <sec> to 0 to disable. Default: %d sec\n", ts->cw_warn_sec);
@@ -557,7 +560,12 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
557 560
 					ts->ecm_report_interval = 86400;
558 561
 				break;
559 562
 			case 'G': // --ecm-irdeto-type
560
-				ts->irdeto_ecm = atoi(optarg);
563
+				ts->irdeto_ecm_idx = strtoul(optarg, NULL, 0);
564
+				ts->irdeto_ecm_filter_type = IRDETO_FILTER_IDX;
565
+				break;
566
+			case '2': // --ecm-irdeto-chid
567
+				ts->irdeto_ecm_chid = strtoul(optarg, NULL, 0);
568
+				ts->irdeto_ecm_filter_type = IRDETO_FILTER_CHID;
561 569
 				break;
562 570
 			case 'K': // --ecm-no-log
563 571
 				ts->ecm_cw_log = !ts->ecm_cw_log;
@@ -734,8 +742,12 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
734 742
 	if (ts->forced_service_id)
735 743
 		ts_LOGf("Service id : 0x%04x (%d)\n",
736 744
 			ts->forced_service_id, ts->forced_service_id);
737
-	if (ts->req_CA_sys == CA_IRDETO)
738
-		ts_LOGf("Irdeto ECM : %d\n", ts->irdeto_ecm);
745
+	if (ts->req_CA_sys == CA_IRDETO) {
746
+		switch (ts->irdeto_ecm_filter_type) {
747
+		case IRDETO_FILTER_IDX : ts_LOGf("Irdeto ECM : Index: 0x%02x (%d)\n", ts->irdeto_ecm_idx, ts->irdeto_ecm_idx); break;
748
+		case IRDETO_FILTER_CHID: ts_LOGf("Irdeto ECM : CHID: 0x%04x (%d)\n", ts->irdeto_ecm_chid, ts->irdeto_ecm_chid); break;
749
+		}
750
+	}
739 751
 
740 752
 	if (ts->output_stream) {
741 753
 		if (ts->output.type == NET_IO) {

Loading…
Cancel
Save