Changeset 7630
- Timestamp:
- 10/07/12 18:37:10 (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/global-functions.h
r7585 r7630 237 237 238 238 /* =========================== 239 * module-cccshare240 * =========================== */241 extern void init_share(void);242 extern void done_share(void);243 244 /* ===========================245 239 * reader-common 246 240 * =========================== */ -
trunk/module-cccam-data.h
r7629 r7630 1 1 /* 2 * module-cccam.h3 *4 2 * Created on: 23.04.2010 5 3 * Author: alno 6 4 */ 7 #ifndef MODULECCCAM_H_ 8 #define MODULECCCAM_H_ 9 10 #include "globals.h" 11 12 #ifdef MODULE_CCCAM 5 #ifndef MODULE_CCCAM_DATA_H_ 6 #define MODULE_CCCAM_DATA_H_ 13 7 14 8 #include "cscrypt/rc6.h" 15 9 #include "cscrypt/idea.h" 10 11 #define CAID_KEY 0x20 16 12 17 13 #define CC_MAXMSGSIZE 0x400 //by Project::Keynation: Buffer size is limited on "O" CCCam to 1024 bytes … … 91 87 92 88 typedef enum { 93 94 95 96 97 98 99 89 CT_LOCALCARD = 1, 90 CT_CARD_BY_SERVICE_READER = 2, 91 CT_CARD_BY_SERVICE_USER = 3, 92 CT_CARD_BY_CAID1 = 4, 93 CT_CARD_BY_CAID2 = 5, 94 CT_CARD_BY_CAID3 = 6, 95 CT_REMOTECARD = 10 100 96 } cc_card_type; 101 97 … … 233 229 }; 234 230 235 int32_t cc_cli_init(struct s_client *cl);236 int32_t cc_cli_init_int(struct s_client *cl);237 void cc_cleanup(struct s_client *cl);238 int32_t cc_cli_connect(struct s_client *cl);239 int32_t cc_get_nxt_ecm(struct s_client *cl);240 int32_t cc_send_pending_emms(struct s_client *cl);241 void cc_rc4_crypt(struct cc_crypt_block *block, uint8_t *data, int32_t len,242 cc_crypt_mode_t mode);243 void free_extended_ecm_idx(struct cc_data *cc);244 void cc_free_card(struct cc_card *card);245 int32_t cc_UA_valid(uint8_t *ua);246 void cc_UA_cccam2oscam(uint8_t *in, uint8_t *out, uint16_t caid);247 int32_t cc_cmd_send(struct s_client *cl, uint8_t *buf, int32_t len, cc_msg_type_t cmd);248 int32_t sid_eq(struct cc_srvid *srvid1, struct cc_srvid *srvid2);249 int32_t same_card(struct cc_card *card1, struct cc_card *card2);250 int32_t same_card2(struct cc_card *card1, struct cc_card *card2, int8_t compare_grp);251 void cc_UA_oscam2cccam(uint8_t *in, uint8_t *out, uint16_t caid);252 void cc_SA_oscam2cccam(uint8_t *in, uint8_t *out);253 void cc_free_cardlist(LLIST *card_list, int32_t destroy_list);254 void cc_update_nodeid(void);255 void set_card_timeout(struct cc_card *card);256 257 extern struct ecm_request_t *ecmcwcache;258 extern CS_MUTEX_LOCK ecmcache_lock;259 260 231 #endif 261 #endif /* MODULECCCAM_H_ */ -
trunk/module-cccam.c
r7627 r7630 23 23 24 24 uint8_t cc_node_id[8]; 25 26 int32_t cc_cli_connect(struct s_client *cl); 27 int32_t cc_send_pending_emms(struct s_client *cl); 25 28 26 29 #define getprefix() (!cl?"":(!cl->cc?"":(((struct cc_data *)(cl->cc))->prefix))) … … 3755 3758 3756 3759 if (cfg.cc_port[0]) 3757 init_share();3760 cccam_init_share(); 3758 3761 #endif 3759 3762 } -
trunk/module-cccam.h
r7175 r7630 1 /* 2 * module-cccam.h 3 * 4 * Created on: 23.04.2010 5 * Author: alno 6 */ 7 #ifndef MODULECCCAM_H_ 8 #define MODULECCCAM_H_ 1 #ifndef MODULE_CCCAM_H_ 2 #define MODULE_CCCAM_H_ 9 3 10 #include " globals.h"4 #include "module-cccam-data.h" 11 5 12 #ifdef MODULE_CCCAM 6 // In this file put functions that are called outside of module-cccam.c and module-cccshare.c 13 7 14 #include "cscrypt/rc6.h" 15 #include "cscrypt/idea.h" 8 void cc_update_nodeid(void); 16 9 17 #define CC_MAXMSGSIZE 0x400 //by Project::Keynation: Buffer size is limited on "O" CCCam to 1024 bytes 18 #define CC_MAX_PROV 32 19 #define SWAPC(X, Y) do { char p; p = *X; *X = *Y; *Y = p; } while(0) 10 void cc_UA_cccam2oscam(uint8_t *in, uint8_t *out, uint16_t caid); 20 11 21 #if (defined(WIN32) || defined(__CYGWIN__)) && !defined(MSG_WAITALL) 22 # define MSG_WAITALL 0 12 int32_t cc_UA_valid(uint8_t *ua); 13 14 void refresh_shares(void); 15 LLIST **get_and_lock_sharelist(void); 16 void unlock_sharelist(void); 17 18 struct cc_card **get_sorted_card_copy(LLIST *cards, int32_t reverse, int32_t *size); 19 20 void cccam_init_share(void); 21 22 #if defined(MODULE_CCCAM) && defined(MODULE_CCCSHARE) 23 void cccam_done_share(void); 24 #else 25 static inline void cccam_done_share(void) { } 23 26 #endif 24 27 25 #define MINIMIZE_NONE 026 #define MINIMIZE_HOPS 127 #define MINIMIZE_CAID 228 #define MINIMIZE_TRANSPARENT 329 30 #define CCCAM_MODE_NOTINIT 031 #define CCCAM_MODE_NORMAL 132 #define CCCAM_MODE_SHUTDOWN 0xFF33 34 #define QUITERROR 135 36 #define MIN_RATING -2537 #define MAX_RATING 2538 39 #define HOP_RATING 540 41 typedef enum {42 DECRYPT, ENCRYPT43 } cc_crypt_mode_t;44 45 typedef enum {46 MSG_CLI_DATA = 0,47 MSG_CW_ECM = 1,48 MSG_EMM_ACK = 2,49 MSG_CARD_REMOVED = 4,50 MSG_CMD_05 = 5,51 MSG_KEEPALIVE = 6,52 MSG_NEW_CARD = 7,53 MSG_SRV_DATA = 8,54 MSG_CMD_0A = 0x0a,55 MSG_CMD_0B = 0x0b,56 MSG_CMD_0C = 0x0c, // CCCam 2.2.x fake client checks57 MSG_CMD_0D = 0x0d, // "58 MSG_CMD_0E = 0x0e, // "59 MSG_NEW_CARD_SIDINFO = 0x0f,60 MSG_SLEEPSEND = 0x80, //Sleepsend support61 MSG_CACHE_PUSH = 0x81, //CacheEx Cache-Push In/Out62 MSG_CW_NOK1 = 0xfe, //Node no more available63 MSG_CW_NOK2 = 0xff, //No decoding64 MSG_NO_HEADER = 0xffff65 } cc_msg_type_t;66 67 struct cc_crypt_block {68 uint8_t keytable[256];69 uint8_t state;70 uint8_t counter;71 uint8_t sum;72 };73 74 struct cc_srvid {75 uint16_t sid;76 uint16_t chid;77 uint8_t ecmlen;78 };79 80 struct cc_srvid_block {81 uint16_t sid;82 uint16_t chid;83 uint8_t ecmlen;84 time_t blocked_till;85 };86 87 struct cc_provider {88 uint32_t prov; //provider89 uint8_t sa[4]; //shared address90 };91 92 typedef enum {93 CT_LOCALCARD = 1,94 CT_CARD_BY_SERVICE_READER = 2,95 CT_CARD_BY_SERVICE_USER = 3,96 CT_CARD_BY_CAID1 = 4,97 CT_CARD_BY_CAID2 = 5,98 CT_CARD_BY_CAID3 = 6,99 CT_REMOTECARD = 10100 } cc_card_type;101 102 struct cc_card {103 uint32_t id; // cccam card (share) id - reader104 uint32_t remote_id;105 uint16_t caid;106 uint8_t hop;107 uint8_t reshare;108 uint8_t hexserial[8]; // card serial (for au)109 LLIST *providers; // providers (struct cc_provider)110 LLIST *badsids; // sids that have failed to decode (struct cc_srvid)111 LLIST *goodsids; //sids that could decoded (struct cc_srvid)112 LLIST *remote_nodes; //remote note id, 8 bytes113 struct s_reader *origin_reader;114 uint32_t origin_id;115 cc_card_type card_type;116 int8_t aufilter;117 struct s_sidtab *sidtab; //pointer to sidtab entry if card_type = CT_CARD_BY_SERVICE118 uint64_t grp;119 uint8_t rdr_reshare;120 SIDTABBITS sidtabno;121 time_t timeout;122 uint8_t is_ext;123 int8_t rating;124 };125 126 typedef enum {127 MODE_UNKNOWN = 0,128 MODE_PLAIN = 1,129 MODE_AES = 2,130 MODE_CC_CRYPT = 3,131 MODE_RC4_CRYPT = 4,132 MODE_LEN0 = 5,133 } cc_cmd05_mode;134 135 typedef enum {136 MODE_CMD_0x0C_NONE = 0,137 MODE_CMD_0x0C_RC6 = 1,138 MODE_CMD_0x0C_RC4 = 2,139 MODE_CMD_0x0C_CC_CRYPT = 3,140 MODE_CMD_0x0C_AES = 4,141 MODE_CMD_0x0C_IDEA = 5,142 } cc_cmd0c_mode;143 144 145 struct cc_extended_ecm_idx {146 uint8_t send_idx;147 uint16_t ecm_idx;148 struct cc_card *card;149 struct cc_srvid srvid;150 uint8_t free_card;151 struct timeb tps;152 uint32_t cccam_id;153 };154 155 struct cc_data {156 uint8_t g_flag;157 char *prefix;158 159 struct cc_crypt_block block[2]; // crypto state blocks160 161 uint8_t node_id[8], // client node id162 peer_node_id[8], // server node id163 peer_version[8], // server version164 dcw[16]; // control words165 uint8_t cmd0b_aeskey[16];166 uint8_t cmd05_aeskey[16];167 struct cc_crypt_block cmd05_cryptkey;168 169 uint8_t is_oscam_cccam;170 uint8_t cmd05_active;171 int32_t cmd05_data_len;172 uint8_t cmd05_data[256];173 cc_cmd05_mode cmd05_mode;174 int32_t cmd05_offset;175 176 cc_cmd0c_mode cmd0c_mode;177 struct cc_crypt_block cmd0c_cryptkey;178 RC6KEY cmd0c_RC6_cryptkey;179 AES_KEY cmd0c_AES_key;180 IDEA_KEY_SCHEDULE cmd0c_IDEA_dkey;181 182 uint8_t receive_buffer[CC_MAXMSGSIZE];183 uint8_t send_buffer[CC_MAXMSGSIZE];184 185 LLIST *cards; // cards list186 187 int32_t max_ecms;188 int32_t ecm_counter;189 int32_t card_added_count;190 int32_t card_removed_count;191 uint8_t just_logged_in; //true for checking NOK direct after login192 uint8_t key_table; //key for CMD 0B193 194 LLIST *pending_emms; //pending emm list195 196 uint32_t recv_ecmtask;197 198 struct cc_card *last_emm_card;199 int32_t server_ecm_pending; //initialized by server200 uint16_t server_ecm_idx;201 202 CS_MUTEX_LOCK lockcmd;203 int8_t ecm_busy;204 CS_MUTEX_LOCK cards_busy;205 struct timeb ecm_time;206 time_t answer_on_keepalive;207 uint8_t last_msg;208 uint8_t cmd05NOK;209 210 char remote_version[7];211 char remote_build[7];212 char remote_oscam[200];213 214 uint8_t cccam220;215 uint32_t remote_build_nr;216 uint8_t sleepsend;217 218 //Extended Mode for SPECIAL clients:219 uint8_t extended_mode;220 LLIST *extended_ecm_idx;221 222 //stats:223 int32_t num_hop1;224 int32_t num_hop2;225 int32_t num_hopx;226 227 int32_t num_reshare0;228 int32_t num_reshare1;229 int32_t num_reshare2;230 int32_t num_resharex;231 232 char* nok_message;233 };234 235 int32_t cc_cli_init(struct s_client *cl);236 int32_t cc_cli_init_int(struct s_client *cl);237 void cc_cleanup(struct s_client *cl);238 int32_t cc_cli_connect(struct s_client *cl);239 int32_t cc_get_nxt_ecm(struct s_client *cl);240 int32_t cc_send_pending_emms(struct s_client *cl);241 void cc_rc4_crypt(struct cc_crypt_block *block, uint8_t *data, int32_t len,242 cc_crypt_mode_t mode);243 void free_extended_ecm_idx(struct cc_data *cc);244 void cc_free_card(struct cc_card *card);245 int32_t cc_UA_valid(uint8_t *ua);246 void cc_UA_cccam2oscam(uint8_t *in, uint8_t *out, uint16_t caid);247 int32_t cc_cmd_send(struct s_client *cl, uint8_t *buf, int32_t len, cc_msg_type_t cmd);248 int32_t sid_eq(struct cc_srvid *srvid1, struct cc_srvid *srvid2);249 int32_t same_card(struct cc_card *card1, struct cc_card *card2);250 int32_t same_card2(struct cc_card *card1, struct cc_card *card2, int8_t compare_grp);251 void cc_UA_oscam2cccam(uint8_t *in, uint8_t *out, uint16_t caid);252 void cc_SA_oscam2cccam(uint8_t *in, uint8_t *out);253 void cc_free_cardlist(LLIST *card_list, int32_t destroy_list);254 void cc_update_nodeid(void);255 void set_card_timeout(struct cc_card *card);256 257 extern struct ecm_request_t *ecmcwcache;258 extern CS_MUTEX_LOCK ecmcache_lock;259 260 28 #endif 261 #endif /* MODULECCCAM_H_ */ -
trunk/module-cccshare.c
r7625 r7630 1 1 #include "globals.h" 2 2 3 #if def MODULE_CCCAM4 #ifdef MODULE_CCCSHARE 3 #if defined(MODULE_CCCAM) && defined(MODULE_CCCSHARE) 4 5 5 #include "module-cccam.h" 6 #include "module-cccshare.h" 6 7 #include "reader-common.h" 7 #include "module-cccshare.h"8 8 #include "oscam-chk.h" 9 9 #include "oscam-client.h" … … 21 21 static int32_t card_dup_count = 0; 22 22 static pthread_t share_updater_thread = 0; 23 24 int32_t card_valid_for_client(struct s_client *cl, struct cc_card *card); 23 25 24 26 LLIST *get_cardlist(uint16_t caid, LLIST **list) … … 1361 1363 } 1362 1364 1363 void init_share(void) {1365 void cccam_init_share(void) { 1364 1366 1365 1367 memset(reported_carddatas_list, 0, sizeof(reported_carddatas_list)); … … 1382 1384 } 1383 1385 1384 void done_share(void) {1386 void cccam_done_share(void) { 1385 1387 if (share_updater_thread) { 1386 1388 pthread_cancel(share_updater_thread); … … 1393 1395 } 1394 1396 #endif 1395 #endif -
trunk/module-cccshare.h
r7175 r7630 1 #include "globals.h"2 #ifdef MODULE_CCCAM3 #ifdef MODULE_CCCSHARE4 1 /* 5 2 * module-cccshare.h … … 8 5 * Author: schlocke 9 6 */ 10 #ifndef MODULE CCCSHARE_H_11 #define MODULE CCCSHARE_H_7 #ifndef MODULE_CCCSHARE_H_ 8 #define MODULE_CCCSHARE_H_ 12 9 13 #include <string.h> 14 #include <stdlib.h> 15 #include "module-cccam.h" 16 #include <time.h> 17 #include "reader-common.h" 18 #include <poll.h> 19 20 #define CAID_KEY 0x20 21 22 void add_share(struct cc_card *card); 23 void remove_share(struct cc_card *card); 24 25 LLIST **get_and_lock_sharelist(void); 26 void unlock_sharelist(void); 27 void refresh_shares(void); 10 // In this file put functions that are shared between module-cccam.c and module-cccshare.c 28 11 29 12 int32_t chk_ident(FTAB *ftab, struct cc_card *card); 30 int32_t card_valid_for_client(struct s_client *cl, struct cc_card *card);31 32 int32_t cc_clear_reported_carddata(LLIST *reported_carddatas, LLIST *except,33 int32_t send_removed);34 int32_t cc_free_reported_carddata(LLIST *reported_carddatas, LLIST *except,35 int32_t send_removed);36 37 int32_t send_card_to_clients(struct cc_card *card, struct s_client *one_client);38 void send_remove_card_to_clients(struct cc_card *card);39 40 13 int32_t cc_srv_report_cards(struct s_client *cl); 41 42 14 LLIST *get_cardlist(uint16_t caid, LLIST **list); 43 15 44 struct cc_card **get_sorted_card_copy(LLIST *cards, int32_t reverse, int32_t *size); 45 #endif /* MODULECCCSHARE_H_ */ 16 void cc_free_card(struct cc_card *card); 17 void cc_free_cardlist(LLIST *card_list, int32_t destroy_list); 18 int32_t cc_cmd_send(struct s_client *cl, uint8_t *buf, int32_t len, cc_msg_type_t cmd); 19 int32_t sid_eq(struct cc_srvid *srvid1, struct cc_srvid *srvid2); 20 int32_t same_card(struct cc_card *card1, struct cc_card *card2); 21 int32_t same_card2(struct cc_card *card1, struct cc_card *card2, int8_t compare_grp); 22 void cc_UA_oscam2cccam(uint8_t *in, uint8_t *out, uint16_t caid); 23 void cc_SA_oscam2cccam(uint8_t *in, uint8_t *out); 24 void set_card_timeout(struct cc_card *card); 25 46 26 #endif 47 #endif -
trunk/oscam.c
r7629 r7630 3 3 #include "coolapi.h" 4 4 #include "csctapi/icc_async.h" 5 #ifdef MODULE_CCCAM6 #include "module-cccam.h"7 #endif8 5 #include "module-anticasc.h" 9 6 #include "module-cacheex.h" 7 #include "module-cccam.h" 10 8 #include "module-dvbapi-azbox.h" 11 9 #include "module-ird-guess.h" … … 537 535 stat_finish(); 538 536 539 #ifdef MODULE_CCCAM 540 #ifdef MODULE_CCCSHARE 541 done_share(); 542 #endif 543 #endif 537 cccam_done_share(); 544 538 545 539 kill_all_clients(); … … 4035 4029 init_srvid(); 4036 4030 init_tierid(); 4037 //Todo #ifdef CCCAM4038 4031 init_provid(); 4039 4032
Note:
See TracChangeset
for help on using the changeset viewer.