|
@@ -60,8 +60,8 @@ int camd_tcp_connect(struct in_addr ip, int port) {
|
60
|
60
|
return fd;
|
61
|
61
|
}
|
62
|
62
|
|
63
|
|
-static int camd35_recv_cw(struct ts *ts) {
|
64
|
|
- struct camd35 *c = &ts->camd35;
|
|
63
|
+static int camd_recv_cw(struct ts *ts) {
|
|
64
|
+ struct camd *c = &ts->camd;
|
65
|
65
|
struct timeval tv1, tv2, last_ts_keyset;
|
66
|
66
|
static uint8_t invalid_cw[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
67
|
67
|
uint16_t ca_id = 0;
|
|
@@ -115,8 +115,8 @@ static int camd35_recv_cw(struct ts *ts) {
|
115
|
115
|
|
116
|
116
|
#undef ERR
|
117
|
117
|
|
118
|
|
-static int camd35_send_ecm(struct ts *ts, uint16_t ca_id, uint16_t service_id, uint16_t idx, uint8_t *data, uint8_t data_len) {
|
119
|
|
- struct camd35 *c = &ts->camd35;
|
|
118
|
+static int camd_send_ecm(struct ts *ts, uint16_t ca_id, uint16_t service_id, uint16_t idx, uint8_t *data, uint8_t data_len) {
|
|
119
|
+ struct camd *c = &ts->camd;
|
120
|
120
|
int ret = c->ops.do_ecm(c, ca_id, service_id, idx, data, data_len);
|
121
|
121
|
if (ret <= 0) {
|
122
|
122
|
ts_LOGf("ERR | Error sending ecm packet, reconnecting to camd.\n");
|
|
@@ -125,7 +125,7 @@ static int camd35_send_ecm(struct ts *ts, uint16_t ca_id, uint16_t service_id, u
|
125
|
125
|
return ret;
|
126
|
126
|
}
|
127
|
127
|
|
128
|
|
- ret = camd35_recv_cw(ts);
|
|
128
|
+ ret = camd_recv_cw(ts);
|
129
|
129
|
if (ret < 48) {
|
130
|
130
|
ts->is_cw_error = 1;
|
131
|
131
|
if (ts->key.ts && time(NULL) - ts->key.ts > KEY_VALID_TIME) {
|
|
@@ -140,8 +140,8 @@ static int camd35_send_ecm(struct ts *ts, uint16_t ca_id, uint16_t service_id, u
|
140
|
140
|
return ret;
|
141
|
141
|
}
|
142
|
142
|
|
143
|
|
-static int camd35_send_emm(struct ts *ts, uint16_t ca_id, uint8_t *data, uint8_t data_len) {
|
144
|
|
- struct camd35 *c = &ts->camd35;
|
|
143
|
+static int camd_send_emm(struct ts *ts, uint16_t ca_id, uint8_t *data, uint8_t data_len) {
|
|
144
|
+ struct camd *c = &ts->camd;
|
145
|
145
|
int ret = c->ops.do_emm(c, ca_id, data, data_len);
|
146
|
146
|
if (ret < 0) {
|
147
|
147
|
c->emm_recv_errors++;
|
|
@@ -159,12 +159,12 @@ static int camd35_send_emm(struct ts *ts, uint16_t ca_id, uint8_t *data, uint8_t
|
159
|
159
|
static void camd_do_msg(struct camd_msg *msg) {
|
160
|
160
|
if (msg->type == EMM_MSG) {
|
161
|
161
|
msg->ts->emm_seen_count++;
|
162
|
|
- if (camd35_send_emm(msg->ts, msg->ca_id, msg->data, msg->data_len) > 0)
|
|
162
|
+ if (camd_send_emm(msg->ts, msg->ca_id, msg->data, msg->data_len) > 0)
|
163
|
163
|
msg->ts->emm_processed_count++;
|
164
|
164
|
}
|
165
|
165
|
if (msg->type == ECM_MSG) {
|
166
|
166
|
msg->ts->ecm_seen_count++;
|
167
|
|
- if (camd35_send_ecm(msg->ts, msg->ca_id, msg->service_id, msg->idx, msg->data, msg->data_len) > 0)
|
|
167
|
+ if (camd_send_ecm(msg->ts, msg->ca_id, msg->service_id, msg->idx, msg->data, msg->data_len) > 0)
|
168
|
168
|
msg->ts->ecm_processed_count++;
|
169
|
169
|
}
|
170
|
170
|
|
|
@@ -205,12 +205,12 @@ static void *camd_thread(void *in_ts) {
|
205
|
205
|
|
206
|
206
|
while (1) {
|
207
|
207
|
struct camd_msg *msg;
|
208
|
|
- void *req = queue_get(ts->camd35.req_queue); // Waits...
|
|
208
|
+ void *req = queue_get(ts->camd.req_queue); // Waits...
|
209
|
209
|
if (!req || ts->camd_stop)
|
210
|
210
|
break;
|
211
|
|
- msg = queue_get_nowait(ts->camd35.ecm_queue);
|
|
211
|
+ msg = queue_get_nowait(ts->camd.ecm_queue);
|
212
|
212
|
if (!msg)
|
213
|
|
- msg = queue_get_nowait(ts->camd35.emm_queue);
|
|
213
|
+ msg = queue_get_nowait(ts->camd.emm_queue);
|
214
|
214
|
if (!msg)
|
215
|
215
|
break;
|
216
|
216
|
camd_do_msg(msg);
|
|
@@ -220,19 +220,19 @@ static void *camd_thread(void *in_ts) {
|
220
|
220
|
|
221
|
221
|
void camd_msg_process(struct ts *ts, struct camd_msg *msg) {
|
222
|
222
|
msg->ts = ts;
|
223
|
|
- if (ts->camd35.thread) {
|
|
223
|
+ if (ts->camd.thread) {
|
224
|
224
|
if (msg->type == EMM_MSG)
|
225
|
|
- queue_add(ts->camd35.emm_queue, msg);
|
|
225
|
+ queue_add(ts->camd.emm_queue, msg);
|
226
|
226
|
if (msg->type == ECM_MSG)
|
227
|
|
- queue_add(ts->camd35.ecm_queue, msg);
|
228
|
|
- queue_add(ts->camd35.req_queue, msg);
|
|
227
|
+ queue_add(ts->camd.ecm_queue, msg);
|
|
228
|
+ queue_add(ts->camd.req_queue, msg);
|
229
|
229
|
} else {
|
230
|
230
|
camd_do_msg(msg);
|
231
|
231
|
}
|
232
|
232
|
}
|
233
|
233
|
|
234
|
234
|
void camd_start(struct ts *ts) {
|
235
|
|
- struct camd35 *c = &ts->camd35;
|
|
235
|
+ struct camd *c = &ts->camd;
|
236
|
236
|
c->ops.connect(c);
|
237
|
237
|
// The input is not file, process messages using async thread
|
238
|
238
|
if (!(ts->input.type == FILE_IO && ts->input.fd != 0)) {
|
|
@@ -244,7 +244,7 @@ void camd_start(struct ts *ts) {
|
244
|
244
|
}
|
245
|
245
|
|
246
|
246
|
void camd_stop(struct ts *ts) {
|
247
|
|
- struct camd35 *c = &ts->camd35;
|
|
247
|
+ struct camd *c = &ts->camd;
|
248
|
248
|
ts->camd_stop = 1;
|
249
|
249
|
if (c->thread) {
|
250
|
250
|
queue_wakeup(c->req_queue);
|