3
* Copyright (C) 2011 Unix Solutions Ltd.
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2
7
* as published by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25
void data_init(struct ts *ts) {
26
memset(ts, 0, sizeof(struct ts));
28
ts->pat = ts_pat_alloc();
29
ts->curpat = ts_pat_alloc();
30
ts->genpat = ts_pat_alloc();
32
ts->cat = ts_cat_alloc();
33
ts->curcat = ts_cat_alloc();
35
ts->pmt = ts_pmt_alloc();
36
ts->curpmt = ts_pmt_alloc();
38
ts->sdt = ts_sdt_alloc();
39
ts->cursdt = ts_sdt_alloc();
41
ts->emm = ts_privsec_alloc();
42
ts->last_emm = ts_privsec_alloc();
43
ts->tmp_emm = ts_privsec_alloc();
45
ts->ecm = ts_privsec_alloc();
46
ts->last_ecm = ts_privsec_alloc();
47
ts->tmp_ecm = ts_privsec_alloc();
49
pidmap_clear(&ts->pidmap);
50
pidmap_clear(&ts->cc);
51
pidmap_clear(&ts->pid_seen);
54
memset(&ts->key, 0, sizeof(ts->key));
55
ts->key.csakey[0] = dvbcsa_key_alloc();
56
ts->key.csakey[1] = dvbcsa_key_alloc();
58
ts->key.bs_csakey[0] = dvbcsa_bs_key_alloc();
59
ts->key.bs_csakey[1] = dvbcsa_bs_key_alloc();
61
gettimeofday(&ts->key.ts_keyset, NULL);
64
memset(&ts->camd, 0, sizeof(ts->camd));
65
ts->camd.server_fd = -1;
66
ts->camd.server_port = 2233;
67
ts->camd.key = &ts->key;
68
ts->camd.user = "user";
69
ts->camd.pass = "pass";
70
strcpy(ts->camd.newcamd.hex_des_key, "0102030405060708091011121314");
72
camd_proto_cs378x(&ts->camd.ops);
75
ts->syslog_port = 514;
81
ts->req_CA_sys = CA_CONAX;
85
ts->emm_report_interval = 60;
86
ts->emm_last_report = time(NULL);
88
ts->ecm_report_interval = 60;
89
ts->ecm_last_report = time(NULL);
92
ts->cw_last_warn= time(NULL);
93
ts->cw_last_warn= ts->cw_last_warn + ts->cw_warn_sec;
94
ts->key.ts = time(NULL);
96
ts->input.fd = 0; // STDIN
97
ts->input.type = FILE_IO;
99
ts->output.fd = 1; // STDOUT
100
ts->output.type = FILE_IO;
104
ts->decode_buf = cbuf_init((7 * dvbcsa_bs_batch_size() * 188) * 16, "decode"); // ~658Kb
105
ts->write_buf = cbuf_init((7 * dvbcsa_bs_batch_size() * 188) * 8, "write"); // ~324Kb
107
ts->input_buffer= list_new("input");
110
void data_free(struct ts *ts) {
111
ts_pat_free(&ts->pat);
112
ts_pat_free(&ts->curpat);
113
ts_pat_free(&ts->genpat);
114
ts_cat_free(&ts->cat);
115
ts_cat_free(&ts->curcat);
116
ts_pmt_free(&ts->pmt);
117
ts_pmt_free(&ts->curpmt);
118
ts_sdt_free(&ts->sdt);
119
ts_sdt_free(&ts->cursdt);
120
ts_privsec_free(&ts->emm);
121
ts_privsec_free(&ts->last_emm);
122
ts_privsec_free(&ts->tmp_emm);
123
ts_privsec_free(&ts->ecm);
124
ts_privsec_free(&ts->last_ecm);
125
ts_privsec_free(&ts->tmp_ecm);
127
dvbcsa_key_free(ts->key.csakey[0]);
128
dvbcsa_key_free(ts->key.csakey[1]);
130
dvbcsa_bs_key_free(ts->key.bs_csakey[0]);
131
dvbcsa_bs_key_free(ts->key.bs_csakey[1]);
133
cbuf_free(&ts->decode_buf);
134
cbuf_free(&ts->write_buf);
136
FREE(ts->input.fname);
137
FREE(ts->output.fname);
139
list_free(&ts->input_buffer, free, NULL);
141
// glibc's crypt function allocates static buffer on first crypt() call.
142
// Since newcamd uses crypt(), the result is saved in c->newcamd.crypt_passwd
143
// and in order to avoid leaking 43 bytes of memory on exit which makes valgrind
144
// unhappy it is a good idea to free the memory (ONCE!).
145
FREE(ts->camd.newcamd.crypt_passwd);