Browse Source

Warn if CW have not been received.

Add --cw-warn-time to set how much time to wait before
starting to complain about code words.
Georgi Chorbadzhiyski 12 years ago
parent
commit
f2f20efa60
5 changed files with 38 additions and 2 deletions
  1. 6
    1
      camd.c
  2. 2
    0
      data.c
  3. 3
    0
      data.h
  4. 4
    0
      tsdecrypt.1
  5. 23
    1
      tsdecrypt.c

+ 6
- 1
camd.c View File

@@ -161,13 +161,18 @@ READ:
161 161
 	char cw_dump[16 * 6];
162 162
 	ts_hex_dump_buf(cw_dump, 16 * 6, cw, 16, 0);
163 163
 
164
-	c->key->is_valid_cw = memcmp(c->key->cw, invalid_cw, 16) != 0;
164
+	int valid_cw = memcmp(c->key->cw, invalid_cw, 16) != 0;
165
+	if (!c->key->is_valid_cw && valid_cw) {
166
+		ts_LOGf("CW  | +++ OK: Valid CW was received.");
167
+	}
168
+	c->key->is_valid_cw = valid_cw;
165 169
 
166 170
 	// At first ts_keyset is not initialized
167 171
 	last_ts_keyset = c->key->ts_keyset;
168 172
 	if (c->key->is_valid_cw) {
169 173
 		gettimeofday(&c->key->ts_keyset, NULL);
170 174
 		c->key->ts = c->key->ts_keyset.tv_sec;
175
+		ts->cw_last_warn = c->key->ts;
171 176
 
172 177
 		dvbcsa_key_set(c->key->cw    , c->key->csakey[0]);
173 178
 		dvbcsa_key_set(c->key->cw + 8, c->key->csakey[1]);

+ 2
- 0
data.c View File

@@ -82,6 +82,8 @@ void data_init(struct ts *ts) {
82 82
 	ts->ecm_report_interval = 60;
83 83
 	ts->ecm_last_report     = time(NULL);
84 84
 
85
+	ts->cw_warn_sec = 20;
86
+
85 87
 	ts->input.fd    = 0; // STDIN
86 88
 	ts->input.type  = FILE_IO;
87 89
 

+ 3
- 0
data.h View File

@@ -116,6 +116,9 @@ struct ts {
116 116
 	unsigned int		ecm_report_interval;
117 117
 	time_t				ecm_last_report;
118 118
 
119
+	unsigned int		cw_warn_sec;
120
+	time_t				cw_last_warn;
121
+
119 122
 	// CAMD handling
120 123
 	struct key			key;
121 124
 	struct camd35		camd35;

+ 4
- 0
tsdecrypt.1 View File

@@ -141,6 +141,10 @@ type is \fB0\fR.
141 141
 \fB\-K\fR, \fB\-\-ecm\-no\-log\fR
142 142
 Disable logging of ECMs and code words. Code word errors and stats
143 143
 reports are not affected by this option.
144
+.TP
145
+\fB\-J\fR, \fB\-\-cw\-warn\-time\fR <seconds>
146
+After how much seconds to warn if valid code word was not received.
147
+The default is \fB20\fR seconds. Set to \fB0\fR to disable the warning.
144 148
 .SH SEE ALSO
145 149
 See the README file for more information. If you have questions, remarks,
146 150
 problems or you just want to contact the developer, write to:

+ 23
- 1
tsdecrypt.c View File

@@ -78,6 +78,7 @@ static const struct option long_options[] = {
78 78
 	{ "ecm-report-time",	required_argument, NULL, 'H' },
79 79
 	{ "ecm-irdeto-type",	required_argument, NULL, 'G' },
80 80
 	{ "ecm-no-log",			no_argument      , NULL, 'K' },
81
+	{ "cw-warn-time",		required_argument, NULL, 'J' },
81 82
 
82 83
 	{ "debug",				required_argument, NULL, 'D' },
83 84
 	{ "help",				no_argument,       NULL, 'h' },
@@ -141,6 +142,8 @@ static void show_help(struct ts *ts) {
141 142
 	printf("                            . the reports. Default: %d sec\n", ts->ecm_report_interval);
142 143
 	printf(" -G --ecm-irdeto-type <int> | Process IRDETO ECMs with type X /0..3/. Default: %d\n", ts->irdeto_ecm);
143 144
 	printf(" -K --ecm-no-log            | Disable ECM and code words logging.\n");
145
+	printf(" -J --cw-warn-time <sec>    | Warn if no valid code word has been received.\n");
146
+	printf("                            . Set <sec> to 0 to disable. Default: %d sec\n", ts->cw_warn_sec);
144 147
 	printf("\n");
145 148
 	printf("Misc options:\n");
146 149
 	printf(" -D --debug <level>         | Message debug level.\n");
@@ -178,7 +181,7 @@ static int parse_io_param(struct io *io, char *opt, int open_flags, mode_t open_
178 181
 
179 182
 static void parse_options(struct ts *ts, int argc, char **argv) {
180 183
 	int j, i, ca_err = 0, server_err = 1, input_addr_err = 0, output_addr_err = 0, output_intf_err = 0, ident_err = 0;
181
-	while ( (j = getopt_long(argc, argv, "i:d:l:L:I:RzO:o:t:pc:s:U:P:y:eZ:Ef:X:G:KD:h", long_options, NULL)) != -1 ) {
184
+	while ( (j = getopt_long(argc, argv, "i:d:l:L:I:RzO:o:t:pc:s:U:P:y:eZ:Ef:X:G:KJ:D:h", long_options, NULL)) != -1 ) {
182 185
 		char *p = NULL;
183 186
 		switch (j) {
184 187
 			case 'i':
@@ -301,6 +304,11 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
301 304
 			case 'K':
302 305
 				ts->ecm_cw_log = 0;
303 306
 				break;
307
+			case 'J':
308
+				ts->cw_warn_sec = strtoul(optarg, NULL, 10);
309
+				if (ts->cw_warn_sec > 86400)
310
+					ts->cw_warn_sec = 86400;
311
+				break;
304 312
 
305 313
 			case 'D':
306 314
 				ts->debug_level = atoi(optarg);
@@ -391,6 +399,11 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
391 399
 	if (!ts->emm_only && ts->ecm_report_interval == 0)
392 400
 		ts_LOGf("ECM report : disabled\n");
393 401
 
402
+	if (!ts->emm_only && ts->cw_warn_sec)
403
+		ts_LOGf("CW warning : %d sec\n", ts->cw_warn_sec);
404
+	if (!ts->emm_only && ts->cw_warn_sec)
405
+		ts_LOGf("CW warning : disabled\n");
406
+
394 407
 	if (!ts->ecm_cw_log)
395 408
 		ts_LOGf("ECM/CW log : disabled\n");
396 409
 
@@ -424,6 +437,11 @@ static void report_ecms(struct ts *ts, time_t now) {
424 437
 	ts->ecm_processed_count = 0;
425 438
 }
426 439
 
440
+static void report_cw_warn(struct ts *ts, time_t now) {
441
+	ts_LOGf("CW  | *** No valid CW was received for %lu seconds!\n", now - ts->cw_last_warn);
442
+	ts->cw_last_warn = now;
443
+}
444
+
427 445
 static void do_reports(struct ts *ts) {
428 446
 	static int first_emm_report = 1;
429 447
 	static int first_ecm_report = 1;
@@ -446,6 +464,10 @@ static void do_reports(struct ts *ts) {
446 464
 			report_ecms(ts, now);
447 465
 		}
448 466
 	}
467
+
468
+	if (!ts->emm_only && !ts->key.is_valid_cw) {
469
+		report_cw_warn(ts, now);
470
+	}
449 471
 }
450 472
 
451 473
 void signal_quit(int sig) {

Loading…
Cancel
Save