1 | #define MODULE_LOG_PREFIX "cccam"
|
---|
2 |
|
---|
3 | #include "globals.h"
|
---|
4 | #include "oscam-array.h"
|
---|
5 |
|
---|
6 | #if defined(CS_CACHEEX) && defined(MODULE_CCCAM)
|
---|
7 |
|
---|
8 | #include "module-cacheex.h"
|
---|
9 | #include "module-cccam-data.h"
|
---|
10 | #include "module-cccam-cacheex.h"
|
---|
11 | #include "oscam-cache.h"
|
---|
12 | #include "oscam-client.h"
|
---|
13 | #include "oscam-ecm.h"
|
---|
14 | #include "oscam-string.h"
|
---|
15 | #include "oscam-chk.h"
|
---|
16 | #include "oscam-reader.h"
|
---|
17 | #include "oscam-chk.h"
|
---|
18 | #include "oscam-config.h"
|
---|
19 |
|
---|
20 | #define CSP_HASH_SWAP(n) (((((uint32_t)(n) & 0xFF)) << 24) | \
|
---|
21 | ((((uint32_t)(n) & 0xFF00)) << 8) | \
|
---|
22 | ((((uint32_t)(n) & 0xFF0000)) >> 8) | \
|
---|
23 | ((((uint32_t)(n) & 0xFF000000)) >> 24))
|
---|
24 |
|
---|
25 | extern int32_t cc_cli_connect(struct s_client *cl);
|
---|
26 | extern int32_t cc_cmd_send(struct s_client *cl, uint8_t *buf, int32_t len, cc_msg_type_t cmd);
|
---|
27 |
|
---|
28 | void cc_cacheex_feature_trigger_in(struct s_client *cl, uint8_t *buf)
|
---|
29 | {
|
---|
30 | int32_t feature = 0;
|
---|
31 | int i = 0;
|
---|
32 | uint8_t filter_count;
|
---|
33 | uint8_t j, k, l, rc;
|
---|
34 | feature = buf[1] | (buf[0] << 8);
|
---|
35 | FTAB *lgonly_tab;
|
---|
36 |
|
---|
37 | switch(feature)
|
---|
38 | {
|
---|
39 | // set localgenerated only
|
---|
40 | case 1:
|
---|
41 | if(cl->typ == 'c' && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1))
|
---|
42 | {
|
---|
43 | if(cfg.cacheex_lg_only_remote_settings || cl->account->cacheex.lg_only_remote_settings)
|
---|
44 | cl->account->cacheex.localgenerated_only = buf[4];
|
---|
45 | else if(buf[4])
|
---|
46 | cl->account->cacheex.localgenerated_only = buf[4];
|
---|
47 | }
|
---|
48 | else if(cl->typ == 'p' && cl->reader->cacheex.mode == 3)
|
---|
49 | {
|
---|
50 | if(cfg.cacheex_lg_only_remote_settings || cl->reader->cacheex.lg_only_remote_settings)
|
---|
51 | cl->reader->cacheex.localgenerated_only = buf[4];
|
---|
52 | else if(buf[4])
|
---|
53 | cl->reader->cacheex.localgenerated_only = buf[4];
|
---|
54 | }
|
---|
55 | break;
|
---|
56 | // set localgenerated only caidtab
|
---|
57 | case 2:
|
---|
58 | filter_count = buf[i+4];
|
---|
59 | i += 5;
|
---|
60 |
|
---|
61 | memset(&lgonly_tab, 0, sizeof(lgonly_tab));
|
---|
62 |
|
---|
63 | if(cl->typ == 'c' && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1))
|
---|
64 | {
|
---|
65 | lgonly_tab = &cl->account->cacheex.lg_only_tab;
|
---|
66 | }
|
---|
67 | else if(cl->typ == 'p' && cl->reader->cacheex.mode == 3)
|
---|
68 | {
|
---|
69 | lgonly_tab = &cl->reader->cacheex.lg_only_tab;
|
---|
70 | }
|
---|
71 |
|
---|
72 | // remotesettings enabled - replace local settings
|
---|
73 | if(cfg.cacheex_lg_only_remote_settings ||
|
---|
74 | (
|
---|
75 | (cl->typ == 'c' && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1) && cl->account->cacheex.lg_only_remote_settings)
|
---|
76 | || (cl->typ == 'p' && cl->reader->cacheex.mode == 3 && cl->reader->cacheex.lg_only_remote_settings)
|
---|
77 | )
|
---|
78 | )
|
---|
79 | {
|
---|
80 | ftab_clear(lgonly_tab);
|
---|
81 |
|
---|
82 | for(j = 0; j < filter_count; j++)
|
---|
83 | {
|
---|
84 | FILTER d;
|
---|
85 | memset(&d, 0, sizeof(d));
|
---|
86 |
|
---|
87 | d.caid = b2i(2, buf + i);
|
---|
88 | i += 2;
|
---|
89 |
|
---|
90 | d.nprids = 1;
|
---|
91 | d.prids[0] = NO_PROVID_VALUE;
|
---|
92 |
|
---|
93 | ftab_add(lgonly_tab, &d);
|
---|
94 | }
|
---|
95 | }
|
---|
96 | // remotesettings disabled - write additional remote-caids received
|
---|
97 | else
|
---|
98 | {
|
---|
99 | for(j = 0; j < filter_count; j++)
|
---|
100 | {
|
---|
101 | FILTER d;
|
---|
102 | memset(&d, 0, sizeof(d));
|
---|
103 |
|
---|
104 | d.caid = b2i(2, buf + i);
|
---|
105 | i += 2;
|
---|
106 |
|
---|
107 | d.nprids = 1;
|
---|
108 | d.prids[0] = NO_PROVID_VALUE;
|
---|
109 |
|
---|
110 | if(!chk_lg_only_cp(d.caid, d.prids[0], lgonly_tab))
|
---|
111 | {
|
---|
112 | cs_log_dbg(D_CACHEEX, "%04X:%06X not found in local settings - adding them", d.caid, d.prids[0]);
|
---|
113 |
|
---|
114 | for(l = rc = 0; (!rc) && (l < lgonly_tab->nfilts); l++)
|
---|
115 | {
|
---|
116 | if(lgonly_tab->filts[l].caid == d.caid)
|
---|
117 | {
|
---|
118 | rc = 1;
|
---|
119 |
|
---|
120 | if(lgonly_tab->filts[l].nprids+1 <= CS_MAXPROV)
|
---|
121 | {
|
---|
122 | lgonly_tab->filts[l].prids[lgonly_tab->filts[l].nprids] = d.prids[0];
|
---|
123 | lgonly_tab->filts[l].nprids++;
|
---|
124 | }
|
---|
125 | else
|
---|
126 | {
|
---|
127 | cs_log_dbg(D_CACHEEX, "error: cacheex_lg_only_tab -> max. number(%i) of providers reached", CS_MAXPROV);
|
---|
128 | }
|
---|
129 | }
|
---|
130 | }
|
---|
131 | if(!rc)
|
---|
132 | {
|
---|
133 | ftab_add(lgonly_tab, &d);
|
---|
134 | }
|
---|
135 | }
|
---|
136 | }
|
---|
137 | }
|
---|
138 | break;
|
---|
139 | // set cacheex_ecm_filter - extended
|
---|
140 | case 4:
|
---|
141 | filter_count = buf[i+4];
|
---|
142 | i += 5;
|
---|
143 |
|
---|
144 | CECSPVALUETAB *filter;
|
---|
145 | memset(&filter, 0, sizeof(filter));
|
---|
146 |
|
---|
147 | if(cl->typ == 'c' && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1) && cl->account->cacheex.allow_filter)
|
---|
148 | {
|
---|
149 | filter = &cl->account->cacheex.filter_caidtab;
|
---|
150 | }
|
---|
151 | else if(cl->typ == 'p' && cl->reader->cacheex.mode == 3 && cl->reader->cacheex.allow_filter)
|
---|
152 | {
|
---|
153 | filter = &cl->reader->cacheex.filter_caidtab;
|
---|
154 | }
|
---|
155 |
|
---|
156 | cecspvaluetab_clear(filter);
|
---|
157 |
|
---|
158 | for(j = 0; j < filter_count; j++)
|
---|
159 | {
|
---|
160 | int32_t caid = -1, cmask = -1, provid = -1, srvid = -1;
|
---|
161 | CECSPVALUETAB_DATA d;
|
---|
162 | memset(&d, 0, sizeof(d));
|
---|
163 |
|
---|
164 | caid = b2i(2, buf + i);
|
---|
165 | if(caid == 0xFFFF) caid = -1;
|
---|
166 | i += 2;
|
---|
167 |
|
---|
168 | cmask = b2i(2, buf + i);
|
---|
169 | if(cmask == 0xFFFF) cmask = -1;
|
---|
170 | i += 2;
|
---|
171 |
|
---|
172 | provid = b2i(3, buf + i);
|
---|
173 | if(provid == 0xFFFFFF) provid = -1;
|
---|
174 | i += 3;
|
---|
175 |
|
---|
176 | srvid = b2i(2, buf + i);
|
---|
177 | if(srvid == 0xFFFF) srvid = -1;
|
---|
178 | i += 2;
|
---|
179 |
|
---|
180 | if(caid > 0)
|
---|
181 | {
|
---|
182 | d.caid = caid;
|
---|
183 | d.cmask = cmask;
|
---|
184 | d.prid = provid;
|
---|
185 | d.srvid = srvid;
|
---|
186 | cecspvaluetab_add(filter, &d);
|
---|
187 | }
|
---|
188 | }
|
---|
189 | break;
|
---|
190 | // no push after
|
---|
191 | case 8: ;
|
---|
192 | CAIDVALUETAB *ctab;
|
---|
193 | memset(&ctab, 0, sizeof(ctab));
|
---|
194 |
|
---|
195 | if(cl->typ == 'c' && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1))
|
---|
196 | {
|
---|
197 | ctab = &cl->account->cacheex.cacheex_nopushafter_tab;
|
---|
198 | }
|
---|
199 | else if(cl->typ == 'p' && cl->reader->cacheex.mode == 3)
|
---|
200 | {
|
---|
201 | ctab = &cl->reader->cacheex.cacheex_nopushafter_tab;
|
---|
202 | }
|
---|
203 |
|
---|
204 | filter_count = buf[i+4];
|
---|
205 | i += 5;
|
---|
206 |
|
---|
207 | caidvaluetab_clear(ctab);
|
---|
208 |
|
---|
209 | for(j = 0; j < filter_count; j++)
|
---|
210 | {
|
---|
211 | uint16_t caid = 0, value = 0;
|
---|
212 | CAIDVALUETAB_DATA d;
|
---|
213 | memset(&d, 0, sizeof(d));
|
---|
214 |
|
---|
215 | caid = b2i(2, buf + i);
|
---|
216 | if(caid == 0xFFFF) caid = -1;
|
---|
217 | i += 2;
|
---|
218 |
|
---|
219 | value = b2i(2, buf + i);
|
---|
220 | if(value == 0xFFFF) value = -1;
|
---|
221 | i += 2;
|
---|
222 |
|
---|
223 | if(caid > 0)
|
---|
224 | {
|
---|
225 | d.caid = caid;
|
---|
226 | d.value = value;
|
---|
227 | caidvaluetab_add(ctab, &d);
|
---|
228 | }
|
---|
229 | }
|
---|
230 | break;
|
---|
231 | // max_hop
|
---|
232 | case 16:
|
---|
233 | if(cl->typ == 'c' && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1) && cl->account->cacheex.allow_maxhop)
|
---|
234 | {
|
---|
235 | cl->account->cacheex.maxhop = buf[4];
|
---|
236 | cl->account->cacheex.maxhop_lg = buf[5];
|
---|
237 | }
|
---|
238 | else if(cl->typ == 'p' && cl->reader->cacheex.mode == 3 && cl->reader->cacheex.allow_maxhop)
|
---|
239 | {
|
---|
240 | cl->reader->cacheex.maxhop = buf[4];
|
---|
241 | cl->reader->cacheex.maxhop_lg = buf[5];
|
---|
242 | }
|
---|
243 | break;
|
---|
244 | // aio-version
|
---|
245 | case 32:
|
---|
246 | if(cl->typ == 'c' && cl->account->cacheex.mode > 0)
|
---|
247 | {
|
---|
248 | char *ofs = (char *)buf + i + 4;
|
---|
249 | cs_strncpy(cl->account->cacheex.aio_version, ofs, sizeof(cl->account->cacheex.aio_version));
|
---|
250 | }
|
---|
251 | else if(cl->typ == 'p' && cl->reader->cacheex.mode > 0)
|
---|
252 | {
|
---|
253 | char *ofs = (char *)buf + i + 4;
|
---|
254 | cs_strncpy(cl->reader->cacheex.aio_version, ofs, sizeof(cl->reader->cacheex.aio_version));
|
---|
255 | }
|
---|
256 | break;
|
---|
257 | // lg_only_tab caid:prov1[,provN][;caid:prov]
|
---|
258 | case 64: ;
|
---|
259 | memset(&lgonly_tab, 0, sizeof(lgonly_tab));
|
---|
260 |
|
---|
261 | if(cl->typ == 'c' && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1))
|
---|
262 | {
|
---|
263 | lgonly_tab = &cl->account->cacheex.lg_only_tab;
|
---|
264 | }
|
---|
265 | else if(cl->typ == 'p' && cl->reader->cacheex.mode == 3)
|
---|
266 | {
|
---|
267 | lgonly_tab = &cl->reader->cacheex.lg_only_tab;
|
---|
268 | }
|
---|
269 |
|
---|
270 | filter_count = buf[i+4];
|
---|
271 | i += 5;
|
---|
272 |
|
---|
273 | // remotesettings enabled - replace local settings
|
---|
274 | if(cfg.cacheex_lg_only_remote_settings ||
|
---|
275 | (
|
---|
276 | (cl->typ == 'c' && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1) && cl->account->cacheex.lg_only_remote_settings)
|
---|
277 | || (cl->typ == 'p' && cl->reader->cacheex.mode == 3 && cl->reader->cacheex.lg_only_remote_settings)
|
---|
278 | || !lgonly_tab->nfilts
|
---|
279 | )
|
---|
280 | )
|
---|
281 | {
|
---|
282 | ftab_clear(lgonly_tab);
|
---|
283 |
|
---|
284 | for(j = 0; j < filter_count; j++)
|
---|
285 | {
|
---|
286 | FILTER d;
|
---|
287 | memset(&d, 0, sizeof(d));
|
---|
288 |
|
---|
289 | d.caid = b2i(2, buf + i);
|
---|
290 | i += 2;
|
---|
291 |
|
---|
292 | d.nprids = b2i(1, buf + i);
|
---|
293 | i += 1;
|
---|
294 |
|
---|
295 | for(k=0; k < d.nprids; k++)
|
---|
296 | {
|
---|
297 | d.prids[k] = b2i(3, buf + i);
|
---|
298 | i += 3;
|
---|
299 | }
|
---|
300 | ftab_add(lgonly_tab, &d);
|
---|
301 |
|
---|
302 | }
|
---|
303 | }
|
---|
304 | // remotesettings disabled - write additional remote-caid/provids received
|
---|
305 | else
|
---|
306 | {
|
---|
307 | for(j = 0; j < filter_count; j++)
|
---|
308 | {
|
---|
309 | FILTER d;
|
---|
310 | memset(&d, 0, sizeof(d));
|
---|
311 |
|
---|
312 | d.caid = b2i(2, buf + i);
|
---|
313 | i += 2;
|
---|
314 |
|
---|
315 | d.nprids = b2i(1, buf + i);
|
---|
316 | i += 1;
|
---|
317 |
|
---|
318 | for(k=0; k < d.nprids; k++)
|
---|
319 | {
|
---|
320 | d.prids[k] = b2i(3, buf + i);
|
---|
321 | i += 3;
|
---|
322 |
|
---|
323 | if(!chk_ident_filter(d.caid, d.prids[k], lgonly_tab))
|
---|
324 | {
|
---|
325 | cs_log_dbg(D_CACHEEX, "%04X:%06X not found in local settings - adding them", d.caid, d.prids[k]);
|
---|
326 |
|
---|
327 | for(l = rc = 0; (!rc) && (l < lgonly_tab->nfilts); l++)
|
---|
328 | {
|
---|
329 | if(lgonly_tab->filts[l].caid == d.caid)
|
---|
330 | {
|
---|
331 | rc = 1;
|
---|
332 |
|
---|
333 | if(lgonly_tab->filts[l].nprids+1 <= CS_MAXPROV)
|
---|
334 | {
|
---|
335 | lgonly_tab->filts[l].prids[lgonly_tab->filts[l].nprids] = d.prids[k];
|
---|
336 | lgonly_tab->filts[l].nprids++;
|
---|
337 | }
|
---|
338 | else
|
---|
339 | {
|
---|
340 | cs_log_dbg(D_CACHEEX, "error: cacheex_lg_only_tab -> max. number of providers reached");
|
---|
341 | }
|
---|
342 | }
|
---|
343 | }
|
---|
344 | if(!rc)
|
---|
345 | {
|
---|
346 | ftab_add(lgonly_tab, &d);
|
---|
347 | }
|
---|
348 | }
|
---|
349 | }
|
---|
350 | }
|
---|
351 | }
|
---|
352 | break;
|
---|
353 | default:
|
---|
354 | return;
|
---|
355 | }
|
---|
356 | }
|
---|
357 |
|
---|
358 | void cc_cacheex_feature_trigger(struct s_client *cl, int32_t feature, uint8_t mode)
|
---|
359 | {
|
---|
360 | // size: (feature-bitfield & mask: 2) + payload-size: 2 + feature-payload :x
|
---|
361 | uint16_t size = 2 + 2;
|
---|
362 | int i = 0;
|
---|
363 | uint8_t j;
|
---|
364 | uint8_t payload[MAX_ECM_SIZE-size];
|
---|
365 | memset(payload, 0, sizeof(payload));
|
---|
366 |
|
---|
367 | switch(feature)
|
---|
368 | {
|
---|
369 | FTAB *lgonly_tab;
|
---|
370 | // set localgenerated only
|
---|
371 | case 1:
|
---|
372 | // bitfield
|
---|
373 | i2b_buf(2, feature, payload + i);
|
---|
374 | i += 2;
|
---|
375 | // payload-size
|
---|
376 | i2b_buf(2, 1, payload + i);
|
---|
377 | i += 2;
|
---|
378 |
|
---|
379 | size += 1;
|
---|
380 |
|
---|
381 | // set payload
|
---|
382 | if(mode == 2)
|
---|
383 | {
|
---|
384 | if(cl->reader->cacheex.localgenerated_only_in)
|
---|
385 | payload[i] = cl->reader->cacheex.localgenerated_only_in;
|
---|
386 | else
|
---|
387 | payload[i] = cfg.cacheex_localgenerated_only_in;
|
---|
388 | i += 1;
|
---|
389 | }
|
---|
390 | else if(mode == 3)
|
---|
391 | {
|
---|
392 | if(cl->account->cacheex.localgenerated_only_in)
|
---|
393 | payload[i] = cl->account->cacheex.localgenerated_only_in;
|
---|
394 | else
|
---|
395 | payload[i] = cfg.cacheex_localgenerated_only_in;
|
---|
396 | i += 1;
|
---|
397 | }
|
---|
398 |
|
---|
399 | break;
|
---|
400 | // set localgenerated only caidtab; cx-aio < 9.2.6-04
|
---|
401 | case 2: ;
|
---|
402 | if(mode == 2)
|
---|
403 | {
|
---|
404 | lgonly_tab = &cl->reader->cacheex.lg_only_in_tab;
|
---|
405 | if(!lgonly_tab->nfilts)
|
---|
406 | lgonly_tab = &cfg.cacheex_lg_only_in_tab;
|
---|
407 | }
|
---|
408 | else if(mode == 3)
|
---|
409 | {
|
---|
410 | lgonly_tab = &cl->account->cacheex.lg_only_in_tab;
|
---|
411 | if(!lgonly_tab->nfilts)
|
---|
412 | lgonly_tab = &cfg.cacheex_lg_only_in_tab;
|
---|
413 | }
|
---|
414 | else
|
---|
415 | {
|
---|
416 | return;
|
---|
417 | }
|
---|
418 |
|
---|
419 | size += (lgonly_tab->nfilts * 2 + 1);
|
---|
420 | if(size < 32)
|
---|
421 | size = 32;
|
---|
422 |
|
---|
423 | // bitfield
|
---|
424 | i2b_buf(2, feature, payload + i);
|
---|
425 | i += 2;
|
---|
426 | // payload-size
|
---|
427 | if((lgonly_tab->nfilts * 2 + 1) > (int)sizeof(payload))
|
---|
428 | {
|
---|
429 | cs_log_dbg(D_CACHEEX, "ERROR: too much localgenerated only caidtab-entries (max. 255)");
|
---|
430 | return;
|
---|
431 | }
|
---|
432 | i2b_buf(2, (lgonly_tab->nfilts * 2 + 1), payload + i); // n * caid + ctnum
|
---|
433 | i += 2;
|
---|
434 | // set payload
|
---|
435 | if(lgonly_tab->nfilts > 255)
|
---|
436 | {
|
---|
437 | cs_log_dbg(D_CACHEEX, "ERROR: too much localgenerated only caidtab-entries (max. 255)");
|
---|
438 | return;
|
---|
439 | }
|
---|
440 | payload[i] = lgonly_tab->nfilts;
|
---|
441 | i += 1;
|
---|
442 |
|
---|
443 | for(j = 0; j < lgonly_tab->nfilts; j++)
|
---|
444 | {
|
---|
445 | FILTER *d = &lgonly_tab->filts[j];
|
---|
446 | if(d->caid)
|
---|
447 | {
|
---|
448 | i2b_buf(2, d->caid, payload + i);
|
---|
449 | i += 2;
|
---|
450 | }
|
---|
451 | else
|
---|
452 | {
|
---|
453 | continue;
|
---|
454 | }
|
---|
455 | }
|
---|
456 | break;
|
---|
457 | // cacchex_ecm_filter extendend
|
---|
458 | case 4: ;
|
---|
459 | CECSPVALUETAB *filter;
|
---|
460 | if(mode == 2)
|
---|
461 | {
|
---|
462 | filter = &cl->reader->cacheex.filter_caidtab;
|
---|
463 | // if not set, use global settings
|
---|
464 | if(cl->reader->cacheex.filter_caidtab.cevnum == 0 && cfg.cacheex_filter_caidtab.cevnum > 0)
|
---|
465 | filter = &cfg.cacheex_filter_caidtab;
|
---|
466 | // if aio, use global aio settings
|
---|
467 | if(cl->reader->cacheex.filter_caidtab.cevnum == 0 && cfg.cacheex_filter_caidtab_aio.cevnum > 0 && cl->cacheex_aio_checked && (cl->reader->cacheex.feature_bitfield & 4))
|
---|
468 | filter = &cfg.cacheex_filter_caidtab_aio;
|
---|
469 | }
|
---|
470 | else if(mode == 3)
|
---|
471 | {
|
---|
472 | filter = &cl->account->cacheex.filter_caidtab;
|
---|
473 | // if not set, use global settings
|
---|
474 | if(cl->account->cacheex.filter_caidtab.cevnum == 0 && cfg.cacheex_filter_caidtab.cevnum > 0)
|
---|
475 | filter = &cfg.cacheex_filter_caidtab;
|
---|
476 | // if aio, use global aio settings
|
---|
477 | if(cl->account->cacheex.filter_caidtab.cevnum == 0 && cfg.cacheex_filter_caidtab_aio.cevnum > 0 && cl->cacheex_aio_checked && (cl->account->cacheex.feature_bitfield & 4))
|
---|
478 | filter = &cfg.cacheex_filter_caidtab_aio;
|
---|
479 | }
|
---|
480 | else
|
---|
481 | {
|
---|
482 | return;
|
---|
483 | }
|
---|
484 |
|
---|
485 | size += (filter->cevnum * 9 + 1);
|
---|
486 |
|
---|
487 | // bitfield
|
---|
488 | i2b_buf(2, feature, payload + i);
|
---|
489 | i += 2;
|
---|
490 | // payload-size
|
---|
491 | if((filter->cevnum * 9 + 1) > (int)sizeof(payload))
|
---|
492 | {
|
---|
493 | cs_log_dbg(D_CACHEEX, "ERROR: to much cacheex_ecm_filter-entries (max. 63), only 30 default cccam-filters sent");
|
---|
494 | return;
|
---|
495 | }
|
---|
496 | i2b_buf(2, (filter->cevnum * 9 + 1), payload + i); // n * (caid2,mask2,provid3,srvid2) + ctnum1
|
---|
497 | i += 2;
|
---|
498 | // set payload
|
---|
499 | payload[i] = filter->cevnum;
|
---|
500 | i += 1;
|
---|
501 |
|
---|
502 | for(j = 0; j < filter->cevnum; j++)
|
---|
503 | {
|
---|
504 | CECSPVALUETAB_DATA *d = &filter->cevdata[j];
|
---|
505 | if(d->caid)
|
---|
506 | {
|
---|
507 | i2b_buf(2, d->caid, payload + i);
|
---|
508 | i += 2;
|
---|
509 | }
|
---|
510 | if(d->cmask)
|
---|
511 | {
|
---|
512 | i2b_buf(2, d->cmask, payload + i);
|
---|
513 | }
|
---|
514 | i += 2;
|
---|
515 |
|
---|
516 | if(d->prid)
|
---|
517 | {
|
---|
518 | i2b_buf(3, d->prid, payload + i);
|
---|
519 | }
|
---|
520 | i += 3;
|
---|
521 |
|
---|
522 | if(d->srvid)
|
---|
523 | {
|
---|
524 | i2b_buf(2, d->srvid, payload + i);
|
---|
525 | }
|
---|
526 | i += 2;
|
---|
527 | }
|
---|
528 | break;
|
---|
529 | // no push after
|
---|
530 | case 8: ;
|
---|
531 | CAIDVALUETAB *ctab;
|
---|
532 | if(mode == 2)
|
---|
533 | {
|
---|
534 | ctab = &cl->reader->cacheex.cacheex_nopushafter_tab;
|
---|
535 | if(!ctab->cvnum)
|
---|
536 | ctab = &cfg.cacheex_nopushafter_tab;
|
---|
537 | }
|
---|
538 | else if(mode == 3)
|
---|
539 | {
|
---|
540 | ctab = &cl->account->cacheex.cacheex_nopushafter_tab;
|
---|
541 | if(!ctab->cvnum)
|
---|
542 | ctab = &cfg.cacheex_nopushafter_tab;
|
---|
543 | }
|
---|
544 | else
|
---|
545 | {
|
---|
546 | return;
|
---|
547 | }
|
---|
548 |
|
---|
549 | size += (ctab->cvnum * 4 + 1);
|
---|
550 |
|
---|
551 | // bitfield
|
---|
552 | i2b_buf(2, feature, payload + i);
|
---|
553 | i += 2;
|
---|
554 | // payload-size
|
---|
555 | if((ctab->cvnum * 4 + 1) > (int)sizeof(payload))
|
---|
556 | {
|
---|
557 | cs_log_dbg(D_CACHEEX, "ERROR: to much no push after caidtvalueab-entries (max. 255)");
|
---|
558 | return;
|
---|
559 | }
|
---|
560 | i2b_buf(2, (ctab->cvnum * 4 + 1), payload + i); // n * (caid2+value2) + cvnum
|
---|
561 | i += 2;
|
---|
562 | // set payload
|
---|
563 | if(ctab->cvnum > 255)
|
---|
564 | {
|
---|
565 | cs_log_dbg(D_CACHEEX, "ERROR: to much no push after caidtvalueab-entries (max. 255)");
|
---|
566 | return;
|
---|
567 | }
|
---|
568 | payload[i] = ctab->cvnum;
|
---|
569 | i += 1;
|
---|
570 |
|
---|
571 | for(j = 0; j < ctab->cvnum; j++)
|
---|
572 | {
|
---|
573 | CAIDVALUETAB_DATA *d = &ctab->cvdata[j];
|
---|
574 | if(d->caid)
|
---|
575 | {
|
---|
576 | i2b_buf(2, d->caid, payload + i);
|
---|
577 | i += 2;
|
---|
578 | i2b_buf(2, d->value, payload + i);
|
---|
579 | i += 2;
|
---|
580 | }
|
---|
581 | else
|
---|
582 | {
|
---|
583 | continue;
|
---|
584 | }
|
---|
585 | }
|
---|
586 | break;
|
---|
587 | // max hop
|
---|
588 | case 16:
|
---|
589 | // bitfield
|
---|
590 | i2b_buf(2, feature, payload + i);
|
---|
591 | i += 2;
|
---|
592 | // payload-size
|
---|
593 | i2b_buf(2, 2, payload + i);
|
---|
594 | i += 2;
|
---|
595 |
|
---|
596 | size += 2;
|
---|
597 |
|
---|
598 | // set payload
|
---|
599 | if(mode == 2)
|
---|
600 | {
|
---|
601 | if(cl->reader->cacheex.maxhop)
|
---|
602 | payload[i] = cl->reader->cacheex.maxhop;
|
---|
603 | else
|
---|
604 | payload[i] = 0;
|
---|
605 | i += 1;
|
---|
606 |
|
---|
607 | if(cl->reader->cacheex.maxhop_lg)
|
---|
608 | payload[i] = cl->reader->cacheex.maxhop_lg;
|
---|
609 | else
|
---|
610 | payload[i] = 0;
|
---|
611 | }
|
---|
612 | else if(mode == 3)
|
---|
613 | {
|
---|
614 | if(cl->account->cacheex.maxhop)
|
---|
615 | payload[i] = cl->account->cacheex.maxhop;
|
---|
616 | else
|
---|
617 | payload[i] = 0;
|
---|
618 | i += 1;
|
---|
619 |
|
---|
620 | if(cl->account->cacheex.maxhop_lg)
|
---|
621 | payload[i] = cl->account->cacheex.maxhop_lg;
|
---|
622 | else
|
---|
623 | payload[i] = 0;
|
---|
624 | }
|
---|
625 | break;
|
---|
626 | // aio-version
|
---|
627 | case 32: ;
|
---|
628 | uint8_t token[12];
|
---|
629 |
|
---|
630 | // bitfield
|
---|
631 | i2b_buf(2, feature, payload + i);
|
---|
632 | i += 2;
|
---|
633 | // payload-size
|
---|
634 | i2b_buf(2, sizeof(token), payload + i);
|
---|
635 | i += 2;
|
---|
636 |
|
---|
637 | size +=sizeof(token);
|
---|
638 | // set payload
|
---|
639 |
|
---|
640 | snprintf((char *)token, sizeof(token), "%s", CS_AIO_VERSION);
|
---|
641 | uint8_t *ofs = payload + i;
|
---|
642 | memcpy(ofs, token, sizeof(token));
|
---|
643 | break;
|
---|
644 | // lg_only_tab
|
---|
645 | case 64: ;
|
---|
646 | // bitfield
|
---|
647 | i2b_buf(2, feature, payload + i);
|
---|
648 | i += 2;
|
---|
649 |
|
---|
650 | if(mode == 2)
|
---|
651 | {
|
---|
652 | lgonly_tab = &cl->reader->cacheex.lg_only_in_tab;
|
---|
653 | if(!lgonly_tab->nfilts)
|
---|
654 | lgonly_tab = &cfg.cacheex_lg_only_in_tab;
|
---|
655 | }
|
---|
656 | else if(mode == 3)
|
---|
657 | {
|
---|
658 | lgonly_tab = &cl->account->cacheex.lg_only_in_tab;
|
---|
659 | if(!lgonly_tab->nfilts)
|
---|
660 | lgonly_tab = &cfg.cacheex_lg_only_in_tab;
|
---|
661 | }
|
---|
662 | else
|
---|
663 | {
|
---|
664 | return;
|
---|
665 | }
|
---|
666 |
|
---|
667 | char *cx_aio_ftab;
|
---|
668 | cx_aio_ftab = cxaio_ftab_to_buf(lgonly_tab);
|
---|
669 | if(strlen(cx_aio_ftab) > 0 && cx_aio_ftab[0] != '\0')
|
---|
670 | {
|
---|
671 | size += strlen(cx_aio_ftab) * sizeof(char);
|
---|
672 |
|
---|
673 | // payload-size
|
---|
674 | i2b_buf(2, strlen(cx_aio_ftab), payload + i);
|
---|
675 | i += 2;
|
---|
676 |
|
---|
677 | // filter counter
|
---|
678 | payload[i] = lgonly_tab->nfilts;
|
---|
679 | i += 1;
|
---|
680 |
|
---|
681 | for(j=0; j<strlen(cx_aio_ftab); j+=2)
|
---|
682 | {
|
---|
683 | payload[i] = (gethexval(cx_aio_ftab[j]) << 4) | gethexval(cx_aio_ftab[j + 1]);
|
---|
684 | i++;
|
---|
685 | }
|
---|
686 | }
|
---|
687 |
|
---|
688 | if(size < 32)
|
---|
689 | size = 32;
|
---|
690 |
|
---|
691 | NULLFREE(cx_aio_ftab);
|
---|
692 | break;
|
---|
693 | default:
|
---|
694 | return;
|
---|
695 | }
|
---|
696 | uint8_t buf[size];
|
---|
697 | memset(buf, 0, sizeof(buf));
|
---|
698 | memcpy(buf, payload, size);
|
---|
699 |
|
---|
700 | cc_cmd_send(cl, payload, size, MSG_CACHE_FEATURE_TRIGGER);
|
---|
701 | }
|
---|
702 |
|
---|
703 | void cc_cacheex_feature_request_save(struct s_client *cl, uint8_t *buf)
|
---|
704 | {
|
---|
705 | int32_t field = b2i(2, buf);
|
---|
706 |
|
---|
707 | if(cl->typ == 'c' && (cl->account->cacheex.mode == 2 ||cl->account->cacheex.mode == 1))
|
---|
708 | {
|
---|
709 | cl->account->cacheex.feature_bitfield = field;
|
---|
710 | // flag 32 => aio-version
|
---|
711 | if(cl->account->cacheex.feature_bitfield & 32)
|
---|
712 | {
|
---|
713 | cc_cacheex_feature_trigger(cl, 32, 2);
|
---|
714 | }
|
---|
715 | }
|
---|
716 |
|
---|
717 | if(cl->typ == 'p' && cl->reader->cacheex.mode == 3)
|
---|
718 | {
|
---|
719 | cl->reader->cacheex.feature_bitfield = field;
|
---|
720 | // flag 32 => aio-version
|
---|
721 | if(cl->reader->cacheex.feature_bitfield & 32)
|
---|
722 | {
|
---|
723 | cc_cacheex_feature_trigger(cl, 32, 3);
|
---|
724 | }
|
---|
725 | }
|
---|
726 |
|
---|
727 | if(cl->typ == 'c' && cl->account->cacheex.mode == 3)
|
---|
728 | {
|
---|
729 | struct s_auth *acc = cl->account;
|
---|
730 | if(acc)
|
---|
731 | {
|
---|
732 | acc->cacheex.feature_bitfield = field;
|
---|
733 | // process feature-specific actions based on feature_bitfield received
|
---|
734 |
|
---|
735 | // flag 1 => set localgenerated only flag
|
---|
736 | if(acc->cacheex.feature_bitfield & 1)
|
---|
737 | {
|
---|
738 | cc_cacheex_feature_trigger(cl, 1, 3);
|
---|
739 | }
|
---|
740 | // flag 2 => set localgenerated only caids flag
|
---|
741 | if(acc->cacheex.feature_bitfield & 2 && !(acc->cacheex.feature_bitfield & 64))
|
---|
742 | {
|
---|
743 | cc_cacheex_feature_trigger(cl, 2, 3);
|
---|
744 | }
|
---|
745 | // flag 4 => set cacheex_ecm_filter (extended)
|
---|
746 | if(acc->cacheex.feature_bitfield & 4)
|
---|
747 | {
|
---|
748 | cc_cacheex_feature_trigger(cl, 4, 3);
|
---|
749 | }
|
---|
750 | // flag 8 => np push after caids
|
---|
751 | if(acc->cacheex.feature_bitfield & 8)
|
---|
752 | {
|
---|
753 | cc_cacheex_feature_trigger(cl, 8, 3);
|
---|
754 | }
|
---|
755 | // flag 16 => maxhop
|
---|
756 | if(acc->cacheex.feature_bitfield & 16)
|
---|
757 | {
|
---|
758 | cc_cacheex_feature_trigger(cl, 16, 3);
|
---|
759 | }
|
---|
760 | // flag 32 => aio-version
|
---|
761 | if(acc->cacheex.feature_bitfield & 32)
|
---|
762 | {
|
---|
763 | cc_cacheex_feature_trigger(cl, 32, 3);
|
---|
764 | }
|
---|
765 | // flag 64 => lg_only_tab
|
---|
766 | if(acc->cacheex.feature_bitfield & 64)
|
---|
767 | {
|
---|
768 | cc_cacheex_feature_trigger(cl, 64, 3);
|
---|
769 | }
|
---|
770 | }
|
---|
771 | else
|
---|
772 | {
|
---|
773 | cs_log_dbg(D_CACHEEX, "feature_bitfield save failed - cl, %s", username(cl));
|
---|
774 | }
|
---|
775 | }
|
---|
776 | else if(cl->typ == 'p' && (cl->reader->cacheex.mode == 2 || cl->reader->cacheex.mode == 1))
|
---|
777 | {
|
---|
778 | struct s_reader *rdr = cl->reader;
|
---|
779 | if(rdr)
|
---|
780 | {
|
---|
781 | rdr->cacheex.feature_bitfield = field;
|
---|
782 | // process feature-specific actions
|
---|
783 |
|
---|
784 | // flag 1 => set localgenerated_only; cause of rdr->cacheex.localgenerated_only_in is set
|
---|
785 | if(rdr->cacheex.feature_bitfield & 1)
|
---|
786 | {
|
---|
787 | cc_cacheex_feature_trigger(cl, 1, 2);
|
---|
788 | }
|
---|
789 |
|
---|
790 | // flag 2 => set localgenerated_only_caidtab; cause of rdr->cacheex.localgenerated_only_in_caidtab is set
|
---|
791 | if(rdr->cacheex.feature_bitfield & 2 && !(rdr->cacheex.feature_bitfield & 64))
|
---|
792 | {
|
---|
793 | cc_cacheex_feature_trigger(cl, 2, 2);
|
---|
794 | }
|
---|
795 |
|
---|
796 | // flag 4 => set cacchex_ecm_filter extendend
|
---|
797 | if(rdr->cacheex.feature_bitfield & 4)
|
---|
798 | {
|
---|
799 | cc_cacheex_feature_trigger(cl, 4, 2);
|
---|
800 | }
|
---|
801 |
|
---|
802 | // flag 8 => np push after caids
|
---|
803 | if(rdr->cacheex.feature_bitfield & 8)
|
---|
804 | {
|
---|
805 | cc_cacheex_feature_trigger(cl, 8, 2);
|
---|
806 | }
|
---|
807 | // flag 16 => maxhop
|
---|
808 | if(rdr->cacheex.feature_bitfield & 16)
|
---|
809 | {
|
---|
810 | cc_cacheex_feature_trigger(cl, 16, 2);
|
---|
811 | }
|
---|
812 | // flag 32 => aio-version
|
---|
813 | if(rdr->cacheex.feature_bitfield & 32)
|
---|
814 | {
|
---|
815 | cc_cacheex_feature_trigger(cl, 32, 2);
|
---|
816 | }
|
---|
817 | // flag 64 => lg_only_tab
|
---|
818 | if(rdr->cacheex.feature_bitfield & 64)
|
---|
819 | {
|
---|
820 | cc_cacheex_feature_trigger(cl, 64, 2);
|
---|
821 | }
|
---|
822 | }
|
---|
823 | else
|
---|
824 | {
|
---|
825 | cs_log_dbg(D_CACHEEX, "feature_bitfield save failed - rdr, %s", username(cl));
|
---|
826 | }
|
---|
827 | }
|
---|
828 | }
|
---|
829 |
|
---|
830 | void cc_cacheex_feature_request_reply(struct s_client *cl)
|
---|
831 | {
|
---|
832 | int32_t size = 2;
|
---|
833 | uint8_t rbuf[size];
|
---|
834 |
|
---|
835 | i2b_buf(2, CACHEEX_FEATURES, rbuf);
|
---|
836 | cc_cmd_send(cl, rbuf, size, MSG_CACHE_FEATURE_EXCHANGE_REPLY);
|
---|
837 | }
|
---|
838 |
|
---|
839 | void cc_cacheex_feature_request(struct s_client *cl)
|
---|
840 | {
|
---|
841 | int32_t size = 2;
|
---|
842 | uint8_t rbuf[2];
|
---|
843 | i2b_buf(2, CACHEEX_FEATURES, rbuf);
|
---|
844 | cc_cmd_send(cl, rbuf, size, MSG_CACHE_FEATURE_EXCHANGE);
|
---|
845 | }
|
---|
846 |
|
---|
847 | void cc_cacheex_filter_out(struct s_client *cl)
|
---|
848 | {
|
---|
849 | struct s_reader *rdr = (cl->typ == 'c') ? NULL : cl->reader;
|
---|
850 | int i = 0, j;
|
---|
851 | CECSPVALUETAB *filter;
|
---|
852 | int32_t size = 482; // minimal size, keep it <= 512 for max UDP packet size without fragmentation
|
---|
853 | uint8_t buf[482];
|
---|
854 | memset(buf, 0, sizeof(buf));
|
---|
855 |
|
---|
856 | if(rdr && (rdr->cacheex.mode == 2 || rdr->cacheex.mode == 1)) // mode == 2 send filters from rdr
|
---|
857 | {
|
---|
858 | filter = &rdr->cacheex.filter_caidtab;
|
---|
859 | // if not set, use global settings
|
---|
860 | if(rdr->cacheex.filter_caidtab.cevnum == 0 && cfg.cacheex_filter_caidtab.cevnum > 0)
|
---|
861 | filter = &cfg.cacheex_filter_caidtab;
|
---|
862 | }
|
---|
863 | else if(cl->typ == 'c' && cl->account && cl->account->cacheex.mode == 3) // mode == 3 send filters from acc
|
---|
864 | {
|
---|
865 | filter = &cl->account->cacheex.filter_caidtab;
|
---|
866 | // if not set, use global settings
|
---|
867 | if(cl->account->cacheex.filter_caidtab.cevnum == 0 && cfg.cacheex_filter_caidtab.cevnum > 0)
|
---|
868 | filter = &cfg.cacheex_filter_caidtab;
|
---|
869 | }
|
---|
870 | else
|
---|
871 | {
|
---|
872 | return;
|
---|
873 | }
|
---|
874 |
|
---|
875 | i2b_buf(2, filter->cevnum, buf + i);
|
---|
876 | i += 2;
|
---|
877 |
|
---|
878 | int32_t max_filters = 30;
|
---|
879 | for(j = 0; j < max_filters; j++)
|
---|
880 | {
|
---|
881 | if(filter->cevnum > j)
|
---|
882 | {
|
---|
883 | CECSPVALUETAB_DATA *d = &filter->cevdata[j];
|
---|
884 | i2b_buf(4, d->caid, buf + i);
|
---|
885 | }
|
---|
886 | i += 4;
|
---|
887 | }
|
---|
888 |
|
---|
889 | for(j = 0; j < max_filters; j++)
|
---|
890 | {
|
---|
891 | if(filter->cevnum > j)
|
---|
892 | {
|
---|
893 | CECSPVALUETAB_DATA *d = &filter->cevdata[j];
|
---|
894 | i2b_buf(4, d->cmask, buf + i);
|
---|
895 | }
|
---|
896 | i += 4;
|
---|
897 | }
|
---|
898 |
|
---|
899 | for(j = 0; j < max_filters; j++)
|
---|
900 | {
|
---|
901 | if(filter->cevnum > j)
|
---|
902 | {
|
---|
903 | CECSPVALUETAB_DATA *d = &filter->cevdata[j];
|
---|
904 | i2b_buf(4, d->prid, buf + i);
|
---|
905 | }
|
---|
906 | i += 4;
|
---|
907 | }
|
---|
908 |
|
---|
909 | for(j = 0; j < max_filters; j++)
|
---|
910 | {
|
---|
911 | if(filter->cevnum > j)
|
---|
912 | {
|
---|
913 | CECSPVALUETAB_DATA *d = &filter->cevdata[j];
|
---|
914 | i2b_buf(4, d->srvid, buf + i);
|
---|
915 | }
|
---|
916 | i += 4;
|
---|
917 | }
|
---|
918 |
|
---|
919 | cs_log_dbg(D_CACHEEX, "cacheex: sending push filter request to %s", username(cl));
|
---|
920 | cc_cmd_send(cl, buf, size, MSG_CACHE_FILTER);
|
---|
921 | }
|
---|
922 |
|
---|
923 | void cc_cacheex_filter_in(struct s_client *cl, uint8_t *buf)
|
---|
924 | {
|
---|
925 | struct s_reader *rdr = (cl->typ == 'c') ? NULL : cl->reader;
|
---|
926 | int i = 0, j;
|
---|
927 | int32_t caid, cmask, provid, srvid;
|
---|
928 | CECSPVALUETAB *filter;
|
---|
929 |
|
---|
930 | // mode == 2 write filters to acc
|
---|
931 | if(cl->typ == 'c' && cl->account && (cl->account->cacheex.mode == 2 || cl->account->cacheex.mode == 1) && cl->account->cacheex.allow_filter == 1)
|
---|
932 | {
|
---|
933 | filter = &cl->account->cacheex.filter_caidtab;
|
---|
934 | }
|
---|
935 | else if(rdr && rdr->cacheex.mode == 3 && rdr->cacheex.allow_filter == 1) // mode == 3 write filters to rdr
|
---|
936 | {
|
---|
937 | filter = &rdr->cacheex.filter_caidtab;
|
---|
938 | }
|
---|
939 | else
|
---|
940 | {
|
---|
941 | return;
|
---|
942 | }
|
---|
943 |
|
---|
944 | cecspvaluetab_clear(filter);
|
---|
945 | i += 2;
|
---|
946 |
|
---|
947 | int32_t max_filters = 30;
|
---|
948 | for(j = 0; j < max_filters; j++)
|
---|
949 | {
|
---|
950 | caid = b2i(4, buf + i);
|
---|
951 | if(caid > 0)
|
---|
952 | {
|
---|
953 | CECSPVALUETAB_DATA d;
|
---|
954 | memset(&d, 0, sizeof(d));
|
---|
955 | d.caid = b2i(4, buf + i);
|
---|
956 | cecspvaluetab_add(filter, &d);
|
---|
957 | }
|
---|
958 | i += 4;
|
---|
959 | }
|
---|
960 |
|
---|
961 | for(j = 0; j < max_filters; j++)
|
---|
962 | {
|
---|
963 | cmask = b2i(4, buf + i);
|
---|
964 | if(j < filter->cevnum)
|
---|
965 | {
|
---|
966 | CECSPVALUETAB_DATA *d = &filter->cevdata[j];
|
---|
967 | d->cmask = cmask;
|
---|
968 | }
|
---|
969 | i += 4;
|
---|
970 | }
|
---|
971 |
|
---|
972 | for(j = 0; j < max_filters; j++)
|
---|
973 | {
|
---|
974 | provid = b2i(4, buf + i);
|
---|
975 | if(j < filter->cevnum)
|
---|
976 | {
|
---|
977 | CECSPVALUETAB_DATA *d = &filter->cevdata[j];
|
---|
978 | d->prid = provid;
|
---|
979 | }
|
---|
980 | i += 4;
|
---|
981 | }
|
---|
982 |
|
---|
983 | for(j = 0; j < max_filters; j++)
|
---|
984 | {
|
---|
985 | srvid = b2i(4, buf + i);
|
---|
986 | if(j < filter->cevnum)
|
---|
987 | {
|
---|
988 | CECSPVALUETAB_DATA *d = &filter->cevdata[j];
|
---|
989 | d->srvid = srvid;
|
---|
990 | }
|
---|
991 | i += 4;
|
---|
992 | }
|
---|
993 |
|
---|
994 | cs_log_dbg(D_CACHEEX, "cacheex: received push filter request from %s", username(cl));
|
---|
995 | }
|
---|
996 |
|
---|
997 | static int32_t cc_cacheex_push_chk(struct s_client *cl, struct ecm_request_t *er)
|
---|
998 | {
|
---|
999 | struct cc_data *cc = cl->cc;
|
---|
1000 | if(chk_is_null_nodeid(cc->peer_node_id,8))
|
---|
1001 | {
|
---|
1002 | cs_log_dbg(D_CACHEEX, "cacheex: NO peer_node_id got yet, skip!");
|
---|
1003 | return 0;
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | if(
|
---|
1007 | ll_count(er->csp_lastnodes) >= cacheex_maxhop(cl) // check max 10 nodes to push
|
---|
1008 | && (!er->localgenerated || (er->localgenerated && (ll_count(er->csp_lastnodes) >= cacheex_maxhop_lg(cl)))) // check maxhop_lg if cw is lg-flagged
|
---|
1009 | )
|
---|
1010 | {
|
---|
1011 | cs_log_dbg(D_CACHEEX, "cacheex: nodelist reached %d nodes(non-lg) or reached %d nodes(lg), no push", cacheex_maxhop(cl), cacheex_maxhop_lg(cl));
|
---|
1012 | return 0;
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 | uint8_t *remote_node = cc->peer_node_id;
|
---|
1016 |
|
---|
1017 | // search existing peer nodes
|
---|
1018 | LL_LOCKITER *li = ll_li_create(er->csp_lastnodes, 0);
|
---|
1019 | uint8_t *node;
|
---|
1020 | while((node = ll_li_next(li)))
|
---|
1021 | {
|
---|
1022 | cs_log_dbg(D_CACHEEX, "cacheex: check node %" PRIu64 "X == %" PRIu64 "X ?",
|
---|
1023 | cacheex_node_id(node), cacheex_node_id(remote_node));
|
---|
1024 |
|
---|
1025 | if(memcmp(node, remote_node, 8) == 0)
|
---|
1026 | {
|
---|
1027 | break;
|
---|
1028 | }
|
---|
1029 | }
|
---|
1030 | ll_li_destroy(li);
|
---|
1031 |
|
---|
1032 | // node found, so we got it from there, do not push
|
---|
1033 | if(node)
|
---|
1034 | {
|
---|
1035 | cs_log_dbg(D_CACHEEX, "cacheex: node %" PRIu64 "X found in list => skip push!", cacheex_node_id(node));
|
---|
1036 | return 0;
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | if(!cl->cc)
|
---|
1040 | {
|
---|
1041 | if(cl->reader && !cl->reader->tcp_connected)
|
---|
1042 | {
|
---|
1043 | cc_cli_connect(cl);
|
---|
1044 | }
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 | if(!cc || !cl->udp_fd)
|
---|
1048 | {
|
---|
1049 | cs_log_dbg(D_CACHEEX, "cacheex: not connected %s -> no push", username(cl));
|
---|
1050 | return 0;
|
---|
1051 | }
|
---|
1052 |
|
---|
1053 | // check if cw is already pushed
|
---|
1054 | if(check_is_pushed(er->cw_cache, cl))
|
---|
1055 | {
|
---|
1056 | return 0;
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | return 1;
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | static int32_t cc_cacheex_push_out(struct s_client *cl, struct ecm_request_t *er)
|
---|
1063 | {
|
---|
1064 | int8_t rc = (er->rc < E_NOTFOUND) ? E_FOUND : er->rc;
|
---|
1065 |
|
---|
1066 | if(rc != E_FOUND && rc != E_UNHANDLED)
|
---|
1067 | {
|
---|
1068 | return -1; // Maybe later we could support other rcs
|
---|
1069 | }
|
---|
1070 |
|
---|
1071 | if(cl->reader)
|
---|
1072 | {
|
---|
1073 | if(!cl->reader->tcp_connected)
|
---|
1074 | {
|
---|
1075 | cc_cli_connect(cl);
|
---|
1076 | }
|
---|
1077 | }
|
---|
1078 |
|
---|
1079 | struct cc_data *cc = cl->cc;
|
---|
1080 | if(!cc || !cl->udp_fd)
|
---|
1081 | {
|
---|
1082 | cs_log_dbg(D_CACHEEX, "cacheex: not connected %s -> no push", username(cl));
|
---|
1083 | return (-1);
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 | uint32_t size = sizeof(er->ecmd5) + sizeof(er->csp_hash) + sizeof(er->cw) + sizeof(uint8_t) +
|
---|
1087 | (ll_count(er->csp_lastnodes) + 1) * 8 + sizeof(uint8_t);
|
---|
1088 |
|
---|
1089 | uint8_t *buf;
|
---|
1090 | if(!cs_malloc(&buf, size + 20)) // camd35_send() adds +20
|
---|
1091 | {
|
---|
1092 | return -1;
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 | // build ecm message
|
---|
1096 | //buf[0] = er->caid >> 8;
|
---|
1097 | //buf[1] = er->caid & 0xff;
|
---|
1098 | //buf[2] = er->prid >> 24;
|
---|
1099 | //buf[3] = er->prid >> 16;
|
---|
1100 | //buf[4] = er->prid >> 8;
|
---|
1101 | //buf[5] = er->prid & 0xff;
|
---|
1102 | //buf[10] = er->srvid >> 8;
|
---|
1103 | //buf[11] = er->srvid & 0xff;
|
---|
1104 | buf[12] = (sizeof(er->ecmd5) + sizeof(er->csp_hash) + sizeof(er->cw)) & 0xff;
|
---|
1105 | buf[13] = (sizeof(er->ecmd5) + sizeof(er->csp_hash) + sizeof(er->cw)) >> 8;
|
---|
1106 | //buf[12] = 0;
|
---|
1107 | //buf[13] = 0;
|
---|
1108 | buf[14] = rc;
|
---|
1109 |
|
---|
1110 | i2b_buf(2, er->caid, buf + 0);
|
---|
1111 | i2b_buf(4, er->prid, buf + 2);
|
---|
1112 | i2b_buf(2, er->srvid, buf + 10);
|
---|
1113 |
|
---|
1114 | if(er->cwc_cycletime && er->cwc_next_cw_cycle < 2)
|
---|
1115 | {
|
---|
1116 | buf[18] = er->cwc_cycletime; // contains cwc stage3 cycletime
|
---|
1117 |
|
---|
1118 | if(er->cwc_next_cw_cycle == 1)
|
---|
1119 | {
|
---|
1120 | buf[18] = (buf[18] | 0x80); // set bit 8 to high
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 | if(cl->typ == 'c' && cl->account && cl->account->cacheex.mode)
|
---|
1124 | {
|
---|
1125 | cl->account->cwc_info++;
|
---|
1126 | }
|
---|
1127 | else if((cl->typ == 'p' || cl->typ == 'r') && (cl->reader && cl->reader->cacheex.mode))
|
---|
1128 | {
|
---|
1129 | cl->cwc_info++;
|
---|
1130 | }
|
---|
1131 |
|
---|
1132 | cs_log_dbg(D_CWC, "CWC (CE) push to %s cycletime: %isek - nextcwcycle: CW%i for %04X@%06X:%04X",
|
---|
1133 | username(cl), er->cwc_cycletime, er->cwc_next_cw_cycle, er->caid, er->prid, er->srvid);
|
---|
1134 | }
|
---|
1135 |
|
---|
1136 | buf[19] = er->ecm[0] != 0x80 && er->ecm[0] != 0x81 ? 0 : er->ecm[0];
|
---|
1137 |
|
---|
1138 | uint8_t *ofs = buf + 20;
|
---|
1139 |
|
---|
1140 | // write oscam ecmd5
|
---|
1141 | memcpy(ofs, er->ecmd5, sizeof(er->ecmd5)); // 16
|
---|
1142 | ofs += sizeof(er->ecmd5);
|
---|
1143 |
|
---|
1144 | // write csp hashcode
|
---|
1145 | i2b_buf(4, CSP_HASH_SWAP(er->csp_hash), ofs);
|
---|
1146 | ofs += 4;
|
---|
1147 |
|
---|
1148 | // write cw
|
---|
1149 | memcpy(ofs, er->cw, sizeof(er->cw)); // 16
|
---|
1150 | ofs += sizeof(er->cw);
|
---|
1151 |
|
---|
1152 | // write node count
|
---|
1153 | *ofs = ll_count(er->csp_lastnodes) + 1;
|
---|
1154 | ofs++;
|
---|
1155 |
|
---|
1156 | // write own node
|
---|
1157 | memcpy(ofs, cc->node_id, 8);
|
---|
1158 | ofs += 8;
|
---|
1159 |
|
---|
1160 | // write other nodes
|
---|
1161 | LL_LOCKITER *li = ll_li_create(er->csp_lastnodes, 0);
|
---|
1162 | uint8_t *node;
|
---|
1163 | while((node = ll_li_next(li)))
|
---|
1164 | {
|
---|
1165 | memcpy(ofs, node, 8);
|
---|
1166 | ofs += 8;
|
---|
1167 | }
|
---|
1168 | ll_li_destroy(li);
|
---|
1169 |
|
---|
1170 | // add localgenerated cw-flag
|
---|
1171 | if(er->localgenerated)
|
---|
1172 | {
|
---|
1173 | *ofs = 1;
|
---|
1174 | }
|
---|
1175 | else
|
---|
1176 | {
|
---|
1177 | *ofs = 0xFF;
|
---|
1178 | }
|
---|
1179 | ofs += 1;
|
---|
1180 |
|
---|
1181 | int32_t res = cc_cmd_send(cl, buf, size + 20, MSG_CACHE_PUSH);
|
---|
1182 | if(res > 0) // cache-ex is pushing out, so no receive but last_g should be updated otherwise disconnect!
|
---|
1183 | {
|
---|
1184 | if(cl->reader)
|
---|
1185 | {
|
---|
1186 | cl->reader->last_s = cl->reader->last_g = time((time_t *)0); // correct
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | if(cl)
|
---|
1190 | {
|
---|
1191 | cl->last = time(NULL);
|
---|
1192 | }
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 | NULLFREE(buf);
|
---|
1196 | return res;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | void cc_cacheex_push_in(struct s_client *cl, uint8_t *buf)
|
---|
1200 | {
|
---|
1201 | struct cc_data *cc = cl->cc;
|
---|
1202 | ECM_REQUEST *er;
|
---|
1203 |
|
---|
1204 | if(!cc)
|
---|
1205 | {
|
---|
1206 | return;
|
---|
1207 | }
|
---|
1208 |
|
---|
1209 | if(cl->reader)
|
---|
1210 | {
|
---|
1211 | cl->reader->last_s = cl->reader->last_g = time((time_t *)0);
|
---|
1212 | }
|
---|
1213 |
|
---|
1214 | if(cl)
|
---|
1215 | {
|
---|
1216 | cl->last = time(NULL);
|
---|
1217 | }
|
---|
1218 |
|
---|
1219 | int8_t rc = buf[14];
|
---|
1220 | if(rc != E_FOUND && rc != E_UNHANDLED) // Maybe later we could support other rcs
|
---|
1221 | {
|
---|
1222 | return;
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | uint16_t size = buf[12] | (buf[13] << 8);
|
---|
1226 | if(size != sizeof(er->ecmd5) + sizeof(er->csp_hash) + sizeof(er->cw))
|
---|
1227 | {
|
---|
1228 | cs_log_dbg(D_CACHEEX, "cacheex: %s received old cash-push format! data ignored!", username(cl));
|
---|
1229 | return;
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | if(!(er = get_ecmtask()))
|
---|
1233 | {
|
---|
1234 | return;
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 | er->caid = b2i(2, buf + 0);
|
---|
1238 | er->prid = b2i(4, buf + 2);
|
---|
1239 | er->srvid = b2i(2, buf + 10);
|
---|
1240 | er->ecm[0] = buf[19] != 0x80 && buf[19] != 0x81 ? 0 : buf[19]; // odd/even byte, usefull to send it over CSP and to check cw for swapping
|
---|
1241 | er->rc = rc;
|
---|
1242 |
|
---|
1243 | er->ecmlen = 0;
|
---|
1244 |
|
---|
1245 | if(buf[18])
|
---|
1246 | {
|
---|
1247 | if(buf[18] & (0x01 << 7))
|
---|
1248 | {
|
---|
1249 | er->cwc_cycletime = (buf[18] & 0x7F); // remove bit 8 to get cycletime
|
---|
1250 | er->cwc_next_cw_cycle = 1;
|
---|
1251 | }
|
---|
1252 | else
|
---|
1253 | {
|
---|
1254 | er->cwc_cycletime = buf[18];
|
---|
1255 | er->cwc_next_cw_cycle = 0;
|
---|
1256 | }
|
---|
1257 | }
|
---|
1258 |
|
---|
1259 | uint8_t *ofs = buf + 20;
|
---|
1260 |
|
---|
1261 | // Read ecmd5
|
---|
1262 | memcpy(er->ecmd5, ofs, sizeof(er->ecmd5)); // 16
|
---|
1263 | ofs += sizeof(er->ecmd5);
|
---|
1264 |
|
---|
1265 | if(!check_cacheex_filter(cl, er))
|
---|
1266 | {
|
---|
1267 | return;
|
---|
1268 | }
|
---|
1269 |
|
---|
1270 | // check cacheex_ecm_filter
|
---|
1271 | if(check_client(cl) && cl->typ == 'p' && cl->reader && cl->reader->cacheex.mode == 2
|
---|
1272 | && ( (cl->reader->cacheex.filter_caidtab.cevnum > 0 && !chk_csp_ctab(er, &cl->reader->cacheex.filter_caidtab)) // reader cacheex_ecm_filter not matching if set
|
---|
1273 | || (cl->reader->cacheex.filter_caidtab.cevnum == 0 && (cl->reader->cacheex.feature_bitfield & 4) && cfg.cacheex_filter_caidtab_aio.cevnum > 0 && !chk_csp_ctab(er, &cfg.cacheex_filter_caidtab_aio)) // global cacheex_ecm_filter_aio not matching if set
|
---|
1274 | || (cl->reader->cacheex.filter_caidtab.cevnum == 0 && cfg.cacheex_filter_caidtab_aio.cevnum == 0 && cfg.cacheex_filter_caidtab.cevnum > 0 && !chk_csp_ctab(er, &cfg.cacheex_filter_caidtab)) // global cacheex_ecm_filter not matching if set
|
---|
1275 | )
|
---|
1276 | )
|
---|
1277 | {
|
---|
1278 | cs_log_dbg(D_CACHEEX, "cacheex: received cache not matching cacheex_ecm_filter => pushing filter again");
|
---|
1279 | cc_cacheex_filter_out(cl); // get cache != cacheex_ecm_filter, send filter again - remote restarted
|
---|
1280 | if(cl->reader->cacheex.feature_bitfield & 4)
|
---|
1281 | cc_cacheex_feature_trigger(cl, 4, 2);
|
---|
1282 | free_push_in_ecm(er);
|
---|
1283 | return;
|
---|
1284 | }
|
---|
1285 |
|
---|
1286 | if(check_client(cl) && cl->typ == 'c' && cl->account && cl->account->cacheex.mode == 3
|
---|
1287 | && ( (cl->account->cacheex.filter_caidtab.cevnum > 0 && !chk_csp_ctab(er, &cl->account->cacheex.filter_caidtab)) // account cacheex_ecm_filter not matching if set
|
---|
1288 | || (cl->account->cacheex.filter_caidtab.cevnum == 0 && (cl->account->cacheex.feature_bitfield & 4) && cfg.cacheex_filter_caidtab_aio.cevnum > 0 && !chk_csp_ctab(er, &cfg.cacheex_filter_caidtab_aio)) // global cacheex_ecm_filter_aio not matching if set
|
---|
1289 | || (cl->account->cacheex.filter_caidtab.cevnum == 0 && cfg.cacheex_filter_caidtab_aio.cevnum == 0 && cfg.cacheex_filter_caidtab.cevnum > 0 && !chk_csp_ctab(er, &cfg.cacheex_filter_caidtab)) // global cacheex_ecm_filter not matching if set
|
---|
1290 | )
|
---|
1291 | )
|
---|
1292 | {
|
---|
1293 | cs_log_dbg(D_CACHEEX, "cacheex: received cache not matching cacheex_ecm_filter => pushing filter again");
|
---|
1294 | cc_cacheex_filter_out(cl); // get cache != cacheex_ecm_filter, send filter again - remote restarted
|
---|
1295 | if(cl->account->cacheex.feature_bitfield & 4)
|
---|
1296 | cc_cacheex_feature_trigger(cl, 4, 3);
|
---|
1297 | free_push_in_ecm(er);
|
---|
1298 | return;
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | // Read csp_hash
|
---|
1302 | er->csp_hash = CSP_HASH_SWAP(b2i(4, ofs));
|
---|
1303 | ofs += 4;
|
---|
1304 |
|
---|
1305 | // Read cw
|
---|
1306 | memcpy(er->cw, ofs, sizeof(er->cw)); // 16
|
---|
1307 | ofs += sizeof(er->cw);
|
---|
1308 |
|
---|
1309 | // Read lastnode count
|
---|
1310 | uint8_t count = *ofs;
|
---|
1311 | ofs++;
|
---|
1312 |
|
---|
1313 | cs_log_dbg(D_CACHEEX, "cacheex: received %d nodes %s", (int32_t)count, username(cl));
|
---|
1314 |
|
---|
1315 | // Read lastnodes
|
---|
1316 | uint8_t *data;
|
---|
1317 | if (er)
|
---|
1318 | {
|
---|
1319 | er->csp_lastnodes = ll_create("csp_lastnodes");
|
---|
1320 | }
|
---|
1321 |
|
---|
1322 | while(count)
|
---|
1323 | {
|
---|
1324 | if(!cs_malloc(&data, 8))
|
---|
1325 | {
|
---|
1326 | break;
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 | memcpy(data, ofs, 8);
|
---|
1330 | ofs += 8;
|
---|
1331 | ll_append(er->csp_lastnodes, data);
|
---|
1332 | count--;
|
---|
1333 |
|
---|
1334 | cs_log_dbg(D_CACHEEX, "cacheex: received node %" PRIu64 "X %s", cacheex_node_id(data), username(cl));
|
---|
1335 | }
|
---|
1336 |
|
---|
1337 | if(b2i(1, ofs) == 1)
|
---|
1338 | {
|
---|
1339 | er->localgenerated = 1;
|
---|
1340 | cs_log_dbg(D_CACHEEX, "cacheex: received ECM with localgenerated flag %04X@%06X:%04X %s", er->caid, er->prid, er->srvid, username(cl));
|
---|
1341 |
|
---|
1342 | //check max nodes for lg flagged cw:
|
---|
1343 | if(ll_count(er->csp_lastnodes) > cacheex_maxhop_lg(cl))
|
---|
1344 | {
|
---|
1345 | cs_log_dbg(D_CACHEEX, "cacheex: received (lg) %d nodes (max=%d), ignored! %s", ll_count(er->csp_lastnodes), cacheex_maxhop_lg(cl), username(cl));
|
---|
1346 | free_push_in_ecm(er);
|
---|
1347 | return;
|
---|
1348 | }
|
---|
1349 | }
|
---|
1350 | // without localgenerated flag
|
---|
1351 | else
|
---|
1352 | {
|
---|
1353 | //check max nodes:
|
---|
1354 | if(ll_count(er->csp_lastnodes) > cacheex_maxhop(cl))
|
---|
1355 | {
|
---|
1356 | cs_log_dbg(D_CACHEEX, "cacheex: received %d nodes (max=%d), ignored! %s", ll_count(er->csp_lastnodes), cacheex_maxhop(cl), username(cl));
|
---|
1357 | free_push_in_ecm(er);
|
---|
1358 | return;
|
---|
1359 | }
|
---|
1360 |
|
---|
1361 | if(
|
---|
1362 | (cl->typ == 'p' && cl->reader && cl->reader->cacheex.mode == 2 && !chk_srvid_localgenerated_only_exception(er) // cx2
|
---|
1363 | && (
|
---|
1364 | // !aio
|
---|
1365 | (cl->cacheex_aio_checked && !cl->reader->cacheex.feature_bitfield
|
---|
1366 | && (
|
---|
1367 | !cfg.cacheex_lg_only_in_aio_only && !cl->reader->cacheex.lg_only_in_aio_only
|
---|
1368 | && (cfg.cacheex_localgenerated_only_in || cl->reader->cacheex.localgenerated_only_in || ((cl->reader->cacheex.feature_bitfield & 64) && (chk_lg_only(er, &cl->reader->cacheex.lg_only_in_tab) || chk_lg_only(er, &cfg.cacheex_lg_only_in_tab))) || ( !(cl->reader->cacheex.feature_bitfield & 64) && (chk_ctab_ex(er->caid, &cl->reader->cacheex.localgenerated_only_in_caidtab) || chk_ctab_ex(er->caid, &cfg.cacheex_localgenerated_only_in_caidtab))))
|
---|
1369 | )
|
---|
1370 | )
|
---|
1371 | ||
|
---|
1372 | // aio
|
---|
1373 | (cl->cacheex_aio_checked && cl->reader->cacheex.feature_bitfield
|
---|
1374 | && (
|
---|
1375 | cfg.cacheex_localgenerated_only_in || cl->reader->cacheex.localgenerated_only_in || ((cl->reader->cacheex.feature_bitfield & 64) && (chk_lg_only(er, &cl->reader->cacheex.lg_only_in_tab) || chk_lg_only(er, &cfg.cacheex_lg_only_in_tab))) || ( !(cl->reader->cacheex.feature_bitfield & 64) && (chk_ctab_ex(er->caid, &cl->reader->cacheex.localgenerated_only_in_caidtab) || chk_ctab_ex(er->caid, &cfg.cacheex_localgenerated_only_in_caidtab)))
|
---|
1376 | )
|
---|
1377 | )
|
---|
1378 | )
|
---|
1379 | )
|
---|
1380 | ||
|
---|
1381 | (cl->typ == 'c' && cl->account && cl->account->cacheex.mode == 3 && !chk_srvid_localgenerated_only_exception(er) // cx3
|
---|
1382 | && (
|
---|
1383 | // !aio
|
---|
1384 | (cl->cacheex_aio_checked && !cl->account->cacheex.feature_bitfield
|
---|
1385 | && (
|
---|
1386 | !cfg.cacheex_lg_only_in_aio_only && !cl->account->cacheex.lg_only_in_aio_only
|
---|
1387 | && (cfg.cacheex_localgenerated_only_in || cl->account->cacheex.localgenerated_only_in || ((cl->account->cacheex.feature_bitfield & 64) && (chk_lg_only(er, &cl->account->cacheex.lg_only_in_tab) || chk_lg_only(er, &cfg.cacheex_lg_only_in_tab))) || ( !(cl->account->cacheex.feature_bitfield & 64) && (chk_ctab_ex(er->caid, &cl->account->cacheex.localgenerated_only_in_caidtab) || chk_ctab_ex(er->caid, &cfg.cacheex_localgenerated_only_in_caidtab))))
|
---|
1388 | )
|
---|
1389 | )
|
---|
1390 | ||
|
---|
1391 | // aio
|
---|
1392 | (cl->cacheex_aio_checked && cl->account->cacheex.feature_bitfield
|
---|
1393 | && (
|
---|
1394 | cfg.cacheex_localgenerated_only_in || cl->account->cacheex.localgenerated_only_in || ((cl->account->cacheex.feature_bitfield & 64) && (chk_lg_only(er, &cl->account->cacheex.lg_only_in_tab) || chk_lg_only(er, &cfg.cacheex_lg_only_in_tab))) || ( !(cl->account->cacheex.feature_bitfield & 64) && (chk_ctab_ex(er->caid, &cl->account->cacheex.localgenerated_only_in_caidtab) || chk_ctab_ex(er->caid, &cfg.cacheex_localgenerated_only_in_caidtab)))
|
---|
1395 | )
|
---|
1396 | )
|
---|
1397 | )
|
---|
1398 | )
|
---|
1399 | )
|
---|
1400 | {
|
---|
1401 | cs_log_dbg(D_CACHEEX, "cacheex: drop ECM without localgenerated flag %04X@%06X:%04X %s", er->caid, er->prid, er->srvid, username(cl));
|
---|
1402 | free_push_in_ecm(er);
|
---|
1403 | return;
|
---|
1404 | }
|
---|
1405 | }
|
---|
1406 |
|
---|
1407 | // for compatibility: add peer node if no node received
|
---|
1408 | if(!ll_count(er->csp_lastnodes))
|
---|
1409 | {
|
---|
1410 | if(!cs_malloc(&data, 8))
|
---|
1411 | {
|
---|
1412 | return;
|
---|
1413 | }
|
---|
1414 |
|
---|
1415 | memcpy(data, cc->peer_node_id, 8);
|
---|
1416 | ll_append(er->csp_lastnodes, data);
|
---|
1417 | cs_log_dbg(D_CACHEEX, "cacheex: added missing remote node id %" PRIu64 "X", cacheex_node_id(data));
|
---|
1418 | }
|
---|
1419 |
|
---|
1420 | if (er->cwc_cycletime && er->cwc_next_cw_cycle < 2)
|
---|
1421 | {
|
---|
1422 | if(cl->typ == 'c' && cl->account && cl->account->cacheex.mode)
|
---|
1423 | {
|
---|
1424 | cl->account->cwc_info++;
|
---|
1425 | }
|
---|
1426 | else if((cl->typ == 'p' || cl->typ == 'r') && (cl->reader && cl->reader->cacheex.mode))
|
---|
1427 | {
|
---|
1428 | cl->cwc_info++;
|
---|
1429 | }
|
---|
1430 |
|
---|
1431 | cs_log_dbg(D_CWC, "CWC (CE) received from %s cycletime: %isek - nextcwcycle: CW%i for %04X@%06X:%04X",
|
---|
1432 | username(cl), er->cwc_cycletime, er->cwc_next_cw_cycle, er->caid, er->prid, er->srvid);
|
---|
1433 | }
|
---|
1434 |
|
---|
1435 | cacheex_add_to_cache(cl, er);
|
---|
1436 | }
|
---|
1437 |
|
---|
1438 | void cc_cacheex_module_init(struct s_module *ph)
|
---|
1439 | {
|
---|
1440 | ph->c_cache_push = cc_cacheex_push_out;
|
---|
1441 | ph->c_cache_push_chk = cc_cacheex_push_chk;
|
---|
1442 | }
|
---|
1443 |
|
---|
1444 | #endif
|
---|