Changeset 3039
- Timestamp:
- 09/12/10 01:38:07 (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-cccam.c
r3038 r3039 337 337 } 338 338 339 void free_current_cards(LLIST *current_cards) { 340 LLIST_ITR itr; 341 struct cc_current_card *c = llist_itr_init(current_cards, &itr); 342 while (c) { 343 free(c); 344 c = llist_itr_remove(&itr); 345 } 346 } 347 348 339 349 340 350 /** … … 368 378 cc_clear_auto_blocked(cc->auto_blocked); 369 379 cc->just_logged_in = 0; 380 free_current_cards(cc->current_cards); 370 381 } 371 382 } … … 380 391 eei->srvid=srvid; 381 392 llist_append(cc->extended_ecm_idx, eei); 382 cs_debug_mask(D_TRACE, "%s add extended ecm-idx: %d:%d", getprefix(), send_idx, ecm_idx);393 //cs_debug_mask(D_TRACE, "%s add extended ecm-idx: %d:%d", getprefix(), send_idx, ecm_idx); 383 394 return eei; 384 395 } … … 393 404 if (remove) 394 405 llist_itr_remove(&itr); 395 cs_debug_mask(D_TRACE, "%s get by send-idx: %d FOUND: %d",396 getprefix(), send_idx, eei->ecm_idx);406 //cs_debug_mask(D_TRACE, "%s get by send-idx: %d FOUND: %d", 407 // getprefix(), send_idx, eei->ecm_idx); 397 408 return eei; 398 409 } … … 413 424 if (remove) 414 425 llist_itr_remove(&itr); 415 cs_debug_mask(D_TRACE, "%s get by ecm-idx: %d FOUND: %d",416 getprefix(), ecm_idx, eei->send_idx);426 //cs_debug_mask(D_TRACE, "%s get by ecm-idx: %d FOUND: %d", 427 // getprefix(), ecm_idx, eei->send_idx); 417 428 return eei; 418 429 } … … 743 754 } 744 755 756 static struct cc_current_card *cc_find_current_card(struct cc_data *cc, struct cc_card *card) { 757 LLIST_ITR itr; 758 struct cc_current_card *c = llist_itr_init(cc->current_cards, &itr); 759 while (c) { 760 if (c->card == card) 761 return c; 762 c = llist_itr_next(&itr); 763 } 764 return NULL; 765 } 766 767 static struct cc_current_card *cc_find_current_card_by_srvid(struct cc_data *cc, ushort caid, ulong prov, struct cc_srvid *srvid) { 768 LLIST_ITR itr; 769 struct cc_current_card *c = llist_itr_init(cc->current_cards, &itr); 770 while (c) { 771 if (c->card->caid==caid && c->prov==prov && sid_eq(&c->srvid, srvid)) 772 return c; 773 c = llist_itr_next(&itr); 774 } 775 return NULL; 776 } 777 778 static void cc_remove_current_card(struct cc_data *cc, struct cc_current_card *current_card) { 779 LLIST_ITR itr; 780 struct cc_current_card *c = llist_itr_init(cc->current_cards, &itr); 781 while (c) { 782 if (c == current_card) { 783 free(c); 784 c = llist_itr_remove(&itr); 785 } 786 else 787 c = llist_itr_next(&itr); 788 } 789 790 } 791 792 static void cc_UA_oscam2cccam(uint8 *in, uint8 *out) { 793 out[7] = in[5]; 794 out[6] = in[4]; 795 out[5] = in[3]; 796 out[4] = in[2]; 797 out[3] = in[1]; 798 out[2] = in[0]; 799 out[1] = in[7]; 800 out[0] = in[6]; 801 } 802 803 static void cc_UA_cccam2oscam(uint8 *in, uint8 *out) { 804 out[5] = in[7]; 805 out[4] = in[6]; 806 out[3] = in[5]; 807 out[2] = in[4]; 808 out[1] = in[3]; 809 out[0] = in[2]; 810 out[7] = in[1]; 811 out[6] = in[0]; 812 } 813 814 745 815 746 816 /** … … 750 820 static int cc_send_ecm(ECM_REQUEST *er, uchar *buf) { 751 821 752 cs_debug_mask(D_TRACE, "%s cc_send_ecm", getprefix());822 //cs_debug_mask(D_TRACE, "%s cc_send_ecm", getprefix()); 753 823 cc_cli_init_int(); 754 824 … … 838 908 cur_srvid.ecmlen = cur_er->l; 839 909 840 //First check last used card: 841 cc->current_ecm_cidx = cur_er->cidx; 842 current_card = &cc->current_card[cur_er->cidx]; 843 if (current_card->card && current_card->prov == cur_er->prid && 844 sid_eq(¤t_card->srvid, &cur_srvid) && 845 !is_sid_blocked(current_card->card, &cur_srvid)) { 910 //search cache: 911 current_card = cc_find_current_card_by_srvid(cc, cur_er->caid, cur_er->prid, &cur_srvid); 912 if (current_card) 913 { 914 if (!current_card->card || is_sid_blocked(current_card->card, &cur_srvid)) { 915 cc_remove_current_card(cc, current_card); 916 current_card = NULL; 917 } 918 } 919 if (current_card) 846 920 card = current_card->card; 847 }848 921 else 849 {850 922 card = NULL; 851 current_card->prov = cur_er->prid;852 current_card->srvid = cur_srvid;853 current_card->card = NULL;854 }855 923 856 924 //then check all other cards … … 862 930 cc->auto_blocked, cur_er->caid, cur_er->prid, &cur_srvid, 60*60*1)) { //TODO: Timeout 60*60*1 = 1h, Config? 863 931 is_auto_blocked = 1; 864 current_card->card = NULL;865 932 } 866 933 else 867 934 { 868 card = llist_itr_init(cc->cards, &itr);869 while ( card) {870 if ( card->caid == cur_er->caid) { // caid matches871 int s = is_sid_blocked( card, &cur_srvid);935 struct cc_card *ncard = llist_itr_init(cc->cards, &itr); 936 while (ncard) { 937 if (ncard->caid == cur_er->caid) { // caid matches 938 int s = is_sid_blocked(ncard, &cur_srvid); 872 939 873 940 LLIST_ITR pitr; 874 uint8 *prov = llist_itr_init(card->provs, &pitr); 875 while (prov && !s) { 876 ulong card_prov = b2i(3, prov); 877 if (!cur_er->prid || !card_prov || card_prov == cur_er->prid) { // provid matches 878 if (((h < 0) || (card->hop < h)) && (card->hop 879 <= reader[ridx].cc_maxhop)) { // card is closer and doesn't exceed max hop 880 //cc->cur_card = card; 881 current_card->card = card; 882 h = card->hop; // card has been matched 941 struct cc_provider *provider = llist_itr_init(ncard->providers, &pitr); 942 while (provider && !s) { 943 if (!cur_er->prid || !provider->prov || provider->prov == cur_er->prid) { // provid matches 944 if (((h < 0) || (ncard->hop < h)) && (ncard->hop 945 <= reader[ridx].cc_maxhop)) { // ncard is closer and doesn't exceed max hop 946 //cc->cur_card = ncard; 947 card = ncard; 948 h = ncard->hop; // ncard has been matched 883 949 } 884 950 } 885 prov = llist_itr_next(&pitr);951 provider = llist_itr_next(&pitr); 886 952 } 887 953 } 888 card = llist_itr_next(&itr);954 ncard = llist_itr_next(&itr); 889 955 } 890 956 } 891 957 } 892 958 893 if (current_card->card) { 894 card = current_card->card; 895 current_card->prov = cur_er->prid; 896 current_card->srvid = cur_srvid; 959 if (card) { 960 if (!current_card) { 961 current_card = malloc(sizeof(struct cc_current_card)); 962 current_card->card = card; 963 current_card->prov = cur_er->prid; 964 current_card->srvid = cur_srvid; 965 llist_insert_first(cc->current_cards, current_card); 966 } 897 967 898 968 card->time = time((time_t) 0); … … 936 1006 if (!reader[ridx].audisabled) { 937 1007 reader[ridx].card_system = get_cardsystem(card->caid); 938 memcpy(reader[ridx].hexserial, card->hexserial, sizeof(card->hexserial)); 1008 cc_UA_cccam2oscam(card->hexserial, reader[ridx].hexserial); 1009 1010 reader[ridx].nprov = llist_count(card->providers); 1011 LLIST_ITR pitr; 1012 int p = 0; 1013 struct cc_provider *provider = llist_itr_init(card->providers, &pitr); 1014 while (provider) { 1015 memcpy(&reader[ridx].prid[p], &provider->prov, sizeof(provider->prov)); 1016 memcpy(&reader[ridx].sa[p], provider->sa, sizeof(provider->sa)); 1017 provider = llist_itr_next(&pitr); 1018 p++; 1019 } 939 1020 cs_debug_mask(D_EMM, "%s au info: caid %04X card system: %d serial: %s", 940 getprefix(), card->caid, reader[ridx].card_system, cs_hexdump(0, card->hexserial, 8));1021 getprefix(), card->caid, reader[ridx].card_system, cs_hexdump(0, reader[ridx].hexserial, 8)); 941 1022 } 942 1023 … … 1033 1114 int size = emmbuf[11]+12; 1034 1115 1035 cc->current_ecm_cidx = 0;1036 1116 cc->just_logged_in = 0; 1037 1117 cs_ftime(&cc->ecm_time); … … 1056 1136 struct cc_card *card = llist_itr_init(cc->cards, &itr); 1057 1137 while (card) { 1058 if ( memcmp(card->hexserial, hexserial, 8) == 0 && card->caid == caid) { //found it!1138 if (card->caid == caid && memcmp(card->hexserial, hexserial, 8) == 0) { //found it! 1059 1139 return card; 1060 1140 } … … 1083 1163 } 1084 1164 1085 struct cc_card *emm_card = cc->current_card[ep->cidx].card; 1086 1087 if (!emm_card || emm_card->caid != b2i(2, ep->caid)) { 1088 emm_card = get_card_by_hexserial(ep->hexserial, b2i(2, ep->caid)); 1165 ushort caid = b2i(2, ep->caid); 1166 1167 //Last used card is first card of current_cards: 1168 LLIST_ITR itr; 1169 struct cc_current_card *current_card = llist_itr_init(cc->current_cards, &itr); 1170 while (current_card && current_card->card->caid != caid) { 1171 current_card = llist_itr_next(&itr); 1172 } 1173 struct cc_card *emm_card = (current_card != NULL)?current_card->card:NULL; 1174 1175 if (!emm_card || emm_card->caid != caid) { 1176 uint8 hs[8]; 1177 cc_UA_oscam2cccam(ep->hexserial, hs); 1178 emm_card = get_card_by_hexserial(hs, caid); 1089 1179 } 1090 1180 … … 1095 1185 1096 1186 cs_debug_mask(D_EMM, "%s emm received for client %d caid %04X for card %08X", getprefix(), ep->cidx, 1097 b2i(2, ep->caid), emm_card->id);1187 caid, emm_card->id); 1098 1188 1099 1189 int size = ep->l+12; … … 1126 1216 return; 1127 1217 1128 if (card->provs) 1129 llist_destroy(card->provs); 1218 if (card->providers) { 1219 LLIST_ITR bitr; 1220 struct cc_provider *provider = llist_itr_init(card->providers, &bitr); 1221 while (provider) { 1222 free(provider); 1223 provider = llist_itr_remove(&bitr); 1224 } 1225 llist_destroy(card->providers); 1226 } 1130 1227 if (card->badsids) 1131 1228 llist_destroy(card->badsids); … … 1140 1237 struct cc_caid_info *caid_info = llist_itr_init(caid_infos, &itr); 1141 1238 while (caid_info) { 1142 llist_destroy(caid_info->provs); 1239 if (caid_info->providers) { 1240 LLIST_ITR pitr; 1241 struct cc_provider *provider = llist_itr_init(caid_info->providers, &pitr); 1242 while (provider) { 1243 free(provider); 1244 provider = llist_itr_remove(&pitr); 1245 } 1246 llist_destroy(caid_info->providers); 1247 } 1143 1248 free(caid_info); 1144 1249 caid_info = llist_itr_remove(&itr); … … 1209 1314 cc_free_reported_carddata(cc->reported_carddatas, 0); 1210 1315 cc_free_auto_blocked(cc->auto_blocked); 1211 if (cc->current_card)1212 free(cc->current_card);1213 1316 if (cc->pending_emms) { 1214 1317 LLIST_ITR itr; … … 1220 1323 llist_destroy(cc->pending_emms); 1221 1324 cc->pending_emms = NULL; 1325 } 1326 if (cc->current_cards) { 1327 free_current_cards(cc->current_cards); 1328 llist_destroy(cc->current_cards); 1222 1329 } 1223 1330 if (cc->extended_ecm_idx) … … 1265 1372 fwrite(&caid_info->remote_id, 1, sizeof(uint32), file); 1266 1373 caid_count++; 1267 uint8 count = 0; 1268 uint8 *prov = llist_itr_init(caid_info->provs, &itr_prov); 1374 uint8 count = llist_count(caid_info->providers); 1375 fwrite(&count, 1, sizeof(uint8), file); 1376 struct cc_provider *prov = llist_itr_init(caid_info->providers, &itr_prov); 1269 1377 while (prov) { 1270 count++; 1271 prov = llist_itr_next(&itr_prov); 1272 } 1273 fwrite(&count, 1, sizeof(uint8), file); 1274 prov = llist_itr_init(caid_info->provs, &itr_prov); 1275 while (prov) { 1276 fwrite(prov, 1, 3, file); 1378 fwrite(prov, 1, sizeof(struct cc_provider), file); 1277 1379 prov = llist_itr_next(&itr_prov); 1278 1380 } … … 1326 1428 caid_info->hop = hop; 1327 1429 caid_info->remote_id = remote_id; 1328 caid_info->prov s = llist_create();1329 uint8*prov;1430 caid_info->providers = llist_create(); 1431 struct cc_provider *prov; 1330 1432 while (count > 0) { 1331 prov = malloc( 3);1332 if (fread(prov, 1, 3, file) <= 0)1433 prov = malloc(sizeof(struct cc_provider)); 1434 if (fread(prov, 1, sizeof(struct cc_provider), file) <= 0) 1333 1435 break; 1334 llist_append(caid_info->prov s, prov);1436 llist_append(caid_info->providers, prov); 1335 1437 count--; 1336 1438 prov_count++; … … 1344 1446 } 1345 1447 1448 static int add_caidinfo_providers(struct cc_caid_info *caid_info, struct cc_card *card) { 1449 int doSaveCaidInfos = 0; 1450 struct cc_provider *prov_info; 1451 LLIST_ITR itr_info; 1452 LLIST_ITR itr_card; 1453 struct cc_provider *provider = llist_itr_init(card->providers, &itr_card); 1454 while (provider) { 1455 prov_info = llist_itr_init(caid_info->providers, &itr_info); 1456 while (prov_info) { 1457 if (prov_info->prov == provider->prov) 1458 break; 1459 prov_info = llist_itr_next(&itr_info); 1460 } 1461 if (!prov_info) { 1462 struct cc_provider *prov_new = malloc(sizeof(struct cc_provider)); 1463 memcpy(prov_new, provider, sizeof(struct cc_provider)); 1464 llist_append(caid_info->providers, prov_new); 1465 doSaveCaidInfos = 1; 1466 } 1467 provider = llist_itr_next(&itr_card); 1468 } 1469 return doSaveCaidInfos; 1470 } 1346 1471 /** 1347 1472 * Adds a new card to the caid_infos. Only caid/provs are used … … 1352 1477 LLIST_ITR itr; 1353 1478 struct cc_caid_info *caid_info = llist_itr_init(cc->caid_infos, &itr); 1354 1355 if (cfg->cc_minimize_cards) { 1479 1480 //Minimize all, transmit just CAID 1481 if (cfg->cc_minimize_cards==MINIMIZE_CAID) { 1356 1482 while (caid_info) { 1357 1483 if (caid_info->caid == card->caid) … … 1362 1488 caid_info = malloc(sizeof(struct cc_caid_info)); 1363 1489 caid_info->caid = card->caid; 1364 caid_info->prov s = llist_create();1490 caid_info->providers = llist_create(); 1365 1491 caid_info->hop = card->hop; 1366 1492 caid_info->remote_id = card->remote_id; … … 1369 1495 1370 1496 //Null-Provider for all Providers! 1371 uint8 *prov_new = malloc(3);1372 memset(prov_new, 0, 3);1373 llist_append(caid_info->prov s, prov_new);1497 struct cc_provider *prov_new = malloc(sizeof(struct cc_provider)); 1498 memset(prov_new, 0, sizeof(struct cc_provider)); 1499 llist_append(caid_info->providers, prov_new); 1374 1500 } 1375 1501 else … … 1382 1508 1383 1509 } 1510 else if (cfg->cc_minimize_cards==MINIMIZE_HOPS) { 1511 while (caid_info) { 1512 if (caid_info->caid == card->caid && 1513 llist_count(caid_info->providers) < CS_MAXPROV) 1514 break; 1515 caid_info = llist_itr_next(&itr); 1516 } 1517 if (!caid_info) { 1518 caid_info = malloc(sizeof(struct cc_caid_info)); 1519 caid_info->caid = card->caid; 1520 caid_info->providers = llist_create(); 1521 caid_info->hop = card->hop; 1522 caid_info->remote_id = card->remote_id; 1523 llist_append(cc->caid_infos, caid_info); 1524 doSaveCaidInfos = 1; 1525 } 1526 else 1527 { 1528 if (card->hop < caid_info->hop) { 1529 caid_info->hop = card->hop; 1530 doSaveCaidInfos = 1; 1531 } 1532 } 1533 add_caidinfo_providers(caid_info, card); 1534 } 1384 1535 else { 1385 1536 while (caid_info) { 1386 1537 if (caid_info->caid == card->caid && 1387 1538 caid_info->hop == card->hop && 1388 caid_info->remote_id == card->remote_id )1389 if (llist_count(caid_info->provs) < CS_MAXPROV)1390 1539 caid_info->remote_id == card->remote_id && 1540 llist_count(caid_info->providers) < CS_MAXPROV) 1541 break; 1391 1542 caid_info = llist_itr_next(&itr); 1392 1543 } … … 1394 1545 caid_info = malloc(sizeof(struct cc_caid_info)); 1395 1546 caid_info->caid = card->caid; 1396 caid_info->prov s = llist_create();1547 caid_info->providers = llist_create(); 1397 1548 caid_info->hop = card->hop; 1398 1549 caid_info->remote_id = card->remote_id; … … 1400 1551 doSaveCaidInfos = 1; 1401 1552 } 1402 1403 uint8 *prov_info; 1404 uint8 *prov_card; 1405 LLIST_ITR itr_info; 1406 LLIST_ITR itr_card; 1407 prov_card = llist_itr_init(card->provs, &itr_card); 1408 while (prov_card) { 1409 prov_info = llist_itr_init(caid_info->provs, &itr_info); 1410 while (prov_info) { 1411 if (b2i(3, prov_info) == b2i(3, prov_card)) 1412 break; 1413 prov_info = llist_itr_next(&itr_info); 1414 } 1415 if (!prov_info) { 1416 uint8 *prov_new = malloc(3); 1417 memcpy(prov_new, prov_card, 3); 1418 llist_append(caid_info->provs, prov_new); 1419 doSaveCaidInfos = 1; 1420 } 1421 prov_card = llist_itr_next(&itr_card); 1422 } 1553 add_caidinfo_providers(caid_info, card); 1423 1554 } 1424 1555 return doSaveCaidInfos; 1425 1556 } 1557 1426 1558 1427 1559 //static void cc_clear_current_card(struct cc_data *cc, int cidx) { … … 1439 1571 // return c; 1440 1572 //} 1441 1442 static struct cc_current_card *cc_find_current_card(struct cc_data *cc, struct cc_card *card) {1443 int i;1444 for (i = 0; i<CS_MAXPID; i++) {1445 if (cc->current_card[i].card == card) {1446 return &cc->current_card[i];1447 }1448 }1449 return NULL;1450 }1451 1573 1452 1574 static void rebuild_caidinfos(struct cc_data *cc) { … … 1562 1684 while ((current_card = cc_find_current_card(cc, card))) { 1563 1685 cs_debug_mask(D_TRACE, "%s current card %08x removed!", getprefix(), card->id); 1564 1565 current_card->card = NULL; 1686 cc_remove_current_card(cc, current_card); 1566 1687 } 1567 1688 free_extended_ecm_idx_by_card(card); … … 1675 1796 memset(card, 0, sizeof(struct cc_card)); 1676 1797 1677 card->prov s = llist_create();1798 card->providers = llist_create(); 1678 1799 card->badsids = llist_create(); 1679 1800 card->goodsids = llist_create(); … … 1690 1811 1691 1812 for (i = 0; i < buf[24]; i++) { // providers 1692 uint8 *prov = malloc(3);1813 struct cc_provider *prov = malloc(sizeof(struct cc_provider)); 1693 1814 if (prov) { 1694 memcpy(prov, buf + 25 + (7 * i), 3); 1695 cs_debug(" prov %d, %06x", i + 1, b2i(3, prov)); 1696 1697 llist_append(card->provs, prov); 1815 prov->prov = b2i(3, buf + 25 + (7 * i)); 1816 memcpy(prov->sa, buf+25+(7*i)+3, 4); 1817 cs_debug(" prov %d, %06x, sa %08x", i + 1, prov->prov, b2i(4, prov->sa)); 1818 1819 llist_append(card->providers, prov); 1698 1820 } 1699 1821 } … … 1736 1858 } 1737 1859 } 1738 uint8 *prov = llist_itr_init(card->provs, &itr);1860 struct cc_provider *prov = llist_itr_init(card->providers, &itr); 1739 1861 while (prov) { 1740 cc_remove_from_auto_blocked(cc->auto_blocked, card->caid, b2i(3, 1741 prov)); 1862 cc_remove_from_auto_blocked(cc->auto_blocked, card->caid, prov->prov); 1742 1863 prov = llist_itr_next(&itr); 1743 1864 } … … 1745 1866 } 1746 1867 break; 1868 1747 1869 case MSG_CARD_REMOVED: { 1748 1870 cc_card_removed(b2i(4, buf + 4)); … … 1954 2076 if (reader[ridx].available) 1955 2077 send_cmd05_answer(); 1956 cc->current_ecm_cidx = 0; //After CMD_05 is always a NOK! So retry ECM1957 2078 } 1958 2079 ret = 0; … … 2021 2142 pthread_mutex_unlock(&cc->ecm_busy); 2022 2143 } 2023 cc->current_ecm_cidx = 0;2024 2144 cc_send_ecm(NULL, NULL); 2025 2145 } … … 2204 2324 client[cs_idx].cc = cc; 2205 2325 cc->auto_blocked = llist_create(); 2206 cc->current_card = malloc(sizeof(struct cc_current_card)*CS_MAXPID);2207 memset(cc->current_card, 0, sizeof(struct cc_current_card)*CS_MAXPID);2208 2326 cc->pending_emms = llist_create(); 2209 2327 cc->extended_ecm_idx = llist_create(); 2328 cc->current_cards = llist_create(); 2210 2329 } 2211 2330 cc->ecm_counter = 0; … … 2411 2530 //Setting UA: (Unique Address): 2412 2531 if (au_allowed) 2413 memcpy(buf + 12, reader[r].hexserial, 8);2532 cc_UA_oscam2cccam(reader[r].hexserial, buf + 12); 2414 2533 buf[20] = reader[r].ftab.filts[j].nprids; 2415 2534 //cs_log("Ident CCcam card report caid: %04X readr %s subid: %06X", reader[r].ftab.filts[j].caid, reader[r].label, reader[r].cc_id); … … 2472 2591 buf[11] = reshare; 2473 2592 if (au_allowed) 2474 memcpy(buf + 12, reader[r].hexserial, 8);2593 cc_UA_oscam2cccam(reader[r].hexserial, buf + 12); 2475 2594 buf[20] = 1; 2476 2595 //cs_log("CAID map CCcam card report caid: %04X nodeid: %s subid: %06X", lcaid, cs_hexdump(0, cc->peer_node_id, 8), reader[r].cc_id); … … 2506 2625 buf[11] = reshare; 2507 2626 if (au_allowed) 2508 memcpy(buf + 12, reader[r].hexserial, 8);2627 cc_UA_cccam2oscam(reader[r].hexserial, buf + 12); 2509 2628 buf[20] = reader[r].nprov; 2510 2629 for (j = 0; j < reader[r].nprov; j++) { … … 2583 2702 int j = 0; 2584 2703 LLIST_ITR itr_prov; 2585 uint8 *prov = llist_itr_init(caid_info->provs, &itr_prov);2704 struct cc_provider *prov = llist_itr_init(caid_info->providers, &itr_prov); 2586 2705 while (prov) { 2587 ulong prid=0; 2588 memcpy((&prid)+1, prov, 3); 2589 memcpy(buf + 21 + (j * 7), prov, 3); 2706 ulong prid = prov->prov; 2707 buf[21 + (j * 7)] = prid >> 16; 2708 buf[22 + (j * 7)] = prid >> 8; 2709 buf[23 + (j * 7)] = prid & 0xFF; 2710 //memcpy(buf+24+(j*7), prov->sa, 4); 2590 2711 prov = llist_itr_next(&itr_prov); 2591 2712 j++; -
trunk/module-cccam.h
r3038 r3039 19 19 #endif 20 20 21 #define CAIDFILE_VERSION 0xffff 21 #define CAIDFILE_VERSION 0xfffe 22 23 #define MINIMIZE_NONE 0 24 #define MINIMIZE_HOPS 1 25 #define MINIMIZE_CAID 2 22 26 23 27 typedef enum { … … 53 57 }; 54 58 59 struct cc_provider { 60 ulong prov; //provider 61 uint8 sa[4]; //shared address 62 }; 63 55 64 struct cc_card { 56 65 uint32 id; // cccam card (share) id … … 60 69 uint8 maxdown; 61 70 uint8 hexserial[8]; // card serial (for au) 62 LLIST *prov s; // providers71 LLIST *providers; // providers (struct cc_provider) 63 72 LLIST *badsids; // sids that have failed to decode (struct cc_srvid) 64 73 time_t time; 65 LLIST *goodsids; //sids that could decoded 74 LLIST *goodsids; //sids that could decoded (struct cc_srvid) 66 75 }; 67 76 … … 74 83 uint16 caid; 75 84 uint32 remote_id; 76 LLIST *prov s;85 LLIST *providers; // struct cc_provider 77 86 uint8 hop; 78 87 }; … … 143 152 uint32 recv_ecmtask; 144 153 145 int current_ecm_cidx; //index to last current_card (reader) 146 struct cc_current_card *current_card; //initialized by reader (index CS_MAXPID) 154 LLIST *current_cards; //reader: current card cache 147 155 int server_ecm_pending; //initialized by server 148 156 LLIST *server_caid_infos[CS_MAXREADER]; -
trunk/module-obj-llist.c
r2151 r3039 34 34 o = llist_itr_remove(&itr); 35 35 } 36 pthread_mutex_destroy(&l->lock); 36 37 free(l); 37 38 // llist_itr_release(&itr); … … 60 61 } 61 62 l->last = ln; 63 64 l->items++; 65 } 66 pthread_mutex_unlock(&l->lock); 67 68 return o; 69 } 70 71 void *llist_insert_first(LLIST *l, void *o) 72 { 73 if (!l) 74 return NULL; 75 pthread_mutex_lock(&l->lock); 76 if (o) { 77 struct llist_node *ln = malloc(sizeof(struct llist_node)); 78 if (!ln) { 79 pthread_mutex_unlock(&l->lock); 80 return NULL; 81 } 82 83 memset(ln, 0, sizeof(struct llist_node)); 84 ln->obj = o; 85 86 if (l->first) { 87 ln->nxt = l->first; 88 ln->nxt->prv = ln; 89 } else { 90 l->last = ln; 91 } 92 l->first = ln; 62 93 63 94 l->items++; -
trunk/module-obj-llist.h
r2150 r3039 42 42 43 43 void *llist_append(LLIST *l, void *o); // append object onto bottom of list, returns ptr to obj 44 void *llist_insert_first(LLIST *l, void *o); // append object onto bottom of list, returns ptr to obj 44 45 45 46 void *llist_itr_init(LLIST *l, LLIST_ITR *itr); // linked list iterator, returns ptr to first obj -
trunk/oscam-config.c
r3015 r3039 1055 1055 } 1056 1056 1057 // cccam: Update cards interval 1058 if (!strcmp(token, "minimizecards")) { 1059 if (strlen(value) == 0) 1060 cfg->cc_minimize_cards = 0; 1061 else 1062 cfg->cc_minimize_cards = atoi(value); 1063 return; 1064 } 1065 1057 1066 1058 1067 if (token[0] != '#') … … 1967 1976 fprintf_conf(f, CONFVARWIDTH, "version", "%s\n", cfg->cc_version); 1968 1977 fprintf_conf(f, CONFVARWIDTH, "updateinterval", "%d\n", cfg->cc_update_interval); 1978 fprintf_conf(f, CONFVARWIDTH, "minimizecards", "%d\n", cfg->cc_minimize_cards); 1969 1979 fprintf(f,"\n"); 1970 1980 } … … 2476 2486 if (reader[i].cc_want_emu) 2477 2487 fprintf_conf(f, CONFVARWIDTH, "cccwantemu", "%d\n", reader[i].cc_want_emu); 2488 2489 if (reader[i].cc_keepalive) 2490 fprintf_conf(f, CONFVARWIDTH, "ccckeepalive", "%d\n", reader[i].cc_keepalive); 2478 2491 } 2479 2492 … … 3550 3563 } 3551 3564 3565 if (!strcmp(token, "ccckeepalive")) { 3566 if (strlen(value) == 0) { 3567 rdr->cc_keepalive = 0; 3568 return; 3569 } else { 3570 rdr->cc_keepalive = atoi(value); 3571 return; 3572 } 3573 } 3574 3552 3575 if (!strcmp(token, "deprecated")) { 3553 3576 if (strlen(value) == 0) { -
trunk/oscam-http.c
r3037 r3039 1622 1622 if (fread(&count, 1, sizeof(count), file) <= 0) 1623 1623 break; 1624 uint8 prov[3];1624 struct cc_provider prov; 1625 1625 int revcount = count; 1626 1626 1627 1627 while (count > 0) { 1628 if (fread( prov, 1, sizeof(prov), file) <= 0)1628 if (fread(&prov, 1, sizeof(prov), file) <= 0) 1629 1629 break; 1630 snprintf(ascprovid, sizeof(ascprovid), "%02X%02X%02X", prov[0], prov[1], prov[2]); 1630 snprintf(ascprovid, sizeof(ascprovid), "%02X%02X%02X", 1631 (uint)(prov.prov >> 16), (uint)(prov.prov>>8), (uint)(prov.prov & 0xFF)); 1631 1632 provider = get_provider(caid, a2i(ascprovid, 3)); 1632 1633
Note:
See TracChangeset
for help on using the changeset viewer.