Browse Source

Report each 60 seconds how many EMMs has been send

Georgi Chorbadzhiyski 13 years ago
parent
commit
a35cfca500
3 changed files with 16 additions and 0 deletions
  1. 10
    0
      camd.c
  2. 2
    0
      data.c
  3. 4
    0
      data.h

+ 10
- 0
camd.c View File

@@ -239,15 +239,25 @@ static int camd35_send_emm(struct ts *ts, uint16_t ca_id, uint8_t *data, uint8_t
239 239
 	if (ret <= 0) {
240 240
 		ts_LOGf("EMM | Error sending packet.\n");
241 241
 		camd35_reconnect(ts);
242
+	} else {
243
+		c->emm_count++;
242 244
 	}
243 245
 	return ret;
244 246
 }
245 247
 
246 248
 static void camd_do_msg(struct camd_msg *msg) {
249
+	struct camd35 *c = &msg->ts->camd35;
247 250
 	if (msg->type == EMM_MSG)
248 251
 		camd35_send_emm(msg->ts, msg->ca_id, msg->data, msg->data_len);
249 252
 	if (msg->type == ECM_MSG)
250 253
 		camd35_send_ecm(msg->ts, msg->ca_id, msg->service_id, msg->idx, msg->data, msg->data_len);
254
+
255
+	if (msg->ts->emm_send && c->emm_count_last_report + c->emm_count_report_interval <= time(NULL)) {
256
+		ts_LOGf("EMM | Send %d messages in %d seconds.\n", c->emm_count, c->emm_count_report_interval);
257
+		c->emm_count = 0;
258
+		c->emm_count_last_report = time(NULL);
259
+	}
260
+
251 261
 	camd_msg_free(&msg);
252 262
 }
253 263
 

+ 2
- 0
data.c View File

@@ -41,6 +41,8 @@ void data_init(struct ts *ts) {
41 41
 	ts->camd35.key          = &ts->key;
42 42
 	strcpy(ts->camd35.user, "user");
43 43
 	strcpy(ts->camd35.pass, "pass");
44
+	ts->camd35.emm_count_report_interval = 60;
45
+	ts->camd35.emm_count_last_report     = time(NULL);
44 46
 
45 47
 	// Config
46 48
 	ts->syslog_port = 514;

+ 4
- 0
data.h View File

@@ -40,6 +40,10 @@ struct camd35 {
40 40
 	char			user[64];
41 41
 	char			pass[64];
42 42
 
43
+	int				emm_count;
44
+	int				emm_count_report_interval;
45
+	time_t			emm_count_last_report;
46
+
43 47
 	AES_KEY			aes_encrypt_key;
44 48
 	AES_KEY			aes_decrypt_key;
45 49
 

Loading…
Cancel
Save