Changeset 4858 for trunk/module-cccshare.c
- Timestamp:
- 03/26/11 13:31:33 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-cccshare.c
r4849 r4858 6 6 static uint32 cc_share_id = 0x64; 7 7 static LLIST *reported_carddatas; 8 static pthread_mutex_t cc_shares_lock;8 //static pthread_mutex_t cc_shares_lock; 9 9 10 10 static int card_added_count = 0; … … 15 15 LLIST *get_and_lock_sharelist() 16 16 { 17 pthread_mutex_lock(&cc_shares_lock);17 //pthread_mutex_lock(&cc_shares_lock); 18 18 return reported_carddatas; 19 19 } … … 21 21 void unlock_sharelist() 22 22 { 23 pthread_mutex_unlock(&cc_shares_lock); 24 } 25 26 int write_card(struct cc_data *cc, uint8 *buf, struct cc_card *card, int add_own, int ext, int au_allowed) { 23 //pthread_mutex_unlock(&cc_shares_lock); 24 } 25 26 void add_good_bad_sids(struct s_sidtab *ptr, SIDTABBITS sidtabno, struct cc_card *card) { 27 //good sids: 28 int l; 29 for (l=0;l<ptr->num_srvid;l++) { 30 struct cc_srvid *srvid = malloc(sizeof(struct cc_srvid)); 31 srvid->sid = ptr->srvid[l]; 32 srvid->ecmlen = 0; //0=undefined, also not used with "O" CCcam 33 ll_append(card->goodsids, srvid); 34 } 35 36 //bad sids: 37 struct s_sidtab *ptr_no; 38 int n; 39 for (n=0,ptr_no=cfg.sidtab; ptr_no; ptr_no=ptr_no->next,n++) { 40 if (sidtabno&((SIDTABBITS)1<<n)) { 41 int m; 42 int ok_caid = FALSE; 43 for (m=0;m<ptr_no->num_caid;m++) { //search bad sids for this caid: 44 if (ptr_no->caid[m] == card->caid) { 45 ok_caid = TRUE; 46 break; 47 } 48 } 49 if (ok_caid) { 50 for (l=0;l<ptr_no->num_srvid;l++) { 51 struct cc_srvid *srvid = malloc(sizeof(struct cc_srvid)); 52 srvid->sid = ptr_no->srvid[l]; 53 srvid->ecmlen = 0; //0=undefined, also not used with "O" CCcam 54 ll_append(card->badsids, srvid); 55 } 56 } 57 } 58 } 59 } 60 61 int write_card(struct cc_data *cc, uint8 *buf, struct cc_card *card, int add_own, int ext, int au_allowed, struct s_client *cl) { 27 62 memset(buf, 0, CC_MAXMSGSIZE); 28 63 buf[0] = card->id >> 24; … … 61 96 //write sids only if cccam 2.2.x: 62 97 if (ext) { 63 //assigned sids: 64 it = ll_iter_create(card->goodsids); 65 struct cc_srvid *srvid; 66 while ((srvid = ll_iter_next(it))) { 67 buf[ofs+0] = srvid->sid >> 8; 68 buf[ofs+1] = srvid->sid & 0xFF; 69 ofs+=2; 70 buf[21]++; //nassign 71 if (buf[21] >= 200) 72 break; 73 } 74 ll_iter_release(it); 75 76 //reject sids: 77 it = ll_iter_create(card->badsids); 78 while ((srvid = ll_iter_next(it))) { 79 buf[ofs+0] = srvid->sid >> 8; 80 buf[ofs+1] = srvid->sid & 0xFF; 81 ofs+=2; 82 buf[22]++; //nreject 83 if (buf[22] >= 200) 84 break; 85 } 86 ll_iter_release(it); 98 if (card->card_type == CT_CARD_BY_SERVICE_USER) { 99 //good sids: 100 struct s_sidtab *ptr = card->sidtab; 101 int l; 102 for (l=0;l<ptr->num_srvid;l++) { 103 buf[ofs+0] = ptr->srvid[l] >> 8; 104 buf[ofs+1] = ptr->srvid[l] & 0xFF; 105 ofs+=2; 106 buf[21]++; //nassign 107 if (buf[21] >= 200) 108 break; 109 } 110 111 //bad sids: 112 int n; 113 for (n=0,ptr=cfg.sidtab; ptr; ptr=ptr->next,n++) { 114 if (cl->sidtabno&((SIDTABBITS)1<<n)) { 115 int m; 116 int ok_caid = FALSE; 117 for (m=0;m<ptr->num_caid;m++) { //search bad sids for this caid: 118 if (ptr->caid[m] == card->caid) { 119 ok_caid = TRUE; 120 break; 121 } 122 } 123 if (ok_caid) { 124 for (l=0;l<ptr->num_srvid;l++) { 125 buf[ofs+0] = ptr->srvid[l] >> 8; 126 buf[ofs+1] = ptr->srvid[l] & 0xFF; 127 ofs+=2; 128 buf[22]++; //nreject 129 if (buf[22] >= 200) 130 break; 131 } 132 } 133 } 134 } 135 } else { 136 //assigned sids: 137 it = ll_iter_create(card->goodsids); 138 struct cc_srvid *srvid; 139 while ((srvid = ll_iter_next(it))) { 140 buf[ofs+0] = srvid->sid >> 8; 141 buf[ofs+1] = srvid->sid & 0xFF; 142 ofs+=2; 143 buf[21]++; //nassign 144 if (buf[21] >= 200) 145 break; 146 } 147 ll_iter_release(it); 148 149 //reject sids: 150 it = ll_iter_create(card->badsids); 151 while ((srvid = ll_iter_next(it))) { 152 buf[ofs+0] = srvid->sid >> 8; 153 buf[ofs+1] = srvid->sid & 0xFF; 154 ofs+=2; 155 buf[22]++; //nreject 156 if (buf[22] >= 200) 157 break; 158 } 159 ll_iter_release(it); 160 } 87 161 } 88 162 … … 105 179 return ofs; 106 180 } 181 107 182 108 183 int send_card_to_clients(struct cc_card *card, struct s_client *one_client) { … … 138 213 card->id = cc_share_id++; 139 214 140 int len = write_card(cc, buf, card, 1, cc->cccam220, ll_count(cl->aureader_list));215 int len = write_card(cc, buf, card, 1, ext, ll_count(cl->aureader_list), cl); 141 216 //buf[10] = card->hop-1; 142 217 buf[11] = new_reshare; … … 302 377 303 378 //Check Card created by Service: 304 if (card->card_type == CT_CARD_BY_SERVICE ) {379 if (card->card_type == CT_CARD_BY_SERVICE_READER || card->card_type == CT_CARD_BY_SERVICE_USER) { 305 380 struct s_sidtab *ptr; 306 381 int j; 307 int ok = 0; 308 for (j=0,ptr=cfg.sidtab; ptr; ptr=ptr->next,j++) { 309 if (ptr == card->sidtab) { 310 ok = 1; 311 if (cl->account->sidtabno&((SIDTABBITS)1<<j)) 312 return 0; 313 if (cl->account->sidtabok&((SIDTABBITS)1<<j)) 314 break; 382 int ok = !cl->sidtabok && !cl->sidtabno; //default valid if no positive services and no negative services 383 if (!ok) { 384 for (j=0,ptr=cfg.sidtab; ptr; ptr=ptr->next,j++) { 385 if (ptr == card->sidtab) { 386 if (cl->account->sidtabno&((SIDTABBITS)1<<j)) 387 return 0; 388 if (cl->account->sidtabok&((SIDTABBITS)1<<j)) 389 ok = 1; 390 break; 391 } 315 392 } 316 393 } … … 641 718 } 642 719 643 void add_good_bad_sids(struct s_sidtab *ptr, SIDTABBITS sidtabno, struct cc_card *card) {644 //good sids:645 int l;646 for (l=0;l<ptr->num_srvid;l++) {647 struct cc_srvid *srvid = malloc(sizeof(struct cc_srvid));648 srvid->sid = ptr->srvid[l];649 srvid->ecmlen = 0; //0=undefined, also not used with "O" CCcam650 ll_append(card->goodsids, srvid);651 }652 653 //bad sids:654 struct s_sidtab *ptr_no;655 int n;656 for (n=0,ptr_no=cfg.sidtab; ptr_no; ptr_no=ptr_no->next,n++) {657 if (sidtabno&((SIDTABBITS)1<<n)) {658 int m;659 int ok_caid = FALSE;660 for (m=0;m<ptr_no->num_caid;m++) { //search bad sids for this caid:661 if (ptr_no->caid[m] == card->caid) {662 ok_caid = TRUE;663 break;664 }665 }666 if (ok_caid) {667 for (l=0;l<ptr_no->num_srvid;l++) {668 struct cc_srvid *srvid = malloc(sizeof(struct cc_srvid));669 srvid->sid = ptr_no->srvid[l];670 srvid->ecmlen = 0; //0=undefined, also not used with "O" CCcam671 ll_append(card->badsids, srvid);672 }673 }674 }675 }676 }677 678 720 679 721 /** … … 704 746 for (k=0;k<ptr->num_caid;k++) { 705 747 struct cc_card *card = create_card2(NULL, (j<<8)|k, ptr->caid[k], 0, cfg.cc_reshare); 706 card->card_type = CT_CARD_BY_SERVICE ;748 card->card_type = CT_CARD_BY_SERVICE_USER; 707 749 card->sidtab = ptr; 708 750 int l; … … 749 791 for (k=0;k<ptr->num_caid;k++) { 750 792 struct cc_card *card = create_card2(rdr, (j<<8)|k, ptr->caid[k], 0, rdr->cc_reshare); 751 card->card_type = CT_CARD_BY_SERVICE ;793 card->card_type = CT_CARD_BY_SERVICE_READER; 752 794 card->sidtab = ptr; 753 795 int l; … … 921 963 922 964 int cc_srv_report_cards(struct s_client *cl) { 923 pthread_mutex_lock(&cc_shares_lock);965 //pthread_mutex_lock(&cc_shares_lock); 924 966 LL_ITER *it = ll_iter_create(reported_carddatas); 925 967 struct cc_card *card; … … 928 970 } 929 971 ll_iter_release(it); 930 pthread_mutex_unlock(&cc_shares_lock);972 //pthread_mutex_unlock(&cc_shares_lock); 931 973 932 974 return 1; … … 935 977 void refresh_shares() 936 978 { 937 pthread_mutex_lock(&cc_shares_lock);979 //pthread_mutex_lock(&cc_shares_lock); 938 980 update_card_list(); 939 pthread_mutex_unlock(&cc_shares_lock);981 //pthread_mutex_unlock(&cc_shares_lock); 940 982 } 941 983 … … 1009 1051 1010 1052 reported_carddatas = ll_create(); 1011 pthread_mutex_init(&cc_shares_lock, NULL);1053 //pthread_mutex_init(&cc_shares_lock, NULL); 1012 1054 1013 1055 share_updater_thread = 0; … … 1034 1076 1035 1077 cc_free_reported_carddata(reported_carddatas, NULL, 0); 1036 pthread_mutex_unlock(&cc_shares_lock);1037 pthread_mutex_destroy(&cc_shares_lock);1078 //pthread_mutex_unlock(&cc_shares_lock); 1079 //pthread_mutex_destroy(&cc_shares_lock); 1038 1080 } 1039 1081 }
Note:
See TracChangeset
for help on using the changeset viewer.