dcw_even = buf[1] == MSG_ECM_REQUEST ? _dcw : NULL;
dcw_odd = buf[1] == MSG_ECM_REQUEST ? _dcw + 8 : NULL;
- tvhtrace(cccam->cc_subsys, "HEADER:");
+ tvhtrace(cccam->cc_subsys, "%s: HEADER:", cccam->cc_name);
tvhlog_hexdump(cccam->cc_subsys, buf, 4);
cc_ecm_reply(ct, es, DESCRAMBLER_CSA_CBC, dcw_even, dcw_odd, seq);
if (len < 4)
return -1;
- tvhtrace(cccam->cc_subsys, "%s:%i: response msg type=%d, response:",
- cccam->cc_hostname, cccam->cc_port, buf[1]);
+ tvhtrace(cccam->cc_subsys, "%s: response msg type=%d, response:",
+ cccam->cc_name, buf[1]);
tvhlog_hexdump(cccam->cc_subsys, buf, len);
switch (buf[1]) {
case MSG_NEW_CARD_SIDINFO:
case MSG_NEW_CARD:
- tvhtrace(cccam->cc_subsys, "%s:%i: add card message received",
- cccam->cc_hostname, cccam->cc_port);
+ tvhtrace(cccam->cc_subsys, "%s: add card message received", cccam->cc_name);
cccam_decode_card_data_reply(cccam, buf);
break;
case MSG_CARD_REMOVED:
- tvhtrace(cccam->cc_subsys, "%s:%i: del card message received",
- cccam->cc_hostname, cccam->cc_port);
+ tvhtrace(cccam->cc_subsys, "%s: del card message received", cccam->cc_name);
break;
case MSG_KEEPALIVE:
- tvhtrace(cccam->cc_subsys, "%s:%i: keepalive",
- cccam->cc_hostname, cccam->cc_port);
+ tvhtrace(cccam->cc_subsys, "%s: keepalive", cccam->cc_name);
break;
case MSG_EMM_REQUEST: /* emm ack */
//cccam_send_msg(cccam, MSG_EMM_REQUEST, NULL, 0, 0, 0, 0);
//sem_post(&cccam->ecm_mutex);
- tvhtrace(cccam->cc_subsys, "%s:%i: EMM message ACK received",
- cccam->cc_hostname, cccam->cc_port);
+ tvhtrace(cccam->cc_subsys, "%s: EMM message ACK received", cccam->cc_name);
break;
case MSG_ECM_NOK1: /* retry */
case MSG_ECM_NOK2: /* decode failed */
if (es->es_resolved) {
mpegts_service_t *t = (mpegts_service_t *)ct->td_service;
tvhdebug(cccam->cc_subsys,
- "%s:%i: Ignore %sECM (PID %d) for service \"%s\" from %s (seq %i)",
- cccam->cc_hostname, cccam->cc_port,
+ "%s: Ignore %sECM (PID %d) for service \"%s\" from %s (seq %i)",
+ cccam->cc_name,
es->es_pending ? "duplicate " : "",
ep->ep_capid, t->s_dvb_svcname, ct->td_nicename, es->es_seq);
return 0;
return 0;
}
}
- tvhwarn(cccam->cc_subsys, "Got unexpected ECM reply (seqno: %d)", seq);
+ tvhwarn(cccam->cc_subsys, "%s: Got unexpected ECM reply (seqno: %d)",
+ cccam->cc_name, seq);
break;
}
case MSG_SRV_DATA:
- tvhinfo(cccam->cc_subsys, "%s:%i: CCcam server version %s nodeid=%02x%02x%02x%02x%02x%02x%02x%02x",
- cccam->cc_hostname, cccam->cc_port, buf + 12,
+ tvhinfo(cccam->cc_subsys,
+ "%s: CCcam server version %s nodeid=%02x%02x%02x%02x%02x%02x%02x%02x",
+ cccam->cc_name, buf + 12,
buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
break;
case MSG_CLI_DATA:
- tvhinfo(cccam->cc_subsys, "%s:%i: CCcam server authentication completed",
- cccam->cc_hostname, cccam->cc_port);
+ tvhinfo(cccam->cc_subsys, "%s: CCcam server authentication completed",
+ cccam->cc_name);
break;
default:
- tvhwarn(cccam->cc_subsys, "%s:%i: Unknown message received",
- cccam->cc_hostname, cccam->cc_port);
+ tvhwarn(cccam->cc_subsys, "%s: Unknown message received",
+ cccam->cc_name);
break;
}
return 0;
ret = tcp_read_timeout(cccam->cc_fd, buf, 4, timeout);
pthread_mutex_lock(&cccam->cc_mutex);
if (ret) {
- tvhdebug(cccam->cc_subsys, "%s:%i: recv error %d or timeout",
- cccam->cc_hostname, cccam->cc_port, ret);
+ tvhdebug(cccam->cc_subsys, "%s: recv error %d or timeout",
+ cccam->cc_name, ret);
return -1;
}
cccam_decrypt(&cccam->recvblock, buf, 4);
msglen = (buf[2] << 8) | buf[3];
if (msglen > 0) {
if (msglen > len - 2) {
- tvhdebug(cccam->cc_subsys, "%s:%i: received message too large",
- cccam->cc_hostname, cccam->cc_port);
+ tvhdebug(cccam->cc_subsys, "%s: received message too large", cccam->cc_name);
return -1;
}
pthread_mutex_unlock(&cccam->cc_mutex);
ret = tcp_read_timeout(cccam->cc_fd, buf + 4, msglen, 5000);
pthread_mutex_lock(&cccam->cc_mutex);
if (ret) {
- tvhdebug(cccam->cc_subsys, "%s:%i: timeout reading message",
- cccam->cc_hostname, cccam->cc_port);
+ tvhdebug(cccam->cc_subsys, "%s: timeout reading message", cccam->cc_name);
return -1;
}
cccam_decrypt(&cccam->recvblock, buf + 4, msglen);
buf[2] = 0;
buf[3] = 0;
- tvhdebug(cccam->cc_subsys, "send keepalive");
+ tvhdebug(cccam->cc_subsys, "%s: send keepalive", cccam->cc_name);
cccam_send_msg(cccam, MSG_NO_HEADER, buf, 4, 0, 0, 0);
}
SHA1_Update(&sha1, buf, 16);
SHA1_Final(hash, &sha1);
- tvhdebug(cccam->cc_subsys, "sha1 hash:");
+ tvhdebug(cccam->cc_subsys, "%s: sha1 hash:", cccam->cc_name);
tvhlog_hexdump(cccam->cc_subsys, hash, sizeof(hash));
cccam_crypt_init(&cccam->recvblock, hash, 20);
cccam_send_msg(cccam, MSG_NO_HEADER, buf, 6, 0, 0, 0);
if (cc_read((cclient_t *)cccam, data, 20, 5000)) {
- tvherror(cccam->cc_subsys, "login failed, pwd ack not received");
+ tvherror(cccam->cc_subsys, "%s: login failed, pwd ack not received", cccam->cc_name);
return -2;
}
cccam_decrypt(&cccam->recvblock, data, 20);
- tvhdebug(cccam->cc_subsys, "login ack, response:");
+ tvhdebug(cccam->cc_subsys, "%s: login ack, response:", cccam->cc_name);
tvhlog_hexdump(cccam->cc_subsys, data, 20);
if (memcmp(data, "CCcam", 5)) {
- tvherror(cccam->cc_subsys, "login failed, usr/pwd invalid");
+ tvherror(cccam->cc_subsys, "%s: login failed, usr/pwd invalid", cccam->cc_name);
return -2;
} else {
- tvhinfo(cccam->cc_subsys, "login succeeded");
+ tvhinfo(cccam->cc_subsys, "%s: login succeeded", cccam->cc_name);
}
return 0;
* Get init seed
*/
if((r = cc_read(cc, buf, 16, 5000))) {
- tvhinfo(cccam->cc_subsys, "%s:%i: init error (no init seed received)",
- cccam->cc_hostname, cccam->cc_port);
+ tvhinfo(cccam->cc_subsys, "%s: init error (no init seed received)", cccam->cc_name);
return -1;
}
- tvhtrace(cccam->cc_subsys, "%s:%d: init seed received:",
- cccam->cc_hostname, cccam->cc_port);
+ tvhtrace(cccam->cc_subsys, "%s: init seed received:", cccam->cc_name);
tvhlog_hexdump(cccam->cc_subsys, buf, 16);
/* check for oscam-cccam */
sum += buf[i];
}
if (sum == recv_sum)
- tvhinfo(cccam->cc_subsys, "%s:%i: oscam server detected",
- cccam->cc_hostname, cccam->cc_port);
+ tvhinfo(cccam->cc_subsys, "%s: oscam server detected", cccam->cc_name);
sha1_make_login_key(cccam, buf);
int seq;
if (len > 255) {
- tvherror(cccam->cc_subsys, "%s:%i: ECM too big (%d bytes)",
- cccam->cc_hostname, cccam->cc_port, len);
+ tvherror(cccam->cc_subsys, "%s: ECM too big (%d bytes)", cccam->cc_name, len);
return 0;
}
int seq;
if (len > 255) {
- tvherror(cccam->cc_subsys, "%s:%i: EMM too big (%d bytes)",
- cccam->cc_hostname, cccam->cc_port, len);
+ tvherror(cccam->cc_subsys, "%s: EMM too big (%d bytes)",
+ cccam->cc_name, len);
return;
}
n = caid2name(caid) ?: "Unknown";
if (ua) {
- tvhinfo(cc->cc_subsys, "%s:%i: Connected as user %s "
+ tvhinfo(cc->cc_subsys, "%s: Connected as user %s "
"to a %s-card [0x%04x : %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x] "
"with %d provider%s",
- cc->cc_hostname, cc->cc_port,
- cc->cc_username, n, caid,
+ cc->cc_name, cc->cc_username, n, caid,
ua[0], ua[1], ua[2], ua[3], ua[4], ua[5], ua[6], ua[7],
pcount, pcount > 1 ? "s" : "");
} else {
- tvhinfo(cc->cc_subsys, "%s:%i: Connected as user %s "
+ tvhinfo(cc->cc_subsys, "%s: Connected as user %s "
"to a %s-card [0x%04x] with %d provider%s",
- cc->cc_hostname, cc->cc_port,
- cc->cc_username, n, caid,
+ cc->cc_name, cc->cc_username, n, caid,
pcount, pcount > 1 ? "s" : "");
}
for (i = 0, ep = pcard->cs_ra.providers; i < pcount; i++, ep++) {
if (psa) {
sa = ep->sa;
- tvhinfo(cc->cc_subsys, "%s:%i: Provider ID #%d: 0x%04x:0x%06x %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x",
- cc->cc_hostname, cc->cc_port, i + 1, caid, ep->id,
+ tvhinfo(cc->cc_subsys, "%s: Provider ID #%d: 0x%04x:0x%06x %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x",
+ cc->cc_name, i + 1, caid, ep->id,
sa[0], sa[1], sa[2], sa[3], sa[4], sa[5], sa[6], sa[7]);
} else {
- tvhinfo(cc->cc_subsys, "%s:%i: Provider ID #%d: 0x%04x:0x%06x",
- cc->cc_hostname, cc->cc_port, i + 1, caid, ep->id);
+ tvhinfo(cc->cc_subsys, "%s: Provider ID #%d: 0x%04x:0x%06x",
+ cc->cc_name, i + 1, caid, ep->id);
}
}
if (es->es_nok >= CC_MAX_NOKS) {
tvhdebug(cc->cc_subsys,
- "Too many NOKs[%i] for service \"%s\"%s from %s",
- es->es_section, t->s_dvb_svcname, chaninfo, ct->td_nicename);
+ "%s: Too many NOKs[%i] for service \"%s\"%s from %s",
+ cc->cc_name, es->es_section, t->s_dvb_svcname, chaninfo, ct->td_nicename);
es->es_keystate = ES_FORBIDDEN;
goto forbid;
}
if (descrambler_resolved((service_t *)t, (th_descrambler_t *)ct)) {
tvhdebug(cc->cc_subsys,
- "NOK[%i] from %s: Already has a key for service \"%s\"",
- es->es_section, ct->td_nicename, t->s_dvb_svcname);
+ "%s: NOK[%i] from %s: Already has a key for service \"%s\"",
+ cc->cc_name, es->es_section, ct->td_nicename, t->s_dvb_svcname);
es->es_nok = CC_MAX_NOKS; /* do not send more ECM requests */
es->es_keystate = ES_IDLE;
if (ct->td_keystate == DS_READY)
}
tvhdebug(cc->cc_subsys,
- "Received NOK[%i] for service \"%s\"%s "
+ "%s: Received NOK[%i] for service \"%s\"%s "
"(seqno: %d Req delay: %"PRId64" ms)",
- es->es_section, t->s_dvb_svcname, chaninfo, seq, delay);
+ cc->cc_name, es->es_section, t->s_dvb_svcname, chaninfo, seq, delay);
forbid:
i = 0;
if (ep == NULL) { /* !UNKNOWN && !RESOLVED */
tvherror(cc->cc_subsys,
- "Can not descramble service \"%s\", access denied (seqno: %d "
+ "%s: Can not descramble service \"%s\", access denied (seqno: %d "
"Req delay: %"PRId64" ms) from %s",
- t->s_dvb_svcname, seq, delay, ct->td_nicename);
+ cc->cc_name, t->s_dvb_svcname, seq, delay, ct->td_nicename);
descrambler_change_keystate((th_descrambler_t *)ct, DS_FORBIDDEN, 1);
ct->ecm_state = ECM_RESET;
/* this pid is not valid, force full scan */
(t->s_dvb_prefcapid != ct->cs_capid &&
t->s_dvb_prefcapid_lock == PREFCAPID_OFF)) {
t->s_dvb_prefcapid = ct->cs_capid;
- tvhdebug(cc->cc_subsys, "Saving prefered PID %d for %s",
- t->s_dvb_prefcapid, ct->td_nicename);
+ tvhdebug(cc->cc_subsys, "%s: Saving prefered PID %d for %s",
+ cc->cc_name, t->s_dvb_prefcapid, ct->td_nicename);
service_request_save((service_t*)t, 0);
}
tvhdebug(cc->cc_subsys,
- "Received ECM reply%s for service \"%s\" [%d] "
+ "%s: Received ECM reply%s for service \"%s\" [%d] "
"(seqno: %d Req delay: %"PRId64" ms)",
- chaninfo, t->s_dvb_svcname, es->es_section, seq, delay);
+ cc->cc_name, chaninfo, t->s_dvb_svcname, es->es_section, seq, delay);
if(es->es_keystate != ES_RESOLVED)
tvhdebug(cc->cc_subsys,
- "Obtained DES keys for service \"%s\" in %"PRId64" ms, from %s",
- t->s_dvb_svcname, delay, ct->td_nicename);
+ "%s: Obtained DES keys for service \"%s\" in %"PRId64" ms, from %s",
+ cc->cc_name, t->s_dvb_svcname, delay, ct->td_nicename);
es->es_keystate = ES_RESOLVED;
es->es_resolved = 1;
pthread_mutex_lock(&cc->cc_mutex);
if (r && tvheadend_is_running())
- tvhwarn(cc->cc_subsys, "read error %d (%s)", r, strerror(r));
+ tvhwarn(cc->cc_subsys, "%s: read error %d (%s)",
+ cc->cc_name, r, strerror(r));
if(cc_must_break(cc))
return ECONNABORTED;
void
cc_write_message(cclient_t *cc, cc_message_t *msg, int enq)
{
- tvhtrace(cc->cc_subsys, "%s:%i: sending message len %u enq %d",
- cc->cc_hostname, cc->cc_port, msg->cm_len, enq);
+ tvhtrace(cc->cc_subsys, "%s: sending message len %u enq %d",
+ cc->cc_name, msg->cm_len, enq);
tvhlog_hexdump(cc->cc_subsys, msg->cm_data, msg->cm_len);
if (enq) {
pthread_mutex_unlock(&cc->cc_writer_mutex);
} else {
if (tvh_write(cc->cc_fd, msg->cm_data, msg->cm_len))
- tvhinfo(cc->cc_subsys, "write error %s", strerror(errno));
+ tvhinfo(cc->cc_subsys, "%s: write error %s",
+ cc->cc_name, strerror(errno));
free(msg);
}
}
pthread_mutex_unlock(&cc->cc_writer_mutex);
// int64_t ts = getfastmonoclock();
if (tvh_write(cc->cc_fd, cm->cm_data, cm->cm_len))
- tvhinfo(cc->cc_subsys, "write error %s", strerror(errno));
+ tvhinfo(cc->cc_subsys, "%s: write error %s",
+ cc->cc_name, strerror(errno));
// printf("Write took %lld usec\n", getfastmonoclock() - ts);
free(cm);
pthread_mutex_lock(&cc->cc_writer_mutex);
if (cc->cc_read(cc))
break;
}
- tvhdebug(cc->cc_subsys, "session thread exiting");
+ tvhdebug(cc->cc_subsys, "%s: session exiting", cc->cc_name);
/**
* Collect the writer thread
cc->cc_writer_running = 0;
tvh_cond_signal(&cc->cc_writer_cond, 0);
pthread_join(writer_thread_id, NULL);
- tvhdebug(cc->cc_subsys, "Write thread joined");
+ tvhdebug(cc->cc_subsys, "%s: Write thread joined", cc->cc_name);
}
/**
cclient_t *cc = aux;
int fd, d, r;
char errbuf[100];
+ char name[256];
char hostname[256];
int port;
int attempts = 0;
cc_invalidate_cards(cc);
caclient_set_status((caclient_t *)cc, CACLIENT_STATUS_READY);
+ snprintf(name, sizeof(name), "%s:%d", cc->cc_hostname, cc->cc_port);
+ cc->cc_name = name;
+
snprintf(hostname, sizeof(hostname), "%s", cc->cc_hostname);
port = cc->cc_port;
- tvhinfo(cc->cc_subsys, "Attemping to connect to %s:%d", hostname, port);
+ tvhinfo(cc->cc_subsys, "%s: Attemping to connect to server", cc->cc_name);
pthread_mutex_unlock(&cc->cc_mutex);
if(fd == -1) {
attempts++;
tvhinfo(cc->cc_subsys,
- "%s:%d: Connection failed: %s",
- hostname, port, errbuf);
+ "%s: Connection failed: %s", cc->cc_name, errbuf);
} else {
if(cc->cc_running == 0) {
break;
}
- tvhinfo(cc->cc_subsys, "%s:%i: Connected", hostname, port);
+ tvhinfo(cc->cc_subsys, "%s: Connected", cc->cc_name);
attempts = 0;
cc->cc_fd = fd;
cc->cc_fd = -1;
close(fd);
- tvhinfo(cc->cc_subsys, "%s:%i: Disconnected", hostname, port);
+ tvhinfo(cc->cc_subsys, "%s: Disconnected", cc->cc_name);
}
if(cc->cc_running == 0) continue;
d = 3;
tvhinfo(cc->cc_subsys,
- "%s:%i: Automatic connection attempt in %d seconds",
- cc->cc_hostname, cc->cc_port, d-1);
+ "%s: Automatic connection attempt in %d seconds",
+ cc->cc_name, d-1);
mono = mclk() + sec2mono(d);
do {
} while (ERRNO_AGAIN(r));
}
- tvhinfo(cc->cc_subsys, "%s:%i inactive", cc->cc_hostname, cc->cc_port);
+ tvhinfo(cc->cc_subsys, "%s: Inactive, thread exit", cc->cc_name);
cc_free_cards(cc);
pthread_mutex_unlock(&cc->cc_mutex);
return NULL;
if (!emm_allowed) {
tvhinfo(cc->cc_subsys,
- "%s:%i: Will not forward EMMs (not allowed by server)",
- cc->cc_hostname, cc->cc_port);
+ "%s: Will not forward EMMs (not allowed by server)",
+ cc->cc_name);
} else {
LIST_FOREACH(pcard, &cc->cc_cards, cs_card)
if (pcard->cs_ra.type != CARD_UNKNOWN) break;
if (pcard) {
- tvhinfo(cc->cc_subsys, "%s:%i: Will forward EMMs",
- cc->cc_hostname, cc->cc_port);
+ tvhinfo(cc->cc_subsys, "%s: Will forward EMMs", cc->cc_name);
} else {
tvhinfo(cc->cc_subsys,
- "%s:%i: Will not forward EMMs (unsupported CA system)",
- cc->cc_hostname, cc->cc_port);
+ "%s: Will not forward EMMs (unsupported CA system)",
+ cc->cc_name);
emm_allowed = 0;
}
}
cc_card_data_t *pcard = aux;
cclient_t *cc = pcard->cs_client;
- tvhtrace(cc->cc_subsys, "sending EMM for %04x mux %p", pcard->cs_ra.caid, mux);
+ tvhtrace(cc->cc_subsys, "%s: sending EMM for %04x mux %p",
+ cc->cc_name, pcard->cs_ra.caid, mux);
tvhlog_hexdump(cc->cc_subsys, radata, ralen);
cc->cc_send_emm(cc, NULL, pcard, 0, radata, ralen);
}
ct->ecm_state = ECM_INIT;
ct->cs_capid = -1;
t->s_dvb_prefcapid = 0;
- tvhdebug(cc->cc_subsys, "%s:%i: Reset after unexpected or no reply for service \"%s\"",
- cc->cc_hostname, cc->cc_port, t->s_dvb_svcname);
+ tvhdebug(cc->cc_subsys, "%s: Reset after unexpected or no reply for service \"%s\"",
+ cc->cc_name, t->s_dvb_svcname);
}
LIST_FOREACH(ep, &ct->cs_pids, ep_link)
if(ep == NULL) {
if (ct->ecm_state == ECM_INIT) {
// Validate prefered ECM PID
- tvhdebug(cc->cc_subsys, "%s:%i: ECM state INIT",
- cc->cc_hostname, cc->cc_port);
+ tvhdebug(cc->cc_subsys, "%s: ECM state INIT", cc->cc_name);
if(t->s_dvb_prefcapid_lock != PREFCAPID_OFF) {
st = service_stream_find((service_t*)t, t->s_dvb_prefcapid);
pcard->cs_ra.caid == c->caid &&
verify_provider(pcard, c->providerid))
goto prefcapid_ok;
- tvhdebug(cc->cc_subsys, "%s:%i: Invalid prefered ECM (PID %d) found for service \"%s\"",
- cc->cc_hostname, cc->cc_port,
- t->s_dvb_prefcapid, t->s_dvb_svcname);
+ tvhdebug(cc->cc_subsys, "%s: Invalid prefered ECM (PID %d) found for service \"%s\"",
+ cc->cc_name, cc->cc_port, t->s_dvb_svcname);
t->s_dvb_prefcapid = 0;
}
ep = calloc(1, sizeof(cc_ecm_pid_t));
ep->ep_capid = pid;
LIST_INSERT_HEAD(&ct->cs_pids, ep, ep_link);
- tvhdebug(cc->cc_subsys, "%s:%i: Insert %s ECM (PID %d) for service \"%s\"",
- cc->cc_hostname, cc->cc_port,
- t->s_dvb_prefcapid ? "preferred" : "new", pid, t->s_dvb_svcname);
+ tvhdebug(cc->cc_subsys, "%s: Insert %s ECM (PID %d) for service \"%s\"",
+ cc->cc_name, t->s_dvb_prefcapid ? "preferred" : "new", pid, t->s_dvb_svcname);
}
}
if(ep == NULL)
es->es_resolved = 0;
if(ct->cs_capid >= 0 && capid > 0 && ct->cs_capid != capid) {
- tvhdebug(cc->cc_subsys, "%s:%i: Filtering ECM (PID %d)",
- cc->cc_hostname, cc->cc_port, capid);
+ tvhdebug(cc->cc_subsys, "%s: Filtering ECM (PID %d)",
+ cc->cc_name, capid);
goto end;
}
es->es_seq = cc->cc_send_ecm(cc, ct, es, pcard, data, len);
tvhdebug(cc->cc_subsys,
- "%s:%i: Sending ECM%s section=%d/%d, for service \"%s\" (seqno: %d)",
- cc->cc_hostname, cc->cc_port, chaninfo, section,
+ "%s: Sending ECM%s section=%d/%d, for service \"%s\" (seqno: %d)",
+ cc->cc_name, chaninfo, section,
ep->ep_last_section, t->s_dvb_svcname, es->es_seq);
es->es_time = getfastmonoclock();
} else {
if (cc->cc_forward_emm && data[0] >= 0x82 && data[0] <= 0x92) {
- tvhtrace(cc->cc_subsys, "%s:%i: sending EMM for %04X:%06X service \"%s\"",
- cc->cc_hostname, cc->cc_port, pcard->cs_ra.caid, provid,
+ tvhtrace(cc->cc_subsys, "%s: sending EMM for %04X:%06X service \"%s\"",
+ cc->cc_name, pcard->cs_ra.caid, provid,
t->s_dvb_svcname);
tvhlog_hexdump(cc->cc_subsys, data, len);
cc->cc_send_emm(cc, ct, pcard, provid, data, len);
ct->ecm_state = ECM_INIT;
td = (th_descrambler_t *)ct;
- snprintf(buf, sizeof(buf), "cc-%s-%i-%04X", cc->cc_hostname, cc->cc_port, pcard->cs_ra.caid);
+ snprintf(buf, sizeof(buf), "%s-%s-%04X",
+ cc->cc_id, cc->cc_name, pcard->cs_ra.caid);
td->td_nicename = strdup(buf);
td->td_service = t;
td->td_stop = cc_service_destroy;
}
if (reuse != 1)
- tvhdebug(cc->cc_subsys, "%s %susing CWC %s:%d",
- service_nicename(t), reuse ? "re" : "", cc->cc_hostname, cc->cc_port);
+ tvhdebug(cc->cc_subsys, "%s: %s %susing CWC %s:%d",
+ cc->cc_name, service_nicename(t), reuse ? "re" : "", cc->cc_hostname, cc->cc_port);
end:
pthread_mutex_unlock(&t->s_stream_mutex);
cc_card_data_t *pcard;
tvhtrace(cc->cc_subsys,
- "caid update event - client %s mux %p caid %04x (%i) pid %04x (%i) valid %i",
- cac->cac_name, mux, caid, caid, pid, pid, valid);
+ "%s: caid update event - client %s mux %p caid %04x (%i) pid %04x (%i) valid %i",
+ cc->cc_name, cac->cac_name, mux, caid, caid, pid, pid, valid);
pthread_mutex_lock(&cc->cc_mutex);
if (valid < 0 || cc->cc_running) {
LIST_FOREACH(pcard, &cc->cc_cards, cs_card) {
pthread_kill(tid, SIGHUP);
pthread_join(tid, NULL);
caclient_set_status(cac, CACLIENT_STATUS_NONE);
+ pthread_mutex_lock(&cc->cc_mutex);
+ free(cc->cc_name);
+ cc->cc_name = NULL;
+ pthread_mutex_unlock(&cc->cc_mutex);
}
}
len -= 12;
if(len < 3) {
- tvhinfo(cwc->cc_subsys, "%s:%i: Invalid card data reply",
- cwc->cc_hostname, cwc->cc_port);
+ tvhinfo(cwc->cc_subsys, "%s: Invalid card data reply", cwc->cc_name);
return -1;
}
plen = (msg[1] & 0xf) << 8 | msg[2];
if(plen < 14) {
- tvhinfo(cwc->cc_subsys, "%s:%i: Invalid card data reply (message)",
- cwc->cc_hostname, cwc->cc_port);
+ tvhinfo(cwc->cc_subsys, "%s: Invalid card data reply (message)", cwc->cc_name);
return -1;
}
plen -= 12;
if(plen < nprov * 11) {
- tvhinfo(cwc->cc_subsys, "%s:%i: Invalid card data reply (provider list)",
- cwc->cc_hostname, cwc->cc_port);
+ tvhinfo(cwc->cc_subsys, "%s: Invalid card data reply (provider list)",
+ cwc->cc_name);
return -1;
}
off = 16;
type = DESCRAMBLER_AES128_ECB;
} else {
- tvherror(cwc->cc_subsys, "wrong ECM reply length %d", len);
+ tvherror(cwc->cc_subsys, "%s: wrong ECM reply length %d",
+ cwc->cc_name, len);
return;
}
cc_ecm_reply(ct, es, type, msg + 3, msg + 3 + off, seq);
case 0x80:
case 0x81:
if (len < 12) {
- tvherror(cwc->cc_subsys, "wrong 0x%02X length %d", msgtype, len);
+ tvherror(cwc->cc_subsys, "%s: wrong 0x%02X length %d",
+ cwc->cc_name, msgtype, len);
return -1;
}
seq = (msg[2] << 8) | msg[3];
if (es->es_resolved) {
mpegts_service_t *t = (mpegts_service_t *)ct->td_service;
tvhdebug(cwc->cc_subsys,
- "Ignore %sECM (PID %d) for service \"%s\" from %s (seq %i)",
+ "%s: Ignore %sECM (PID %d) for service \"%s\" from %s (seq %i)",
+ cwc->cc_name,
es->es_pending ? "duplicate " : "",
ep->ep_capid, t->s_dvb_svcname, ct->td_nicename, es->es_seq);
return 0;
return 0;
}
}
- tvhwarn(cwc->cc_subsys, "Got unexpected ECM reply (seqno: %d, len: %d)", seq, len);
+ tvhwarn(cwc->cc_subsys, "%s: Got unexpected ECM reply (seqno: %d, len: %d)",
+ cwc->cc_name, seq, len);
break;
case 0xD3:
if (len < 16) {
- tvherror(cwc->cc_subsys, "wrong 0xD3 length %d", len);
+ tvherror(cwc->cc_subsys, "%s: wrong 0xD3 length %d", cwc->cc_name, len);
return -1;
}
if (caid){
if(len < 3) {
- tvhinfo(cwc->cc_subsys, "Invalid card data reply");
+ tvhinfo(cwc->cc_subsys, "%s: Invalid card data reply", cwc->cc_name);
return -1;
}
plen = (msg[1] & 0xf) << 8 | msg[2];
if(plen < 14) {
- tvhinfo(cwc->cc_subsys, "Invalid card data reply (message)");
+ tvhinfo(cwc->cc_subsys, "%s: Invalid card data reply (message)", cwc->cc_name);
return -1;
}
if((r = cc_read((cclient_t *)cwc, buf, 2, timeout))) {
if (tvheadend_is_running())
- tvhinfo(cwc->cc_subsys, "%s:%i: %s: Read error (header): %s",
- cwc->cc_hostname, cwc->cc_port, state, strerror(r));
+ tvhinfo(cwc->cc_subsys, "%s: %s: Read error (header): %s",
+ cwc->cc_name, state, strerror(r));
return -1;
}
msglen = (buf[0] << 8) | buf[1];
if(msglen > len) {
if (tvheadend_is_running())
- tvhinfo(cwc->cc_subsys, "%s:%i: %s: Invalid message size: %d",
- cwc->cc_hostname, cwc->cc_port, state, msglen);
+ tvhinfo(cwc->cc_subsys, "%s: %s: Invalid message size: %d",
+ cwc->cc_name, state, msglen);
return -1;
}
if((r = cc_read((cclient_t *)cwc, buf + 2, msglen, 1000))) {
if (tvheadend_is_running())
- tvhinfo(cwc->cc_subsys, "%s:%i: %s: Read error: %s",
- cwc->cc_hostname, cwc->cc_port, state, strerror(r));
+ tvhinfo(cwc->cc_subsys, "%s: %s: Read error: %s",
+ cwc->cc_name, state, strerror(r));
return -1;
}
if((msglen = des_decrypt(buf, msglen + 2, cwc)) < 15) {
- tvhinfo(cwc->cc_subsys, "%s:%i: %s: Decrypt failed",
- cwc->cc_hostname, cwc->cc_port, state);
+ tvhinfo(cwc->cc_subsys, "%s: %s: Decrypt failed",
+ cwc->cc_name, state);
return -1;
}
* Get login key
*/
if ((r = cc_read((cclient_t *)cwc, buf, 14, 5000))) {
- tvhinfo(cwc->cc_subsys, "%s:%i: No login key received: %s",
- cwc->cc_hostname, cwc->cc_port, strerror(r));
+ tvhinfo(cwc->cc_subsys, "%s: No login key received: %s",
+ cwc->cc_name, strerror(r));
return -1;
}
return -1;
if(buf[12] != MSG_CLIENT_2_SERVER_LOGIN_ACK) {
- tvhinfo(cwc->cc_subsys, "%s:%i: Login failed",
- cwc->cc_hostname, cwc->cc_port);
+ tvhinfo(cwc->cc_subsys, "%s: Login failed", cwc->cc_name);
return -1;
}
return -1;
if (buf[12] != MSG_CARD_DATA) {
- tvhinfo(cwc->cc_subsys, "%s:%i: Card data request failed",
- cwc->cc_hostname, cwc->cc_port);
+ tvhinfo(cwc->cc_subsys, "%s: Card data request failed", cwc->cc_name);
return -1;
}