Permalink
Browse files

cwc: Allow updating of EMMs only from one channel at a time

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
  • Loading branch information...
1 parent 98dd353 commit 84842c951c4fded196e27d8a614c06b00a211a4d @perexg perexg committed Apr 10, 2012
Showing with 40 additions and 12 deletions.
  1. +3 −0 docs/html/config_cwc.html
  2. +28 −10 src/cwc.c
  3. +9 −2 src/webui/static/app/cwceditor.js
@@ -51,6 +51,9 @@
<dt>Update Card
<dd>Forward Entitlement Management Messages (EMMs) to the server.
+ <dt>Update One
+ <dd>Forward EMMs only from one channel at a time.
+
<dt>Comment
<dd>Allows the administrator to set a comment only visible in this editor.
It does not serve any active purpose.
View
@@ -247,6 +247,10 @@ typedef struct cwc {
} cwc_viaccess_emm;
#define cwc_cryptoworks_emm cwc_viaccess_emm
+ /* one update id */
+ int64_t cwc_update_time;
+ void *cwc_update_id;
+
/* Card type */
card_type_t cwc_card_type;
@@ -261,6 +265,7 @@ typedef struct cwc {
int cwc_port;
char *cwc_id;
int cwc_emm;
+ int cwc_emmex;
const char *cwc_errtxt;
@@ -280,10 +285,10 @@ void cwc_emm_conax(cwc_t *cwc, uint8_t *data, int len);
void cwc_emm_irdeto(cwc_t *cwc, uint8_t *data, int len);
void cwc_emm_dre(cwc_t *cwc, uint8_t *data, int len);
void cwc_emm_seca(cwc_t *cwc, uint8_t *data, int len);
-void cwc_emm_viaccess(cwc_t *cwc, uint8_t *data, int len, void *ca_update_id);
+void cwc_emm_viaccess(cwc_t *cwc, uint8_t *data, int len);
void cwc_emm_nagra(cwc_t *cwc, uint8_t *data, int len);
void cwc_emm_nds(cwc_t *cwc, uint8_t *data, int len);
-void cwc_emm_cryptoworks(cwc_t *cwc, uint8_t *data, int len, void *ca_update_id);
+void cwc_emm_cryptoworks(cwc_t *cwc, uint8_t *data, int len);
/**
@@ -1198,6 +1203,15 @@ cwc_emm(uint8_t *data, int len, uint16_t caid, void *ca_update_id)
TAILQ_FOREACH(cwc, &cwcs, cwc_link) {
if(cwc->cwc_caid == caid &&
cwc->cwc_forward_emm && cwc->cwc_writer_running) {
+ if (cwc->cwc_emmex) {
+ if (cwc->cwc_update_id != ca_update_id) {
+ int64_t delta = getmonoclock() - cwc->cwc_update_time;
+ if (delta < 25000000UL) /* 25 seconds */
+ continue;
+ }
+ cwc->cwc_update_time = getmonoclock();
+ }
+ cwc->cwc_update_id = ca_update_id;
switch (cwc->cwc_card_type) {
case CARD_CONAX:
cwc_emm_conax(cwc, data, len);
@@ -1209,7 +1223,7 @@ cwc_emm(uint8_t *data, int len, uint16_t caid, void *ca_update_id)
cwc_emm_seca(cwc, data, len);
break;
case CARD_VIACCESS:
- cwc_emm_viaccess(cwc, data, len, ca_update_id);
+ cwc_emm_viaccess(cwc, data, len);
break;
case CARD_DRE:
cwc_emm_dre(cwc, data, len);
@@ -1221,7 +1235,7 @@ cwc_emm(uint8_t *data, int len, uint16_t caid, void *ca_update_id)
cwc_emm_nds(cwc, data, len);
break;
case CARD_CRYPTOWORKS:
- cwc_emm_cryptoworks(cwc, data, len, ca_update_id);
+ cwc_emm_cryptoworks(cwc, data, len);
break;
case CARD_UNKNOWN:
break;
@@ -1383,7 +1397,7 @@ static int via_provider_id(uint8_t * data)
void
-cwc_emm_viaccess(cwc_t *cwc, uint8_t *data, int mlen, void *ca_update_id)
+cwc_emm_viaccess(cwc_t *cwc, uint8_t *data, int mlen)
{
/* Get SCT len */
int len = 3 + ((data[1] & 0x0f) << 8) + data[2];
@@ -1415,15 +1429,15 @@ cwc_emm_viaccess(cwc_t *cwc, uint8_t *data, int mlen, void *ca_update_id)
if (cwc->cwc_viaccess_emm.shared_emm) {
cwc->cwc_viaccess_emm.shared_len = len;
memcpy(cwc->cwc_viaccess_emm.shared_emm, data, len);
- cwc->cwc_viaccess_emm.ca_update_id = ca_update_id;
+ cwc->cwc_viaccess_emm.ca_update_id = cwc->cwc_update_id;
}
cwc->cwc_viaccess_emm.shared_toggle = data[0];
}
}
break;
case 0x8e:
if (cwc->cwc_viaccess_emm.shared_emm &&
- cwc->cwc_viaccess_emm.ca_update_id == ca_update_id) {
+ cwc->cwc_viaccess_emm.ca_update_id == cwc->cwc_update_id) {
int match = 0;
int i;
/* Match SA and provider in shared */
@@ -1670,7 +1684,7 @@ cwc_emm_nds(cwc_t *cwc, uint8_t *data, int len)
}
void
-cwc_emm_cryptoworks(cwc_t *cwc, uint8_t *data, int len, void *ca_update_id)
+cwc_emm_cryptoworks(cwc_t *cwc, uint8_t *data, int len)
{
int match = 0;
@@ -1689,13 +1703,13 @@ cwc_emm_cryptoworks(cwc_t *cwc, uint8_t *data, int len, void *ca_update_id)
if (cwc->cwc_cryptoworks_emm.shared_emm) {
cwc->cwc_cryptoworks_emm.shared_len = len;
memcpy(cwc->cwc_cryptoworks_emm.shared_emm, data, len);
- cwc->cwc_cryptoworks_emm.ca_update_id = ca_update_id;
+ cwc->cwc_cryptoworks_emm.ca_update_id = cwc->cwc_update_id;
}
}
break;
case 0x86: /* emm-sb */
if (cwc->cwc_cryptoworks_emm.shared_emm &&
- cwc->cwc_cryptoworks_emm.ca_update_id == ca_update_id) {
+ cwc->cwc_cryptoworks_emm.ca_update_id == cwc->cwc_update_id) {
/* python: EMM_SH[0:12] + EMM_SB[5:-1] + EMM_SH[12:-1] */
uint32_t elen = len - 5 + cwc->cwc_cryptoworks_emm.shared_len - 12;
uint8_t *tmp = malloc(elen);
@@ -1998,6 +2012,7 @@ cwc_record_build(cwc_t *cwc)
htsmsg_add_str(e, "deskey", buf);
htsmsg_add_u32(e, "emm", cwc->cwc_emm);
+ htsmsg_add_u32(e, "emmex", cwc->cwc_emmex);
htsmsg_add_str(e, "comment", cwc->cwc_comment ?: "");
return e;
@@ -2084,6 +2099,9 @@ cwc_entry_update(void *opaque, const char *id, htsmsg_t *values, int maycreate)
if(!htsmsg_get_u32(values, "emm", &u32))
cwc->cwc_emm = u32;
+ if(!htsmsg_get_u32(values, "emmex", &u32))
+ cwc->cwc_emmex = u32;
+
cwc->cwc_reconfigure = 1;
if(cwc->cwc_fd != -1)
@@ -14,6 +14,12 @@ tvheadend.cwceditor = function() {
width: 100
});
+ var emmexColumn = new Ext.grid.CheckColumn({
+ header: "Update One",
+ dataIndex: 'emmex',
+ width: 100
+ });
+
function setMetaAttr(meta, record){
var enabled = record.get('enabled');
if(!enabled) return;
@@ -72,6 +78,7 @@ tvheadend.cwceditor = function() {
editor: new fm.TextField({allowBlank: false})
},
emmColumn,
+ emmexColumn,
{
header: "Comment",
dataIndex: 'comment',
@@ -86,7 +93,7 @@ tvheadend.cwceditor = function() {
var rec = Ext.data.Record.create([
'enabled', 'connected', 'hostname', 'port', 'username',
- 'password', 'deskey', 'emm', 'comment'
+ 'password', 'deskey', 'emm', 'emmex', 'comment'
]);
var store = new Ext.data.JsonStore({
@@ -99,7 +106,7 @@ tvheadend.cwceditor = function() {
});
var grid = new tvheadend.tableEditor('Code Word Client', 'cwc', cm, rec,
- [enabledColumn, emmColumn], store,
+ [enabledColumn, emmColumn, emmexColumn], store,
'config_cwc.html', 'key');
tvheadend.comet.on('cwcStatus', function(msg) {

0 comments on commit 84842c9

Please sign in to comment.