Changeset 4574 for trunk/module-cccam.c
- Timestamp:
- 01/23/11 17:59:57 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-cccam.c
r4571 r4574 304 304 } 305 305 306 void free_current_cards(LLIST *current_cards) {307 LL_ITER *it = ll_iter_create(current_cards);308 struct cc_current_card *c;309 while ((c = ll_iter_next(it)))310 c = ll_iter_remove(it);311 ll_iter_release(it);312 }313 314 306 /** 315 307 * reader … … 339 331 340 332 cc->just_logged_in = 0; 341 free_current_cards(cc->current_cards);342 333 } 343 334 … … 783 774 } 784 775 785 struct cc_current_card *cc_find_current_card(struct cc_data *cc,786 struct cc_card *card) {787 LL_ITER *it = ll_iter_create(cc->current_cards);788 struct cc_current_card *c;789 while ((c = ll_iter_next(it)))790 if (c->card == card) {791 break;792 }793 ll_iter_release(it);794 return c;795 }796 797 struct cc_current_card *cc_find_current_card_by_srvid(struct cc_data *cc,798 ushort caid, ulong prov, struct cc_srvid *srvid) {799 LL_ITER *it = ll_iter_create(cc->current_cards);800 struct cc_current_card *c;801 while ((c = ll_iter_next(it)))802 if (c->card->caid == caid && c->prov == prov803 && sid_eq(&c->srvid, srvid)) {804 break;805 }806 ll_iter_release(it);807 return c;808 }809 810 void cc_remove_current_card(struct cc_data *cc,811 struct cc_current_card *current_card) {812 LL_ITER *it = ll_iter_create(cc->current_cards);813 struct cc_current_card *c;814 while ((c = ll_iter_next(it)))815 if (c == current_card)816 ll_iter_remove_data(it);817 ll_iter_release(it);818 }819 820 776 int get_UA_ofs(uint16 caid) { 821 777 int ofs = 0; … … 938 894 * Updates AU Data: UA (Unique ID / Hexserial) und SA (Shared ID - Provider) 939 895 */ 940 void set_au_data(struct s_client *cl __attribute__((unused)), struct s_reader *rdr, struct cc_card *card, ECM_REQUEST *cur_er) {896 void set_au_data(struct s_client *cl, struct s_reader *rdr, struct cc_card *card, ECM_REQUEST *cur_er) { 941 897 if (rdr->audisabled || !cc_UA_valid(card->hexserial)) 942 898 return; 943 899 900 struct cc_data *cc = cl->cc; 901 cc->last_emm_card = card; 902 944 903 rdr->card_system = get_cardsystem(card->caid); 945 904 cc_UA_cccam2oscam(card->hexserial, rdr->hexserial, rdr->caid[0]); … … 1014 973 struct cc_data *cc = cl->cc; 1015 974 struct cc_card *card = NULL; 1016 struct cc_current_card *current_card = NULL;1017 975 LL_ITER *it; 1018 976 ECM_REQUEST *cur_er; … … 1100 1058 1101 1059 pthread_mutex_lock(&cc->cards_busy); 1102 //search cache:1103 current_card = cc_find_current_card_by_srvid(cc, cur_er->caid,1104 cur_er->prid, &cur_srvid);1105 if (current_card) {1106 if (!current_card->card || is_sid_blocked(current_card->card,1107 &cur_srvid)) {1108 cc_remove_current_card(cc, current_card);1109 current_card = NULL;1110 }1111 }1112 if (current_card)1113 card = current_card->card;1114 else1115 card = NULL;1116 1117 //then check all other cards1118 if (!card) {1119 1060 it = ll_iter_create(cc->cards); 1120 1061 struct cc_card *ncard; … … 1152 1093 } 1153 1094 ll_iter_release(it); 1154 }1155 1095 1156 1096 if (card) { 1157 if (!current_card) {1158 current_card = cs_malloc(¤t_card, sizeof(struct cc_current_card), QUITERROR);1159 current_card->card = card;1160 current_card->prov = cur_er->prid;1161 current_card->srvid = cur_srvid;1162 ll_prepend(cc->current_cards, current_card);1163 }1164 1165 1097 card->time = time((time_t) 0); 1166 1098 uint8 ecmbuf[255+13]; … … 1357 1289 //Last used card is first card of current_cards: 1358 1290 pthread_mutex_lock(&cc->cards_busy); 1359 LL_ITER *it = ll_iter_create(cc->current_cards); 1360 struct cc_current_card *current_card; 1361 while ((current_card = ll_iter_next(it))) 1362 if (current_card->card->caid == caid && cc_UA_valid(current_card->card->hexserial)) 1363 break; //found it 1364 ll_iter_release(it); 1365 1366 struct cc_card *emm_card = (current_card != NULL) ? current_card->card 1367 : NULL; 1291 1292 struct cc_card *emm_card = cc->last_emm_card; 1368 1293 1369 1294 if (!emm_card) { … … 1526 1451 cc_free_reported_carddata(cl, cc->reported_carddatas, NULL, FALSE); 1527 1452 ll_destroy_data(cc->pending_emms); 1528 free_current_cards(cc->current_cards);1529 ll_destroy(cc->current_cards);1530 1453 if (cc->extended_ecm_idx) 1531 1454 free_extended_ecm_idx(cc); … … 1793 1716 //cs_debug_mask(D_CLIENT, "cccam: card %08x removed, caid %04X, count %d", 1794 1717 // card->id, card->caid, ll_count(cc->cards)); 1795 struct cc_card *next_card = ll_iter_peek(it, 0);1796 1718 ll_iter_remove(it); 1797 struct cc_current_card *current_card;1798 while ((current_card = cc_find_current_card(cc, card))) {1719 if (cc->last_emm_card == card) { 1720 cc->last_emm_card = NULL; 1799 1721 cs_debug_mask(D_READER, "%s current card %08x removed!", 1800 1722 getprefix(), card->id); 1801 cc_remove_current_card(cc, current_card);1802 1723 } 1803 1724 free_extended_ecm_idx_by_card(cl, card); 1804 1725 cc_free_card(card); 1805 card = next_card;1806 1726 cc->cards_modified++; 1807 1727 //break; … … 1826 1746 if (card) { 1827 1747 cs_debug_mask(D_READER, "%s CMD05: Moving card %08X to the end...", getprefix(), card_to_move->id); 1828 //cleaning current cards:1829 it = ll_iter_create(cc->cards);1830 struct cc_current_card *current_card;1831 while ((current_card = cc_find_current_card(cc, card))) {1832 cc_remove_current_card(cc, current_card);1833 }1834 ll_iter_release(it);1835 1748 free_extended_ecm_idx_by_card(cl, card); 1836 1837 1749 ll_append(cc->cards, card_to_move); 1838 1750 } 1839 1751 } 1840 1752 1841 1842 void check_peer_changed(struct cc_data *cc, uint8 *node_id, uint8 *version) {1843 if (memcmp(cc->peer_node_id, node_id, 8) != 0 || memcmp(cc->peer_version, version, 8) != 0) {1844 //Remote Id has changed, clear cached data:1845 cc_free_cardlist(cc->cards, FALSE);1846 free_current_cards(cc->current_cards);1847 }1848 }1849 1753 1850 1754 /** … … 1932 1836 1933 1837 if (l == 0x48) { //72 bytes: normal server data 1934 check_peer_changed(cc, data, data+8); 1935 1838 pthread_mutex_lock(&cc->cards_busy); 1839 cc_free_cardlist(cc->cards, FALSE); 1840 cc->last_emm_card = NULL; 1841 pthread_mutex_unlock(&cc->cards_busy); 1842 1936 1843 memcpy(cc->peer_node_id, data, 8); 1937 1844 memcpy(cc->peer_version, data + 8, 8); … … 2267 2174 cs_ftime(&tpe); 2268 2175 ulong cwlastresptime = 1000*(tpe.time-cc->ecm_time.time)+tpe.millitm-cc->ecm_time.millitm; 2269 if (cwlastresptime > cfg->ftimeout ) {2176 if (cwlastresptime > cfg->ftimeout && !cc->extended_mode) { 2270 2177 cs_debug_mask(D_READER, "%s card %04X is too slow, moving to the end...", getprefix(), card->id); 2271 2178 move_card_to_end(cl, card); … … 3751 3658 cc->pending_emms = ll_create(); 3752 3659 cc->extended_ecm_idx = ll_create(); 3753 cc->current_cards = ll_create();3754 3660 cc_init_cc(cc); 3755 3661 } else { … … 3763 3669 ll_iter_release(it); 3764 3670 } 3765 if (cc->current_cards)3766 free_current_cards(cc->current_cards);3767 3671 if (cc->extended_ecm_idx) 3768 3672 free_extended_ecm_idx(cc); … … 3783 3687 cc->answer_on_keepalive = time(NULL); 3784 3688 cc->extended_mode = 0; 3689 cc->last_emm_card = NULL; 3690 3785 3691 memset(&cc->cmd05_data, 0, sizeof(cc->cmd05_data)); 3786 3692 memset(&cc->receive_buffer, 0, sizeof(cc->receive_buffer));
Note:
See TracChangeset
for help on using the changeset viewer.